[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:13:19 UTC 2012
The following commit has been merged in the debian/master branch:
commit 182eb0eac57a270edc4e33adfe8a0b1267bf92bb
Author: Naparuba <naparuba at gmail.com>
Date: Thu Jan 12 14:31:41 2012 +0100
*Fix : VAR/RUN error in the init.d script
*Add : if address is not available, ip_tag module take the host_name
diff --git a/bin/init.d/shinken b/bin/init.d/shinken
index 4a23aa5..9210bb6 100755
--- a/bin/init.d/shinken
+++ b/bin/init.d/shinken
@@ -219,7 +219,7 @@ getpidfile() {
then
echo "$pidfile"
else
- echo "$VAR/${mod}d.pid"
+ echo "$RUN/${mod}d.pid"
fi
}
diff --git a/shinken/modules/ip_tag_arbiter/ip_tag_arbiter.py b/shinken/modules/ip_tag_arbiter/ip_tag_arbiter.py
index f31a493..c62a7a0 100644
--- a/shinken/modules/ip_tag_arbiter/ip_tag_arbiter.py
+++ b/shinken/modules/ip_tag_arbiter/ip_tag_arbiter.py
@@ -44,22 +44,31 @@ class Ip_Tag_Arbiter(BaseModule):
def hook_early_configuration(self, arb):
logger.log("[IpTag] in hook late config")
for h in arb.conf.hosts:
- if not hasattr(h, 'address'):
+ if not hasattr(h, 'address') and not hasattr(h, 'host_name'):
continue
+ # The address to resolve
+ addr = None
+
+ #By default take the address, if not, take host_name
+ if not hasattr(h, 'address'):
+ addr = h.host_name
+ else:
+ addr = h.address
+
print "Looking for h", h.get_name()
- print h.address
+ print addr
h_ip = None
try:
- IP(h.address)
+ IP(addr)
# If we reach here, it's it was a real IP :)
- h_ip = h.address
+ h_ip = addr
except:
pass
# Ok, try again with name resolution
if not h_ip:
try:
- h_ip = socket.gethostbyname(h.address)
+ h_ip = socket.gethostbyname(addr)
except:
pass
diff --git a/test/etc/module_ip_tag/hosts.cfg b/test/etc/module_ip_tag/hosts.cfg
index 29e77c1..24c37fc 100644
--- a/test/etc/module_ip_tag/hosts.cfg
+++ b/test/etc/module_ip_tag/hosts.cfg
@@ -50,3 +50,18 @@ define host{
_oslicense gpl
}
+#No addr, just host_name
+define host{
+ alias up_0
+ check_command check-host-alive-parent!up!$HOSTSTATE:test_router_0$
+ event_handler eventhandler
+ check_period 24x7
+ host_name 127.0.0.1
+ hostgroups hostgroup_01,up
+ parents test_router_0
+ use generic-host
+ criticity 5
+ _ostype gnulinux
+ _oslicense gpl
+}
+
diff --git a/test/test_module_ip_tag.py b/test/test_module_ip_tag.py
index 0de9f0a..facf137 100755
--- a/test/test_module_ip_tag.py
+++ b/test/test_module_ip_tag.py
@@ -70,12 +70,13 @@ class TestIpTag(ShinkenTest):
#Change ME :)
- def test_hack_cmd_poller_tag(self):
+ def test_hack_cmd_grp(self):
modconf = self.conf.modules.find_by_name('IpTagAppend')
# look for a objects that use it
h1 = self.sched.hosts.find_by_name("test_host_0")
h2 = self.sched.hosts.find_by_name("test_router_0")
+ h3 = self.sched.hosts.find_by_name("127.0.0.1")
#get our modules
mod = get_instance(modconf)
@@ -86,6 +87,7 @@ class TestIpTag(ShinkenTest):
# and find a better way to manage this in tests
h1.hostgroups = 'linux,windows'
h2.hostgroups = 'linux,windows'
+ h3.hostgroups = 'linux,windows'
# Calls the mod with our config
mod.hook_early_configuration(self)
@@ -94,9 +96,13 @@ class TestIpTag(ShinkenTest):
print "H1", h1.hostgroups
self.assert_('newgroup' not in h1.hostgroups)
- print"H2", h2.hostgroups
+ print "H2", h2.hostgroups
self.assert_('newgroup' in h2.hostgroups)
+ print "H3", h3.hostgroups
+ self.assert_('newgroup' in h3.hostgroups)
+
+
if __name__ == '__main__':
unittest.main()
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list