npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mccoyb-nodejs-collectd

v1.1.4

Published

collectd protocol over UDP for node js

Downloads

6

Readme

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);
});