Permalink
Browse files

Implement actually submitting data to an rrd-simple server. Of course,

you will need to customise the config before this actually works..
  • Loading branch information...
1 parent 0a7e81a commit fcdbfcef855c92f74495f6d7d3ae7cefe78b5889 @jperkin committed Feb 29, 2012
Showing with 31 additions and 7 deletions.
  1. +9 −4 config.js
  2. +22 −3 node-statusmon.js
View
@@ -2,11 +2,16 @@ var config = {}
// This both configures which probes to run, and their frequency.
config.probes = [
- ["system.uptime", "300"],
- [/.*/, "60"],
+ ['system.uptime', '300'],
+ [/.*/, '60'],
]
-// Possible options: ["rrd-simple", "graphite"]
-config.output_format = "rrd-simple"; //"graphite";
+// Possible options: ['rrd-simple', 'graphite']
+config.output_format = 'rrd-simple';
+
+config.rrdsimple = {};
+config.rrdsimple.host = 'rrd.me.uk';
+config.rrdsimple.port = 80;
+config.rrdsimple.path = '/cgi-bin/rrd-server.cgi'
module.exports = config;
View
@@ -13,7 +13,7 @@ function load_module(path)
for (var m in mod.probes) {
if (m in probes) {
- console.log("WARNING: " + path + " attempting to override " + m + ", ignoring");
+ console.log('WARNING: ' + path + ' attempting to override ' + m + ', ignoring');
} else {
probes[m] = mod.probes[m];
}
@@ -36,7 +36,7 @@ function update_stats(data)
for (var v in data) {
switch (config.output_format) {
case 'graphite':
- console.log([[os.hostname(), v].join("."), data[v], timenow].join(" "));
+ console.log([[os.hostname(), v].join('.'), data[v], timenow].join(' '));
break;
case 'rrd-simple':
/*
@@ -46,7 +46,26 @@ function update_stats(data)
*/
var off = timenow % 60;
timenow = (off <= 30) ? timenow - off : timenow + (60 - off);
- console.log([[timenow, v].join("."), data[v]].join(" "));
+ /*
+ * POST data
+ */
+ var data = [[timenow, v].join('.'), data[v]].join(' ');
+ var http = require('http');
+ var opts = {
+ host: config.rrdsimple.host,
+ port: config.rrdsimple.port,
+ path: config.rrdsimple.path,
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Content-Length': data.length
+ }
+ }
+ console.log('[' + new Date().toISOString() + '] ' +
+ [timenow, v].join('.') + ' -> ' + opts['host']);
+ var req = http.request(opts, function (res) {
+ // We currently fire-and-forget..
+ }).write(data);
break;
}
}

0 comments on commit fcdbfce

Please sign in to comment.