GithubHelp home page GithubHelp logo

fullcube / loopback-component-ping Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 3.0 27 KB

Retrieve the internal state of the LoopBack API Node process.

JavaScript 100.00%
loopback ping loopback-component-ping mit lb2 loopback-component express-ping fullcube

loopback-component-ping's Introduction

loopback-component-ping

Greenkeeper badge

CircleCI Coverage Status Dependencies semantic-release

Component for LoopBack that adds a model for retrieving the internal state of the Node process.

It is a wrapper around the express-ping package.

Installation

Install the module

$ npm install --save loopback-component-ping

Configure the module in server/component-config.json

The configuration object accepts the following parameters:

  • acls (array) (optional) allows you to specify LoopBack ACL definitions that will be applied to the Ping model. (Default: no ACL)
  • modelName (string) (optional) allows to specify the name of the API endpoint that's used. (Default: 'Ping'),
  • parts (object) (optional) allows you to filter out parts of the output by setting the value to false. (Default: show all parts)
{
  "loopback-component-ping": {
    "parts": {
      "application": true,
      "environment": true,
      "resources": true,
      "system": true,
      "timestamp": true,
      "uptime": true
    },
    "modelName": "Ping",
    "acls": [{
      "accessType": "*",
      "principalType": "ROLE",
      "principalId": "$unauthenticated",
      "permission": "ALLOW"
    }]
  }
}

Usage

After installation you should be able to retrieve data about the Node process through the new endpoint on your API:

http://0.0.0.0:3000/api/Ping

{
  "application": {
    "name": "test-server",
    "version": "1.0.0",
    "pid": 25663,
    "title": "node",
    "argv": [
      "/usr/local/bin/node",
      "/Users/beeman/workspace/fullcube/loopback-component-ping/test/test-server/server/server.js"
    ],
    "versions": {
      "http_parser": "2.7.0",
      "node": "6.9.0",
      "v8": "5.1.281.84",
      "uv": "1.9.1",
      "zlib": "1.2.8",
      "ares": "1.10.1-DEV",
      "icu": "57.1",
      "modules": "48",
      "openssl": "1.0.2j"
    },
    "node_env": "development"
  },
  "environment": {
    "- CUT -": "ALL ENV VARS WILL BE SHOWN",
    "NODE": "/usr/local/bin/node",
    "NODE_ENV": "development"
  },
  "resources": {
    "memory": {
      "rss": 127225856,
      "heapTotal": 100749312,
      "heapUsed": 77737976
    },
    "loadavg": [
      2.23828125,
      1.830078125,
      1.59423828125
    ],
    "cpu": [
      {
        "model": "Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz",
        "speed": 2800,
        "times": {
          "user": 2503330,
          "nice": 0,
          "sys": 2401620,
          "idle": 23095740,
          "irq": 0
        }
      },
      {
        "- CUT -": "ALL CORES WILL BE SHOWN"
      }
    ],
    "disk": [
      {
        "filesystem": "/dev/disk1",
        "size": 487358464,
        "used": 350916048,
        "available": 136186416,
        "capacity": 0.73,
        "mount": "/"
      },
      {
        "- CUT -": "ALL DISKS WILL BE SHOWN"
      }
    ],
    "nics": {
      "lo0": [
        {
          "address": "::1",
          "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
          "family": "IPv6",
          "mac": "00:00:00:00:00:00",
          "scopeid": 0,
          "internal": true
        },
        {
          "address": "127.0.0.1",
          "netmask": "255.0.0.0",
          "family": "IPv4",
          "mac": "00:00:00:00:00:00",
          "internal": true
        },
        {
          "address": "fe80::1",
          "netmask": "ffff:ffff:ffff:ffff::",
          "family": "IPv6",
          "mac": "00:00:00:00:00:00",
          "scopeid": 1,
          "internal": true
        }
      ],
      "- CUT -": "ALL NICS WILL BE SHOWN"
    }
  },
  "system": {
    "arch": "x64",
    "platform": "darwin",
    "type": "Darwin",
    "release": "15.6.0",
    "hostname": "dev.local",
    "uptime": 27998,
    "cores": 8,
    "memory": 17179869184
  },
  "timestamp": 1477214879328,
  "uptime": 22.002
}

loopback-component-ping's People

Contributors

beeman avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

loopback-component-ping's Issues

configuration 'parts' doesn't work

Configuration parts doesn't work, if you don't pass parts param in Ping.ping method, it was replaced with a callback instead of undefined.

To fix it, we should specify the accepts param

  "methods": {
    "ping": {
      "accepts": [
        {"arg": "parts", "type": "Object"}
      ],
      "returns": {
        "arg": "result",
        "type": "Object",
        "root": true
      },
      "description": "Ping the API to retrieve its internal state",
      "http": {
        "path": "/",
        "verb": "get"
      }
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.