1.2 dev & filtering status.cgi
rader at ginseng.hep.wisc.edu
rader at ginseng.hep.wisc.edu
Thu Oct 21 10:06:22 CEST 2004
I need to filter by service name, so I implemented
status.cgi?servicefilter=str
It just does strncmp() matches (ie /^str/), but it's still perfectly
usable. Refer to http://noc.hep.wisc.edu/nagios/ user guest password guest
Is the 1.x version line dead? If not, is there any chance of this
patch getting into the source? If so, would a patch to the lastest
2.0 source be accepted? (Ahhh, assuming the functionality doesn't
exist in 2.x.)
steve
- - -
systems & network guy
high energy physics
university of wisconsin
-------------- next part --------------
*** status.c.orig Sat Nov 22 19:37:22 2003
--- status.c Tue Oct 19 03:35:42 2004
***************
*** 126,131 ****
--- 126,133 ----
char alert_message[MAX_MESSAGE_BUFFER];
char *host_name=NULL;
char *hostgroup_name=NULL;
+ /* SR servicefilter cgi var */
+ char *service_filter=NULL;
int host_alert=FALSE;
int show_all_hosts=TRUE;
int show_all_hostgroups=TRUE;
***************
*** 298,304 ****
/* right hand column of top row */
printf("<td align=center valign=top width=33%%>\n");
printf("<table border=0 width=100%%>\n");
! printf("<tr><td>\n");
show_service_status_totals();
printf("</td></tr>\n");
--- 300,308 ----
/* right hand column of top row */
printf("<td align=center valign=top width=33%%>\n");
printf("<table border=0 width=100%%>\n");
! /* SR center "Service Status Totals"... */
! /* printf("<tr><td>\n"); */
! printf("<tr><td align=center>\n");
show_service_status_totals();
printf("</td></tr>\n");
***************
*** 585,590 ****
--- 589,605 ----
/* we found the noheader option */
else if(!strcmp(variables[x],"noheader"))
display_header=FALSE;
+
+ /* SR servicefilter cgi var */
+ else if(!strcmp(variables[x],"servicefilter")){
+ x++;
+ if(variables[x]==NULL){
+ error=TRUE;
+ break;
+ }
+ service_filter=strdup(variables[x]);
+ }
+
}
/* free memory allocated to the CGI variables */
***************
*** 1067,1072 ****
--- 1082,1091 ----
else
printf("Host Group '%s'",hostgroup_name);
}
+ /* SR servicefilter cgi var */
+ if(service_filter!=NULL){
+ printf(" Filtered By Services Matching \'%s\'",service_filter);
+ }
printf("</DIV>\n");
if(use_sort==TRUE){
***************
*** 1226,1231 ****
--- 1245,1261 ----
}
}
+ /* SR servicefilter cgi var */
+ if(service_filter!=NULL) {
+ /* printf("<PRE>%s vs %s",temp_status->description,service_filter); */
+ if(!strncmp(temp_status->description,service_filter,strlen(service_filter))) {
+ /* printf(" ... MATCH</PRE>\n"); */
+ } else {
+ /* printf(" ... NO MATCH</PRE>\n"); */
+ continue;
+ }
+ }
+
if((display_type==DISPLAY_HOSTS && (show_all_hosts==TRUE || !strcmp(host_name,temp_status->host_name))) || display_type==DISPLAY_HOSTGROUPS ){
if(strcmp(last_host,temp_status->host_name))
More information about the Developers
mailing list