Hello,
Am 2013-03-01 09:05, schrieb Andreas Ericsson:
On 02/28/2013 10:49 PM, Jonas Meurer wrote:
Am 20.02.2013 16:13, schrieb Jonas Meurer:
Hello,
Hey again,
we're using Nagios as monitoring system for several hundred systems.
While navigating through hosts and services, recently two questions
regarding the quick search (in navigation bar) raised:
1/ Why doesn't nagios search for host aliases as well? Is it possible
to enable alias searching? We're using rather short values for
host_name, and tend to add information like server position to the
alias. Thus searching for host_name and alias would be awesome for
us.
Today it's not possible to enable alias searching. Patches welcome.
If you create one, please use some format that makes it possible to add
searching on other fields as well, such as "alias~<regex>" or some
such.
2/ When searching for IP addresses, only the first match is returned.
In some cases (e.g. NRPE Port forwarding through firewall), several
hosts have the same IP address. For these cases it's rather
irritating,
that only the first matching host is returned.
Tru dat. Patches welcome. You'll want to find and remove the correct
"break" statement, I guess. Other than that it shouldn't be much
trouble.
I finally managed to prepare a patch that fixes both shortcomings. It
adds
two new configuration options to configure the behavior of the
navigation
bar search: search for hostname only, or also for addresses, or also for
aliases.
I reported the patch as feature request at
http://tracker.nagios.org/view.php?id=459
Kind regards,
jonas
diff -rNu nagios.old/cgi/cgiutils.c nagios/cgi/cgiutils.c
--- nagios.old/cgi/cgiutils.c 2013-05-29 18:11:10.304014397 +0200
+++ nagios/cgi/cgiutils.c 2013-05-29 18:07:58.473016731 +0200
@@ -71,6 +71,9 @@
char *splunk_url = NULL;
int lock_author_names = TRUE;
+int navbar_search_for_addresses = FALSE;
+int navbar_search_for_aliases = FALSE;
+
extern time_t program_start;
extern int nagios_pid;
extern int daemon_mode;
@@ -446,6 +449,12 @@
else if(!strcmp(var, "use_ssl_authentication"))
use_ssl_authentication = (atoi(val) > 0) ? TRUE : FALSE;
+
+ else if(!strcmp(var, "navbar_search_for_addresses"))
+ navbar_search_for_addresses = (atoi(val) > 0) ? TRUE : FALSE;
+
+ else if(!strcmp(var, "navbar_search_for_aliases"))
+ navbar_search_for_aliases = (atoi(val) > 0) ? TRUE : FALSE;
}
/* free memory and close the file */
diff -rNu nagios.old/cgi/status.c nagios/cgi/status.c
--- nagios.old/cgi/status.c 2013-05-29 18:09:30.584012585 +0200
+++ nagios/cgi/status.c 2013-05-29 18:05:11.209512764 +0200
@@ -60,6 +60,9 @@
extern int enable_splunk_integration;
+extern int navbar_search_for_addresses;
+extern int navbar_search_for_aliases;
+
extern host *host_list;
extern service *service_list;
extern hostgroup *hostgroup_list;
@@ -144,6 +147,7 @@
char alert_message[MAX_MESSAGE_BUFFER];
char *host_name = NULL;
+char *host_address = NULL;
char *host_filter = NULL;
char *hostgroup_name = NULL;
char *servicegroup_name = NULL;
@@ -281,8 +285,15 @@
if(is_authorized_for_host(temp_host, ¤t_authdata) == FALSE)
continue;
if(!strcmp(host_name, temp_host->address)) {
- free(host_name);
- host_name = strdup(temp_host->name);
+ host_address = strdup(temp_host->address);
+ host_filter = malloc(sizeof(char) * (strlen(host_address) * 2 + 3));
+ len = strlen(host_address);
+ for(i = 0; i < len; i++, regex_i++) {
+ host_filter[regex_i] = host_address[i];
+ }
+ host_filter[0] = '^';
+ host_filter[regex_i++] = '$';
+ host_filter[regex_i] = '\0';
break;
}
}
@@ -1294,6 +1305,7 @@
/* display a detailed listing of the status of all services... */
void show_service_detail(void) {
+ printf("<br>SERVICEDETAIL<br>\n");
regex_t preg, preg_hostname;
time_t t;
char date_time[MAX_DATETIME_LENGTH];
@@ -1574,8 +1586,16 @@
show_service = TRUE;
else if(host_filter != NULL && 0 == regexec(&preg_hostname, temp_status->host_name, 0, NULL, 0))
show_service = TRUE;
+ else if(host_filter != NULL && navbar_search_for_addresses == TRUE && 0 == regexec(&preg_hostname, temp_host->address, 0, NULL, 0))
+ show_service = TRUE;
+ else if(host_filter != NULL && navbar_search_for_aliases == TRUE && 0 == regexec(&preg_hostname, temp_host->alias, 0, NULL, 0))
+ show_service = TRUE;
else if(!strcmp(host_name, temp_status->host_name))
show_service = TRUE;
+ else if(navbar_search_for_addresses == TRUE && !strcmp(host_name, temp_host->address))
+ show_service = TRUE;
+ else if(navbar_search_for_aliases == TRUE && !strcmp(host_name, temp_host->alias))
+ show_service = TRUE;
}
else if(display_type == DISPLAY_HOSTGROUPS) {
diff -rNu nagios.old/sample-config/cgi.cfg nagios/sample-config/cgi.cfg
--- nagios.old/sample-config/cgi.cfg 2013-05-29 18:10:12.192015180 +0200
+++ nagios/sample-config/cgi.cfg 2013-05-29 18:05:15.445513365 +0200
@@ -360,3 +360,12 @@
#splunk_url=http://127.0.0.1:8000/
+
+# NAVIGATION BAR SEARCH OPTIONS
+# The following options allow to configure the navbar search. Default
+# is to search for hostnames. With enabled navbar_search_for_addresses,
+# the navbar search queries IP addresses as well. It's also possible
+# to enable search for aliases by setting navbar_search_for_aliases=1.
+
+navbar_search_for_addresses=1
+navbar_search_for_aliases=1
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting
any issue.
::: Messages without supporting info will risk being sent to /dev/null