[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:07:18 UTC 2012
The following commit has been merged in the debian/master branch:
commit d2e3d096d8ca539559db3505d18b892986fb8d0c
Author: Naparuba <naparuba at gmail.com>
Date: Mon Nov 21 14:53:27 2011 +0100
Fix : (reported by : Venelin Petkov) print in hostgroup names was a problem.
diff --git a/THANKS b/THANKS
index 5a1066a..f0ba62b 100644
--- a/THANKS
+++ b/THANKS
@@ -26,7 +26,7 @@ To Kristoffer Moegle for this patch on arbiter configuration module
To Eric Beaulieu for his help on the ssl certificates, adn for the Windows installation script :)
To Laurent Guyon, our best bug hunter :)
To Alan Brenner for his SSL core for the NRPE module
-To Venelin Petkov for this bug report about missing customs on services
+To Venelin Petkov for this bug report about missing customs on services, and the 'print' in name bug problem :)
To Papp Tamas for his bug report of bad python version under ubuntu (and debian)
To Rémi BUISSON for his bug report about bad etc/default/shinken file :)
To Julien Toscano for his bug report about bad launch_all.sh launch.
diff --git a/shinken/objects/item.py b/shinken/objects/item.py
index 4964c93..de021e4 100644
--- a/shinken/objects/item.py
+++ b/shinken/objects/item.py
@@ -972,10 +972,14 @@ class Items(object):
str_setexpr = hg_name_rebuild_str(ctxres.full_res)
+ # We must protect the eval() against some names that will be match as
+ # Python things like - or print and not real names. So we "change" them with __OTHERNAME__
+ # values in the HostGroup_Name_Parse_Ctx class.
groupsname2hostsnames = hg_name_get_groupnames(ctxres.full_res, hosts, hostgroups)
newgroupname2hostnames = {}
for gn, val in groupsname2hostsnames.items():
gn = gn.replace('-', HostGroup_Name_Parse_Ctx.minus_sign_in_name)
+ gn = gn.replace('print', HostGroup_Name_Parse_Ctx.print_in_name)
newgroupname2hostnames[gn] = val
set_res = []
@@ -989,7 +993,7 @@ class Items(object):
err = "There is an unknown name in '%s' (names=%s), err=%s" % (expr, groupsname2hostsnames, e)
self.configuration_errors.append(err)
print err
-
+
return list(set_res)
@@ -1045,7 +1049,8 @@ class HostGroup_Name_Parse_Ctx(object):
space_chars = ( ' ', '\t', )
# no group should be named like that :
catch_all_name = "__ALLELEMENTS__"
- minus_sign_in_name = "__MINUSSIGN_IN_NAME__"
+ minus_sign_in_name = "__MINUSSIGN_IN_NAME__"
+ print_in_name = "__PRINT_IN_NAME__"
# flags:
@@ -1358,10 +1363,14 @@ def hg_name_rebuild_str(parse_res):
parse_res must be the 'full_res' attribute of a 'HostGroup_Name_Parse_Ctx' object. """
# trivial case:
if isinstance(parse_res, (str, unicode)):
+ # It's where we protect our token that got 'python' strings that will put
+ # an eval() call with problems of syntax
if parse_res != "-":
parse_res = parse_res.replace('-', HostGroup_Name_Parse_Ctx.minus_sign_in_name)
if parse_res == '*':
parse_res = HostGroup_Name_Parse_Ctx.catch_all_name
+ if 'print' in parse_res:
+ parse_res = parse_res.replace('print', HostGroup_Name_Parse_Ctx.print_in_name)
return parse_res
# nearly trivial case, parse_res is here a list of objects:
diff --git a/test/etc/nagios_1r_1h_1s.cfg b/test/etc/nagios_service_with_print_as_name.cfg
similarity index 87%
copy from test/etc/nagios_1r_1h_1s.cfg
copy to test/etc/nagios_service_with_print_as_name.cfg
index 1566c73..d902882 100644
--- a/test/etc/nagios_1r_1h_1s.cfg
+++ b/test/etc/nagios_service_with_print_as_name.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=service_with_print_as_name/hosts.cfg
+cfg_file=service_with_print_as_name/services.cfg
+cfg_file=service_with_print_as_name/contacts.cfg
+cfg_file=service_with_print_as_name/commands.cfg
+cfg_file=service_with_print_as_name/timeperiods.cfg
+cfg_file=service_with_print_as_name/hostgroups.cfg
+cfg_file=service_with_print_as_name/servicegroups.cfg
+cfg_file=service_with_print_as_name/shinken-specific.cfg
check_external_commands=1
check_for_orphaned_hosts=1
check_for_orphaned_services=1
diff --git a/test/etc/1r_1h_1s/commands.cfg b/test/etc/service_with_print_as_name/commands.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/commands.cfg
copy to test/etc/service_with_print_as_name/commands.cfg
diff --git a/test/etc/1r_1h_1s/contacts.cfg b/test/etc/service_with_print_as_name/contacts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/contacts.cfg
copy to test/etc/service_with_print_as_name/contacts.cfg
diff --git a/test/etc/realms/hostgroups.cfg b/test/etc/service_with_print_as_name/hostgroups.cfg
similarity index 91%
copy from test/etc/realms/hostgroups.cfg
copy to test/etc/service_with_print_as_name/hostgroups.cfg
index 2c71e05..4b56077 100644
--- a/test/etc/realms/hostgroups.cfg
+++ b/test/etc/service_with_print_as_name/hostgroups.cfg
@@ -1,5 +1,12 @@
define hostgroup {
+ hostgroup_name print
+ alias print
+ members test_router_0,test_host_0
+}
+
+
+define hostgroup {
hostgroup_name router
alias All Router Hosts
}
@@ -60,10 +67,3 @@ define hostgroup {
members test_router_0,test_host_0
}
-
-define hostgroup {
- hostgroup_name in_realm2
- alias in_realm2
- realm realm2
-}
-
diff --git a/test/etc/1r_1h_1s/hosts.cfg b/test/etc/service_with_print_as_name/hosts.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/hosts.cfg
copy to test/etc/service_with_print_as_name/hosts.cfg
diff --git a/test/etc/1r_1h_1s/servicegroups.cfg b/test/etc/service_with_print_as_name/servicegroups.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/servicegroups.cfg
copy to test/etc/service_with_print_as_name/servicegroups.cfg
diff --git a/test/etc/spaces_in_commands/services.cfg b/test/etc/service_with_print_as_name/services.cfg
similarity index 80%
copy from test/etc/spaces_in_commands/services.cfg
copy to test/etc/service_with_print_as_name/services.cfg
index 2561a6e..d4a9210 100644
--- a/test/etc/spaces_in_commands/services.cfg
+++ b/test/etc/service_with_print_as_name/services.cfg
@@ -42,9 +42,19 @@ define service{
_custname custvalue
}
+
+
+
+define service{
+ use generic-service
+ hostgroup_name print
+ service_description print
+ check_command check_service!ok
+}
+
define service{
- use generic-service
- host_name test_host_0
- service_description test_port_2
- check_command check_snmp_int!public!"Nortel Ethernet Routing Switch 5530-24TFD Module - Port 2 "!"90000,90000"!"120000,120000"
+ use generic-service
+ hostgroup_name print
+ service_description other
+ check_command check_service!ok
}
diff --git a/test/etc/1r_1h_1s/shinken-specific.cfg b/test/etc/service_with_print_as_name/shinken-specific.cfg
similarity index 100%
copy from test/etc/1r_1h_1s/shinken-specific.cfg
copy to test/etc/service_with_print_as_name/shinken-specific.cfg
diff --git a/test/etc/10r_1000h_20000s/timeperiods.cfg b/test/etc/service_with_print_as_name/timeperiods.cfg
similarity index 100%
copy from test/etc/10r_1000h_20000s/timeperiods.cfg
copy to test/etc/service_with_print_as_name/timeperiods.cfg
diff --git a/test/test_linkify_template.py b/test/test_service_with_print_as_name.py
similarity index 83%
copy from test/test_linkify_template.py
copy to test/test_service_with_print_as_name.py
index 13b621a..b1c812c 100755
--- a/test/test_linkify_template.py
+++ b/test/test_service_with_print_as_name.py
@@ -26,18 +26,17 @@
from shinken_test import *
-class TestLinkifyTemplate(ShinkenTest):
+class TestServiceWithPrintName(ShinkenTest):
#Uncomment this is you want to use a specific configuration
#for your test
def setUp(self):
- self.setup_with_file('etc/nagios_linkify_template.cfg')
+ self.setup_with_file('etc/nagios_service_with_print_as_name.cfg')
#Change ME :)
- def test_linkify_template(self):
- svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
- b = svc.is_correct()
- self.assert_(not b)
+ def test_service_with_print_as_name(self):
+ svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "print")
+ self.assert_(svc is not None)
if __name__ == '__main__':
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list