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

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


The following commit has been merged in the debian/master branch:
commit 59de6f68dea4775af1f6be78f660e20bda3bd556
Author: Naparuba <naparuba at gmail.com>
Date:   Wed Dec 21 16:40:14 2011 +0100

    *Add : manage \; to be change in ; without cut teh rest of the line to be removed as a comment.

diff --git a/shinken/objects/config.py b/shinken/objects/config.py
index 4876120..a45d5e5 100644
--- a/shinken/objects/config.py
+++ b/shinken/objects/config.py
@@ -483,8 +483,12 @@ class Config(Item):
             if line.startswith("# IMPORTEDFROM="):
                 filefrom = line.split('=')[1]
                 continue
+            # Protect \; to be considered as commetns
+            line = line.replace('\;', '__ANTI-VIRG__')
             line = line.split(';')[0].strip()
-            #A backslash means, there is more to come
+            # Now we removed real comments, replace them with just ;
+            line = line.replace('__ANTI-VIRG__', ';')
+            # A backslash means, there is more to come
             if re.search("\\\s*$", line):
                 continuation_line = True
                 line = re.sub("\\\s*$", "", line)
@@ -492,7 +496,7 @@ class Config(Item):
                 tmp_line += line
                 continue
             elif continuation_line:
-                #Now the continuation line is complete
+                # Now the continuation line is complete
                 line = re.sub("^\s+", "", line)
                 line = tmp_line + line
                 tmp_line = ''
@@ -502,8 +506,8 @@ class Config(Item):
             if re.search("^\s*\t*#|^\s*$|^\s*}", line):
                 pass
 
-            #A define must be catch and the type save
-            #The old entry must be save before
+            # A define must be catch and the type save
+            # The old entry must be save before
             elif re.search("^define", line):
                 in_define = True
                 if tmp_type not in objectscfg:
@@ -511,7 +515,7 @@ class Config(Item):
                 objectscfg[tmp_type].append(tmp)
                 tmp = []
                 tmp.append("imported_from "+ filefrom)
-                #Get new type
+                # Get new type
                 elts = re.split('\s', line)
                 tmp_type = elts[1]
                 tmp_type = tmp_type.split('{')[0]
@@ -521,7 +525,7 @@ class Config(Item):
                 else:
                     params.append(line)
 
-        #Maybe the type of the last element is unknown, declare it
+        # Maybe the type of the last element is unknown, declare it
         if not tmp_type in objectscfg:
             objectscfg[tmp_type] = []
 
@@ -530,7 +534,7 @@ class Config(Item):
 
         #print "Params", params
         self.load_params(params)
-        #And then update our MACRO dict
+        # And then update our MACRO dict
         self.fill_resource_macros_names_macros()
 
         for type in objectscfg:
diff --git a/test/etc/inheritance_and_plus/commands.cfg b/test/etc/dot_virg_in_command/commands.cfg
similarity index 94%
copy from test/etc/inheritance_and_plus/commands.cfg
copy to test/etc/dot_virg_in_command/commands.cfg
index 7614492..fc6dcdd 100644
--- a/test/etc/inheritance_and_plus/commands.cfg
+++ b/test/etc/dot_virg_in_command/commands.cfg
@@ -22,7 +22,7 @@ define command{
 }
 define command{
   command_name eventhandler
-  command_line    $USER1$/test_eventhandler.pl $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
+  command_line    $USER1$/test_eventhandler.pl $ARG1$
 }
 define command{
   command_name    special_macro
diff --git a/test/etc/1r_1h_1s/contacts.cfg b/test/etc/dot_virg_in_command/contacts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/contacts.cfg
copy to test/etc/dot_virg_in_command/contacts.cfg
diff --git a/test/etc/1r_1h_1s/hostgroups.cfg b/test/etc/dot_virg_in_command/hostgroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hostgroups.cfg
copy to test/etc/dot_virg_in_command/hostgroups.cfg
diff --git a/test/etc/1r_1h_1s/hosts.cfg b/test/etc/dot_virg_in_command/hosts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hosts.cfg
copy to test/etc/dot_virg_in_command/hosts.cfg
diff --git a/test/etc/1r_1h_1s/servicegroups.cfg b/test/etc/dot_virg_in_command/servicegroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/servicegroups.cfg
copy to test/etc/dot_virg_in_command/servicegroups.cfg
diff --git a/test/etc/1r_1h_1s/services.cfg b/test/etc/dot_virg_in_command/services.cfg
similarity index 94%
copy from test/etc/1r_1h_1s/services.cfg
copy to test/etc/dot_virg_in_command/services.cfg
index e16682e..897aa37 100644
--- a/test/etc/1r_1h_1s/services.cfg
+++ b/test/etc/dot_virg_in_command/services.cfg
@@ -36,7 +36,7 @@ define service{
   service_description            test_ok_0
   servicegroups                  servicegroup_01,ok
   use                            generic-service
-  event_handler                  eventhandler
+  event_handler                  eventhandler!sudo -s pkill toto \; cd /my/path && ./toto
   notes_url                      /nagios/wiki/doku.php/$HOSTNAME$/$SERVICEDESC$
   action_url                     /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
   _custname			 custvalue
diff --git a/test/etc/1r_1h_1s/shinken-specific.cfg b/test/etc/dot_virg_in_command/shinken-specific.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/shinken-specific.cfg
copy to test/etc/dot_virg_in_command/shinken-specific.cfg
diff --git a/test/etc/10r_1000h_20000s/timeperiods.cfg b/test/etc/dot_virg_in_command/timeperiods.cfg
similarity index 100%
copy from test/etc/10r_1000h_20000s/timeperiods.cfg
copy to test/etc/dot_virg_in_command/timeperiods.cfg
diff --git a/test/etc/nagios_1r_1h_1s.cfg b/test/etc/nagios_dot_virg_in_command.cfg
similarity index 88%
copy from test/etc/nagios_1r_1h_1s.cfg
copy to test/etc/nagios_dot_virg_in_command.cfg
index 1566c73..d5455a4 100644
--- a/test/etc/nagios_1r_1h_1s.cfg
+++ b/test/etc/nagios_dot_virg_in_command.cfg
@@ -8,14 +8,14 @@ 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=dot_virg_in_command/hosts.cfg
+cfg_file=dot_virg_in_command/services.cfg
+cfg_file=dot_virg_in_command/contacts.cfg
+cfg_file=dot_virg_in_command/commands.cfg
+cfg_file=dot_virg_in_command/timeperiods.cfg
+cfg_file=dot_virg_in_command/hostgroups.cfg
+cfg_file=dot_virg_in_command/servicegroups.cfg
+cfg_file=dot_virg_in_command/shinken-specific.cfg
 check_external_commands=1
 check_for_orphaned_hosts=1
 check_for_orphaned_services=1
diff --git a/test/jenkins/longtests.txt b/test/jenkins/longtests.txt
index ca43e53..076675c 100644
--- a/test/jenkins/longtests.txt
+++ b/test/jenkins/longtests.txt
@@ -85,6 +85,7 @@ test_service_template_inheritance.py
 test_spaces_in_commands.py
 test_inheritance_and_plus.py
 test_module_ip_tag.py
+test_dot_virg_in_command.py
 test_parse_perfdata.py
 
 # takes long
diff --git a/test/jenkins/shorttests.txt b/test/jenkins/shorttests.txt
index ae0c44f..69ff0b7 100644
--- a/test/jenkins/shorttests.txt
+++ b/test/jenkins/shorttests.txt
@@ -92,4 +92,5 @@ test_service_template_inheritance.py
 test_spaces_in_commands.py
 test_inheritance_and_plus.py
 test_module_ip_tag.py
+test_dot_virg_in_command.py
 test_parse_perfdata.py
diff --git a/test/quick_tests.sh b/test/quick_tests.sh
index 8b49d68..61ef5ba 100755
--- a/test/quick_tests.sh
+++ b/test/quick_tests.sh
@@ -130,6 +130,7 @@ launch_and_assert test_livestatus_db.py
 launch_and_assert test_parse_perfdata.py
 launch_and_assert test_service_template_inheritance.py
 launch_and_assert test_module_ip_tag.py
+launch_and_assert test_dot_virg_in_command.py
 
 launch_and_assert test_maintenance_period.py
 #Live status is a bit longer than the previous, so we put it at the end.
diff --git a/test/test_dummy.py b/test/test_dot_virg_in_command.py
similarity index 86%
copy from test/test_dummy.py
copy to test/test_dot_virg_in_command.py
index a096fad..c931fc3 100755
--- a/test/test_dummy.py
+++ b/test/test_dot_virg_in_command.py
@@ -30,7 +30,7 @@ class TestConfig(ShinkenTest):
     #Uncomment this is you want to use a specific configuration
     #for your test
     def setUp(self):
-        self.setup_with_file('etc/nagios_1r_1h_1s.cfg')
+        self.setup_with_file('etc/nagios_dot_virg_in_command.cfg')
 
     
     #Change ME :)
@@ -50,9 +50,8 @@ class TestConfig(ShinkenTest):
         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.scheduler_loop(2, [[host, 0, 'UP | value1=1 value2=2'], [router, 0, 'UP | rtt=10'], [svc, 2, 'BAD | value1=0 value2=0']])
-        self.assert_(host.state == 'UP')
-        self.assert_(host.state_type == 'HARD')
+        print svc.event_handler.args
+        self.assert_('sudo -s pkill toto ; cd /my/path && ./toto' in svc.event_handler.args)
 
 
 if __name__ == '__main__':

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list