[icinga-checkins] icinga.org: icinga-core/master: add new is_volatile setting of 2 for services, which respects the re-notification interval for notifications (Ton Voon)

git at icinga.org git at icinga.org
Wed May 19 13:41:52 CEST 2010


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

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed May 12 21:39:32 2010 +0200

add new is_volatile setting of 2 for services, which respects the re-notification interval for notifications (Ton Voon)

fixes #413

---

 Changelog            |    1 +
 base/checks.c        |    4 ++--
 base/notifications.c |   10 ++++++----
 cgi/config.c         |    2 +-
 common/objects.c     |    2 +-
 include/objects.h    |    6 ++++++
 xdata/xodtemplate.c  |    2 +-
 7 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/Changelog b/Changelog
index 5848f68..10554a3 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ Icinga 1.0.x Change Log
 ENHANCEMENTS
 * core: init script shows config errors option; don't remove pidfile if icinga did not stop in a timely manner
 * core: add in sync retention facility (Ton Voon, Opsera Ltd)
+* core: add new is_volatile setting of 2 for services, which respects the re-notification interval for notifications (Ton Voon)
 
 * idoutils: remove mysql binary selects, use case-sensitive collation instead (William Preston)
 * idoutils: Spread the list of linked lists thinner (extend objects hash slots) (Opsera Ltd)
diff --git a/base/checks.c b/base/checks.c
index 94d8f3a..ac91806 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -1505,7 +1505,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
 			        }
 
 			/* else log the problem (again) if this service is flagged as being volatile */
-			else if(temp_service->is_volatile==TRUE){
+			else if(temp_service->is_volatile==FALSE){
 				log_service_event(temp_service);
 				state_was_logged=TRUE;
 			        }
@@ -1524,7 +1524,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
 			service_notification(temp_service,NOTIFICATION_NORMAL,NULL,NULL,NOTIFICATION_OPTION_NONE);
 
 			/* run the service event handler if we changed state from the last hard state or if this service is flagged as being volatile */
-			if(hard_state_change==TRUE || temp_service->is_volatile==TRUE)
+			if(hard_state_change==TRUE || temp_service->is_volatile==FALSE)
 				handle_service_event(temp_service);
 
 			/* save the last hard state */
diff --git a/base/notifications.c b/base/notifications.c
index 27a0860..9b518bd 100644
--- a/base/notifications.c
+++ b/base/notifications.c
@@ -513,10 +513,12 @@ int check_service_notification_viability(service *svc, int type, int options){
 	        }
 	
 	/* don't notify if we haven't waited long enough since the last time (and the service is not marked as being volatile) */
-	if((current_time < svc->next_notification) && svc->is_volatile==FALSE){
-		log_debug_info(DEBUGL_NOTIFICATIONS,1,"We haven't waited long enough to re-notify contacts about this service.\n");
-		log_debug_info(DEBUGL_NOTIFICATIONS,1,"Next valid notification time: %s",ctime(&svc->next_notification));
-		return ERROR;
+	if((current_time < svc->next_notification)){
+		if (svc->is_volatile==FALSE || svc->is_volatile==VOLATILE_WITH_RENOTIFICATION_INTERVAL) {
+			log_debug_info(DEBUGL_NOTIFICATIONS,1,"We haven't waited long enough to re-notify contacts about this service.\n");
+			log_debug_info(DEBUGL_NOTIFICATIONS,1,"Next valid notification time: %s",ctime(&svc->next_notification));
+			return ERROR;
+			}
 	        }
 
 	/* if this service is currently in a scheduled downtime period, don't send the notification */
diff --git a/cgi/config.c b/cgi/config.c
index 0dc95e8..3aad451 100644
--- a/cgi/config.c
+++ b/cgi/config.c
@@ -1246,7 +1246,7 @@ void display_services(void){
 
 		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->parallelize==TRUE)?"Yes":"No");
 
-		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->is_volatile==TRUE)?"Yes":"No");
+		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->is_volatile==FALSE)?"Yes":"No");
 
 		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->obsess_over_service==TRUE)?"Yes":"No");
 
diff --git a/common/objects.c b/common/objects.c
index 4ec1da4..525e51a 100644
--- a/common/objects.c
+++ b/common/objects.c
@@ -1636,7 +1636,7 @@ service *add_service(char *host_name, char *description, char *display_name, cha
 	new_service->notify_on_recovery=(notify_recovery>0)?TRUE:FALSE;
 	new_service->notify_on_flapping=(notify_flapping>0)?TRUE:FALSE;
 	new_service->notify_on_downtime=(notify_downtime>0)?TRUE:FALSE;
-	new_service->is_volatile=(is_volatile>0)?TRUE:FALSE;
+	new_service->is_volatile=(is_volatile>0)?((is_volatile==2)?VOLATILE_WITH_RENOTIFICATION_INTERVAL:TRUE):FALSE;
 	new_service->flap_detection_enabled=(flap_detection_enabled>0)?TRUE:FALSE;
 	new_service->low_flap_threshold=low_flap_threshold;
 	new_service->high_flap_threshold=high_flap_threshold;
diff --git a/include/objects.h b/include/objects.h
index 167adfc..112553c 100644
--- a/include/objects.h
+++ b/include/objects.h
@@ -66,6 +66,12 @@
 #define HOSTESCALATION_SKIPLIST                10
 #define SERVICEESCALATION_SKIPLIST             11
 
+/****************** DEFINITIONS *******************/
+/*#define VOLATILE_FALSE 0 - uses FALSE*/
+/*#define VOLATILE_TRUE  1 - uses TRUE */
+#define VOLATILE_WITH_RENOTIFICATION_INTERVAL 2
+
+
 /******** escalation condition connectors ******/
 #define EC_CONNECTOR_NO                   0
 #define EC_CONNECTOR_OR                   1
diff --git a/xdata/xodtemplate.c b/xdata/xodtemplate.c
index 4564563..29616b8 100644
--- a/xdata/xodtemplate.c
+++ b/xdata/xodtemplate.c
@@ -3893,7 +3893,7 @@ int xodtemplate_add_object_property(char *input, int options){
 			temp_service->have_parallelize_check=TRUE;
 		        }
 		else if(!strcmp(variable,"is_volatile")){
-			temp_service->is_volatile=(atoi(value)>0)?TRUE:FALSE;
+			temp_service->is_volatile=(atoi(value)>0)?((atoi(value)==2)?VOLATILE_WITH_RENOTIFICATION_INTERVAL:TRUE):FALSE;
 			temp_service->have_is_volatile=TRUE;
 		        }
 		else if(!strcmp(variable,"obsess_over_service")){





More information about the icinga-checkins mailing list