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

rrdtools

v0.0.1

Published

Node.js native binding for RRDtool

Downloads

7

Readme

Description

node_rrd is a node.js (http://nodejs.org) native binding for RRDtool (http://oss.oetiker.ch/rrdtool/).

Dependencies

In order to compile the c++ sources, you need to have:

  • node-gyp (npm install -g node-gyp)
  • a compiler toolchain (gcc etc...)
  • the RRDtool library (http://oss.oetiker.ch/rrdtool/).

For tests:

  • mocha (http://visionmedia.github.com/mocha/).

Install

Using git

$ git clone <this repository>
$ cd node_rrd
$ npm install .

Basic usage

Require the module

var rrd = require('rrd');

create

rrd.create(String filename, Integer step, Integer start_time, [ String ds, ..., String rra, ... ], Function callback(error)) 

Example:

var filename = '/tmp/test.rrd';
var now = Math.ceil((new Date).getTime() / 1000);

rrd.create(filename, 60, now, ["DS:busy:GAUGE:120:0:U", "RRA:LAST:0.5:1:60"], function (error) { 
	if (error) console.log("Error:", error);
});

info

rrd.info(String filename, Function callback(Object info)) 

Example:

var filename = '/tmp/test.rrd';

rrd.info(filename, function (info) {
	console.log(info.filename, info.rrd_version);
}); 

last

rrd.last(String filename, Function callback(Integer last)) 

Example:

var filename = '/tmp/test.rrd';

rrd.last(filename, function (last) {
	console.log(last);
});

update

rrd.update(String filename, String template, [ String updates, ... ], Function callback(error)) 

Example:

var filename = '/tmp/test.rrd';
var value = 80.0;
var now = Math.ceil((new Date).getTime() / 1000);

rrd.update(filename, 'busy', [[now, value].join(':')], function (error) { 
	if (error) console.log("Error:", error);
});

fetch

rrd.fetch(String filename, String cf, Integer start, Integer end, Integer steps, Function callback(Integer time, Object data)) 

Example:

var filename = '/tmp/test.rrd';
var now = Math.ceil((new Date).getTime() / 1000);

rrd.fetch(filename, "LAST", now - 1000, now, null, function (time, data) { 
	console.log(time, data); 
});

Example

Let's create an RRD to store the system load average over 1 minute for the last hour.

#!/usr/bin/env node

var rrd = require('./build/Release/rrd')
,	os = require('os')
,	filename = '/tmp/test.rrd'
;

function now() { return Math.ceil((new Date).getTime() / 1000); }

function startUpdating() {
	function updateNow() {
		rrd.update(filename, "loadavg1", [[now(), os.loadavg()[0]].join(':')], function (error) {
			console.log(error === null ? '.' : error);
		});
	}

	setInterval(updateNow, 60 * 1000);
}

rrd.create(filename, 60, now(), ['DS:loadavg1:GAUGE:120:0:U', 'RRA:LAST:0.5:1:60'], function (error) {
	if (error !== null) { throw 'Error creating RRD:' + error; }

	console.log("RRD created!");
	startUpdating();
});

Alpha

This module is in early development stage which means the API is not frozen etc... At this point not all rrdtool commands are binded. I did the ones that where the most important to me. If you really need xport or an other command feel free to contact me (thierry dot passeron at gmail dot com).

Tests

There are some (few) tests in /test done with mocha (http://visionmedia.github.com/mocha/). I plan to include more tests in the future.

License terms

Copyright (c), 2012 Thierry Passeron

The MIT License

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.