Skip to content

linuxfabrik.lfops.uptimerobot_monitor_info

List UptimeRobot monitors

Synopsis

  • Calls getMonitors on the UptimeRobot v2 API and returns every monitor on the account, paginated transparently.
  • Enum-coded fields are translated to human-readable labels - type becomes http/keyw/ping/port/beat, status becomes paused/wait/up/seems_down/down, http_method/keyword_type/keyword_case_type/http_auth_type are unmangled, and the type of each entry in nested alert_contacts[] is mapped to its label (sms, email, slack, ...).
  • Read-only; the module always reports changed=false and is safe to run in check mode.

Available since LFOps 6.0.2.

Optional Parameters

api_key

  • UptimeRobot API key. See uptimerobot_monitor for the resolution order.
  • Type: String.

api_key_file

  • Path to a file whose first line is the UptimeRobot API key. Tilde-expanded.
  • Type: String.
  • Default: ~/.uptimerobot

friendly_name

  • Filter the returned list to the monitor whose friendly_name is an exact match for this value. The result is still a list (length 0 or 1) for shape stability. Applied client-side after search has narrowed the API response.
  • Type: String.

search

  • Server-side, case-insensitive substring filter forwarded to UptimeRobot's search parameter. Useful to keep the response small when the account has thousands of monitors. Combine with friendly_name to narrow further.
  • Type: String.

Examples

# 1) Quick ad-hoc list of every monitor on the account. The API key is read
#    from ~/.uptimerobot when not passed.
- name: 'Capture all monitors'
  linuxfabrik.lfops.uptimerobot_monitor_info:
  register: 'ur_monitors'

- ansible.builtin.debug:
    msg: '{{ ur_monitors.monitors | length }} monitors total'

# 2) Filter by friendly_name (exact match). Returns at most one entry.
- name: 'Capture one monitor by friendly_name'
  linuxfabrik.lfops.uptimerobot_monitor_info:
    friendly_name: '001 www.example.com'
  register: 'ur_monitor'

- ansible.builtin.debug:
    msg: 'Status: {{ ur_monitor.monitors[0].status }} ({{ ur_monitor.monitors[0].interval }}s interval)'

# 3) Server-side substring filter — useful for prefixed inventories.
- linuxfabrik.lfops.uptimerobot_monitor_info:
    search: '001 '
  register: 'ur_001'

- ansible.builtin.debug:
    msg: '{{ ur_001.monitors | map(attribute="friendly_name") | list }}'

# 4) Drive a maintenance task: pause every monitor matching a prefix while a
#    deployment is in progress (see uptimerobot_monitor for the pause action).
- linuxfabrik.lfops.uptimerobot_monitor_info:
    search: '001 '
  register: 'ur_to_pause'

- linuxfabrik.lfops.uptimerobot_monitor:
    friendly_name: '{{ item.friendly_name }}'
    status: 'paused'
    state: 'present'
  loop: '{{ ur_to_pause.monitors }}'
  loop_control:
    label: '{{ item.friendly_name }}'

# 5) Reporting — list monitors that are currently down or seem down.
- linuxfabrik.lfops.uptimerobot_monitor_info:
  register: 'ur_all'

- ansible.builtin.debug:
    msg: >-
      Down: {{
        ur_all.monitors
        | selectattr("status", "in", ["down", "seems_down"])
        | map(attribute="friendly_name")
        | list
      }}

Return Values

debug

  • Diagnostic information about the API call. Stable enough to assert against, not stable enough to be load-bearing.
  • Type: Dictionary.
  • Returned: always.
  • Sample:

    yaml count: 17 operation: list

monitors

  • List of monitor dicts. Empty list when nothing matched.
  • Type: List.
  • Returned: always.

Authors

  • Linuxfabrik GmbH, Zurich, Switzerland (info (at) linuxfabrik (dot) ch)