mirror of
https://github.com/mtan93/cachet-url-monitor.git
synced 2026-03-08 05:31:58 +00:00
Make update status optional
This commit is contained in:
@@ -33,6 +33,7 @@ cachet:
|
|||||||
token: my_token
|
token: my_token
|
||||||
component_id: 1
|
component_id: 1
|
||||||
metric_id: 1
|
metric_id: 1
|
||||||
|
update_status: true
|
||||||
frequency: 30
|
frequency: 30
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ frequency: 30
|
|||||||
- **token**, the API token.
|
- **token**, the API token.
|
||||||
- **component_id**, the id of the component we're monitoring. This will be used to update the status of the component.
|
- **component_id**, the id of the component we're monitoring. This will be used to update the status of the component.
|
||||||
- **metric_id**, this will be used to store the latency of the API. If this is not set, it will be ignored.
|
- **metric_id**, this will be used to store the latency of the API. If this is not set, it will be ignored.
|
||||||
|
- **update_status**, boolean to decide if the component status should be changed in case of a check failure.
|
||||||
- **frequency**, how often we'll send a request to the given URL. The unit is in seconds.
|
- **frequency**, how often we'll send a request to the given URL. The unit is in seconds.
|
||||||
|
|
||||||
## Setting up
|
## Setting up
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ class Configuration(object):
|
|||||||
"""
|
"""
|
||||||
return 'create_incident' in self.data['cachet'] and self.data['cachet']['create_incident']
|
return 'create_incident' in self.data['cachet'] and self.data['cachet']['create_incident']
|
||||||
|
|
||||||
|
def is_update_status(self):
|
||||||
|
"""Will verify if the configuration is set to update status or not.
|
||||||
|
:return True if the configuration is set to update status or False it otherwise.
|
||||||
|
"""
|
||||||
|
return 'update_status' in self.data['cachet'] and self.data['cachet']['update_status']
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
"""Validates the configuration by verifying the mandatory fields are
|
"""Validates the configuration by verifying the mandatory fields are
|
||||||
present and in the correct format. If the validation fails, a
|
present and in the correct format. If the validation fails, a
|
||||||
|
|||||||
@@ -51,8 +51,10 @@ class Scheduler(object):
|
|||||||
|
|
||||||
if self.configuration.is_create_incident():
|
if self.configuration.is_create_incident():
|
||||||
self.agent = CreateIncidentAgent(self.configuration)
|
self.agent = CreateIncidentAgent(self.configuration)
|
||||||
else:
|
elif self.configuration.is_update_status():
|
||||||
self.agent = UpdateStatusAgent(self.configuration)
|
self.agent = UpdateStatusAgent(self.configuration)
|
||||||
|
else:
|
||||||
|
self.agent = Agent(self.configuration)
|
||||||
|
|
||||||
self.stop = False
|
self.stop = False
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ cachet:
|
|||||||
component_id: 1
|
component_id: 1
|
||||||
#metric_id: 1
|
#metric_id: 1
|
||||||
create_incident: true
|
create_incident: true
|
||||||
|
update_status: true
|
||||||
frequency: 30
|
frequency: 30
|
||||||
|
|||||||
Reference in New Issue
Block a user