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

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


The following commit has been merged in the debian/master branch:
commit 76ecc733d3d96e534674dc8fb28261fb922fcddd
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date:   Thu Feb 23 01:48:02 2012 +0100

    Add more modified_command updates in external commands

diff --git a/shinken/external_command.py b/shinken/external_command.py
index 9a27630..fd9070f 100644
--- a/shinken/external_command.py
+++ b/shinken/external_command.py
@@ -585,12 +585,14 @@ class ExternalCommandManager:
         service.modified_attributes |= MODATTR_CUSTOM_VARIABLE
         service.customs[varname.upper()] = varvalue
 
-    # CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command> # TODO
+    # CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command>
     def CHANGE_GLOBAL_HOST_EVENT_HANDLER(self, event_handler_command):
+        # TODO: MODATTR_EVENT_HANDLER_COMMAND
         pass
 
     # CHANGE_GLOBAL_SVC_EVENT_HANDLER;<event_handler_command> # TODO
     def CHANGE_GLOBAL_SVC_EVENT_HANDLER(self, event_handler_command):
+        # TODO: MODATTR_EVENT_HANDLER_COMMAND
         pass
 
     # CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>
@@ -617,25 +619,25 @@ class ExternalCommandManager:
 
     # CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>
     def CHANGE_MAX_HOST_CHECK_ATTEMPTS(self, host, check_attempts):
-        host.max_check_attempts = check_attempts
         host.modified_attributes |= MODATTR_MAX_CHECK_ATTEMPTS
+        host.max_check_attempts = check_attempts
         if host.state_type == 'HARD' and host.state == 'UP' and host.attempt > 1:
             host.attempt = host.max_check_attempts
         self.sched.get_and_register_status_brok(host)
 
     # CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>
     def CHANGE_MAX_SVC_CHECK_ATTEMPTS(self, service, check_attempts):
-        service.max_check_attempts = check_attempts
         service.modified_attributes |= MODATTR_MAX_CHECK_ATTEMPTS
+        service.max_check_attempts = check_attempts
         if service.state_type == 'HARD' and service.state == 'OK' and service.attempt > 1:
             service.attempt = service.max_check_attempts
         self.sched.get_and_register_status_brok(service)
 
     # CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>
     def CHANGE_NORMAL_HOST_CHECK_INTERVAL(self, host, check_interval):
+        host.modified_attributes |= MODATTR_NORMAL_CHECK_INTERVAL
         old_interval = host.check_interval
         host.check_interval = check_interval
-        host.modified_attributes |= MODATTR_NORMAL_CHECK_INTERVAL
         # If there were no regular checks (interval=0), then schedule
         # a check immediately.
         if old_interval == 0 and host.checks_enabled:
@@ -644,9 +646,9 @@ class ExternalCommandManager:
 
     # CHANGE_NORMAL_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
     def CHANGE_NORMAL_HOST_CHECK_INTERVAL(self, service, check_interval):
+        service.modified_attributes |= MODATTR_NORMAL_CHECK_INTERVAL
         old_interval = service.check_interval
         service.check_interval = check_interval
-        service.modified_attributes |= MODATTR_NORMAL_CHECK_INTERVAL
         # If there were no regular checks (interval=0), then schedule
         # a check immediately.
         if old_interval == 0 and service.checks_enabled:
@@ -655,14 +657,14 @@ class ExternalCommandManager:
 
     # CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<check_interval>
     def CHANGE_RETRY_HOST_CHECK_INTERVAL(self, host, check_interval):
-        host.retry_interval = check_interval
         host.modified_attributes |= MODATTR_RETRY_CHECK_INTERVAL
+        host.retry_interval = check_interval
         self.sched.get_and_register_status_brok(host)
 
     # CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
     def CHANGE_RETRY_SVC_CHECK_INTERVAL(self, service, check_interval):
-        service.retry_interval = check_interval
         service.modified_attributes |= MODATTR_RETRY_CHECK_INTERVAL
+        service.retry_interval = check_interval
         self.sched.get_and_register_status_brok(service)
 
     # CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>
@@ -765,31 +767,41 @@ class ExternalCommandManager:
 
     # DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
     def DISABLE_CONTACT_HOST_NOTIFICATIONS(self, contact):
-        contact.host_notifications_enabled = False
-        self.sched.get_and_register_status_brok(contact)
+        if contact.host_notifications_enabled:
+            contact.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            contact.host_notifications_enabled = False
+            self.sched.get_and_register_status_brok(contact)
 
     # DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
     def DISABLE_CONTACT_SVC_NOTIFICATIONS(self, contact):
-        contact.service_notifications_enabled = False
-        self.sched.get_and_register_status_brok(contact)
+        if contact.service_notifications_enabled:
+             contact.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+             contact.service_notifications_enabled = False
+             self.sched.get_and_register_status_brok(contact)
 
     # DISABLE_EVENT_HANDLERS
     def DISABLE_EVENT_HANDLERS(self):
-        self.conf.enable_event_handlers = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.enable_event_handlers:
+            self.conf.modified_attributes |= MODATTR_EVENT_HANDLER_ENABLED
+            self.conf.enable_event_handlers = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # DISABLE_FAILURE_PREDICTION
     def DISABLE_FAILURE_PREDICTION(self):
-        self.conf.enable_failure_prediction = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.enable_failure_prediction:
+            self.conf.modified_attributes |= MODATTR_FAILURE_PREDICTION_ENABLED
+            self.conf.enable_failure_prediction = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # DISABLE_FLAP_DETECTION
     def DISABLE_FLAP_DETECTION(self):
-        self.conf.enable_flap_detection = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.enable_flap_detection:
+            self.conf.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            self.conf.enable_flap_detection = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
     def DISABLE_HOSTGROUP_HOST_CHECKS(self, hostgroup):
@@ -844,18 +856,24 @@ class ExternalCommandManager:
 
     # DISABLE_HOST_FLAP_DETECTION;<host_name>
     def DISABLE_HOST_FLAP_DETECTION(self, host):
-        host.flap_detection_enabled = False
-        self.sched.get_and_register_status_brok(host)
+        if host.flap_detection_enabled:
+            host.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            host.flap_detection_enabled = False
+            self.sched.get_and_register_status_brok(host)
 
     # DISABLE_HOST_FRESHNESS_CHECKS
     def DISABLE_HOST_FRESHNESS_CHECKS(self, host):
-        host.check_freshness = False
-        self.sched.get_and_register_status_brok(host)
+        if host.check_freshness:
+            host.modified_attributes |= MODATTR_FRESHNESS_CHECKS_ENABLED
+            host.check_freshness = False
+            self.sched.get_and_register_status_brok(host)
 
     # DISABLE_HOST_NOTIFICATIONS;<host_name>
     def DISABLE_HOST_NOTIFICATIONS(self, host):
-        host.notifications_enabled = False
-        self.sched.get_and_register_status_brok(host)
+        if host.notifications_enabled:
+            host.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            host.notifications_enabled = False
+            self.sched.get_and_register_status_brok(host)
 
     # DISABLE_HOST_SVC_CHECKS;<host_name>
     def DISABLE_HOST_SVC_CHECKS(self, host):
@@ -870,9 +888,11 @@ class ExternalCommandManager:
 
     # DISABLE_NOTIFICATIONS
     def DISABLE_NOTIFICATIONS(self):
-        self.conf.enable_notifications = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.enable_notifications:
+            self.conf.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            self.conf.enable_notifications = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # DISABLE_PASSIVE_HOST_CHECKS;<host_name>
     def DISABLE_PASSIVE_HOST_CHECKS(self, host):
@@ -883,14 +903,18 @@ class ExternalCommandManager:
 
     # DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
     def DISABLE_PASSIVE_SVC_CHECKS(self, service):
-        service.passive_checks_enabled = False
-        self.sched.get_and_register_status_brok(service)
+        if service.passive_checks_enabled:
+            service.modified_attributes |= MODATTR_PASSIVE_CHECKS_ENABLED
+            service.passive_checks_enabled = False
+            self.sched.get_and_register_status_brok(service)
 
     # DISABLE_PERFORMANCE_DATA
     def DISABLE_PERFORMANCE_DATA(self):
-        self.conf.process_performance_data = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.process_performance_data:
+            self.conf.modified_attributes |= MODATTR_PERFORMANCE_DATA_ENABLED
+            self.conf.process_performance_data = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
     def DISABLE_SERVICEGROUP_HOST_CHECKS(self, servicegroup):
@@ -924,14 +948,18 @@ class ExternalCommandManager:
 
     # DISABLE_SERVICE_FLAP_DETECTION;<host_name>;<service_description>
     def DISABLE_SERVICE_FLAP_DETECTION(self, service):
-        service.flap_detection_enabled = False
-        self.sched.get_and_register_status_brok(service)
+        if service.flap_detection_enabled:
+            service.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            service.flap_detection_enabled = False
+            self.sched.get_and_register_status_brok(service)
 
     # DISABLE_SERVICE_FRESHNESS_CHECKS
     def DISABLE_SERVICE_FRESHNESS_CHECKS(self):
-        self.conf.check_service_freshness = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.check_service_freshness:
+            self.conf.modified_attributes |= MODATTR_FRESHNESS_CHECKS_ENABLED
+            self.conf.check_service_freshness = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # DISABLE_SVC_CHECK;<host_name>;<service_description>
     def DISABLE_SVC_CHECK(self, service):
@@ -942,19 +970,23 @@ class ExternalCommandManager:
 
     # DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
     def DISABLE_SVC_EVENT_HANDLER(self, service):
-        service.event_handler_enabled = False
-        self.sched.get_and_register_status_brok(service)
+        if service.event_handler_enabled:
+            service.modified_attributes |= MODATTR_EVENT_HANDLER_ENABLED
+            service.event_handler_enabled = False
+            self.sched.get_and_register_status_brok(service)
 
     # DISABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
     def DISABLE_SVC_FLAP_DETECTION(self, service):
-        service.flap_detection_enabled = False
-        self.sched.get_and_register_status_brok(service)
+        if service.flap_detection_enabled:
+            service.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            service.flap_detection_enabled = False
+            self.sched.get_and_register_status_brok(service)
 
     # DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
     def DISABLE_SVC_NOTIFICATIONS(self, service):
         if service.notifications_enabled:
-            service.notifications_enabled = False
             service.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            service.notifications_enabled = False
             self.sched.get_and_register_status_brok(service)
 
     # ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
@@ -973,31 +1005,41 @@ class ExternalCommandManager:
 
     # ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
     def ENABLE_CONTACT_HOST_NOTIFICATIONS(self, contact):
-        contact.host_notifications_enabled = True
-        self.sched.get_and_register_status_brok(contact)
+        if not contact.host_notifications_enabled:
+            contact.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            contact.host_notifications_enabled = True
+            self.sched.get_and_register_status_brok(contact)
 
     # ENABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
     def ENABLE_CONTACT_SVC_NOTIFICATIONS(self, contact):
-        contact.service_notifications_enabled = True
-        self.sched.get_and_register_status_brok(contact)
+        if not contact.service_notifications_enabled:
+            contact.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            contact.service_notifications_enabled = True
+            self.sched.get_and_register_status_brok(contact)
 
     # ENABLE_EVENT_HANDLERS
     def ENABLE_EVENT_HANDLERS(self):
-        self.conf.enable_event_handlers = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.enable_event_handlers:
+            self.conf.modified_attributes |= MODATTR_EVENT_HANDLER_ENABLED
+            self.conf.enable_event_handlers = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # ENABLE_FAILURE_PREDICTION
     def ENABLE_FAILURE_PREDICTION(self):
-        self.conf.enable_failure_prediction = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.enable_failure_prediction:
+            self.conf.modified_attributes |= MODATTR_FAILURE_PREDICTION_ENABLED
+            self.conf.enable_failure_prediction = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # ENABLE_FLAP_DETECTION
     def ENABLE_FLAP_DETECTION(self):
-        self.conf.enable_flap_detection = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.enable_flap_detection:
+            self.conf.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            self.conf.enable_flap_detection = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
     def ENABLE_HOSTGROUP_HOST_CHECKS(self, hostgroup):
@@ -1052,19 +1094,24 @@ class ExternalCommandManager:
 
     # ENABLE_HOST_FLAP_DETECTION;<host_name>
     def ENABLE_HOST_FLAP_DETECTION(self, host):
-        host.flap_detection_enabled = True
-        self.sched.get_and_register_status_brok(host)
+        if not host.flap_detection_enabled:
+            host.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            host.flap_detection_enabled = True
+            self.sched.get_and_register_status_brok(host)
 
     # ENABLE_HOST_FRESHNESS_CHECKS
     def ENABLE_HOST_FRESHNESS_CHECKS(self):
-        self.conf.check_host_freshness = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not host.check_freshness:
+            host.modified_attributes |= MODATTR_FRESHNESS_CHECKS_ENABLED
+            host.check_freshness = True
+            self.sched.get_and_register_status_brok(host)
 
     # ENABLE_HOST_NOTIFICATIONS;<host_name>
     def ENABLE_HOST_NOTIFICATIONS(self, host):
-        host.notifications_enabled = True
-        self.sched.get_and_register_status_brok(host)
+        if not host.notifications_enabled:
+            host.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            host.notifications_enabled = True
+            self.sched.get_and_register_status_brok(host)
 
     # ENABLE_HOST_SVC_CHECKS;<host_name>
     def ENABLE_HOST_SVC_CHECKS(self, host):
@@ -1079,9 +1126,11 @@ class ExternalCommandManager:
 
     # ENABLE_NOTIFICATIONS
     def ENABLE_NOTIFICATIONS(self):
-        self.conf.enable_notifications = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.enable_notifications:
+            self.conf.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            self.conf.enable_notifications = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # ENABLE_PASSIVE_HOST_CHECKS;<host_name>
     def ENABLE_PASSIVE_HOST_CHECKS(self, host):
@@ -1092,14 +1141,18 @@ class ExternalCommandManager:
 
     # ENABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
     def ENABLE_PASSIVE_SVC_CHECKS(self, service):
-        service.passive_checks_enabled = True
-        self.sched.get_and_register_status_brok(service)
+        if not service.passive_checks_enabled:
+            service.modified_attributes |= MODATTR_PASSIVE_CHECKS_ENABLED
+            service.passive_checks_enabled = True
+            self.sched.get_and_register_status_brok(service)
 
     # ENABLE_PERFORMANCE_DATA
     def ENABLE_PERFORMANCE_DATA(self):
-        self.conf.process_performance_data = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.process_performance_data:
+            self.conf.modified_attributes |= MODATTR_PERFORMANCE_DATA_ENABLED
+            self.conf.process_performance_data = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
     def ENABLE_SERVICEGROUP_HOST_CHECKS(self, servicegroup):
@@ -1133,32 +1186,38 @@ class ExternalCommandManager:
 
     # ENABLE_SERVICE_FRESHNESS_CHECKS
     def ENABLE_SERVICE_FRESHNESS_CHECKS(self):
-        self.conf.check_service_freshness = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.check_service_freshness:
+            self.conf.modified_attributes |= MODATTR_FRESHNESS_CHECKS_ENABLED
+            self.conf.check_service_freshness = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # ENABLE_SVC_CHECK;<host_name>;<service_description>
     def ENABLE_SVC_CHECK(self, service):
         if not service.active_checks_enabled:
-            service.active_checks_enabled = True
             service.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+            service.active_checks_enabled = True
             self.sched.get_and_register_status_brok(service)
 
     # ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
     def ENABLE_SVC_EVENT_HANDLER(self, service):
-        service.event_handler_enabled = True
-        self.sched.get_and_register_status_brok(service)
+        if not service.event_handler_enabled:
+            service.modified_attributes |= MODATTR_EVENT_HANDLER_ENABLED
+            service.event_handler_enabled = True
+            self.sched.get_and_register_status_brok(service)
 
     # ENABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
     def ENABLE_SVC_FLAP_DETECTION(self, service):
-        service.flap_detection_enabled = True
-        self.sched.get_and_register_status_brok(service)
+        if not service.flap_detection_enabled:
+            service.modified_attributes |= MODATTR_FLAP_DETECTION_ENABLED
+            service.flap_detection_enabled = True
+            self.sched.get_and_register_status_brok(service)
 
     # ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
     def ENABLE_SVC_NOTIFICATIONS(self, service):
         if not service.notifications_enabled:
-            service.notifications_enabled = True
             service.modified_attributes |= MODATTR_NOTIFICATIONS_ENABLED
+            service.notifications_enabled = True
             self.sched.get_and_register_status_brok(service)
 
     # PROCESS_FILE;<file_name>;<delete>
@@ -1342,27 +1401,35 @@ class ExternalCommandManager:
 
     # START_ACCEPTING_PASSIVE_HOST_CHECKS
     def START_ACCEPTING_PASSIVE_HOST_CHECKS(self):
-        self.conf.accept_passive_host_checks = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.accept_passive_host_checks:
+            self.conf.modified_attributes |= MODATTR_PASSIVE_CHECKS_ENABLED
+            self.conf.accept_passive_host_checks = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # START_ACCEPTING_PASSIVE_SVC_CHECKS
     def START_ACCEPTING_PASSIVE_SVC_CHECKS(self):
-        self.conf.accept_passive_service_checks = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.accept_passive_service_checks:
+            self.conf.modified_attributes |= MODATTR_PASSIVE_CHECKS_ENABLED
+            self.conf.accept_passive_service_checks = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # START_EXECUTING_HOST_CHECKS
     def START_EXECUTING_HOST_CHECKS(self):
-        self.conf.execute_host_checks = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.execute_host_checks:
+            self.conf.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+            self.conf.execute_host_checks = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # START_EXECUTING_SVC_CHECKS
     def START_EXECUTING_SVC_CHECKS(self):
-        self.conf.execute_service_checks = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.execute_service_checks:
+            self.conf.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+            self.conf.execute_service_checks = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # START_OBSESSING_OVER_HOST;<host_name>
     def START_OBSESSING_OVER_HOST(self, host):
@@ -1373,43 +1440,58 @@ class ExternalCommandManager:
 
     # START_OBSESSING_OVER_HOST_CHECKS
     def START_OBSESSING_OVER_HOST_CHECKS(self):
-        self.conf.obsess_over_hosts = True
-        self.conf.explode_global_conf()
+        if not self.conf.obsess_over_hosts:
+            self.conf.modified_attributes |= MODATTR_OBSESSIVE_HANDLER_ENABLED
+            self.conf.obsess_over_hosts = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # START_OBSESSING_OVER_SVC;<host_name>;<service_description>
     def START_OBSESSING_OVER_SVC(self, service):
-        service.obsess_over_service = True
-        self.sched.get_and_register_status_brok(service)
+        if not service.obsess_over_service:
+            service.modified_attributes |= MODATTR_OBSESSIVE_HANDLER_ENABLED
+            service.obsess_over_service = True
+            self.sched.get_and_register_status_brok(service)
 
     # START_OBSESSING_OVER_SVC_CHECKS
     def START_OBSESSING_OVER_SVC_CHECKS(self):
-        self.conf.obsess_over_services = True
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if not self.conf.obsess_over_services:
+            self.conf.modified_attributes |= MODATTR_OBSESSIVE_HANDLER_ENABLED
+            self.conf.obsess_over_services = True
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # STOP_ACCEPTING_PASSIVE_HOST_CHECKS
     def STOP_ACCEPTING_PASSIVE_HOST_CHECKS(self):
-        self.conf.accept_passive_host_checks = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.accept_passive_host_checks:
+            self.conf.modified_attributes |= MODATTR_PASSIVE_CHECKS_ENABLED
+            self.conf.accept_passive_host_checks = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # STOP_ACCEPTING_PASSIVE_SVC_CHECKS
     def STOP_ACCEPTING_PASSIVE_SVC_CHECKS(self):
-        self.conf.accept_passive_service_checks = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.accept_passive_service_checks:
+            self.conf.modified_attributes |= MODATTR_PASSIVE_CHECKS_ENABLED
+            self.conf.accept_passive_service_checks = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # STOP_EXECUTING_HOST_CHECKS
     def STOP_EXECUTING_HOST_CHECKS(self):
-        self.conf.execute_host_checks = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.execute_host_checks:
+            self.conf.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+            self.conf.execute_host_checks = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # STOP_EXECUTING_SVC_CHECKS
     def STOP_EXECUTING_SVC_CHECKS(self):
-        self.conf.execute_service_checks = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.execute_service_checks:
+            self.conf.modified_attributes |= MODATTR_ACTIVE_CHECKS_ENABLED
+            self.conf.execute_service_checks = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # STOP_OBSESSING_OVER_HOST;<host_name>
     def STOP_OBSESSING_OVER_HOST(self, host):
@@ -1420,20 +1502,26 @@ class ExternalCommandManager:
 
     # STOP_OBSESSING_OVER_HOST_CHECKS
     def STOP_OBSESSING_OVER_HOST_CHECKS(self):
-        self.conf.obsess_over_hosts = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.obsess_over_hosts:
+            self.conf.modified_attributes |= MODATTR_OBSESSIVE_HANDLER_ENABLED
+            self.conf.obsess_over_hosts = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
     # STOP_OBSESSING_OVER_SVC;<host_name>;<service_description>
     def STOP_OBSESSING_OVER_SVC(self, service):
-        service.obsess_over_service = False
-        self.sched.get_and_register_status_brok(service)
+        if service.obsess_over_service:
+            service.modified_attributes |= MODATTR_OBSESSIVE_HANDLER_ENABLED
+            service.obsess_over_service = False
+            self.sched.get_and_register_status_brok(service)
 
     # STOP_OBSESSING_OVER_SVC_CHECKS
     def STOP_OBSESSING_OVER_SVC_CHECKS(self):
-        self.conf.obsess_over_services = False
-        self.conf.explode_global_conf()
-        self.sched.get_and_register_update_program_status_brok()
+        if self.conf.obsess_over_services:
+            self.conf.modified_attributes |= MODATTR_OBSESSIVE_HANDLER_ENABLED
+            self.conf.obsess_over_services = False
+            self.conf.explode_global_conf()
+            self.sched.get_and_register_update_program_status_brok()
 
 
     ### Now the shinken specific ones
diff --git a/shinken/objects/config.py b/shinken/objects/config.py
index 5a4bfb7..137ac78 100644
--- a/shinken/objects/config.py
+++ b/shinken/objects/config.py
@@ -222,6 +222,7 @@ class Config(Item):
         'debug_level':          UnusedProp(text=None),
         'debug_verbosity':      UnusedProp(text=None),
         'max_debug_file_size':  UnusedProp(text=None),
+        'modified_attributes':  IntegerProp(default=0L),
         #'$USERn$ : {'required':False, 'default':''} # Add at run in __init__
 
         # SHINKEN SPECIFIC

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list