Add health status functionality

This commit is contained in:
Dan Rowe 2013-03-28 13:41:06 -04:00
Родитель 045b1deee4
Коммит 8dadf9f232
3 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -11,6 +11,7 @@ available:
* counters - a dump of all the current counters
* gauges - a dump of all the current gauges
* timers - a dump of the current timers
* health - a way to set the health status of statsd
The stats output currently will give you:
@ -44,4 +45,8 @@ A simple nagios check can be found in the utils/ directory that can be used to
check metric thresholds, for example the number of seconds since the last
successful flush to graphite.
The health output:
* the health command alone allows you to see the current health status.
* using health up or health down, you can change the current health status.
* the healthStatus configuration option allows you to set the default health status at start.

Просмотреть файл

@ -25,6 +25,7 @@ Optional Variables:
mgmt_address: address to run the management TCP interface on
[default: 0.0.0.0]
mgmt_port: port to run the management TCP interface on [default: 8126]
healthStatus: default health status to be returned and statsd process starts ['up' or 'down', default: 'up']
dumpMessages: log all incoming messages
flushInterval: interval (in ms) to flush to Graphite
percentThreshold: for time information, calculate the Nth percentile(s)

Просмотреть файл

@ -234,6 +234,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {
});
mgmtServer = net.createServer(function(stream) {
var healthStatus = config.healthStatus || 'up';
stream.setEncoding('ascii');
stream.on('error', function(err) {
@ -246,7 +247,19 @@ config.configFile(process.argv[2], function (config, oldConfig) {
switch(cmd) {
case "help":
stream.write("Commands: stats, counters, timers, gauges, delcounters, deltimers, delgauges, quit\n\n");
stream.write("Commands: stats, counters, timers, gauges, delcounters, deltimers, delgauges, health, quit\n\n");
break;
case "health":
if (cmdline.length > 0) {
var cmdaction = cmdline[0].toLowerCase();
if (cmdaction === 'up') {
healthStatus = 'up';
} else if (cmdaction === 'down') {
healthStatus = 'down';
}
}
stream.write("health: " + healthStatus + "\n");
break;
case "stats":