www.uptimerobot.com is an excellent service which provides monitoring of up to 50 websites for free. The developers of this service have also created an API allowing for programmatically creating and modifying the data in one's account. Here is a command line tool which allows to create new monitors from the Linux command line or a shell script which is very useful if one is hosting many websites at once. RequirementsThe command line utility is a python script and therefore should run on any Linux system. It was tested on Debian. DownloadThe software is currently available as a source code package only, but it can easily be build and installed from the source. See below. Download the source code from https://github.com/uptimerobot/uptimerobot-cli/archive/master.zip. InstallationAs root, install the required python packages (the statements below will work with Debian, Ubuntu and other Debian-based distributions).
Download and unpack the source code.
After that create a package from the source code and install it:
The TutorialFirst, create a free account at www.uptimerobot.com, select "My Settings" and enable the API access by clicking the "API Information (show details)" link in your profile. Note the API key - we need it for every access to the uptimerobot site. You should also add one or two monitors manually so that you can list and modify them using the Working with contactsFirst, let's list all alert contacts. These are the email addresses that will receive a notification email if there is a problem with a monitored site:
This command should return the email address of your uptimerobot account, and all additional email addresses that you have registered. Note the alert contact id for each alert contact, it is needed to reference a contact when administrating a website monitor. Add a new alert contact:
The new alert contact is created on the uptimerobot site, and an activation email is sent to that email address. Similarly, it is also possible to delete an entry by referencing it by its id or email-address:
Working with monitorsNow let's list the existing monitors (this should return the entry that you have created manually):
Add a new monitor by entering its URL and the corresponding alert id:
You can of course also delete the monitor by referencing it by name or monitor id.
Using defaultsIt is annoying to have to add the api key to every single Copy the file
HelpThe uptimerobot command comes with a builtin help. Just run uptimerobot -h or uptimerobot SUBCOMMAND -h to learn about all options of the program. There are many more options and features available, which are not mentioned in this tutorial. During development we stumbled upon a few minor bugs in the uptimerobot API. If things do not work even if they should, you may have found a new bug. Documentationget-monitors: Get information about some or all monitorsSynopsisuptimerobot get-monitors [OPTION] ... -h, --help show this help message and exit.
--api-key STR Your uptimerobot.com api-key (for account or individual monitor).
--monitors MONITOR [MONITOR ...] IDs or names of monitors.
--uptime NUM-HOURS [NUM-HOURS ...] Show custom uptime ratios, for one or more periods (in hours).
--show-log Show logs associated with this monitor.
--log-alerts Show logs with their associated alert contacts (ignored without
--show-alerts shows alert contacts associated with this monitor.
--log-timezone shows timezone for the logs (ignored without new-monitor: create a new monitorSynopsisuptimerobot new-monitor NAME URL [OPTION] ...
positional arguments:NAME Friendly name for new monitor URL URL for new monitor
optional arguments:-h, --help show this help message and exit
--api-key STR Your uptimerobot.com api-key (for account or individual monitor).
--type N Monitor type. The parameter is one of these integer values: 1: http(s)
--subtype N Monitor subtype. The parameter is one of these integer values: 1: http
--port N Port to monitor
--keyword-type N When monitoring for keywords (parameter " 1: exists
--keyword STR Keyword to monitor
--username STR HTTP username to use for private site
--password STR HTTP password to use for private site
--alerts ID [ID ...] IDs of alert contacts to use
edit-monitor: Edit an existing monitorSynopsisuptimerobot edit-monitor ID [OPTION] ...
positional arguments:ID ID of monitor to edit
optional arguments:-h, --help show this help message and exit
--api-key STR Your uptimerobot.com api-key (for account or individual monitor).
--name STR Friendly name of monitor
--status N Status to set the monitor to: one of 0: paused
--url STR URL to monitor
--type N Monitor type. The parameter is one of these integer values: 1: http(s)
--subtype N Monitor subtype. The parameter is one of these integer values: 1: http
--port N Port to monitor
--keyword-type N When monitoring for keywords (parameter " 1: exists
--keyword STR Keyword to monitor
--username STR HTTP username to use for private site
--password STR HTTP password to use for private site
--alerts ID [ID ...] IDs of alert contacts to use
delete-monitor: Delete a monitorget-alerts: Get information about some or all alert contacts |
LinksWebsite:Source Code: |