This Python script will parse the obtain component data, and accordingly to the tags values monitor that component. Current there are only 3 monitoring mechanisms (check for open port, check ping result and check http return code), but they can be easily modified for personal usage.
For HTTP code check, create a component, set Link with the target to monitor and specify in the Tags code, 200
if you are expecting 200 HTTP code.
For ping check, create a component, set in the Tags ping, 8.8.8.8
if you want to ping 8.8.8.8. Here you can also specify DNS name.
For port status check, create a component, set Tags port, 193.136.92.1:1194
if you are expecting 1194 to be open on 193.136.92.1.
Here I'm interested in Internet, Upload and Latency metrics. But they are option, you don't need to have all 3 metrics for this to work. But you do need to create this manually and write down the ID of each metric for script to know which metrics is which.
In the metric edit page you can obtain the ID by grabbing the last number in the URL.
- CachetHQ version 3.x
- Python 2.x
usage: main.py [-h] --url URL --key KEY [--components] [--speedtest] [--download-id DOWNLOAD_ID] [--upload-id UPLOAD_ID] [--latency-id LATENCY_ID] [--debug]
optional arguments: -h, --help show this help message and exit --url URL Cachet API url ex: http://127.0.0.1/api/v1 --key KEY Cachet API key --components Check components status --speedtest Post SpeedTest results on Cachet metrics graph --download-id DOWNLOAD_ID Metric ID for download graph (Optional) --upload-id UPLOAD_ID Metric ID for upload graph (Optional) --latency-id LATENCY_ID Metric ID for latency graph (Optional) --debug Enable debug
* * * * * /usr/bin/python /var/www/cachet/cachet-robot/main.py --url http://URL/api/v1 --key API_KEY --components > /dev/null
*/5 * * * * /usr/bin/python /var/www/cachet/cachet-robot/main.py --url http://URL/api/v1 --key API_KEY --speedtest --download-id 1 --upload-id 2 --latency-id 3 > /dev/null