utr – Ansible-like Management of UptimeRobot

news tools

utr is a CLI tool for UptimeRobot. Unlike other tools, it enables you to manage monitors, maintenance windows, alert contacts and status pages based on status, in a manner similar to Ansible. The desired configuration is defined in YAML files, and utr ensures that the actual state automatically corresponds to the desired state in an idempotent manner.

All you need is Python 3 and a valid UptimeRobot API key. This can be entered either directly using the --api_key option, or via a file (the default is ~/.uptimerobot). You can install the tool using pip install --user uptimerobot-cli. Typing utr --help displays all available commands and options.

It was developed in the Linuxfabrik, is open source, and is licensed under the UNLICENSE. Further details and documentation can be found at github.com/linuxfabrik.

Step 1: Create a YAML template

Define monitors, maintenance windows (MWindows) and alarm contacts in one or more YAML files. Example:

mwindows:
  - type: 'weekly'
    value: 'wed'
    start_time: '03:30'
    end_time: '05:30'
    status: 'active'
    state: 'present'

monitors:
  - prefix: 'prod'
    url: 'https://www.example.com/'
    interval: 30
    http_method: 'get'
    type: 'keyw'
    keyword_type: 'notex'
    keyword_case_type: 'ci'
    keyword_value: 'Example Inc.'
    mwindows:
      - friendly_name: 'weekly wed 03:30-05:30'
    state: 'present'

Further details on the YAML syntax can be found in the project's YAML documentation.

Step 2: Apply the configuration

Use the apply function to apply the YAML definition to UptimeRobot:

utr apply config.yml

In UptimeRobot, create, update and delete actions are performed idempotently to achieve the desired state.

Ad hoc commands

For quick queries or bulk updates that don't require YAML, the get and set commands are available. Examples:

  • Display account details, rate limits, etc.: utr get account
  • Display a list of all monitors: utr get monitors --output=table
  • Pause all "example" monitors: utr set monitors --search=example --status=paused

This allows you to manage individual resources quickly and easily.

Previous Post Next Post