Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4
Bash script to work with UptimeRobot, StatusCake, HealthChecks.io, & Upptime monitoring providers
License
tronyx/tronitor
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A bash script to work withUptimeRobot,StatusCake,HealthChecks.io, andUpptime monitors via their respective APIs. It checks to make sure that the API key/token, username for StatusCake, and your GitHub username and the name of your Upptime repository on GitHub, that you provided are valid before performing any requested operations.
Big thanks tonemchik for all the ideas and help with getting some things to work, and to1activegeek for asking me to create this for him in the first place, albeit MUCH less complicated than what it's become.
Feel free to check out their work and buy them a beer too!
This script partners up with myApplication Healthchecks script that provides checks for a lot of popular HTPC applications, IE: Plex, Sonarr, Radarr, etc. that work with HealthChecks.io. Tronitor would allow you to pause and unpause the checks manually or on a schedule, via a cronjob, for planned maintenance, etc. This essentially allows you to create your own maintenance windows without having to pay for a premium account with either of the providers.
ThecURL command is required for the script to function as it's used to submit API calls to the providers. If it is not installed before you execute the script most, if not all, operations will fail. Because of this, the script does check whether or notcURL is installed and, if not, it will inform you as such and then exit.
Thejq command is required for the script to function as it is used to more easily extract data from JSON files created by the script when gathering information for the monitoring providers and the corresponding checks/tests.
It is also used by the script to automatically format the JSON output into a human-readable and colorized output. There is a variable at the beginning of the script to set the use of thejq command (strictly for displaying the output of the script) to true or false. I've personally encountered some issues with it when using the script within a cronjob and not usingjq to format the output resolves them. It is set totrue by default.
# Set JQ to false to disable its use for displaying output.# This works better for using the script with cronjobs, etc.jq='true'
tronyx@suladan:~$ sudo apt install jqReading package lists... DoneBuilding dependency treeReading state information... DoneThe following NEW packages will be installed: jq0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.Need to get 45.6 kB of archives.After this operation, 90.1 kB of additional disk space will be used.Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 jq amd64 1.5+dfsg-2 [45.6 kB]Fetched 45.6 kBin 0s (123 kB/s)Selecting previously unselected package jq.(Reading database ... 107503 files and directories currently installed.)Preparing to unpack .../jq_1.5+dfsg-2_amd64.deb ...Unpacking jq (1.5+dfsg-2) ...Setting up jq (1.5+dfsg-2) ...Processing triggersfor man-db (2.8.3-2) ...
The best method to get the script working is to usegit to clone the repository onto your preferred machine:
tronyx@suladan:~$ git clone https://github.com/tronyx/tronitor.gitCloning into'tronitor'...remote: Enumerating objects: 108, done.remote: Counting objects: 100% (108/108), done.remote: Compressing objects: 100% (75/75), done.remote: Total 262 (delta 60), reused 76 (delta 32), pack-reused 154Receiving objects: 100% (262/262), 161.85 KiB| 6.74 MiB/s, done.Resolving deltas: 100% (143/143), done.
tronitor.sh script itself, but the monitor creation functionality will not work as it depends on the included template files in the repository.
The script stores the API keys/token, username for StatusCake, and, for Upptime, your GitHub username, PAT (Personal Access Token), and the name of your Upptime reposistory, for up to all four providers so that you do not need multiple copies of the script to work with each of the different providers.
If you do not know how to create a PAT for your GitHub account, you can checkout their documentation on itHERE.
The first time that you run the script for a specific monitor it will alert you that the API key/token, etc. are missing and prompt you to input them:
healthchecksDomain variable online 24 of thetronitor.sh script with the domain name that you're hosting the application with.
You can also simply open the script with your favorite text editor and add your provider's API key, if you're using StatusCake, your account username, and, if you're using Upptime, the repository owner (organization or user), your GitHub username, PAT (Personal Access Token), and the name of your Upptime reposistory.
After entering the information, the script will check whether or not it is valid and then add it to the script for you.
If you use the alert option, be sure to also enter in your Discord/Slack webhook URL. If you forget this as well, the script will also prompt you to enter it:
The-m/--monitor option accepts both full and shorthand versions of the provider's name:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m uptimerobot -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m statuscake -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m sc -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m healthchecks -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m hc -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m upptime -ltronyx@suladan:~/tronitor$ ./tronitor.sh -m up -l
Display basic statistics for your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m uptimerobot -sHere are the basic statistics for your UptimeRobot account:{"stat":"ok","account": {"email":"me@domain.com","monitor_limit":50,"monitor_interval":5,"up_monitors":14,"down_monitors":0,"paused_monitors":0 }}
Display all monitors associated with your account and their current statuses:
tronyx@suladan:~/tronitor$ ./tronitor.sh --monitor ur -lThe following UptimeRobot monitors were found in your UptimeRobot account:Plex (ID: 779783111) - Status: UpRadarr (ID: 780859973) - Status: DownSonarr (ID: 780859962) - Status: PausedTautulli (ID: 780859975) - Status: Seems down
Find and display all monitors in your account that are currently paused and then prompt you as to whether or not you would like to unpause them:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -fThe following StatusCake monitors are currently paused:Plex (ID: 779783111)Radarr (ID: 780859973)Sonarr (ID: 780859962)Tautulli (ID: 780859975)Would you like to unpause the paused monitors? ([Y]es or [N]o):
You can also use the-n option to display the same list, but not display a prompt to unpause the paused monitors.
Using the-w option will check for any paused monitors and, if there are any, send an alert to the specified Discord/Slack webhook like below:
If you set thenotifyAll option totrue, Tronitor will send a notification even if there are no paused monitors:
Display all information for a single monitor:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m uptimerobot -i 'plex'{"stat":"ok","pagination": {"offset":0,"limit":50,"total":1 },"monitors": [ {"id":779783111,"friendly_name":"Plex","url":"https://plex.tv","type":1,"sub_type":"","keyword_type":null,"keyword_value":"","http_username":"","http_password":"","port":"","interval":300,"status":2,"create_datetime":1513815865 } ]}
Displays a list of all of the alert contacts configured for the account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -aThe following alert contacts have been found for your UptimeRobot account:{"stat":"ok","offset":0,"limit":50,"total":2,"alert_contacts": [ {"id":"0526944","friendly_name":"E-Mail","type":2,"status":2,"value":"me@domain.com" }, {"id":"2611518","friendly_name":"Discord","type":11,"status":2,"value":"https://discordapp.com/api/webhooks/123456789/qwerty-qwerty-qwerty/slack" } ]}
This can be helpful when creating a new monitor as you can use theid field of the alert contact to specify the alert contact that you want to be notified when an event occurs with the new monitor that you're creating.
Pause all monitors in your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m uptimerobot -p allPausing Plex:{"stat":"ok","monitor": {"id":779783111 }}Pausing Radarr:{"stat":"ok","monitor": {"id":780859973 }}Pausing Sonarr:{"stat":"ok","monitor": {"id":780859962 }}Pausing Tautulli:{"stat":"ok","monitor": {"id":780859975 }}
/tmp/tronitor/healthchecks.lock, so that you can modify your existing HC.io script to check for the lock file and not send pings if it is present.
Pause specific monitors in your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh --monitor ur -p 'Plex',780859973Pausing Plex:{"stat":"ok","monitor": {"id":779783111 }}Pausing Radarr:{"stat":"ok","monitor": {"id":780859973 }}
/tmp/tronitor/MONITOR-UUID.lock, so that you can modify your existing HC.io script to check for the lock file and not send pings if it is present.
Unpause all monitors in your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -u allUnpausing Plex:{"stat":"ok","monitor": {"id":779783111 }}Unpausing Radarr:{"stat":"ok","monitor": {"id":780859973 }}Unpausing Sonarr:{"stat":"ok","monitor": {"id":780859962 }}Unpausing Tautulli:{"stat":"ok","monitor": {"id":780859975 }}
Unpause specific monitors that are currently paused in your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -u 'Plex',780859973Unpausing Plex:{"stat":"ok","monitor": {"id":779783111 }}Unpausing Radarr:{"stat":"ok","monitor": {"id":780859973 }}
Monitors can be created using this option.
Modify the settings of the corresponding monitor type template file in the correspondingTemplates directory for your provider, IE: creating a new HTTP(s) monitor for UptimeRobot would require you to modify theTemplates/UptimeRobot/new-http-monitor.json file. The full API documentation for the two providers can be foundHERE (UR),HERE (SC), andHERE (HC) for information on monitor types and any required values and what they're for.
The following example is for creating a new HTTP(s) monitor for Google:
tronyx@suladan:~/tronitor$ cat Templates/UptimeRobot/new-http-monitor.json{"api_key":"","friendly_name":"Google","url":"https://google.com","type":1,"http_username":"","http_password":"","interval":300,"alert_contacts":"","ignore_ssl_errors":"false","format":"json"}
Theapi_key field is filled in automatically by the script, but you can still add it yourself if you'd like to. Thealert_contacts field can be filled in with theid field from your preferred alert contact which you can retrieve using the-a/--alerts option with the script.
Then just execute the script to create the monitor:
tronyx@suladan:~/tronitor$ ./tronitor.sh --monitor uptimerobot -c http{"stat":"ok","monitor": {"id":781067574,"status":1 }}
Reset (deleting all stats and response time data) all or specific monitors in your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -r google***WARNING*** This will reset ALL data for the specified monitors!!!Are you sure you wish to continue? ([Y]es or [N]o):yResetting Google:{"stat":"ok","monitor": {"id":781067574 }}
Delete all, or a specific, monitor from your account:
tronyx@suladan:~/tronitor$ ./tronitor.sh -m ur -d plex***WARNING*** This will delete the specified monitor from your account!!!Are you sure you wish to continue? ([Y]es or [N]o):yDeleting Plex:{"stat":"ok","monitor": {"id":781067560 }}
About
Bash script to work with UptimeRobot, StatusCake, HealthChecks.io, & Upptime monitoring providers
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.









