[icinga-checkins] icinga.org: icinga-core/master: classic-ui: fixed extinfo. cgi shows localtime(0) instead of "NOT SET" when global notifications are not set to expire #3482

git at icinga.org git at icinga.org
Wed Jan 2 21:31:48 CET 2013


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

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Tue Dec 18 19:51:25 2012 +0100

classic-ui: fixed extinfo.cgi shows localtime(0) instead of "NOT SET" when global notifications are not set to expire #3482

refs: #3482

* if no expiry date is set an notifications are switched off it
  displays "NOT SET".
* added "disable_notifications_expire_time" to CSV and JSON data
* added expiry date to "info table" if set.

---

 Changelog      |    1 +
 Changelog_json |    1 +
 cgi/cgiutils.c |   12 ++++++++++--
 cgi/extinfo.c  |    8 +++++++-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 9facce9..18d3a00 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ FIXES
 * classic ui: fixed backtrack_archives only getting calculated on a daily log rotation basis #3416 - RB
 * classic ui: fixed invalid freeing of last_check in 'scheduling queue' for first time checks #3444 - RB
 * classic ui: fixed Warning and Unknown States are mixed up in Alert Summary Report #3488 - RB
+* classic ui: fixed extinfo.cgi shows localtime(0) instead of "NOT SET" when global notifications are not set to expire #3482 - RB
 
 * docs: add missing cmd_mod description in cgi params #3438 - MF
 * docs: search_string as cgi GET param works also for status.cgi #3451 - MF
diff --git a/Changelog_json b/Changelog_json
index 0410030..b12b467 100644
--- a/Changelog_json
+++ b/Changelog_json
@@ -4,6 +4,7 @@ Classic-UI JSON Change Log
 
 1.9.0 - only values added, no existing values changed
 * added icinga_status to every json response #3172
+* added disable_notifications_expire_time to extinfo/processinfo #3482
 
 1.8.0 - IMPORTANT: strings changed (making string names more consitent throughout all cgis) #2693
 * changed host -> host_name  !!!!!
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 1513249..c52ba67 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -1934,6 +1934,7 @@ char * escape_string(char *input) {
 
 void display_info_table(char *title, authdata *current_authdata, int daemon_check) {
 	char date_time[MAX_DATETIME_LENGTH];
+	char disable_notif_expire_time[MAX_DATETIME_LENGTH];
 	char *dir_to_check = NULL;
 	time_t current_time;
 	int result;
@@ -1949,6 +1950,9 @@ void display_info_table(char *title, authdata *current_authdata, int daemon_chec
 	time(&current_time);
 	get_time_string(&current_time, date_time, (int)sizeof(date_time), LONG_DATE_TIME);
 
+	/* disabled notifications expire time */
+	get_time_string(&disable_notifications_expire_time, disable_notif_expire_time, (int)sizeof(disable_notif_expire_time), SHORT_DATE_TIME);
+
 	printf("Last Updated: %s ", date_time);
 
 	/* display only if refresh is supported */
@@ -2007,8 +2011,12 @@ void display_info_table(char *title, authdata *current_authdata, int daemon_chec
 		printf("<DIV CLASS='infoBoxBadProcStatus'>Warning: Could not read program status information!</DIV>");
 
 	else {
-		if (enable_notifications == FALSE)
-			printf("<DIV CLASS='infoBoxBadProcStatus'>- Notifications are disabled</DIV>");
+		if (enable_notifications == FALSE) {
+			printf("<DIV CLASS='infoBoxBadProcStatus'>- Notifications are disabled");
+			if (disable_notifications_expire_time != 0)
+				printf(" until %s", disable_notif_expire_time);
+			printf("</DIV>");
+		}
 
 		if (execute_service_checks == FALSE)
 			printf("<DIV CLASS='infoBoxBadProcStatus'>- Service checks are disabled</DIV>");
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index 2913049..0ea5769 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -1065,6 +1065,10 @@ void show_process_info(void) {
 
 		printf("\"icinga_pid\": %d,\n", nagios_pid);
 		printf("\"notifications_enabled\": %s,\n", (enable_notifications == TRUE) ? "true" : "false");
+		if (disable_notifications_expire_time == (time_t)0)
+			printf("\"disable_notifications_expire_time\": null,\n");
+		else
+			printf("\"disable_notifications_expire_time\": \"%s\",\n", disable_notif_expire_time);
 		printf("\"service_checks_being_executed\": %s,\n", (execute_service_checks == TRUE) ? "true" : "false");
 		printf("\"passive_service_checks_being_accepted\": %s,\n", (accept_passive_service_checks == TRUE) ? "true" : "false");
 		printf("\"host_checks_being_executed\": %s,\n", (execute_host_checks == TRUE) ? "true" : "false");
@@ -1090,6 +1094,7 @@ void show_process_info(void) {
 		printf("%sLAST_LOG_FILE_ROTATION%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
 		printf("%sICINGA_PID%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
 		printf("%sNOTIFICATIONS_ENABLED%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
+		printf("%sNOTIFICATIONS_DISABLED_EXPIRE_TIME%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
 		printf("%sSERVICE_CHECKS_BEING_EXECUTED%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
 		printf("%sPASSIVE_SERVICE_CHECKS_BEING_ACCEPTED%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
 		printf("%sHOST_CHECKS_BEING_EXECUTED%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
@@ -1115,6 +1120,7 @@ void show_process_info(void) {
 		printf("%s%s%s%s", csv_data_enclosure, (last_log_rotation == (time_t)0) ? "N/A" : last_log_rotation_time, csv_data_enclosure, csv_delimiter);
 		printf("%s%d%s%s", csv_data_enclosure, nagios_pid, csv_data_enclosure, csv_delimiter);
 		printf("%s%s%s%s", csv_data_enclosure, (enable_notifications == TRUE) ? "YES" : "NO", csv_data_enclosure, csv_delimiter);
+		printf("%s%s%s%s", csv_data_enclosure, (disable_notifications_expire_time == (time_t)0) ? "N/A" : disable_notif_expire_time, csv_data_enclosure, csv_delimiter);
 		printf("%s%s%s%s", csv_data_enclosure, (execute_service_checks == TRUE) ? "YES" : "NO", csv_data_enclosure, csv_delimiter);
 		printf("%s%s%s%s", csv_data_enclosure, (accept_passive_service_checks == TRUE) ? "YES" : "NO", csv_data_enclosure, csv_delimiter);
 		printf("%s%s%s%s", csv_data_enclosure, (execute_host_checks == TRUE) ? "YES" : "NO", csv_data_enclosure, csv_delimiter);
@@ -1170,7 +1176,7 @@ void show_process_info(void) {
 
 		/* notifications enabled */
 		printf("<TR><TD CLASS='dataVar'>Notifications Enabled?</TD><TD CLASS='dataVal'><DIV CLASS='notifications%s'>  %s  </DIV></TD></TR>\n", (enable_notifications == TRUE) ? "ENABLED" : "DISABLED", (enable_notifications == TRUE) ? "YES" : "NO");
-		if (enable_notifications == FALSE)
+		if (enable_notifications == FALSE && disable_notifications_expire_time != 0)
 			printf("<TR><TD CLASS='dataVar'>Notifications Disabled Expire Time:</TD><TD CLASS='dataVal'>%s</TD></TR>\n", disable_notif_expire_time);
 		else
 			printf("<TR><TD CLASS='dataVar'>Notifications Disabled Expire Time:</TD><TD CLASS='dataVal'><DIV CLASS='notificationsUNKNOWN'>  NOT SET  </DIV></TD></TR>\n");





More information about the icinga-checkins mailing list