Created
March 3, 2014 21:04
-
-
Save torkelo/9334573 to your computer and use it in GitHub Desktop.
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 influx = require('influx'); | |
var client = influx('localhost', 8086, 'root', 'root', 'site'); | |
var data = {}; | |
setInterval(function() { | |
randomWalk('request_count', 1000, 100); | |
randomWalk('request_count2', 1000, 100); | |
randomWalk('request_count3', 1000, 100); | |
randomWalk('request_time', 10, 5); | |
randomWalk('request_time2', 10, 5); | |
}, 10000); | |
function randomWalk(name, start, variation) { | |
if (!data[name]) { | |
data[name] = start; | |
} | |
data[name] += (Math.random() * variation) - (variation / 2); | |
console.log('Writing ' + name + " :" + data[name]); | |
client.writePoint(name, { time: new Date(), value: data[name] }, function(err) { | |
if (err) { | |
console.log('InfluxDB Error', err); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment