[Nagios-devel] PATCH: terse display in service status details screen for downed hosts
Posted: Thu Dec 08, 2005 12:54 pm
Hello all,
When a host is down or unreachable, it logically follows that any services
running on that host would have the same fate. Currently, the service
status detail screen will list all the downed services for a host even when
the host itself is down. The following patch adds a configurable option to
not list any services in the service detail screen when the host is down.
diff -ur nagios-2.0b6~/cgi/cgiutils.c nagios-2.0b6/cgi/cgiutils.c
--- nagios-2.0b6~/cgi/cgiutils.c Wed Nov 16 03:49:35 2005
+++ nagios-2.0b6/cgi/cgiutils.c Thu Dec 8 15:35:53 2005
@@ -89,6 +89,8 @@
int show_context_help=FALSE;
+int collapse_downed_host_services=TRUE;
+
int hosts_have_been_read=FALSE;
int hostgroups_have_been_read=FALSE;
int servicegroups_have_been_read=FALSE;
@@ -313,6 +315,17 @@
use_authentication=TRUE;
}
+ else if((strstr(input,"collapse_downed_host_services=")==input)){
+ temp_buffer=strtok(input,"=");
+ temp_buffer=strtok(NULL,"\n");
+ if(temp_buffer==NULL)
+ collapse_downed_host_services=TRUE;
+ else if(atoi(temp_buffer)==0)
+ collapse_downed_host_services=FALSE;
+ else
+ collapse_downed_host_services=TRUE;
+ }
+
else if(strstr(input,"nagios_check_command=")==input){
temp_buffer=strtok(input,"=");
temp_buffer=strtok(NULL,"\x0");
diff -ur nagios-2.0b6~/cgi/status.c nagios-2.0b6/cgi/status.c
--- nagios-2.0b6~/cgi/status.c Wed Nov 16 03:49:35 2005
+++ nagios-2.0b6/cgi/status.c Thu Dec 8 15:35:53 2005
@@ -52,6 +52,8 @@
extern int suppress_alert_window;
+extern int collapse_downed_host_services;
+
extern host *host_list;
extern service *service_list;
extern hostgroup *hostgroup_list;
@@ -1213,6 +1215,8 @@
int duration_error=FALSE;
int total_entries=0;
int show_service=FALSE;
+ int show_downed_host_services=TRUE;
+ int thishost_down=FALSE;
/* sort the service list if necessary */
@@ -1243,10 +1247,14 @@
printf("Service Status Details For ");
if(display_type==DISPLAY_HOSTS){
- if(show_all_hosts==TRUE)
+ if(show_all_hosts==TRUE){
+ if (collapse_downed_host_services)
+ show_downed_host_services = FALSE;
printf("All Hosts");
- else
+ }
+ else{
printf("Host '%s'",host_name);
+ }
}
else if(display_type==DISPLAY_SERVICEGROUPS){
if(show_all_servicegroups==TRUE)
@@ -1255,10 +1263,14 @@
printf("Service Group '%s'",servicegroup_name);
}
else{
- if(show_all_hostgroups==TRUE)
+ if(show_all_hostgroups==TRUE){
+ if (collapse_downed_host_services)
+ show_downed_host_services = FALSE;
printf("All Host Groups");
- else
+ }
+ else{
printf("Host Group '%s'",hostgroup_name);
+ }
}
printf("\n");
@@ -1516,6 +1528,8 @@
}
status[sizeof(status)-1]='\x0';
+ if (!show_downed_host_services && thishost_down && !new_host)
+ continue;
printf("\n");
@@ -1525,6 +1539,7 @@
/* find extended information for this host */
temp_hostextinfo=find_hostextinfo(temp_status->host_name);
+ thishost_down = FALSE;
if(temp_hoststatus->status==HOST_DOWN){
if(temp_hoststatus->problem_has_been_acknowledged==TRUE)
host_status_bg_class="HOSTDOWNACK";
@@ -1532,6 +1547,7 @@
host_status_bg_class="HOSTDOWNSCHED";
else
host_status_bg_class="HOSTDOWN";
+ thishost_down = TRUE;
}
else if(temp_hoststatus->status==HOST_UNREACHABLE){
if(temp_hoststatus->problem_has_been_acknowledged==TRUE)
@@ -1540,6 +1556,7 @@
host_status_bg_class="HOSTUNREACHABLESCHED";
else
host_status_bg_class="HOSTUNREACHABLE";
+ thishost_down = TRUE;
}
else
host_status_bg_class=(odd)?"Even":"Odd";
@@ -1608,6 +1625,90 @@
printf("\n");
printf("\n");
printf("\n");
+ if (!show_downed_host_services && thishost_down){
+ /* make sure user has rights to see this... */
+ if(is_authorized_for_host(temp_host,¤t_authdata)==FALSE){
+ thishost_down = FALSE;
+ }
+ else{
+ status_class="";
+ status_bg_class="";
+
+ /* get the last host check time */
+ t=temp_hoststatus->last_check;
+ get_time_string(&t,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
+ if((unsigned
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
When a host is down or unreachable, it logically follows that any services
running on that host would have the same fate. Currently, the service
status detail screen will list all the downed services for a host even when
the host itself is down. The following patch adds a configurable option to
not list any services in the service detail screen when the host is down.
diff -ur nagios-2.0b6~/cgi/cgiutils.c nagios-2.0b6/cgi/cgiutils.c
--- nagios-2.0b6~/cgi/cgiutils.c Wed Nov 16 03:49:35 2005
+++ nagios-2.0b6/cgi/cgiutils.c Thu Dec 8 15:35:53 2005
@@ -89,6 +89,8 @@
int show_context_help=FALSE;
+int collapse_downed_host_services=TRUE;
+
int hosts_have_been_read=FALSE;
int hostgroups_have_been_read=FALSE;
int servicegroups_have_been_read=FALSE;
@@ -313,6 +315,17 @@
use_authentication=TRUE;
}
+ else if((strstr(input,"collapse_downed_host_services=")==input)){
+ temp_buffer=strtok(input,"=");
+ temp_buffer=strtok(NULL,"\n");
+ if(temp_buffer==NULL)
+ collapse_downed_host_services=TRUE;
+ else if(atoi(temp_buffer)==0)
+ collapse_downed_host_services=FALSE;
+ else
+ collapse_downed_host_services=TRUE;
+ }
+
else if(strstr(input,"nagios_check_command=")==input){
temp_buffer=strtok(input,"=");
temp_buffer=strtok(NULL,"\x0");
diff -ur nagios-2.0b6~/cgi/status.c nagios-2.0b6/cgi/status.c
--- nagios-2.0b6~/cgi/status.c Wed Nov 16 03:49:35 2005
+++ nagios-2.0b6/cgi/status.c Thu Dec 8 15:35:53 2005
@@ -52,6 +52,8 @@
extern int suppress_alert_window;
+extern int collapse_downed_host_services;
+
extern host *host_list;
extern service *service_list;
extern hostgroup *hostgroup_list;
@@ -1213,6 +1215,8 @@
int duration_error=FALSE;
int total_entries=0;
int show_service=FALSE;
+ int show_downed_host_services=TRUE;
+ int thishost_down=FALSE;
/* sort the service list if necessary */
@@ -1243,10 +1247,14 @@
printf("Service Status Details For ");
if(display_type==DISPLAY_HOSTS){
- if(show_all_hosts==TRUE)
+ if(show_all_hosts==TRUE){
+ if (collapse_downed_host_services)
+ show_downed_host_services = FALSE;
printf("All Hosts");
- else
+ }
+ else{
printf("Host '%s'",host_name);
+ }
}
else if(display_type==DISPLAY_SERVICEGROUPS){
if(show_all_servicegroups==TRUE)
@@ -1255,10 +1263,14 @@
printf("Service Group '%s'",servicegroup_name);
}
else{
- if(show_all_hostgroups==TRUE)
+ if(show_all_hostgroups==TRUE){
+ if (collapse_downed_host_services)
+ show_downed_host_services = FALSE;
printf("All Host Groups");
- else
+ }
+ else{
printf("Host Group '%s'",hostgroup_name);
+ }
}
printf("\n");
@@ -1516,6 +1528,8 @@
}
status[sizeof(status)-1]='\x0';
+ if (!show_downed_host_services && thishost_down && !new_host)
+ continue;
printf("\n");
@@ -1525,6 +1539,7 @@
/* find extended information for this host */
temp_hostextinfo=find_hostextinfo(temp_status->host_name);
+ thishost_down = FALSE;
if(temp_hoststatus->status==HOST_DOWN){
if(temp_hoststatus->problem_has_been_acknowledged==TRUE)
host_status_bg_class="HOSTDOWNACK";
@@ -1532,6 +1547,7 @@
host_status_bg_class="HOSTDOWNSCHED";
else
host_status_bg_class="HOSTDOWN";
+ thishost_down = TRUE;
}
else if(temp_hoststatus->status==HOST_UNREACHABLE){
if(temp_hoststatus->problem_has_been_acknowledged==TRUE)
@@ -1540,6 +1556,7 @@
host_status_bg_class="HOSTUNREACHABLESCHED";
else
host_status_bg_class="HOSTUNREACHABLE";
+ thishost_down = TRUE;
}
else
host_status_bg_class=(odd)?"Even":"Odd";
@@ -1608,6 +1625,90 @@
printf("\n");
printf("\n");
printf("\n");
+ if (!show_downed_host_services && thishost_down){
+ /* make sure user has rights to see this... */
+ if(is_authorized_for_host(temp_host,¤t_authdata)==FALSE){
+ thishost_down = FALSE;
+ }
+ else{
+ status_class="";
+ status_bg_class="";
+
+ /* get the last host check time */
+ t=temp_hoststatus->last_check;
+ get_time_string(&t,date_time,(int)sizeof(date_time),SHORT_DATE_TIME);
+ if((unsigned
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]