Simple service to observe healthy of other services.
You should to create new class inheriting from InspectorAbstract
from utils.common
. Simple example:
class GoogleInspector(InspectorAbstract):
interval = 60
name = "Google Main Page"
def check(self):
return requests.head('https://google.com').ok
where required parameters:
- interval - value in seconds for rerun
check
method - name - name of checker for viewing
- check - main method for running check
Just put .py
file with inspectors into inspectors
folder. Name of file will be name of project.
Are you want to more details in report? Not a problem - just describe self.details
in check
method, like this:
...
def check(self):
response = requests.get('https://google.com')
self.details = {'status': response.status_code}
return response.ok
For reusing HTTP connection for requests can use Session
class from utils.sessions
, like this:
session = Session('https://google.com')
...
return session.head('https://google.com').ok
You can using telegram bot for reporting of services status. For this set parameters:
- TELEGRAM_TOKEN - token of bot
- TELEGRAM_CHANNEL - number of channel for reporting