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

Nicolas DUPEUX nicolas.dupeux at arkea.com
Tue Feb 28 22:19:17 UTC 2012


The following commit has been merged in the debian/master branch:
commit 2c794ad9d684c5db2cf58c8c0ce9a73837ec4531
Author: Nicolas DUPEUX <nicolas.dupeux at arkea.com>
Date:   Mon Feb 6 16:53:33 2012 +0100

    Add support for max_packet_age

diff --git a/shinken/modules/nsca.py b/shinken/modules/nsca.py
index 57ea9bc..f3288e1 100644
--- a/shinken/modules/nsca.py
+++ b/shinken/modules/nsca.py
@@ -65,20 +65,25 @@ def get_instance(plugin):
         password = plugin.password
     else:
         password = ""
+    if hasattr(plugin, 'max_packet_age'):
+        max_packet_age = min(plugin.max_packet_age,900)
+    else:
+        max_packet_age = 30
 
-    instance = NSCA_arbiter(plugin, host, port, encryption_method, password)
+    instance = NSCA_arbiter(plugin, host, port, encryption_method, password, max_packet_age)
     return instance
 
 
 #Just print some stuff
 class NSCA_arbiter(BaseModule):
-    def __init__(self, modconf, host, port, encryption_method, password):
+    def __init__(self, modconf, host, port, encryption_method, password, max_packet_age):
         BaseModule.__init__(self, modconf)
         self.host = host
         self.port = port
         self.encryption_method = encryption_method
         self.password = password
         self.rng = random.Random(password)
+        self.max_packet_age = max_packet_age
 
 
     #Ok, main function that is called in the CONFIGURATION phase
@@ -181,7 +186,14 @@ class NSCA_arbiter(BaseModule):
                         (timestamp, rc, hostname, service, output)=self.read_check_result(databuffer[s],IVs[s])
                         del databuffer[s]
                         del IVs[s]
-                        self.post_command(timestamp,rc,hostname,service,output)
+                        current_time = time.time()
+                        check_result_age = current_time - timestamp
+                        if timestamp > current_time:
+                            print "Dropping packet with future timestamp."
+                        elif check_result_age > self.max_packet_age:
+                            print "Dropping packet with stale timestamp - packet was %s seconds old." % check_result_age
+                        else:
+                            self.post_command(timestamp,rc,hostname,service,output)
                         try:
                             s.shutdown(2)
                         except Exception , exp:

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list