mirror of
https://github.com/mtan93/cachet-url-monitor.git
synced 2026-03-08 05:31:58 +00:00
Update component status only when it has changed
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user