1.1.4 • Published 7 years ago

mccoyb-nodejs-collectd v1.1.4

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

nodejs-collectd

nodejs-collectd is a library for integration of CDS monitoring infrastructure and node js monitoring tools.

nodejs-collectd can be easily deployed with node js app; encode metrics with ASE256 with collectd protocol over UDP; push metrics to collectd proxy which redirect to CDS graphite servers.

API: The API is as simple as the one below. It takes a pair of metric name and value, encrypts it with ASE256 and send it over collectd protocol on top of UDP to collectd proxy.

sendMessage(metricName, metricValue)

Installation: nodejs-collectd is available at npm, use the command below for installation.

npm install nodejs-collectd

Integration with Node Monitor:

Node monitor is a light-weighted and powerful node js monitoring tool, which is available at https://github.com/lorenwest/node-monitor

For use with node monitor following the example below.

  1. Under a node js app directory, run the commands below: npm install nodejs-collectd npm install monitor
  2. Create a settings object in your app that contains these values: 2.1 host: the collectd proxy ip addr 2.2 user: the user name to login to collectd proxy 2.3 password: the password of the user 2.4 prefix: try in this format: env.region.service.plan.host 2.5 encryption: enabled by default; or disabled 2.6 configure metrics following the sample below. Note the prefix for each metric will overwrite the global metric prefix.
  3. Call the init() function and pass in the settings object you've created.

Sample Metrics object:

{
  "host": "127.0.0.1",
  "port": "25825",
  "user": "nodejs-mon",
  "password": "password",
  "prefix":"host",
  "encryption":"enabled",
  "metrics": {
    "used": {
        "prefix":"host",
        "plugin": "cpu",
        "pluginInstance":"cpu0",
        "type":"gauge"
    },
    "freemem": {
        "prefix":"host",
        "plugin": "memory",
        "pluginInstance":"memory0",
        "type":"gauge"
    }  
  }
}

Sample code of monitoring a metric named freemem:

var Monitor = require('monitor');

var e2e = require('nodejs-collectd');

e2e.init(settingsObj);

var processMonitor = new Monitor({probeClass:'Process',initParams:{pollInterval:10000}});

processMonitor.connect();

processMonitor.on('change',function(){

    var freemem= processMonitor.get('freemem');

	console.log(freemem);

	e2e.sendMessage('freemem',freemem);

})

Integration with appmetrics:

Compared with node monitor, appmetrics installation/configuration are more complex. It requires to install MQTT for the communication between agents and clients. Similar with the integration with node monitor. 1. Following the documentation https://github.com/RuntimeTools/appmetrics to install and configure appmetrics 2. npm install nodejs-collectd under nodejs app directory 3. Following the sample below.

var e2e = require('nodejs-collectd');

e2e.init(settingsObj);

var appmetrics = require('appmetrics');

var monitoring = appmetrics.monitor();

monitoring.on('initialized', function (env) {

    env = monitoring.getEnvironment();

    for (var entry in env) {

        console.log(entry + ':' + env[entry]);

    };

});

monitoring.on('cpu', function (cpu) {

    console.log('[' + new Date(cpu.time) + '] CPU: ' + cpu.process);
    e2e.sendMessage('cpu-process',cpu.process);
});
1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago