Last active
September 1, 2015 15:15
-
-
Save AoJ/62c085391a511ccae416 to your computer and use it in GitHub Desktop.
example for using rrdjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rrdjs = require('rrdjs'); | |
var start = 0; | |
var end = start; | |
var i = 0; | |
step = 10; | |
var sources = [ "DS:test:GAUGE:1:0:U", "RRA:MAX:0.5:10:6" ]; | |
rrdjs.create('test.rrd', 1, start, sources, created); | |
function duration() { | |
return ~~(Date.now() / 1000) - start; | |
} | |
var s = 100; | |
function update() { | |
if(end <= 30) { | |
console.log([ end + ':' + s ]); | |
rrdjs.update('test.rrd', 'test', [ end + ':' + s++ ], function() {}); | |
end += 1; | |
s++; | |
} else { | |
finish() | |
} | |
} | |
function finish() { | |
rrdjs.fetch('test.rrd', 'MAX', 0, end - step, step, function(){ | |
console.log(arguments); | |
process.exit() | |
}) | |
} | |
function created(err) { | |
setInterval(update, 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment