From da7568300ed8b06cb6d8201b7ee99507b3564da8 Mon Sep 17 00:00:00 2001 From: Jacek Szubert Date: Thu, 9 Mar 2017 18:10:18 +1100 Subject: [PATCH] Update component status only when it has changed --- cachet_url_monitor/configuration.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cachet_url_monitor/configuration.py b/cachet_url_monitor/configuration.py index 626bb8a..c557a65 100644 --- a/cachet_url_monitor/configuration.py +++ b/cachet_url_monitor/configuration.py @@ -83,6 +83,7 @@ class Configuration(object): # We need the current status so we monitor the status changes. This is necessary for creating incidents. self.status = get_current_status(self.api_url, self.component_id, self.headers) + self.previous_status = self.status # Get remaining settings self.public_incidents = int(os.environ.get('CACHET_PUBLIC_INCIDENTS') or self.data['cachet']['public_incidents']) @@ -180,6 +181,10 @@ class Configuration(object): """Pushes the status of the component to the cachet server. It will update the component status based on the previous call to evaluate(). """ + if self.previous_status == self.status: + return + self.previous_status = self.status + params = {'id': self.component_id, 'status': self.status} component_request = requests.put('%s/components/%d' % (self.api_url, self.component_id), params=params, headers=self.headers)