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

Naparuba naparuba at gmail.com
Tue Feb 28 22:21:09 UTC 2012


The following commit has been merged in the debian/master branch:
commit 52b968059a5c43764fe65177b708a867e7a949c0
Author: Naparuba <naparuba at gmail.com>
Date:   Thu Feb 16 16:39:43 2012 +0100

    Fix (reported by : Nicolas Dupeux): local/global issue with properties names between class and isntances for freshness.

diff --git a/shinken/objects/config.py b/shinken/objects/config.py
index e21e6bb..e5f94ac 100644
--- a/shinken/objects/config.py
+++ b/shinken/objects/config.py
@@ -201,9 +201,9 @@ class Config(Item):
         'service_perfdata_file_processing_command': StringProp(managed=False, default=None),
         'check_for_orphaned_services': BoolProp(default='1', class_inherit=[(Service, 'check_for_orphaned')]),
         'check_for_orphaned_hosts': BoolProp(default='1', class_inherit=[(Host, 'check_for_orphaned')]),
-        'check_service_freshness': BoolProp(default='1', class_inherit=[(Service, 'check_freshness')]),
+        'check_service_freshness': BoolProp(default='1', class_inherit=[(Service, 'global_check_freshness')]),
         'service_freshness_check_interval': IntegerProp(default='60'),
-        'check_host_freshness': BoolProp(default='1', class_inherit=[(Host, 'check_freshness')]),
+        'check_host_freshness': BoolProp(default='1', class_inherit=[(Host, 'global_check_freshness')]),
         'host_freshness_check_interval': IntegerProp(default='60'),
         'additional_freshness_latency': IntegerProp(default='15', class_inherit=[(Host, None), (Service, None)]),
         'enable_embedded_perl': BoolProp(managed=False, default='1', help='It will surely never be managed, but it should not be useful with poller performances.'),
diff --git a/shinken/objects/schedulingitem.py b/shinken/objects/schedulingitem.py
index 939743d..40202ac 100644
--- a/shinken/objects/schedulingitem.py
+++ b/shinken/objects/schedulingitem.py
@@ -188,7 +188,7 @@ class SchedulingItem(Item):
         # Then check if item whant fressness, then check fressness
         cls = self.__class__
         if not self.in_checking:
-            if cls.check_freshness:
+            if cls.global_check_freshness:
                 if self.check_freshness and self.freshness_threshold != 0:
                     if self.last_state_update < now - (self.freshness_threshold + cls.additional_freshness_latency):
                         # Raise a log
diff --git a/test/etc/1r_1h_1s/commands.cfg b/test/etc/freshness/commands.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/commands.cfg
copy to test/etc/freshness/commands.cfg
diff --git a/test/etc/1r_1h_1s/contacts.cfg b/test/etc/freshness/contacts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/contacts.cfg
copy to test/etc/freshness/contacts.cfg
diff --git a/test/etc/1r_1h_1s/hostgroups.cfg b/test/etc/freshness/hostgroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hostgroups.cfg
copy to test/etc/freshness/hostgroups.cfg
diff --git a/test/etc/1r_1h_1s/hosts.cfg b/test/etc/freshness/hosts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hosts.cfg
copy to test/etc/freshness/hosts.cfg
diff --git a/test/etc/1r_1h_1s/servicegroups.cfg b/test/etc/freshness/servicegroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/servicegroups.cfg
copy to test/etc/freshness/servicegroups.cfg
diff --git a/test/etc/1r_1h_1s/services.cfg b/test/etc/freshness/services.cfg
similarity index 97%
copy from test/etc/1r_1h_1s/services.cfg
copy to test/etc/freshness/services.cfg
index e16682e..16663dd 100644
--- a/test/etc/1r_1h_1s/services.cfg
+++ b/test/etc/freshness/services.cfg
@@ -1,6 +1,6 @@
 define service{
   active_checks_enabled          1
-  check_freshness                0
+  check_freshness                1
   check_interval                 1
   check_period                   24x7
   contact_groups                 test_contact
diff --git a/test/etc/1r_1h_1s/shinken-specific.cfg b/test/etc/freshness/shinken-specific.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/shinken-specific.cfg
copy to test/etc/freshness/shinken-specific.cfg
diff --git a/test/etc/10r_1000h_20000s/timeperiods.cfg b/test/etc/freshness/timeperiods.cfg
similarity index 100%
copy from test/etc/10r_1000h_20000s/timeperiods.cfg
copy to test/etc/freshness/timeperiods.cfg
diff --git a/test/etc/nagios_1r_1h_1s.cfg b/test/etc/nagios_freshness.cfg
similarity index 90%
copy from test/etc/nagios_1r_1h_1s.cfg
copy to test/etc/nagios_freshness.cfg
index 1566c73..0afe1f4 100644
--- a/test/etc/nagios_1r_1h_1s.cfg
+++ b/test/etc/nagios_freshness.cfg
@@ -8,21 +8,21 @@ auto_rescheduling_interval=30
 auto_rescheduling_window=180
 cached_host_check_horizon=15
 cached_service_check_horizon=15
-cfg_file=1r_1h_1s/hosts.cfg
-cfg_file=1r_1h_1s/services.cfg
-cfg_file=1r_1h_1s/contacts.cfg
-cfg_file=1r_1h_1s/commands.cfg
-cfg_file=1r_1h_1s/timeperiods.cfg
-cfg_file=1r_1h_1s/hostgroups.cfg
-cfg_file=1r_1h_1s/servicegroups.cfg
-cfg_file=1r_1h_1s/shinken-specific.cfg
+cfg_file=freshness/hosts.cfg
+cfg_file=freshness/services.cfg
+cfg_file=freshness/contacts.cfg
+cfg_file=freshness/commands.cfg
+cfg_file=freshness/timeperiods.cfg
+cfg_file=freshness/hostgroups.cfg
+cfg_file=freshness/servicegroups.cfg
+cfg_file=freshness/shinken-specific.cfg
 check_external_commands=1
 check_for_orphaned_hosts=1
 check_for_orphaned_services=1
 check_host_freshness=0
 check_result_path=var/spool/checkresults
 check_result_reaper_frequency=10
-check_service_freshness=1
+check_service_freshness=0
 command_check_interval=-1
 command_file=var/shinken.cmd
 daemon_dumps_core=0
diff --git a/test/jenkins/longtests.txt b/test/jenkins/longtests.txt
index 58d64c0..6edada7 100644
--- a/test/jenkins/longtests.txt
+++ b/test/jenkins/longtests.txt
@@ -94,6 +94,7 @@ test_groups_with_no_alias.py
 test_define_with_space.py
 test_objects_and_notifways.py
 test_star_in_hostgroups.py
+test_freshness.py
 test_parse_perfdata.py
 
 # takes long
diff --git a/test/jenkins/shorttests.txt b/test/jenkins/shorttests.txt
index 8ec2c95..91cbfe0 100644
--- a/test/jenkins/shorttests.txt
+++ b/test/jenkins/shorttests.txt
@@ -101,4 +101,5 @@ test_timeperiods_state_logs.py
 test_define_with_space.py
 test_objects_and_notifways.py
 test_star_in_hostgroups.py
+test_freshness.py
 test_parse_perfdata.py
diff --git a/test/quick_tests.sh b/test/quick_tests.sh
index bef079c..5544471 100755
--- a/test/quick_tests.sh
+++ b/test/quick_tests.sh
@@ -138,6 +138,7 @@ launch_and_assert test_notif_too_much.py
 launch_and_assert test_timeperiods_state_logs.py
 launch_and_assert test_define_with_space.py
 launch_and_assert test_objects_and_notifways.py
+launch_and_assert test_freshness.py
 launch_and_assert test_star_in_hostgroups.py
 
 launch_and_assert test_maintenance_period.py
diff --git a/test/test_freshness.py b/test/test_freshness.py
new file mode 100755
index 0000000..b554b9d
--- /dev/null
+++ b/test/test_freshness.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python2.6
+#Copyright (C) 2009-2010 :
+#    Gabes Jean, naparuba at gmail.com
+#    Gerhard Lausser, Gerhard.Lausser at consol.de
+#
+#This file is part of Shinken.
+#
+#Shinken is free software: you can redistribute it and/or modify
+#it under the terms of the GNU Affero General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#Shinken is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU Affero General Public License for more details.
+#
+#You should have received a copy of the GNU Affero General Public License
+#along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# This file is used to test reading and processing of config files
+#
+
+#It's ugly I know....
+from shinken_test import *
+
+
+class TestFreshness(ShinkenTest):
+    #Uncomment this is you want to use a specific configuration
+    #for your test
+    def setUp(self):
+        self.setup_with_file('etc/nagios_freshness.cfg')
+
+
+    #Check if the check_freshnes is doing it's job
+    def test_check_freshness(self):
+        self.print_header()
+        #We want an eventhandelr (the perfdata command) to be put in the actions dict
+        #after we got a service check
+        now = time.time()
+        svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
+        svc.checks_in_progress = []
+        svc.act_depend_of = [] # no hostchecks on critical checkresults
+
+        self.assert_(svc.check_freshness == True)
+        #--------------------------------------------------------------
+        # initialize host/service state
+        #--------------------------------------------------------------
+        #We do not want to be just a string but a real command
+        print "Additonal freshness latency", svc.__class__.additional_freshness_latency
+        self.scheduler_loop(1, [[svc, 0, 'OK | bibi=99%']])
+        print "Addi :", svc.last_state_update, svc.freshness_threshold , svc.check_freshness
+        #By default check fresh ness is set at false, so no new checks
+        self.assert_(len(svc.actions) == 0)
+        svc.do_check_freshness()
+        self.assert_(len(svc.actions) == 0)
+
+        #We make it 10s less than it was
+        svc.last_state_update = svc.last_state_update - 10
+
+
+        #Now we active it, with a too small value (now - 10s is still higer than now - (1 - 15, the addition time)
+        #So still no check
+        #svc.check_freshness = True
+        svc.freshness_threshold = 1
+        print "Addi:", svc.last_state_update, svc.freshness_threshold , svc.check_freshness
+        svc.do_check_freshness()
+        self.assert_(len(svc.actions) == 0)
+
+        # Now active globaly the check freshness
+        cmd = "[%lu] ENABLE_SERVICE_FRESHNESS_CHECKS" % now
+        self.sched.run_external_command(cmd)
+
+        #Ok, now, we remove again 10s. Here we will saw the new entry
+        svc.last_state_update = svc.last_state_update - 10
+        svc.do_check_freshness()
+        self.assert_(len(svc.actions) == 1)
+        #And we check for the message in the log too
+        self.assert_(self.log_match(1, 'Warning: The results of service'))
+
+
+if __name__ == '__main__':
+    unittest.main()
+
diff --git a/test/test_services.py b/test/test_services.py
index f797411..70c43f0 100755
--- a/test/test_services.py
+++ b/test/test_services.py
@@ -139,45 +139,6 @@ class TestService(ShinkenTest):
         self.assert_(svc.is_state('CRITICAL') == True)
         self.assert_(svc.is_state('c') == True)
 
-    #Check if the check_freshnes is doing it's job
-    def test_check_freshness(self):
-        self.print_header()
-        #We want an eventhandelr (the perfdata command) to be put in the actions dict
-        #after we got a service check
-        now = time.time()
-        svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
-        svc.checks_in_progress = []
-        svc.act_depend_of = [] # no hostchecks on critical checkresults
-        #--------------------------------------------------------------
-        # initialize host/service state
-        #--------------------------------------------------------------
-        #We do not want to be just a string but a real command
-        print "Additonal freshness latency", svc.__class__.additional_freshness_latency
-        self.scheduler_loop(1, [[svc, 0, 'OK | bibi=99%']])
-        print "Addi :", svc.last_state_update, svc.freshness_threshold , svc.check_freshness
-        #By default check fresh ness is set at false, so no new checks
-        self.assert_(len(svc.actions) == 0)
-        svc.do_check_freshness()
-        self.assert_(len(svc.actions) == 0)
-
-        #We make it 10s less than it was
-        svc.last_state_update = svc.last_state_update - 10
-
-
-        #Now we active it, with a too small value (now - 10s is still higer than now - (1 - 15, the addition time)
-        #So still no check
-        svc.check_freshness = True
-        svc.freshness_threshold = 1
-        print "Addi:", svc.last_state_update, svc.freshness_threshold , svc.check_freshness
-        svc.do_check_freshness()
-        self.assert_(len(svc.actions) == 0)
-
-        #Ok, now, we remove again 10s. Here we will saw the new entry
-        svc.last_state_update = svc.last_state_update - 10
-        svc.do_check_freshness()
-        self.assert_(len(svc.actions) == 1)
-        #And we check for the message in the log too
-        self.assert_(self.log_match(1, 'Warning: The results of service'))
 
 
     def test_business_impact_value(self):

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list