[icinga-checkins] icinga.org: icinga-core/master: classic ui: allow searching for host display_name normal and via regexp #1393

git at icinga.org git at icinga.org
Sat Apr 30 21:33:37 CEST 2011


Module: icinga-core
Branch: master
Commit: 5795a1b3940c1968a2165b7619bf21bf33239ed1
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=5795a1b3940c1968a2165b7619bf21bf33239ed1

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Apr 27 20:02:34 2011 +0200

classic ui: allow searching for host display_name normal and via regexp #1393

refs #1383

---

 Changelog    |    1 +
 cgi/status.c |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index 33a965e..37bc5ac 100644
--- a/Changelog
+++ b/Changelog
@@ -20,6 +20,7 @@ ENHANCEMENTS
 * classic ui: speed up data processing in summary.cgi #1392
 * classic ui: Add an optional alternative CGI driven view for the top frame (Matthew Brooks) #1406
 * classic ui: Added json output "&jsonoutput" to nearly all pages in classic ui #1217
+* classic ui: allow searching for host display_name normal and via regexp #1393
 
 * idoutils: add db socket as config option in ido2db.cfg for mysql and postgresql #1107
 * idoutils: reduce housekeeping cycle to every 3600s, set housekeeping thread startup delay to 300s #1157
diff --git a/cgi/status.c b/cgi/status.c
index 695d445..da83fbe 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -305,26 +305,41 @@ int main(void){
 				for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
 					if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
 						continue;
+					/* address */
 					if(!strcmp(host_name,temp_host->address)){
 						free(host_name);
 						host_name=strdup(temp_host->name);
 						break;
 					}
+					/* address6 */
 					if(!strcmp(host_name,temp_host->address6)){
 						free(host_name);
 						host_name=strdup(temp_host->name);
 						break;
 					}
+					/* display_name */
+                                        if(!strcmp(host_name,temp_host->display_name)){
+                                                free(host_name);
+                                                host_name=strdup(temp_host->name);
+                                                break;
+                                        }
 				}
 				if(temp_host==NULL){
 					for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
 						if(is_authorized_for_host(temp_host,&current_authdata)==FALSE)
 							continue;
+						/* host_name */
 						if((strstr(temp_host->name,host_name)==temp_host->name) || !strncasecmp(temp_host->name,host_name,strlen(host_name))){
 							free(host_name);
 							host_name=strdup(temp_host->name);
 							break;
 						}
+						/* display_name, use host_name as found identifier */
+						else if((strstr(temp_host->display_name,host_name)==temp_host->display_name) || !strncasecmp(temp_host->display_name,host_name,strlen(host_name))){
+							free(host_name);
+							host_name=strdup(temp_host->name);
+							break;
+						}
 					}
 				}
 			}
@@ -4968,10 +4983,16 @@ void grab_statusdata(void) {
 			if(display_type==DISPLAY_HOSTS){
 				if(show_all_hosts==TRUE)
 					grab_service=TRUE;
+				/* for the host_name ... */
 				else if(host_filter!=NULL && 0==regexec(&preg_hostname,temp_servicestatus->host_name,0,NULL,0))
 					grab_service=TRUE;
 				else if(!strcmp(host_name,temp_servicestatus->host_name))
 					grab_service=TRUE;
+				/* and for the display_name */
+				else if(host_filter!=NULL && 0==regexec(&preg_hostname,temp_host->display_name,0,NULL,0))
+					grab_service=TRUE;
+				else if(!strcmp(host_name,temp_host->display_name))
+					grab_service=TRUE;
 			}
 
 			else if(display_type==DISPLAY_HOSTGROUPS){





More information about the icinga-checkins mailing list