[patch] Re: flap detection + state retention

Tom Throckmorton throck at duke.edu
Fri Jan 25 16:45:20 CET 2008


On Jan 24 15:17, Tom Throckmorton wrote:
> *delurks*
> 
> Hello all,
> 
> Can someone here please verify that in Nagios 2.x the state of flap_detection
> should or shouldn't be persistent across a reload / restart?
> 
> See my post below, and the brief thread on nagios-users:
> 
> http://thread.gmane.org/gmane.network.nagios.user/52044
> 
> Tests on 2.x seem to show that the retained values for global/host/service flap
> detection aren't being honored on a reload.  This seems to contradict the docs,
> so I'm thinking it's a bug.

So, it looks as if the calls for modified_attributes were completely missing
from the flapping routines, and appear to have been so since the inception of
2.x.  As i'm reading the code, these calls flag the attributes as modified,
which means they'll be considered later in the state retention code.  Without
the calls, the state retention code ignores these attributes, which leads to
the problem.

Please consider the attached patch against base/flapping.c - this is against
2.10, which happens to be the same as CVS.  I'd appreciate it if someone with a
better handle on the code (and better programming skills) would have a look to
make sure I'm not doing something dumb.

I've tested this on 2.10 running on CentOS 5, and it appears to do the right
thing regarding retaining state across reloads.

Cheers,


-tt


-- 
Tom Throckmorton
OIT - CSI
Duke University
-------------- next part --------------
--- base/flapping.c.dist	2006-05-19 10:25:03.000000000 -0400
+++ base/flapping.c	2008-01-25 09:15:41.000000000 -0500
@@ -41,6 +41,8 @@
 extern double   low_host_flap_threshold;
 extern double   high_host_flap_threshold;
 
+extern unsigned long    modified_host_process_attributes;
+extern unsigned long    modified_service_process_attributes;
 
 /******************************************************************/
 /******************** FLAP DETECTION FUNCTIONS ********************/
@@ -457,6 +459,10 @@
 	printf("enable_flap_detection() start\n");
 #endif
 
+	/* set the attribute modified flag */
+	modified_host_process_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+	modified_service_process_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+
 	/* set flap detection flag */
 	enable_flap_detection=TRUE;
 
@@ -479,6 +485,11 @@
 	printf("disable_flap_detection() start\n");
 #endif
 
+	/* set the attribute modified flag */
+	modified_host_process_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+	modified_service_process_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+
+
 	/* set flap detection flag */
 	enable_flap_detection=FALSE;
 
@@ -502,6 +513,9 @@
 	printf("enable_host_flap_detection() start\n");
 #endif
 
+	/* set the attribute modified flag */
+	hst->modified_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+
 	/* nothing to do... */
 	if(hst->flap_detection_enabled==TRUE)
 		return;
@@ -536,6 +550,9 @@
 	printf("disable_host_flap_detection() start\n");
 #endif
 
+	/* set the attribute modified flag */
+	hst->modified_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+
 	/* nothing to do... */
 	if(hst->flap_detection_enabled==FALSE)
 		return;
@@ -586,6 +603,9 @@
 	printf("enable_service_flap_detection() start\n");
 #endif
 
+	/* set the attribute modified flag */
+	svc->modified_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+
 	/* nothing to do... */
 	if(svc->flap_detection_enabled==TRUE)
 		return;
@@ -620,6 +640,9 @@
 	printf("disable_service_flap_detection() start\n");
 #endif
 
+	/* set the attribute modified flag */
+	svc->modified_attributes|=MODATTR_FLAP_DETECTION_ENABLED;
+
 	/* nothing to do... */
 	if(svc->flap_detection_enabled==FALSE)
 		return;
@@ -660,9 +683,3 @@
 
 	return;
         }
-
-
-
-
-
-
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list