Skip to content

Commit

Permalink
Provide a delcounters and deltimers method for management
Browse files Browse the repository at this point in the history
Without this, it is necessary to restart statsd to delete
a metric which is not needed anymore.
  • Loading branch information
pyr committed Feb 8, 2012
1 parent c9d827a commit ba2d084
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ config.configFile(process.argv[2], function (config, oldConfig) {
stream.setEncoding('ascii');

stream.on('data', function(data) {
var cmd = data.trim();
var cmdline = data.trim().split(" ");
var cmd = cmdline.shift();

switch(cmd) {
case "help":
stream.write("Commands: stats, counters, timers, quit\n\n");
stream.write("Commands: stats, counters, timers, delcounters, deltimers, quit\n\n");
break;

case "stats":
Expand Down Expand Up @@ -116,6 +117,22 @@ config.configFile(process.argv[2], function (config, oldConfig) {
stream.write("END\n\n");
break;

case "delcounters":
for (index in cmdline) {
delete counters[cmdline[index]];
stream.write("deleted: " + cmdline[index] + "\n");
}
stream.write("END\n\n");
break;

case "deltimers":
for (index in cmdline) {
delete timers[cmdline[index]];
stream.write("deleted: " + cmdline[index] + "\n");
}
stream.write("END\n\n");
break;

case "quit":
stream.end();
break;
Expand Down

0 comments on commit ba2d084

Please sign in to comment.