This a tool that helps automate the CRUD tasks for uptime robot.
-
Clone the repository
-
From the root of the repo build
make build
-
uptimerobot-toolingexecutable file should be created on the root.
Rationale for the tool is that
friendly_nameshould be unique however this can be disabled by settingMONITOR_RESOLVE_BY_FRIENDLY_NAMEto false(default is true) and maintainingMONITOR_RESOLVE_ALERT_CONTACTS_BY_FRIENDLY_NAMEto false as is default.
For the fields below use the supported values as they will be mapped to their id.
| Resource | Field | Supported Values |
|---|---|---|
monitor |
type |
HTTP,HTTPS,Heartbeat,Ping,Port,Keyword |
monitor |
sub_type |
HTTP,HTTPS,FTP,SMTP,POP3,IMAP |
monitor |
keyword_type |
exists, not exists |
monitor |
keyword_case_type |
case sensitive, case insensitive |
monitor |
keyword_case_type |
Basic, Digest,HTTP Basic Auth |
Arguments Supported:
| Arg | Description | Default Value | Supported Values |
|---|---|---|---|
| d | Data/input | "" |
text or json (single object or array) file |
| r | Resource to be acted upon. | monitor |
monitor |
| a | action to be performed on the resource. Create will create the monitor. Update will either create or update only if either id or friendly_name are provided on the payload. Delete removes the monitor using id or friendly_name to identify a monitor.In update and delete id is given priority over friendly_name if both are specified.i.e (update by id, delete by id). |
create |
create, update, delete |
Environment Variables Supported:
| Variable | Resource | Description | Default |
|---|---|---|---|
UPTIME_ROBOT_API_KEY |
all |
Your Uptime robot API key. | |
UPTIME_ROBOT_API_URL |
all |
Unless specified otherwise it defaults to https://api.uptimerobot.com/v2/. | https://api.uptimerobot.com/v2/ |
MONITOR_RESOLVE_BY_FRIENDLY_NAME |
monitor |
If false it will not resolve monitor by friendly_name i.e updates/deletes will need id. |
true |
MONITOR_RESOLVE_ALERT_CONTACTS_BY_FRIENDLY_NAME |
monitor |
if true alert contacts can be resolved by their friendly_name in addition to id i.e instead of supplying its id in the alert_contacts field one can simply use its friendly_name. |
false |
MONITOR_ALERT_CONTACTS_DELIMITER |
monitor |
Delimiter used to separate alert contacts when creating/updating a monitor. Default as specified here. | - |
MONITOR_ALERT_CONTACTS_ATTRIB_DELIMITER |
monitor |
Delimiter used to separate alert contacts attributes when creating/updating a monitor. Default as specified here. | _ |
(Running from the root of the repository)
./uptimerobot-tooling -h{
"friendly_name": "example-com",
"url": "https://example.com",
"type": "HTTP"
}./uptimerobot-tooling -r=monitor -a=update -d=test.json./uptimerobot-tooling -r=monitor -a=delete -d='{"friendly_name":"example-com","url":"https://example.com","type":"HTTP"}'or
./uptimerobot-tooling -r=monitor -a=delete -d='{"id":"34","url":"https://example.com","type":"HTTP"}'-
If
MONITOR_RESOLVE_ALERT_CONTACTS_BY_FRIENDLY_NAMEisfalseon your setup ignore this section. -
From the api documentation one can specify alert contact with or without appending recurrence and threshold attributes like so
1,1_0_6. With this tooling one can use eitherfriendly_nameoridof alert contact like soalertContactA,1,alertContactA_0_6,alertContactA_0_6-alertContactA_0-5,1_0_6.{ ... "alert_contacts": "alertContactA_0_6" } ... [{ ... "alert_contacts": "1_0_6" }] -
If alert contact
friendly_namehas-or_one can override the default delimiters for alert contacts and alert contacts attributes by specifyingMONITOR_ALERT_CONTACTS_DELIMITERand/orMONITOR_ALERT_CONTACTS_ATTRIB_DELIMITERrespectively. For example instead of:alert-contact-a_0_5-|alert-contact-b(friendly_name has hyphen that will affect alert contact splitting) setMONITOR_ALERT_CONTACTS_DELIMITERto|then supplyalert-contact-a_0_5|alert-contact-b.alert_contact_a|0|5(friendly_name has underscore that will affect alert contact attribute splitting) setMONITOR_ALERT_CONTACTS_ATTRIB_DELIMITERto|andMONITOR_ALERT_CONTACTS_DELIMITERto-then supplyalert_contact_a|0|5-alert_contact_b|0|5.