[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Gerhard Lausser gerhard.lausser at consol.de
Tue Feb 28 22:18:34 UTC 2012


The following commit has been merged in the debian/master branch:
commit c4b20bc12bb41a0cae5365fe74f7b9159fe97750
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date:   Sat Feb 4 21:19:46 2012 +0100

    Add a before_after_hook to the regenerator. This gives other modules the chance to take actions when a state change occurs. (used for livestatus)

diff --git a/shinken/misc/regenerator.py b/shinken/misc/regenerator.py
index 5e86a75..cd45173 100644
--- a/shinken/misc/regenerator.py
+++ b/shinken/misc/regenerator.py
@@ -417,6 +417,14 @@ class Regenerator(object):
 
 ############### Brok management part
 
+    def before_after_hook(self, brok, obj):
+        """
+        This can be used by derived classes to compare the data in the brok
+        with the object which will be updated by these data. For example,
+        it is possible to find out in this method whether the state of a
+        host or service has changed.
+        """
+        pass
 
 ####### INITIAL PART
 
@@ -876,6 +884,7 @@ class Regenerator(object):
         h = self.hosts.find_by_name(hname)
 
         if h:
+            self.before_after_hook(b, h)
             self.update_element(h, data)
 
             # We can have some change in our impacts and source problems.
@@ -919,6 +928,7 @@ class Regenerator(object):
         sdesc = data['service_description']
         s = self.services.find_srv_by_name_and_hostname(hname, sdesc)
         if s:
+            self.before_after_hook(b, s)
             self.update_element(s, data)
 
             # We can have some change in our impacts and source problems.
@@ -996,6 +1006,7 @@ class Regenerator(object):
 
         h = self.hosts.find_by_name(hname)
         if h:
+            self.before_after_hook(b, h)
             self.update_element(h, data)
 
 
@@ -1011,6 +1022,7 @@ class Regenerator(object):
         sdesc = data['service_description']
         s = self.services.find_srv_by_name_and_hostname(hname, sdesc)
         if s:
+            self.before_after_hook(b, s)
             self.update_element(s, data)
 
 

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list