[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: default downtime duration is configurable in cgi.cfg #1642

git at icinga.org git at icinga.org
Wed Jun 29 13:50:45 CEST 2011


Module: icinga-core
Branch: mfriedrich/core
Commit: 57e6579b937a6d6955fe4a920a352fc54e6db538
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=57e6579b937a6d6955fe4a920a352fc54e6db538

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Tue Jun 14 22:05:53 2011 +0200

default downtime duration is configurable in cgi.cfg #1642

refs: #1642

---

 Changelog                |    1 +
 cgi/cgiutils.c           |    4 ++++
 cgi/cmd.c                |   12 +++++++++---
 sample-config/cgi.cfg.in |    7 +++++++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index f45cf44..52e9463 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ ENHANCEMENTS
 * classic ui: Added option to suppress coloring of hosts/services in maintenance (Matthew Brooks) #992
 * classic ui: Added option to show partial hostgroups (Matthew Brooks) #1013
 * classic ui: changing drop down menu in status.cgi to jquery-dd #1644
+* classic ui: default downtime duration is configurable in cgi.cfg #1642
 
 FIXES
 * core: remove duplicated unlinks for check result files with multiple results #1615
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index c7d46f0..e9ad28e 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -143,6 +143,7 @@ int		enforce_comments_on_actions=FALSE;
 int		week_starts_on_monday=FALSE;
 
 int		show_partial_hostgroups=FALSE;
+int		default_downtime_duration=7200;
 
 extern hostgroup       *hostgroup_list;
 extern contactgroup    *contactgroup_list;
@@ -553,6 +554,9 @@ int read_cgi_config_file(char *filename){
 		else if(!strcmp(var,"lock_author_names"))
 			lock_author_names=(atoi(val)>0)?TRUE:FALSE;
 
+		else if(!strcmp(var,"default_downtime_duration"))
+			default_downtime_duration=atoi(val);
+
 		else if(!strcmp(var,"use_ssl_authentication"))
 			use_ssl_authentication=(atoi(val)>0)?TRUE:FALSE;
 
diff --git a/cgi/cmd.c b/cgi/cmd.c
index bd4d981..81d5453 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -61,6 +61,7 @@ extern int  daemon_check;
 extern int enforce_comments_on_actions;
 extern int date_format;
 extern int use_logging;
+extern int default_downtime_duration;
 
 extern scheduled_downtime *scheduled_downtime_list;
 extern comment *comment_list;
@@ -823,6 +824,7 @@ void print_help_box(char *content) {
 
 void print_form_element(int element,int cmd) {
 	time_t t;
+	int t_hour,t_min;
 	char buffer[MAX_INPUT_BUFFER];
 
 	switch(element) {
@@ -930,7 +932,7 @@ void print_form_element(int element,int cmd) {
 	case PRINT_CHECK_TIME:
 		time(&t);
 		if (element == PRINT_END_TIME )
-			t+=(unsigned long)7200;
+			t+=(unsigned long)default_downtime_duration;
 		get_time_string(&t,buffer,sizeof(buffer)-1,SHORT_DATE_TIME);
 		printf("<tr><td class=\"objectDescription descriptionleft\">");
 		if (element == PRINT_START_TIME ){
@@ -948,6 +950,10 @@ void print_form_element(int element,int cmd) {
 		break;
 
 	case PRINT_FIXED_FLEXIBLE_TYPE:
+		default_downtime_duration = default_downtime_duration / 60;
+		t_min = default_downtime_duration % 60;
+		default_downtime_duration = default_downtime_duration - t_min;
+		t_hour = (default_downtime_duration / 60 ) ;
 
 		snprintf(help_text,sizeof(help_text),"If you select the <i>fixed</i> option, the downtime will be in effect between the start and end times you specify. If you do not select the <i>fixed</i> "
 				 "option, %s will treat this as <i>flexible</i> downtime. Flexible downtime starts when the host goes down or becomes unreachable / service becomes critical (sometime between the "
@@ -971,9 +977,9 @@ void print_form_element(int element,int cmd) {
 		printf("</td><td align=\"left\">\n");
 		printf("\t<table border=0  cellspacing=0 cellpadding=0>\n");
 		printf("\t\t<tr>\n");
-		printf("\t\t\t<td><INPUT TYPE='TEXT' NAME='hours' VALUE='2' SIZE=2 MAXLENGTH=2></td>\n");
+		printf("\t\t\t<td><INPUT TYPE='TEXT' NAME='hours' VALUE='%d' SIZE=2 MAXLENGTH=2></td>\n",t_hour);
 		printf("\t\t\t<td width=\"50\"> Hours</td>\n");
-		printf("\t\t\t<td><INPUT TYPE='TEXT' NAME='minutes' VALUE='0' SIZE=2 MAXLENGTH=2></td>\n");
+		printf("\t\t\t<td><INPUT TYPE='TEXT' NAME='minutes' VALUE='%d' SIZE=2 MAXLENGTH=2></td>\n",t_min);
 		printf("\t\t\t<td width=\"50\"> Minutes</td>\n");
 		printf("\t\t</tr>\n");
 		printf("\t</table>\n");
diff --git a/sample-config/cgi.cfg.in b/sample-config/cgi.cfg.in
index 9731824..0fdce28 100644
--- a/sample-config/cgi.cfg.in
+++ b/sample-config/cgi.cfg.in
@@ -434,6 +434,13 @@ lock_author_names=1
 
 
 
+# DEFAULT DOWNTIME DURATION
+# This option defines the default duration (in seconds) of fixed and
+# flexible downtimes. Default is 7200 seconds (2 hours).
+#default_donwtime_duration=7200
+
+
+
 # SHOW LONG PLUGIN OUTPUT IN STATUS OPTION
 # This option allows you to specify the length of status information
 # in output of status.cgi. If you set the value to 1 it shows the





More information about the icinga-checkins mailing list