[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Gerhard Lausser
gerhard.lausser at consol.de
Tue Feb 28 22:21:53 UTC 2012
The following commit has been merged in the debian/master branch:
commit cddfb548c824d5ce754802ef5b89912e07eea1f9
Merge: e29105a0ab75112165abc0fa82c53a6a7313f5cc 2b10a8d40ac87eefc43ca280da34e518551c8b3d
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date: Sun Feb 19 15:39:48 2012 +0100
Merge branch 'modattr'
diff --combined test/test_livestatus.py
index fcd5f14,723422f..e2f4eba
--- a/test/test_livestatus.py
+++ b/test/test_livestatus.py
@@@ -65,7 -65,7 +65,7 @@@ class TestConfig(ShinkenTest)
brok = self.sched.broks[brok_id]
#print "Managing a brok type", brok.type, "of id", brok_id
#if brok.type == 'update_service_status':
- # print "Problem?", brok.data['is_problem']
+ # print "Problem?", brok.data
if dodeepcopy:
brok = copy.deepcopy(brok)
self.livestatus_broker.manage_brok(brok)
@@@ -361,70 -361,6 +361,70 @@@ ResponseHeader: fixed1
print nagresponse
self.assert_(self.lines_equal(response, nagresponse))
+ def test_nonsense(self):
+ self.print_header()
+ now = time.time()
+ objlist = []
+ for host in self.sched.hosts:
+ objlist.append([host, 0, 'UP'])
+ for service in self.sched.services:
+ objlist.append([service, 0, 'OK'])
+ self.scheduler_loop(1, objlist)
+ self.update_broker()
+
+ # non-existing filter-column
+ request = """GET hosts
+Columns: name state
+Filter: serialnumber = localhost
+"""
+ goodresponse = """Invalid GET request, no such column 'serialnumber'
+"""
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print "response", response
+ self.assert_(response == goodresponse)
+
+ # this time as fixed16
+ request = """GET hosts
+Columns: name state
+Filter: serialnumber = localhost
+ResponseHeader: fixed16
+"""
+ goodresponse = """450 51
+Invalid GET request, no such column 'serialnumber'
+"""
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print "response", response
+ self.assert_(response == goodresponse)
+
+ # invalid filter-clause. attribute, operator missing
+ request = """GET hosts
+Columns: name state
+Filter: localhost
+ResponseHeader: fixed16
+"""
+ goodresponse = """452 106
+Completely invalid GET request 'GET hosts
+Columns: name state
+Filter: localhost
+ResponseHeader: fixed16
+'
+"""
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print response
+ self.assert_(response == goodresponse)
+
+ # non-existing table
+ request = """GET hostshundsglumpvarreckts
+Columns: name state
+ResponseHeader: fixed16
+"""
+ goodresponse = """404 62
+Invalid GET request, no such table 'hostshundsglumpvarreckts'
+"""
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print response
+ self.assert_(response == goodresponse)
+
def test_bad_column(self):
self.print_header()
now = time.time()
@@@ -705,6 -641,45 +705,45 @@@ Filter: host_state !=
# TODO looks like a timing problem with nagios
#self.assert_(self.lines_equal(response, nagresponse))
+ def test_modified_attributes(self):
+ host = self.sched.hosts.find_by_name("test_host_0")
+ host.checks_in_progress = []
+ host.act_depend_of = [] # ignore the router
+ svc = self.sched.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
+ self.scheduler_loop(2, [[host, 0, 'UP'], [svc, 0, 'OK']])
+ self.update_broker()
+
+ request = """GET services
+ Columns: host_name description modified_attributes modified_attributes_list
+ Filter: host_name = test_host_0
+ Filter: description = test_ok_0
+ """
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print "response1", response
+ self.assert_(response == "test_host_0;test_ok_0;0;\n")
+
+ now = time.time()
+ cmd = "[%lu] DISABLE_SVC_CHECK;test_host_0;test_ok_0" % now
+ self.sched.run_external_command(cmd)
+ self.sched.get_new_actions()
+ self.scheduler_loop(2, [[host, 0, 'UP'], [svc, 0, 'OK']])
+ self.update_broker()
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print "response2", response
+ self.assert_(response == 'test_host_0;test_ok_0;2;active_checks_enabled\n')
+ lssvc = self.livestatus_broker.datamgr.get_service("test_host_0", "test_ok_0")
+ print "ma", lssvc.modified_attributes
+ now = time.time()
+ cmd = "[%lu] DISABLE_SVC_NOTIFICATIONS;test_host_0;test_ok_0" % now
+ self.sched.run_external_command(cmd)
+ self.sched.get_new_actions()
+ self.scheduler_loop(2, [[host, 0, 'UP'], [svc, 0, 'OK']])
+ self.update_broker()
+ response, keepalive = self.livestatus_broker.livestatus.handle_request(request)
+ print "response3", response
+ self.assert_(response == 'test_host_0;test_ok_0;3;notifications_enabled,active_checks_enabled\n')
+ print "ma", lssvc.modified_attributes
+
def test_json(self):
self.print_header()
@@@ -1629,27 -1604,14 +1668,27 @@@ othernode;0;broker-2;7772;
self.update_broker()
host = self.sched.hosts.find_by_name("test_host_0")
host.checks_in_progress = []
- host.act_depend_of = [] # ignore the router
+ # We need the dependency here, so comment it out!!!!!!
+ #host.act_depend_of = [] # ignore the router
router = self.sched.hosts.find_by_name("test_router_0")
router.checks_in_progress = []
- router.act_depend_of = [] # ignore the router
+ #router.act_depend_of = [] # ignore the router
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
+
+ lshost = self.livestatus_broker.rg.hosts.find_by_name("test_host_0")
+ lsrouter = self.livestatus_broker.rg.hosts.find_by_name("test_router_0")
+ lssvc = self.livestatus_broker.rg.services.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
+ print " scheduler livestatus"
+ print "host %9s %s" % (host.is_problem, lshost.is_problem)
+ print "router %9s %s" % (router.is_problem, lsrouter.is_problem)
+ print "svc %9s %s" % (svc.is_problem, lssvc.is_problem)
self.scheduler_loop(4, [[host, 2, 'DOWN'], [router, 2, 'DOWN'], [svc, 2, 'BAD']])
+ print " scheduler livestatus"
+ print "host %9s %s" % (host.is_problem, lshost.is_problem)
+ print "router %9s %s" % (router.is_problem, lsrouter.is_problem)
+ print "svc %9s %s" % (svc.is_problem, lssvc.is_problem)
print "Is router a problem?", router.is_problem, router.state, router.state_type
print "Is host a problem?", host.is_problem, host.state, host.state_type
print "Is service a problem?", svc.is_problem, svc.state, svc.state_type
@@@ -1658,10 -1620,6 +1697,10 @@@
for h in self.livestatus_broker.datamgr.rg.hosts:
print h.get_dbg_name(), h.is_problem
+ print " scheduler livestatus"
+ print "host %9s %s" % (host.is_problem, lshost.is_problem)
+ print "router %9s %s" % (router.is_problem, lsrouter.is_problem)
+ print "svc %9s %s" % (svc.is_problem, lssvc.is_problem)
#---------------------------------------------------------------
# get the columns meta-table
#---------------------------------------------------------------
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list