Skip to content
Permalink
Browse files
Allow multiple metrics to be passed in one UDP packet delimited by a …
…newline character.
  • Loading branch information
PSUdaemon committed Jun 4, 2012
1 parent 087fde9 commit 65d038afba0cc21b6664eea4e01254601cac6a0e
Showing 1 changed file with 6 additions and 2 deletions.
@@ -85,8 +85,11 @@ config.configFile(process.argv[2], function (config, oldConfig) {
var keyFlushInterval = Number((config.keyFlush && config.keyFlush.interval) || 0);

server = dgram.createSocket('udp4', function (msg, rinfo) {
if (config.dumpMessages) { util.log(msg.toString()); }
var bits = msg.toString().split(':');
var metrics = msg.toString().split("\n");

for (midx in metrics) {
if (config.dumpMessages) { util.log(metrics[midx].toString()); }
var bits = metrics[midx].toString().split(':');
var key = bits.shift()
.replace(/\s+/g, '_')
.replace(/\//g, '-')
@@ -128,6 +131,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {
counters[key] += Number(fields[0] || 1) * (1 / sampleRate);
}
}
}

stats['messages']['last_msg_seen'] = Math.round(new Date().getTime() / 1000);
});

0 comments on commit 65d038a

Please sign in to comment.