[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Gerhard Lausser
gerhard.lausser at consol.de
Tue Feb 28 22:20:34 UTC 2012
The following commit has been merged in the debian/master branch:
commit 7d0ac143ccb4a72c528653845faa88f5a278b0a7
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date: Mon Feb 13 01:44:28 2012 +0100
Start with modified_attributes
diff --git a/shinken/external_command.py b/shinken/external_command.py
index fbb1a00..bab17db 100644
--- a/shinken/external_command.py
+++ b/shinken/external_command.py
@@ -35,6 +35,26 @@ from shinken.commandcall import CommandCall
from shinken.log import logger
from shinken.pollerlink import PollerLink
+MODATTR_NONE = 0
+MODATTR_NOTIFICATIONS_ENABLED = 1
+MODATTR_ACTIVE_CHECKS_ENABLED = 2
+MODATTR_PASSIVE_CHECKS_ENABLED = 4
+MODATTR_EVENT_HANDLER_ENABLED = 8
+MODATTR_FLAP_DETECTION_ENABLED = 16
+MODATTR_FAILURE_PREDICTION_ENABLED = 32
+MODATTR_PERFORMANCE_DATA_ENABLED = 64
+MODATTR_OBSESSIVE_HANDLER_ENABLED = 128
+MODATTR_EVENT_HANDLER_COMMAND = 256
+MODATTR_CHECK_COMMAND = 512
+MODATTR_NORMAL_CHECK_INTERVAL = 1024
+MODATTR_RETRY_CHECK_INTERVAL = 2048
+MODATTR_MAX_CHECK_ATTEMPTS = 4096
+MODATTR_FRESHNESS_CHECKS_ENABLED = 8192
+MODATTR_CHECK_TIMEPERIOD = 16384
+MODATTR_CUSTOM_VARIABLE = 32768
+MODATTR_NOTIFICATION_TIMEPERIOD = 65536
+
+
""" TODO : Add some comment about this class for the doc"""
class ExternalCommand:
@@ -878,8 +898,10 @@ class ExternalCommandManager:
# DISABLE_SVC_CHECK;<host_name>;<service_description>
def DISABLE_SVC_CHECK(self, service):
- service.disable_active_checks()
- self.sched.get_and_register_status_brok(service)
+ if service.active_checks_enabled:
+ service.disable_active_checks()
+ service.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+ self.sched.get_and_register_status_brok(service)
# DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
def DISABLE_SVC_EVENT_HANDLER(self, service):
@@ -893,8 +915,10 @@ class ExternalCommandManager:
# DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
def DISABLE_SVC_NOTIFICATIONS(self, service):
- service.notifications_enabled = False
- self.sched.get_and_register_status_brok(service)
+ if service.notifications_enabled:
+ service.notifications_enabled = False
+ service.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+ self.sched.get_and_register_status_brok(service)
# ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
def ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self, host):
@@ -1073,8 +1097,10 @@ class ExternalCommandManager:
# ENABLE_SVC_CHECK;<host_name>;<service_description>
def ENABLE_SVC_CHECK(self, service):
- service.active_checks_enabled = True
- self.sched.get_and_register_status_brok(service)
+ if not service.active_checks_enabled:
+ service.active_checks_enabled = True
+ service.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+ self.sched.get_and_register_status_brok(service)
# ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
def ENABLE_SVC_EVENT_HANDLER(self, service):
@@ -1088,8 +1114,10 @@ class ExternalCommandManager:
# ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
def ENABLE_SVC_NOTIFICATIONS(self, service):
- service.notifications_enabled = True
- self.sched.get_and_register_status_brok(service)
+ if not service.notifications_enables:
+ service.notifications_enabled = True
+ service.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+ self.sched.get_and_register_status_brok(service)
# PROCESS_FILE;<file_name>;<delete>
def PROCESS_FILE(self, file_name, delete):
diff --git a/shinken/objects/service.py b/shinken/objects/service.py
index e38494f..d38744b 100644
--- a/shinken/objects/service.py
+++ b/shinken/objects/service.py
@@ -129,6 +129,7 @@ class Service(SchedulingItem):
# properties used in the running state
running_properties = SchedulingItem.running_properties.copy()
running_properties.update({
+ 'modified_attributes': IntegerProp(default=0L, fill_brok=['full_status'], retention=True),
'last_chk': IntegerProp(default=0, fill_brok=['full_status', 'check_result'], retention=True),
'next_chk': IntegerProp(default=0, fill_brok=['full_status', 'next_schedule'], retention=True),
'in_checking': BoolProp (default=False, fill_brok=['full_status', 'check_result', 'next_schedule'], retention=True),
diff --git a/test/test_livestatus.py b/test/test_livestatus.py
index e4599ae..c21cee7 100755
--- a/test/test_livestatus.py
+++ b/test/test_livestatus.py
@@ -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)
@@ -641,6 +641,45 @@ Filter: host_state != 0
# 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
+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\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)
+ self.assert_(response == 'test_host_0;test_ok_0;3\n')
+ print "ma", lssvc.modified_attributes
+
+
def test_json(self):
self.print_header()
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list