- Python > 3.8 recommended
Notice:
- All settings are stored in JSON format, so it's easy to exchange data using the API.
- JSON file is individual for the instance you create, which allows you to configure different entry points.
- Import Package
- Create class prototype:
monitor = WebMonitor(pcf='WebMonitor')
Args:
pcf
- Storage name for Class, default = 'WebMonitor'
monitor.add('google.com')
Supported list format:
monitor.add(['example.org', 'yandex.com', 'bing.com'])
Return: hosts list
If you use an empty method (without params), then will be checked all hosts in the config .pcf file and recorded in history.
Example:
print(monitor.check())
If you specified a list of hosts, they will be checked and recorded in history. Without adding to the configuration.
Example:
print(monitor.check('yahoo.com', 'ibm.com'))
Or supported list format:
print(monitor.check(['intel.com', 'ibm.com']))
Return: hosts list
If you use an empty method (without params), then will be removed all hosts in the config .pcf file. Before deleting, you will be prompted to delete. By default, pressing enter means consent to deletion.
Example:
monitor.remove()
If you specified a list of hosts, they will be checked and removed from configuration.
Example:
monitor.remove('google.com')
Or supported list format:
monitor.remove(['example.org', 'bing.com'])
Return: hosts list
monitor.show()
Call: print hosts as strings
Return: hosts list
print(monitor.history())
If you need clear history:
print(monitor.history(clear=True))
History search terms supported:
- id
- date
- host
- status_code
Format parameters: [{field: value}, *multiply]
Typical:
history = monitor.history(by=[{'date': '2020.12.05'}, {'host': 'google.com'}])
Or create conditions list with dict {filed
: value
} and pass in method, example:
conditions = [
{'date': '2020.12.05'},
{'host': 'google.com'}
]
history = monitor.history(by=conditions)
print(history)
Return: formatted table report
- Fix or define correct protocol for host (now used http)
- Create Watcher (endless loop or timer)
- Create notifications to Telegram bot (?)
- Create notifications to Email (?)
- Optimize code (?)
Please see the changelog for more extensive changes.
Run WebMonitorTest.py