[icinga-checkins] icinga.org: icinga-core/test/core: classic ui: Implement #3476, " set_expire_ack_by_default"

git at icinga.org git at icinga.org
Thu Jan 10 20:24:04 CET 2013


Module: icinga-core
Branch: test/core
Commit: 6139cf55be7defce633739efcfd8cb579adba756
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=6139cf55be7defce633739efcfd8cb579adba756

Author: Carl Friend <crfriend at rcn.com>
Date:   Tue Dec 11 17:44:14 2012 -0500

classic ui: Implement #3476, "set_expire_ack_by_default"

refs: #3476

This commit implements proposed feature #3476, with input from
Ricardo (and with thanks), in cgi.cfg which automatically ticks the
"Use Expire Time:" check-box in cmd.cgi.  The default behaviour is
to *NOT* tick the checkbox thereby preserving well-established bevaviour.

The intent of the change is in response to observed administrator behaviour
in large organisations where problems get acknowledged and then never fixed
leading to later system failure.  Expiring acknowledgments will assist in
reminding staff in disparate departments and locations that a problem has
not been fixed in a reasonable amount of time specified by the cgi.cfg
setting "default_expiring_acknowledgement_duration" or a different value
given in the "acknowledge problem" dialog.

---

 cgi/cgiutils.c           |    4 ++++
 cgi/cmd.c                |    5 +++--
 cgi/config.c             |    4 ++++
 sample-config/cgi.cfg.in |    9 +++++++++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index d12400f..0baad7b 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -174,6 +174,7 @@ int		week_starts_on_monday = FALSE;
 int		show_partial_hostgroups = FALSE;
 int		default_downtime_duration = 7200;
 int		default_expiring_acknowledgement_duration = 86400;
+int		set_expire_ack_by_default = FALSE;
 int		default_expiring_disabled_notifications_duration = 86400;
 
 int		result_limit = 50;
@@ -560,6 +561,9 @@ int read_cgi_config_file(char *filename) {
 		else if (!strcmp(var, "default_expiring_acknowledgement_duration"))
 			default_expiring_acknowledgement_duration = atoi(val);
 
+		else if (!strcmp(var, "set_expire_ack_by_default"))
+			set_expire_ack_by_default = (atoi(val) > 0) ? TRUE : FALSE;
+
 		else if (!strcmp(var, "default_expiring_disabled_notifications_duration"))
 			default_expiring_disabled_notifications_duration = atoi(val);
 
diff --git a/cgi/cmd.c b/cgi/cmd.c
index f06b2ac..ae0279b 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -54,6 +54,7 @@ extern int  use_authentication;
 extern int  lock_author_names;
 extern int  persistent_ack_comments;
 extern int  default_expiring_acknowledgement_duration;
+extern int  set_expire_ack_by_default;
 extern int  default_expiring_disabled_notifications_duration;
 
 extern int  display_header;
@@ -1106,7 +1107,7 @@ void print_form_element(int element, int cmd) {
 		printf("<tr><td class=\"objectDescription descriptionleft\">Use Expire Time:");
 		print_help_box(help_text);
 		printf("</td><td align=\"left\">");
-		printf("<INPUT TYPE='checkbox' ID='expire_checkbox' NAME='use_ack_end_time' onClick=\"if (document.getElementById('expire_checkbox').checked == true) document.getElementById('expired_date_row').style.display = ''; else document.getElementById('expired_date_row').style.display = 'none';\"></td></tr>\n");
+		printf("<INPUT TYPE='checkbox' ID='expire_checkbox' NAME='use_ack_end_time' onClick=\"if (document.getElementById('expire_checkbox').checked == true) document.getElementById('expired_date_row').style.display = ''; else document.getElementById('expired_date_row').style.display = 'none';\" %s></td></tr>\n", (set_expire_ack_by_default == TRUE) ? "CHECKED" : "");
 
 		snprintf(help_text, sizeof(help_text), "Enter here the expire date/time for this acknowledgement. %s will automatically delete the acknowledgement after this time expired.", PROGRAM_NAME);
 		help_text[sizeof(help_text)-1] = '\x0';
@@ -1115,7 +1116,7 @@ void print_form_element(int element, int cmd) {
 		t += (unsigned long)default_expiring_acknowledgement_duration;
 		get_time_string(&t, buffer, sizeof(buffer) - 1, SHORT_DATE_TIME);
 
-		printf("<tr id=\"expired_date_row\" style=\"display:none;\"><td class=\"objectDescription descriptionleft\">Expire Time:");
+		printf("<tr id=\"expired_date_row\" style=\"display:%s;\"><td class=\"objectDescription descriptionleft\">Expire Time:", (set_expire_ack_by_default == TRUE) ? "" : "none");
 		print_help_box(help_text);
 		printf("</td><td align=\"left\"><INPUT TYPE='TEXT' class='timepicker' NAME='end_time' VALUE='%s' SIZE=\"25\"></td></tr>\n", buffer);
 		break;
diff --git a/cgi/config.c b/cgi/config.c
index 7baeaea..b4a10e6 100644
--- a/cgi/config.c
+++ b/cgi/config.c
@@ -107,6 +107,7 @@ extern int color_transparency_index_r;
 extern int cgi_log_rotation_method;
 extern int default_downtime_duration;
 extern int default_expiring_acknowledgement_duration;
+extern int set_expire_ack_by_default;
 extern int display_status_totals;
 extern int default_statusmap_layout_method;
 extern int enable_splunk_integration;
@@ -226,6 +227,7 @@ int org_color_transparency_index_r;
 int org_cgi_log_rotation_method;
 int org_default_downtime_duration;
 int org_default_expiring_acknowledgement_duration;
+int org_set_expire_ack_by_default;
 int org_display_status_totals;
 int org_default_statusmap_layout;
 int org_enable_splunk_integration;
@@ -4113,6 +4115,7 @@ void display_cgiconfig(void) {
 	PRINT_CONFIG_LINE_STRING(service_critical_sound, org_service_critical_sound)
 	PRINT_CONFIG_LINE_STRING(service_unknown_sound, org_service_unknown_sound)
 	PRINT_CONFIG_LINE_STRING(service_warning_sound, org_service_warning_sound)
+	PRINT_CONFIG_LINE_INT(set_expire_ack_by_default, org_set_expire_ack_by_default, "bool")
 	PRINT_CONFIG_LINE_INT(show_all_services_host_is_authorized_for, org_show_all_services_host_is_authorized_for, "bool")
 	PRINT_CONFIG_LINE_INT(show_partial_hostgroups, org_show_partial_hostgroups, "bool")
 	PRINT_CONFIG_LINE_INT(show_tac_header, org_show_tac_header, "bool")
@@ -4521,6 +4524,7 @@ void store_default_settings(void) {
 	org_cgi_log_rotation_method = org_cgi_log_rotation_method;
 	org_default_downtime_duration = default_downtime_duration;
 	org_default_expiring_acknowledgement_duration = default_expiring_acknowledgement_duration;
+	org_set_expire_ack_by_default = set_expire_ack_by_default;
 	org_display_status_totals = display_status_totals;
 	org_default_statusmap_layout = default_statusmap_layout_method;
 	org_enable_splunk_integration = enable_splunk_integration;
diff --git a/sample-config/cgi.cfg.in b/sample-config/cgi.cfg.in
index 8d12692..69e3221 100644
--- a/sample-config/cgi.cfg.in
+++ b/sample-config/cgi.cfg.in
@@ -502,6 +502,15 @@ lock_author_names=1
 default_downtime_duration=7200
 
 
+# SET EXPIRE ACK BY DEFAULT
+# This option either sets or clears the checkbox for "Use Expire Time"
+# in the acknowledgement menu.  Valid values are 0 (DO NOT tick the
+# checkbox by default) or 1 (tick the checkbox by default).  The default
+# is 0 (leave the checkbox blank).
+
+set_expire_ack_by_default=0
+
+
 
 # DEFAULT EXPIRING ACKNOWLEDGEMENT DURATION
 # This option defines the default duration (in seconds) of a expiring





More information about the icinga-checkins mailing list