[packages/nagios] Rel 6; quick search now also searches in services descriptions
arekm
arekm at pld-linux.org
Thu Apr 9 22:58:21 CEST 2026
commit 57e1d323e54fafd6a1af5510fe3fe5acfc3e8e51
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Apr 9 22:58:11 2026 +0200
Rel 6; quick search now also searches in services descriptions
nagios-search-service.patch | 174 ++++++++++++++++++++++++++++++++++++++++++++
nagios.spec | 4 +-
2 files changed, 177 insertions(+), 1 deletion(-)
---
diff --git a/nagios.spec b/nagios.spec
index 9600784..da17a1e 100644
--- a/nagios.spec
+++ b/nagios.spec
@@ -13,7 +13,7 @@ Summary(pl.UTF-8): Program do monitorowania serwerów/usług/sieci
Summary(pt_BR.UTF-8): Programa para monitoração de máquinas e serviços
Name: nagios
Version: 4.5.11
-Release: 5
+Release: 6
License: GPL v2+
Group: Networking
# https://www.nagios.org/downloads/nagios-core/thanks/?product_download=nagioscore-source
@@ -49,6 +49,7 @@ Patch8: archivelog-timeformat.patch
Patch10: system-jquery.patch
Patch11: %{name}-resilient-refresh.patch
+Patch12: %{name}-search-service.patch
URL: https://www.nagios.org/projects/nagios-core/
BuildRequires: autoconf
BuildRequires: automake
@@ -267,6 +268,7 @@ mv %{name}-%{version}/* .
%patch -P10 -p1
%patch -P11 -p1
+%patch -P12 -p1
find -name .cvsignore -o -name .gitignore | xargs rm
diff --git a/nagios-search-service.patch b/nagios-search-service.patch
new file mode 100644
index 0000000..1522daf
--- /dev/null
+++ b/nagios-search-service.patch
@@ -0,0 +1,174 @@
+--- nagios-4.5.11/cgi/status.c.orig 2026-04-09 22:41:44.273115611 +0200
++++ nagios-4.5.11/cgi/status.c 2026-04-09 22:44:07.679782291 +0200
+@@ -59,6 +59,7 @@ extern int enable_splunk_integration;
+
+ extern int navbar_search_addresses;
+ extern int navbar_search_aliases;
++extern int navbar_search_services;
+
+ extern hoststatus *hoststatus_list;
+ extern servicestatus *servicestatus_list;
+@@ -145,6 +146,8 @@ char *host_filter = NULL;
+ char *hostgroup_name = NULL;
+ char *servicegroup_name = NULL;
+ char *service_filter = NULL;
++char *navbar_service_filter = NULL;
++char *navbar_search_term = NULL;
+ int host_alert = FALSE;
+ int show_all_hosts = TRUE;
+ int show_all_hostgroups = TRUE;
+@@ -241,6 +244,9 @@ int main(void) {
+ if (i > 0)
+ memmove(host_name, host_name + i, strlen(host_name + i) + 1);
+
++ /* save the original search term before host resolution modifies host_name */
++ navbar_search_term = strdup(host_name);
++
+ if(NULL != strstr(host_name, "*")) {
+ /* allocate for 3 extra chars, ^, $ and \0 */
+ host_filter = malloc(sizeof(char) * (strlen(host_name) * 2 + 3));
+@@ -256,6 +262,9 @@ int main(void) {
+ host_filter[0] = '^';
+ host_filter[regex_i++] = '$';
+ host_filter[regex_i] = '\0';
++ /* use the same anchored pattern for service description matching */
++ if(navbar_search_services == TRUE)
++ navbar_service_filter = strdup(host_filter);
+ }
+ else {
+ if((temp_host = find_host(host_name)) == NULL) {
+@@ -301,6 +310,10 @@ int main(void) {
+ free(host_name);
+ servicegroup_name = strdup(temp_servicegroup->group_name);
+ }
++ else if(navbar_search_services == TRUE) {
++ /* no host/hostgroup/servicegroup match, try service description substring match */
++ navbar_service_filter = strdup(host_name);
++ }
+ }
+ }
+ }
+@@ -858,9 +871,12 @@ void show_service_status_totals(void) {
+ host *temp_host;
+ int count_service;
+ regex_t preg_hostname;
++ regex_t preg_servicename;
+
+ if(host_filter != NULL)
+ regcomp(&preg_hostname, host_filter, REG_ICASE);
++ if(navbar_service_filter != NULL)
++ regcomp(&preg_servicename, navbar_service_filter, REG_ICASE);
+
+ /* check the status of all services... */
+ for(temp_servicestatus = servicestatus_list; temp_servicestatus != NULL; temp_servicestatus = temp_servicestatus->next) {
+@@ -890,6 +906,8 @@ void show_service_status_totals(void) {
+ count_service = 1;
+ else if(host_filter != NULL && navbar_search_aliases == TRUE && 0 == regexec(&preg_hostname, temp_host->alias, 0, NULL, 0))
+ count_service = 1;
++ else if(navbar_search == TRUE && navbar_service_filter != NULL && 0 == regexec(&preg_servicename, temp_servicestatus->description, 0, NULL, 0))
++ count_service = 1;
+ }
+ else if(display_type == DISPLAY_SERVICEGROUPS) {
+
+@@ -1123,11 +1141,15 @@ void show_host_status_totals(void) {
+ int total_problems = 0;
+ hoststatus *temp_hoststatus;
+ host *temp_host;
++ servicestatus *temp_svc;
+ int count_host;
+ regex_t preg_hostname;
++ regex_t preg_servicename;
+
+ if(host_filter != NULL)
+ regcomp(&preg_hostname, host_filter, REG_ICASE);
++ if(navbar_service_filter != NULL)
++ regcomp(&preg_servicename, navbar_service_filter, REG_ICASE);
+
+ /* check the status of all hosts... */
+ for(temp_hoststatus = hoststatus_list; temp_hoststatus != NULL; temp_hoststatus = temp_hoststatus->next) {
+@@ -1156,6 +1178,15 @@ void show_host_status_totals(void) {
+ count_host = 1;
+ else if(host_filter != NULL && navbar_search_aliases == TRUE && 0 == regexec(&preg_hostname, temp_host->alias, 0, NULL, 0))
+ count_host = 1;
++ else if(navbar_search == TRUE && navbar_service_filter != NULL) {
++ /* include host if any of its services match the search term */
++ for(temp_svc = servicestatus_list; temp_svc != NULL; temp_svc = temp_svc->next) {
++ if(!strcmp(temp_svc->host_name, temp_hoststatus->host_name) && 0 == regexec(&preg_servicename, temp_svc->description, 0, NULL, 0)) {
++ count_host = 1;
++ break;
++ }
++ }
++ }
+ }
+ else if(display_type == DISPLAY_SERVICEGROUPS) {
+ if(show_all_servicegroups == TRUE) {
+@@ -1389,7 +1420,7 @@ void show_host_status_totals(void) {
+
+ /* display a detailed listing of the status of all services... */
+ void show_service_detail(void) {
+- regex_t preg, preg_hostname;
++ regex_t preg, preg_hostname, preg_servicename;
+ time_t t;
+ char date_time[MAX_DATETIME_LENGTH];
+ char state_duration[48];
+@@ -1453,6 +1484,8 @@ void show_service_detail(void) {
+ if(display_type == DISPLAY_HOSTS) {
+ if(show_all_hosts == TRUE)
+ printf("All Hosts");
++ else if(navbar_search == TRUE && navbar_search_term != NULL)
++ printf("Search '%s'", navbar_search_term);
+ else
+ printf("Host '%s'", host_name);
+ }
+@@ -1590,6 +1623,8 @@ void show_service_detail(void) {
+ regcomp(&preg, service_filter, 0);
+ if(host_filter != NULL)
+ regcomp(&preg_hostname, host_filter, REG_ICASE);
++ if(navbar_service_filter != NULL)
++ regcomp(&preg_servicename, navbar_service_filter, REG_ICASE);
+
+ temp_hostgroup = find_hostgroup(hostgroup_name);
+ temp_servicegroup = find_servicegroup(servicegroup_name);
+@@ -1676,6 +1711,8 @@ void show_service_detail(void) {
+ show_service = TRUE;
+ else if(navbar_search_aliases == TRUE && !strcmp(host_name, temp_host->alias))
+ show_service = TRUE;
++ else if(navbar_search == TRUE && navbar_service_filter != NULL && 0 == regexec(&preg_servicename, temp_status->description, 0, NULL, 0))
++ show_service = TRUE;
+ }
+
+ else if(display_type == DISPLAY_HOSTGROUPS) {
+--- nagios-4.5.11/cgi/cgiutils.c.orig 2026-04-09 22:41:44.275091054 +0200
++++ nagios-4.5.11/cgi/cgiutils.c 2026-04-09 22:42:00.509782275 +0200
+@@ -68,6 +68,7 @@ int lock_author_names = TRUE
+
+ int navbar_search_addresses = TRUE;
+ int navbar_search_aliases = TRUE;
++int navbar_search_services = TRUE;
+
+ int ack_no_sticky = FALSE;
+ int ack_no_send = FALSE;
+@@ -437,6 +438,8 @@ int read_cgi_config_file(const char *fil
+
+ else if(!strcmp(var, "navbar_search_aliases"))
+ navbar_search_aliases = (atoi(val) > 0) ? TRUE : FALSE;
++ else if(!strcmp(var, "navbar_search_services"))
++ navbar_search_services = (atoi(val) > 0) ? TRUE : FALSE;
+ else if(!strcmp(var, "ack_no_sticky"))
+ ack_no_sticky = (atoi(val) > 0) ? TRUE : FALSE;
+ else if(!strcmp(var, "ack_no_send"))
+--- nagios-4.5.11/sample-config/cgi.cfg.in.orig 2026-04-09 22:41:44.276829349 +0200
++++ nagios-4.5.11/sample-config/cgi.cfg.in 2026-04-09 22:42:16.059782277 +0200
+@@ -378,9 +378,12 @@ lock_author_names=1
+ # 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.
++# When navbar_search_for_services is enabled, the search also matches
++# service descriptions, showing all hosts with matching services.
+
+ navbar_search_for_addresses=1
+ navbar_search_for_aliases=1
++navbar_search_for_services=1
+
+
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios.git/commitdiff/57e1d323e54fafd6a1af5510fe3fe5acfc3e8e51
More information about the pld-cvs-commit
mailing list