jbuchbinder/node-gmetric


node.js gmetric module

Language: JavaScript


node-gmetric build status

Gmetric packet submission for node.js

Sending metrics

Unspoofed

var Gmetric = require('gmetric');

var gmetric = new Gmetric();
var metric = {
  hostname: 'awesomehost.mydomain.com',
  group: 'testgroup',
  units: 'widgets/sec',
  slope: 'positive',

  name: 'bestmetric',
  value: 10,
  type: 'int32'
};

gmetric.send('127.0.0.1', 8649, metric);

Spoofed

var Gmetric = require('gmetric');

var gmetric = new Gmetric();
var metric = {
  hostname: '192.168.20.15:awesomehost.mydomain.com',
  group: 'testgroup',
  spoof: true,
  units: 'widgets/sec',
  slope: 'positive',

  name: 'bestmetric',
  value: 10,
  type: 'int32'
};

gmetric.send('127.0.0.1', 8649, metric);

Receiving and unpacking metrics

var util = require('util'),
    dgram = require('dgram'),
    server = dgram.createSocket('udp4');

var Gmetric = require('gmetric'),
    gmetric = new Gmetric();

server.on('message', function(msg, rinfo) {
  var msg_type = msg.readInt32BE(0);
  if(msg_type === 128){
    var meta = gmetric.unpack(msg);
    console.log('Received Meta Packet:');
    console.log(util.inspect(meta)   "\n");
  } else if (msg_type === 133){
    var data = gmetric.unpack(msg);
    console.log('Received Data Packet:');
    console.log(util.inspect(data)   "\n");
  }
});

server.on('listening', function(){
  console.log('Gmetric server listening...');
});

server.bind(8649);

License

Copyright Jeff Buchbinder, and other contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

Project Statistics

Sourcerank 6
Repository Size 247 KB
Stars 7
Forks 7
Watchers 3
Open issues 0
Dependencies 2
Contributors 4
Tags 10
Created
Last updated
Last pushed

Top Contributors See all

Josh Toft Jeff Buchbinder Ori Livneh Mattias Hansson

Packages Referencing this Repo

gmetric
Ganglia gmetric submission for node.js
Latest release 0.2.2 - Updated - 7 stars

Recent Tags See all

0.2.2 June 11, 2013
0.2.1 January 01, 2013
0.2.0 December 31, 2012
0.1.3 December 27, 2012
0.1.2 December 27, 2012
0.1.1 December 27, 2012
0.1.0 December 26, 2012
0.0.5 December 12, 2012
0.0.4 May 09, 2012
0.0.3 April 14, 2012

Interesting Forks See all

seryl/node-gmetric
node.js gmetric module
JavaScript - Last pushed - 1 stars - 1 forks

Something wrong with this page? Make a suggestion

Last synced: 2016-05-27 14:50:56 UTC

Login to resync this repository