Permalink
Browse files

Provide a delcounters and deltimers method for management

Without this, it is necessary to restart statsd to delete
a metric which is not needed anymore.
  • Loading branch information...
1 parent c9d827a commit ba2d084ff3a58b9d9ffe784b8fe7eeeca8ce73c8 @pyr pyr committed Feb 8, 2012
Showing with 19 additions and 2 deletions.
  1. +19 −2 stats.js
View
@@ -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":
@@ -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;

0 comments on commit ba2d084

Please sign in to comment.