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

Naparuba naparuba at gmail.com
Tue Feb 28 22:16:39 UTC 2012


The following commit has been merged in the debian/master branch:
commit 9fe8497cf0c281c5f9252114707f2380fd62c436
Author: Naparuba <naparuba at gmail.com>
Date:   Fri Jan 27 16:40:12 2012 +0100

    Fix : issue #85

diff --git a/etc/skonf.cfg b/etc/skonf.cfg
index 50a39c2..29b2313 100644
--- a/etc/skonf.cfg
+++ b/etc/skonf.cfg
@@ -15,6 +15,9 @@ cfg_file=discovery_runs.cfg
 # Load all commands that will be used
 cfg_file=commands.cfg
 
+# Load modules, for possible bdd connection
+cfg_file=shinken-specific.cfg
+
 # Some important macros
 resource_file=resource.cfg
 
diff --git a/shinken/discovery/discoverymanager.py b/shinken/discovery/discoverymanager.py
index f5355c9..8d99632 100644
--- a/shinken/discovery/discoverymanager.py
+++ b/shinken/discovery/discoverymanager.py
@@ -48,7 +48,7 @@ class DiscoveryManager:
         self.log.load_obj(self)
         self.config_files = [path]
         self.conf = Config()
-        self.conf.read_config(self.config_files)
+
         buf = self.conf.read_config(self.config_files)
         
         # Add macros on the end of the buf so they will
diff --git a/shinken/modules/service_perfdata_broker/service_perfdata_broker.py b/shinken/modules/service_perfdata_broker/service_perfdata_broker.py
index f98760c..03e8b11 100644
--- a/shinken/modules/service_perfdata_broker/service_perfdata_broker.py
+++ b/shinken/modules/service_perfdata_broker/service_perfdata_broker.py
@@ -77,6 +77,7 @@ class Service_perfdata_broker(BaseModule):
             '$SERVICEOUTPUT$' : data['output'],
             '$SERVICESTATE$' : current_state,
             '$SERVICEPERFDATA$' : data['perf_data'],
+            '$LASTSERVICESTATE$' : data['last_state']
             }
         s = self.template
         for m in macros:
diff --git a/shinken/objects/config.py b/shinken/objects/config.py
index d843a1e..2cdc75b 100644
--- a/shinken/objects/config.py
+++ b/shinken/objects/config.py
@@ -418,7 +418,8 @@ class Config(Item):
                     cfg_file_name = cfg_file_name.strip()
                     try:
                         fd = open(cfg_file_name, 'rU')
-                        logger.log("Processing object config file '%s'" % cfg_file_name)
+                        if self.read_config_silent == 0:
+                            logger.log("Processing object config file '%s'" % cfg_file_name)
                         res.write(os.linesep + '# IMPORTEDFROM=%s' % (cfg_file_name) + os.linesep)
                         res.write(fd.read().decode('utf8', 'replace'))
                         #Be sure to add a line return so we won't mix files
@@ -442,7 +443,8 @@ class Config(Item):
                     for root, dirs, files in os.walk(cfg_dir_name):
                         for file in files:
                             if re.search("\.cfg$", file):
-                                logger.log("Processing object config file '%s'" % os.path.join(root, file))
+                                if self.read_config_silent == 0:
+                                    logger.log("Processing object config file '%s'" % os.path.join(root, file))
                                 try:
                                     res.write(os.linesep + '# IMPORTEDFROM=%s' % (os.path.join(root, file)) + os.linesep)
                                     fd = open(os.path.join(root, file), 'rU')
@@ -1259,7 +1261,8 @@ class Config(Item):
         r = self.conf_is_correct
 
         # Globally unamanged parameters
-        logger.log('Checking global parameters...')
+        if self.read_config_silent == 0:
+            logger.log('Checking global parameters...')
         if not self.check_error_on_hard_unmanaged_parameters():
             r = False
             logger.log("check global parameters failed")
@@ -1267,12 +1270,14 @@ class Config(Item):
         for x in ('hosts', 'hostgroups', 'contacts', 'contactgroups', 'notificationways',
                   'escalations', 'services', 'servicegroups', 'timeperiods', 'commands',
                   'hostsextinfo','servicesextinfo'):
-            logger.log('Checking %s...' % (x))
+            if self.read_config_silent == 0:
+                logger.log('Checking %s...' % (x))
             cur = getattr(self, x)
             if not cur.is_correct():
                 r = False
                 logger.log("\t%s conf incorrect !!" % (x))
-            logger.log('\tChecked %d %s' % (len(cur), x))
+            if self.read_config_silent == 0:
+                logger.log('\tChecked %d %s' % (len(cur), x))
 
         # Hosts got a special check for loops
         if not self.hosts.no_loop_in_parents():
@@ -1284,11 +1289,13 @@ class Config(Item):
                    'discoveryrules', 'discoveryruns', 'businessimpactmodulations'):
             try: cur = getattr(self, x)
             except: continue
-            logger.log('Checking %s...' % (x))
+            if self.read_config_silent == 0:
+                logger.log('Checking %s...' % (x))
             if not cur.is_correct():
                 r = False
                 logger.log("\t%s conf incorrect !!" % (x))
-            logger.log('\tChecked %d %s' % (len(cur), x))
+            if self.read_config_silent == 0:
+                logger.log('\tChecked %d %s' % (len(cur), x))
 
         # Look that all scheduler got a broker that will take brok.
         # If there are no, raiea Warning
diff --git a/shinken/objects/host.py b/shinken/objects/host.py
index b49aaaa..a9af549 100644
--- a/shinken/objects/host.py
+++ b/shinken/objects/host.py
@@ -143,9 +143,9 @@ class Host(SchedulingItem):
         'state_type_id':        IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
         'current_event_id':     StringProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
         'last_event_id':        IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
-        'last_state':           StringProp(default='PENDING', fill_brok=['full_status'], retention=True),
-        'last_state_id':        IntegerProp(default=0, fill_brok=['full_status'], retention=True),
-        'last_state_type' :     StringProp(default='HARD', fill_brok=['full_status'],  retention=True),
+        'last_state':           StringProp(default='PENDING', fill_brok=['full_status', 'check_result'], retention=True),
+        'last_state_id':        IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
+        'last_state_type' :     StringProp(default='HARD', fill_brok=['full_status', 'check_result'],  retention=True),
         'last_state_change':    FloatProp(default=time.time(), fill_brok=['full_status'], retention=True),
         'last_hard_state_change': FloatProp(default=time.time(), fill_brok=['full_status', 'check_result'], retention=True),
         'last_hard_state':      StringProp(default='PENDING', fill_brok=['full_status'], retention=True),
diff --git a/shinken/objects/service.py b/shinken/objects/service.py
index e599776..1d15e37 100644
--- a/shinken/objects/service.py
+++ b/shinken/objects/service.py
@@ -138,9 +138,9 @@ class Service(SchedulingItem):
         'state_id':           IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
         'current_event_id':   IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
         'last_event_id':      IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
-        'last_state':         StringProp (default='PENDING', fill_brok=['full_status'], retention=True),
-        'last_state_type':    StringProp (default='HARD', fill_brok=['full_status'], retention=True),
-        'last_state_id':      IntegerProp(default=0, fill_brok=['full_status'], retention=True),
+        'last_state':         StringProp (default='PENDING', fill_brok=['full_status', 'check_result'], retention=True),
+        'last_state_type':    StringProp (default='HARD', fill_brok=['full_status', 'check_result'], retention=True),
+        'last_state_id':      IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
         'last_state_change':  FloatProp (default=time.time(), fill_brok=['full_status'], retention=True),
         'last_hard_state_change': FloatProp(default=time.time(), fill_brok=['full_status', 'check_result'], retention=True),
         'last_hard_state':    StringProp (default='PENDING', fill_brok=['full_status'], retention=True),
diff --git a/test/shinken_test.py b/test/shinken_test.py
index 58b8a78..41eff95 100755
--- a/test/shinken_test.py
+++ b/test/shinken_test.py
@@ -110,7 +110,6 @@ class ShinkenTest(unittest.TestCase):
         self.log.load_obj(self)
         self.config_files = [path]
         self.conf = Config()
-        self.conf.read_config(self.config_files)
         buf = self.conf.read_config(self.config_files)
         raw_objects = self.conf.read_config_buf(buf)
         self.conf.create_objects_for_type(raw_objects, 'arbiter')
diff --git a/test/test_module_service_perfdata.py b/test/test_module_service_perfdata.py
index 1a1ca1a..0c172cb 100755
--- a/test/test_module_service_perfdata.py
+++ b/test/test_module_service_perfdata.py
@@ -31,7 +31,7 @@ from shinken_test import unittest, ShinkenTest
 from shinken.modules.service_perfdata_broker import get_instance
 
 
-class TestConfig(ShinkenTest):
+class TestModSRVPErfdata(ShinkenTest):
     #setUp is in shinken_test
 
     #Change ME :)
@@ -111,6 +111,36 @@ class TestConfig(ShinkenTest):
         os.unlink(mod.path)
 
 
+        
+        #Now change with a new template, a CENTREON ONE
+        mod.template = '$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$LASTSERVICESTATE$\t$SERVICESTATE$\t$SERVICEPERFDATA$\n'
+        sl2 = get_instance(mod)
+        sl2.init()
+        print sl2.__dict__
+        t = int(time.time())
+        print "T", t
+        self.scheduler_loop(1, [[svc, 2, 'BAD | value1=0 value2=0'u'\xf6']])
+        #manage all service check result broks
+        for b in self.sched.broks.values():
+            if b.type == 'service_check_result':
+                sl2.manage_brok(b)
+        sl2.file.close()
+        #Ok, go for writing
+        sl2.hook_tick(None)
+
+        fd = open(mod.path)
+        buf = fd.readline().decode('utf8')
+        print fd.read()
+
+        
+        comparison = u'%d\t%s\t%s\t%s\t%s\t%s\n' % (t, "test_host_0", "test_ok_0", 'CRITICAL', 'CRITICAL', 'value1=0 value2=0'+u'\xf6')
+        #print "BUF", buf
+        #print "COM", comparison
+        self.assert_(buf == comparison)
+        fd.close()
+        os.unlink(mod.path)
+
+
 if __name__ == '__main__':
     unittest.main()
 

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list