Giter VIP home page Giter VIP logo

node-collectdout's Introduction

Synopsis

Periodically send values out to a Collectd server for statistics.

This piece of code has been sponsored by Superfeedr. They are awesome and you should really consider their service if you process RSS feeds!

Installation

npm i collectdout

Usage

Spawn a client that sends the data every 60s to myserver:

var Collectd = require('collectdout');
var client = new Collectd(60000, "collectd_server", 25826, "my_server");

Fourth argument is optional, default is os.hostname()

To transmit data securely with username 'alice' and password '12345', you can select authentication (HMAC) by setting the security level to 1.

var client = new Collectd(60000, "collectd_server", 25826, "my_server",
                          1, 'alice', '12345');

You can also encrypt the trasmitted data by setting the security level to 2.

var client = new Collectd(60000, "collectd_server", 25826, "my_server",
                          2, 'alice', '12345');

Create your plugin instance:

var plugin = client.plugin('myapp', 'worker13');

Set gauges, they are averaged within a sampling period:

plugin.setGauge('users', 'total', 23);
plugin.setGauge('load', '0', [1.0, 0.85, 0.7]);

Manipulate counters:

plugin.setCounter('if_octets', 'eth0', [0, 0]);
plugin.addCounter('uptime', '0', 1);

Change log

  • v0.0.8
    • Adding crypto support
  • v0.0.7
    • Fix counter bug
  • v0.0.6
    • Possibility to send notification
  • v0.0.5
    • Add this changelog
    • Possibility to send data to more than one server
  • v0.0.4
    • Fix interval issue
    • Add optionnal parameter to set hostname
  • v0.0.3
    • Fix multiple value sending

node-collectdout's People

Contributors

astro avatar dimrozakis avatar feraudet avatar thodoras avatar ymettier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-collectdout's Issues

Extra zero padding on collectd packets

I recently deployed the CollectM project (https://github.com/perfwatcher/collectm), which embeds your library, on our Windows servers. I found that after a period of time ranging from minutes to hours, the remote collectd server being written to would start consuming all available memory before finally being nuked by the OOM killer. Which is obviously a horrible bug on the main collectd project's part, but I wanted to see what was different about the traffic coming from node-collectdout to trigger it.

The remote server is currently running collectd 5.4.2 and has been handling about 600 Linux clients with no issue for years. As soon as we added the Windows client (using node-collectdout), the problem surfaced. I disabled the 15 or so Windows clients, and it immediately stabilized.

I captured the traffic between the collectd server and a Windows client, and Wireshark's collectd parser flagged every packet as invalid. Due to a bunch of 0x00 bytes at the end. Looking at the code, it sends a 1024 byte payload every time, regardless of the actual length of the data. A bunch of zeroes are sent after the end of the data to fill out the packet.

I modified the code to match the packet size to the data. Since deploying that patch, the server has been running with zero issues. I'll submit a pull request shortly. nodejs is definitely not my "native language" so I'm open to suggestions on how to do this differently.

Even if collectd fixes their server to handle this better, it's still preferable not to send hundreds of bytes of pointless zeroes. Not a big deal in the era of 10 gig ethernet, but still :)

Control Number.MAX_VALUE

Hello:

It is not clear to me if you are taking into consideration Number.MAX_VALUE for counters.
I mean, if I'm counting values for a long period of time, I might get to an invalid value for a javascript number, so I'd need to revert counter to 0.

This is the code for addCounter function:

addCounter: function(name, instance, increments) {
    if (increments.constructor !== Array)
        increments = [increments];

    doubleHashUpdate(this.counters, name, instance, function(counters) {
        return increments.map(function(increment) {
        var counter = counters && counters[0] || 0;
        return counter + increment;
        });
    });
    }

Where do you store the result of "counter + increment" of the map function?

Thanks

Problem with multiple value gauge

Hi,

I have an issue with this code :

var Collectd = require('collectdout');
client = new Collectd(1000, 'localhost', 25826);
var plugin = client.plugin('df', 'c');
plugin.setGauge('df', '', [10, 10]);

Collectd say : ERROR: Numerical result out of range

An idea ?

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.