Skip to content

Commit

Permalink
Record how many UDP messages we receive every interval.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgb authored and Ryan Murphy committed Jun 21, 2011
1 parent 5f75080 commit f04693b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var dgram = require('dgram')

var counters = {};
var timers = {};
var debugInt, flushInt, server;
var debugInt, flushInt, server, packetCount;

config.configFile(process.argv[2], function (config, oldConfig) {
if (! config.debug && debugInt) {
Expand All @@ -21,8 +21,10 @@ config.configFile(process.argv[2], function (config, oldConfig) {
}

if (server === undefined) {
packetCount = 0;
server = dgram.createSocket('udp4', function (msg, rinfo) {
if (config.dumpMessages) { sys.log(msg.toString()); }
packetCount += 1;
var bits = msg.toString().split(':');
var key = bits.shift()
.replace(/\s+/g, '_')
Expand Down Expand Up @@ -130,6 +132,8 @@ config.configFile(process.argv[2], function (config, oldConfig) {
}

statString += 'statsd.numStats ' + numStats + ' ' + ts + "\n";
statString += 'statsd.packetCount ' + packetCount + ' ' + ts + "\n";
packetCount = 0;

try {
var graphite = net.createConnection(config.graphitePort, config.graphiteHost);
Expand Down

0 comments on commit f04693b

Please sign in to comment.