acknowledged hosts/services in nagiostats was: nagiostats Config Parameters

Jens Hektor hektor at rz.rwth-aachen.de
Thu Jun 21 09:57:04 CEST 2012


Am 21.06.2012 09:36, schrieb Andreas Ericsson:
> It might. nagiostats hasn't been changed in a very long time. I'll try
> and find out.

I pick up this ball and would like to propose a small patch for nagiostats.c
that enables me to query for ackowledged host & services.

Would be very happy if this patch could be accepted:


--- nagios-3.4.1/base/nagiostats.c.orig 2012-05-12 02:00:53.000000000 +0200
+++ nagios-3.4.1/base/nagiostats.c      2012-06-06 09:54:38.000000000 +0200
@@ -125,6 +125,7 @@
 int services_in_downtime = 0;
 int services_checked = 0;
 int services_scheduled = 0;
+int services_acknowledged = 0;
 int passive_host_checks = 0;
 int active_host_checks = 0;
 int hosts_up = 0;
@@ -134,6 +135,7 @@
 int hosts_in_downtime = 0;
 int hosts_checked = 0;
 int hosts_scheduled = 0;
+int hosts_acknowledged = 0;

 int passive_services_checked_last_1min = 0;
 int passive_services_checked_last_5min = 0;
@@ -350,6 +352,7 @@
                printf(" NUMSVCPROB           number of service problems (WARNING, UNKNOWN or CRITIAL).\n");
                printf(" NUMSVCCHECKED        number of services that have been checked since start.\n");
                printf(" NUMSVCSCHEDULED      number of services that are currently scheduled to be checked.\n");
+                printf(" NUMSVCACKNOWLEDGED   number of down services that are currently acknowledged.\n");
                printf(" NUMSVCFLAPPING       number of services that are currently flapping.\n");
                printf(" NUMSVCDOWNTIME       number of services that are currently in downtime.\n");
                printf(" NUMHSTUP             number of hosts UP.\n");
@@ -358,6 +361,7 @@
                printf(" NUMHSTPROB           number of host problems (DOWN or UNREACHABLE).\n");
                printf(" NUMHSTCHECKED        number of hosts that have been checked since start.\n");
                printf(" NUMHSTSCHEDULED      number of hosts that are currently scheduled to be checked.\n");
+                printf(" NUMHSTACKNOWLEDGED   number of down hosts that are currently acknowledged.\n");
                printf(" NUMHSTFLAPPING       number of hosts that are currently flapping.\n");
                printf(" NUMHSTDOWNTIME       number of hosts that are currently in downtime.\n");
                printf(" NUMHSTACTCHKxM       number of hosts actively checked in last 1/5/15/60 minutes.\n");
@@ -734,6 +738,8 @@
                        printf("%d%s", services_checked, mrtg_delimiter);
                else if(!strcmp(temp_ptr, "NUMSVCSCHEDULED"))
                        printf("%d%s", services_scheduled, mrtg_delimiter);
+                else if(!strcmp(temp_ptr, "NUMSVCACKNOWLEDGED"))
+                        printf("%d%s", services_acknowledged, mrtg_delimiter);
                else if(!strcmp(temp_ptr, "NUMSVCFLAPPING"))
                        printf("%d%s", services_flapping, mrtg_delimiter);
                else if(!strcmp(temp_ptr, "NUMSVCDOWNTIME"))
@@ -754,6 +760,8 @@
                        printf("%d%s", hosts_checked, mrtg_delimiter);
                else if(!strcmp(temp_ptr, "NUMHSTSCHEDULED"))
                        printf("%d%s", hosts_scheduled, mrtg_delimiter);
+                else if(!strcmp(temp_ptr, "NUMHSTACKNOWLEDGED"))
+                        printf("%d%s", hosts_acknowledged, mrtg_delimiter);
                else if(!strcmp(temp_ptr, "NUMHSTFLAPPING"))
                        printf("%d%s", hosts_flapping, mrtg_delimiter);
                else if(!strcmp(temp_ptr, "NUMHSTDOWNTIME"))
@@ -798,6 +806,8 @@
        printf("Total Services:                         %d\n", status_service_entries);
        printf("Services Checked:                       %d\n", services_checked);
        printf("Services Scheduled:                     %d\n", services_scheduled);
+        printf("Services Acknowledged:                  %d\n", services_acknowledged);
+
        printf("Services Actively Checked:              %d\n", active_service_checks);
        printf("Services Passively Checked:             %d\n", passive_service_checks);
        printf("Total Service State Change:             %.3f / %.3f / %.3f %%\n", min_service_state_change, max_service_state_change, average_service_state_change);
@@ -815,6 +825,8 @@
        printf("Total Hosts:                            %d\n", status_host_entries);
        printf("Hosts Checked:                          %d\n", hosts_checked);
        printf("Hosts Scheduled:                        %d\n", hosts_scheduled);
+        printf("Hosts Acknowledged:                     %d\n", hosts_acknowledged);
+
        printf("Hosts Actively Checked:                 %d\n", active_host_checks);
        printf("Host Passively Checked:                 %d\n", passive_host_checks);
        printf("Total Host State Change:                %.3f / %.3f / %.3f %%\n", min_host_state_change, max_host_state_change, average_host_state_change);
@@ -922,6 +934,7 @@
        time_t last_check = 0L;
        int should_be_scheduled = TRUE;
        int has_been_checked = TRUE;
+       int has_been_acknowledged = FALSE;


        time(&current_time);
@@ -1074,6 +1087,9 @@
                                                hosts_checked++;
                                        if(should_be_scheduled == TRUE)
                                                hosts_scheduled++;
+                                        if(has_been_acknowledged == TRUE)
+                                                hosts_acknowledged++;
+
                                        break;

                                case STATUS_SERVICE_DATA:
@@ -1179,6 +1195,9 @@
                                                services_checked++;
                                        if(should_be_scheduled == TRUE)
                                                services_scheduled++;
+                                        if(has_been_acknowledged == TRUE)
+                                                services_acknowledged++;
+
                                        break;

                                default:
@@ -1197,6 +1216,8 @@
                        last_check = (time_t)0;
                        has_been_checked = FALSE;
                        should_be_scheduled = FALSE;
+                        has_been_acknowledged = FALSE;
+
                        }


@@ -1339,6 +1360,9 @@
                                                has_been_checked = (atoi(val) > 0) ? TRUE : FALSE;
                                        else if(!strcmp(var, "should_be_scheduled"))
                                                should_be_scheduled = (atoi(val) > 0) ? TRUE : FALSE;
+                                        else if(!strcmp(var, "problem_has_been_acknowledged"))
+                                                has_been_acknowledged = (atoi(val) > 0) ? TRUE : FALSE;
+
                                        break;

                                case STATUS_SERVICE_DATA:
@@ -1362,6 +1386,9 @@
                                                has_been_checked = (atoi(val) > 0) ? TRUE : FALSE;
                                        else if(!strcmp(var, "should_be_scheduled"))
                                                should_be_scheduled = (atoi(val) > 0) ? TRUE : FALSE;
+                                        else if(!strcmp(var, "problem_has_been_acknowledged"))
+                                                has_been_acknowledged = (atoi(val) > 0) ? TRUE : FALSE;
+
                                        break;

                                default:
@@ -1519,6 +1546,8 @@
                        hosts_checked = atoi(val);
                else if(!strcmp(var, "hosts_scheduled"))
                        hosts_scheduled = atoi(val);
+                else if(!strcmp(var, "hosts_acknowledged"))
+                        hosts_acknowledged = atoi(val);
                else if(!strcmp(var, "hosts_flapping"))
                        hosts_flapping = atoi(val);
                else if(!strcmp(var, "hosts_in_downtime"))
@@ -1611,6 +1640,8 @@
                        services_checked = atoi(val);
                else if(!strcmp(var, "services_scheduled"))
                        services_scheduled = atoi(val);
+                else if(!strcmp(var, "services_acknowledged"))
+                        services_acknowledged = atoi(val);
                else if(!strcmp(var, "services_flapping"))
                        services_flapping = atoi(val);
                else if(!strcmp(var, "services_in_downtime"))


-- 
Dipl.-Phys. Jens Hektor, Netzbetrieb
RWTH Aachen University, Center for Computing and Communication
Room 2.04, Wendlingweg 10, 52074 Aachen (Germany)
Phone: +49 241 80 29206 - Fax: +49 241 80 22100
http://www.rz.rwth-aachen.de - hektor at rz.rwth-aachen.de



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4512 bytes
Desc: S/MIME Kryptografische Unterschrift
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20120621/990bf5f9/attachment.bin>
-------------- next part --------------
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list