[icinga-checkins] icinga.org: icinga-core/test/cgis: classic ui: Fixed status.cgi: host param not honoured with servicefilter #2262
git at icinga.org
git at icinga.org
Sun Feb 5 14:17:51 CET 2012
Module: icinga-core
Branch: test/cgis
Commit: 3d9ac8010fe6a9210c755c42f26e9382c5ed5836
URL: https://git.icinga.org/?p=icinga-core.git;a=commit;h=3d9ac8010fe6a9210c755c42f26e9382c5ed5836
Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date: Sun Jan 15 00:53:01 2012 +0100
classic ui: Fixed status.cgi: host param not honoured with servicefilter #2262
refs: #2262
servicefilter now honored again properly
---
Changelog | 3 ++-
cgi/status.c | 46 ++++++++++++++++++++++++++++++++++++++--------
2 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/Changelog b/Changelog
index d4b0ff5..495ec05 100644
--- a/Changelog
+++ b/Changelog
@@ -18,7 +18,8 @@ FIXES
* classic ui: Fixed wrong URLs for status.cgi overview #2173
* classic ui: Fixed Host staus sorting in status.cgi not working #2220
* classic ui: Fixed notifications.cgi - memory access error #2234
-* classic ui: Done clean up document_header() and unused vars in cgi's #2252
+* classic ui: Done clean up document_header() and unused vars in cgi's #2252
+* classic ui: Fixed status.cgi: host param not honoured with servicefilter #2262
1.6.0 - 30/11/2011
diff --git a/cgi/status.c b/cgi/status.c
index b902c51..c72a0f1 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -204,6 +204,7 @@ char *url_hostgroups_part = NULL;
char *url_servicegroups_part = NULL;
char *search_string = NULL;
+char *service_filter = NULL;
int show_all_hosts = TRUE;
int show_all_hostgroups = TRUE;
@@ -442,6 +443,10 @@ int main(void) {
search_string = strdup(req_hosts[0].entry);
}
+ /* allow service_filter only for status lists */
+ if (group_style_type == STYLE_SUMMARY || group_style_type == STYLE_GRID || group_style_type == STYLE_OVERVIEW)
+ my_free(service_filter);
+
/* see if user tried searching something */
if (search_string != NULL) {
@@ -565,6 +570,9 @@ int main(void) {
show_all_hostgroups == TRUE && show_all_servicegroups == TRUE)
continue;
+ if (service_filter != NULL && strcmp(service_filter, temp_servicestatus->description))
+ continue;
+
/* find the service */
temp_service = find_service(temp_servicestatus->host_name, temp_servicestatus->description);
@@ -1099,6 +1107,7 @@ int main(void) {
my_free(url_hostgroups_part);
my_free(url_servicegroups_part);
my_free(search_string);
+ my_free(service_filter);
return OK;
}
@@ -1120,7 +1129,7 @@ int process_cgivars(void) {
}
/* we found the search_string argument */
- else if (!strcmp(variables[x], "search_string") || !strcmp(variables[x], "servicefilter")) {
+ else if (!strcmp(variables[x], "search_string")) {
x++;
if (variables[x] == NULL) {
error = TRUE;
@@ -1131,6 +1140,17 @@ int process_cgivars(void) {
search_string = strdup(variables[x]);
}
+ /* we found the servicefilter argument */
+ else if (!strcmp(variables[x], "servicefilter")) {
+ x++;
+ if (variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ service_filter = (char *)strdup(variables[x]);
+ }
+
/* we found the navbar search argument */
/* kept for backwards compatibility */
else if (!strcmp(variables[x], "navbarsearch")) {
@@ -1391,11 +1411,11 @@ void show_service_status_totals(void) {
else if (display_all_unhandled_problems == TRUE)
snprintf(status_url, sizeof(status_url) - 1, "%s?hoststatustypes=%d&serviceprops=%d&style=%s", STATUS_CGI, HOST_UP | HOST_PENDING, service_problems_unhandled, style);
else if (display_type == DISPLAY_HOSTS)
- snprintf(status_url, sizeof(status_url) - 1, "%s?%s&style=%s&hoststatustypes=%d", STATUS_CGI, url_hosts_part, style, host_status_types);
+ snprintf(status_url, sizeof(status_url) - 1, "%s?%s%s%s&style=%s&hoststatustypes=%d", STATUS_CGI, url_hosts_part, (service_filter != NULL) ? "&servicefilter=" : "", (service_filter != NULL) ? url_encode(service_filter) : "", style, host_status_types);
else if (display_type == DISPLAY_SERVICEGROUPS)
- snprintf(status_url, sizeof(status_url) - 1, "%s?%s&style=%s&hoststatustypes=%d", STATUS_CGI, url_servicegroups_part, style, host_status_types);
+ snprintf(status_url, sizeof(status_url) - 1, "%s?%s%s%s&style=%s&hoststatustypes=%d", STATUS_CGI, url_servicegroups_part, (service_filter != NULL) ? "&servicefilter=" : "", (service_filter != NULL) ? url_encode(service_filter) : "", style, host_status_types);
else
- snprintf(status_url, sizeof(status_url) - 1, "%s?%s&style=%s&hoststatustypes=%d", STATUS_CGI, url_hostgroups_part, style, host_status_types);
+ snprintf(status_url, sizeof(status_url) - 1, "%s?%s%s%s&style=%s&hoststatustypes=%d", STATUS_CGI, url_hostgroups_part, (service_filter != NULL) ? "&servicefilter=" : "", (service_filter != NULL) ? url_encode(service_filter) : "", style, host_status_types);
status_url[sizeof(status_url)-1] = '\x0';
@@ -1556,11 +1576,11 @@ void show_host_status_totals(void) {
else if (display_all_unhandled_problems == TRUE)
snprintf(status_url, sizeof(status_url) - 1, "%s?hoststatustypes=%d&hostprops=%d&style=%s", STATUS_CGI, all_host_problems, host_problems_unhandled, style);
else if (display_type == DISPLAY_HOSTS)
- snprintf(status_url, sizeof(status_url) - 1, "%s?%s&style=%s", STATUS_CGI, url_hosts_part, style);
+ snprintf(status_url, sizeof(status_url) - 1, "%s?%s%s%s&style=%s", STATUS_CGI, url_hosts_part, (service_filter != NULL) ? "&servicefilter=" : "", (service_filter != NULL) ? url_encode(service_filter) : "", style);
else if (display_type == DISPLAY_SERVICEGROUPS)
- snprintf(status_url, sizeof(status_url) - 1, "%s?%s&style=%s", STATUS_CGI, url_servicegroups_part, style);
+ snprintf(status_url, sizeof(status_url) - 1, "%s?%s%s%s&style=%s", STATUS_CGI, url_servicegroups_part, (service_filter != NULL) ? "&servicefilter=" : "", (service_filter != NULL) ? url_encode(service_filter) : "", style);
else
- snprintf(status_url, sizeof(status_url) - 1, "%s?%s&style=%s", STATUS_CGI, url_hostgroups_part, style);
+ snprintf(status_url, sizeof(status_url) - 1, "%s?%s%s%s&style=%s", STATUS_CGI, url_hostgroups_part, (service_filter != NULL) ? "&servicefilter=" : "", (service_filter != NULL) ? url_encode(service_filter) : "", style);
my_free(style);
@@ -1811,6 +1831,11 @@ void show_service_detail(void) {
my_free(temp_url);
dummy = asprintf(&temp_url, "%s&hostprops=%lu", temp_buffer, host_properties);
}
+ if (service_filter != NULL) {
+ strncpy(temp_buffer, temp_url, sizeof(temp_buffer));
+ my_free(temp_url);
+ dummy = asprintf(&temp_url, "%s&servicefilter=%s", temp_buffer, url_encode(service_filter));
+ }
}
my_free(style);
@@ -2360,6 +2385,11 @@ void show_host_detail(void) {
my_free(temp_url);
dummy = asprintf(&temp_url, "%s&hostprops=%lu", temp_buffer, host_properties);
}
+ if (service_filter != NULL) {
+ strncpy(temp_buffer, temp_url, sizeof(temp_buffer));
+ my_free(temp_url);
+ dummy = asprintf(&temp_url, "%s&servicefilter=%s", temp_buffer, url_encode(service_filter));
+ }
}
my_free(style);
@@ -4336,7 +4366,7 @@ void show_hostgroup_summaries(void) {
/* check if there are any services to display */
if (service_status_types != all_service_status_types && found == FALSE) {
-
+
/* check all services... */
for (temp_status = statusdata_list; temp_status != NULL; temp_status = temp_status->next) {
More information about the icinga-checkins
mailing list