This commit is contained in:
Will Farrington 2013-12-02 17:31:35 -08:00
Родитель 5d1f56faf0
Коммит f5ac7d71b1
3 изменённых файлов: 56 добавлений и 0 удалений

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

@ -11,6 +11,7 @@
#include "commands/help.h"
#include "commands/notifications.h"
#include "commands/problems.h"
#include "commands/stats.h"
#include "commands/status.h"
// COMMANDS
@ -46,6 +47,7 @@ commands[] = {
{ "unacknowledge", nez_cmd_unacknowledge },
{ "problems", nez_cmd_problems },
{ "muted", nez_cmd_show_muted },
{ "stats", nez_cmd_stats},
};
nez_handler_t

47
src/commands/stats.c Normal file
Просмотреть файл

@ -0,0 +1,47 @@
#include <nagios/nagios.h>
#include "../helper.h"
#include "stats.h"
int
nez_cmd_stats(int sd, char* object, char* rest)
{
// we take no arguments
(void)object;
(void)rest;
// track object counts
int ok = 0;
int warning = 0;
int critical = 0;
int unknown = 0;
for (service* svc = service_list; svc; svc = svc->next) {
switch(svc->current_state) {
case STATE_OK:
ok++;
break;
case STATE_WARNING:
warning++;
break;
case STATE_CRITICAL:
critical++;
break;
case STATE_UNKNOWN:
unknown++;
break;;
default:
break;
}
}
nsock_printf_nul(sd,
"ok: %d, warning: %d, critical: %d, unknown: %d",
ok,
warning,
critical,
unknown);
return 200;
}

7
src/commands/stats.h Normal file
Просмотреть файл

@ -0,0 +1,7 @@
#ifndef NEZ_COMMANDS_STATS_H
#define NEZ_COMMANDS_STATS_H
int
nez_cmd_stats(int sd, char* object, char* rest);
#endif NEZ_COMMANDS_STATS_H