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

Gerhard Lausser gerhard.lausser at consol.de
Tue Feb 28 22:08:34 UTC 2012


The following commit has been merged in the debian/master branch:
commit df5700b32d9f989122f57b1eef892cb025849c29
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date:   Wed Dec 14 02:24:09 2011 +0100

    *add attributes "services" and "services_with_state" to livestatus Host

diff --git a/shinken/modules/livestatus_broker/mapping.py b/shinken/modules/livestatus_broker/mapping.py
index c040908..a402cd7 100644
--- a/shinken/modules/livestatus_broker/mapping.py
+++ b/shinken/modules/livestatus_broker/mapping.py
@@ -540,6 +540,18 @@ out_map = {
                 'description' : 'The number of downtimes this host is currently in',
                 'type' : 'int',
             },
+            'services' : {
+                'depythonize' : lambda x: [y.get_name() for y in x],
+                'description' : 'A list of all services of the host',
+                'prop' : 'services',
+                'type' : 'list',
+            },
+            'services_with_state' : {
+                'fulldepythonize' : lambda p, e, r: join_with_separators(p, e, r, p.get_name(), p.state_id, p.has_been_checked),
+                'description' : 'A list of all services of the host together with state and has_been_checked',
+                'prop' : 'services',
+                'type' : 'list',
+            },
             'state' : {
                 'converter' : int,
                 'description' : 'The current state of the host (0: up, 1: down, 2: unreachable)',
@@ -3941,7 +3953,7 @@ out_map = {
                 'type' : 'string',
             },
             'hostgroup_alias' : {
-                'depythonize' : lambda x: getattr(x, 'hostgroup_alias', ''),
+                'depythonize' : lambda x: getattr(x, 'alias', ''),
                 'description' : 'An alias of the hostgroup',
                 'prop' : 'hostgroup',
                 'type' : 'string',
diff --git a/test/test_livestatus.py b/test/test_livestatus.py
index 6a59ac6..463efcc 100755
--- a/test/test_livestatus.py
+++ b/test/test_livestatus.py
@@ -1946,6 +1946,43 @@ test_host_0;test_ok_0;CUSTNAME;custvalue
 """)
 
 
+    def test_multisite_hostgroup_alias(self):
+        self.print_header()
+        self.update_broker()
+        a_h0 = self.sched.hosts.find_by_name("test_host_0")
+        a_hg01 = self.sched.hostgroups.find_by_name("hostgroup_01")
+        b_hg01 = self.livestatus_broker.hostgroups["hostgroup_01"]
+        # must have hostgroup_alias_01
+        print a_hg01.hostgroup_name, a_hg01.alias
+        print b_hg01.hostgroup_name, b_hg01.alias
+        self.assert_(a_hg01.hostgroup_name == b_hg01.hostgroup_name)
+        self.assert_(a_hg01.alias == b_hg01.alias)
+        request = """GET hostsbygroup
+Columns: host_name host_alias hostgroup_name hostgroup_alias
+Filter: host_name = test_host_0
+OutputFormat: csv
+"""
+        response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+        print response
+        self.assert_(response == """test_host_0;up_0;allhosts;All Hosts
+test_host_0;up_0;hostgroup_01;hostgroup_alias_01
+test_host_0;up_0;up;All Up Hosts
+""")
+
+        request = """GET hostsbygroup
+Columns: host_name hostgroup_name host_services_with_state host_services
+Filter: host_name = test_host_0
+OutputFormat: csv
+"""
+        response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+        print response
+        self.assert_(response == """test_host_0;allhosts;test_ok_0|0|0;test_ok_0
+test_host_0;hostgroup_01;test_ok_0|0|0;test_ok_0
+test_host_0;up;test_ok_0|0|0;test_ok_0
+""")
+
+
+
     def test_multisite_in_check_period(self):
         self.print_header()
         self.update_broker()

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list