community.general.sensu_check (8.5.0) — module

Manage Sensu checks

Authors: Anders Ingemann (@andsens)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manage the checks that should be run on a machine by I(Sensu).

Most options do not have a default and will not be added to the check definition unless specified.

All defaults except O(path), O(state), O(backup) and O(metric) are not managed by this module,

they are simply specified for your convenience.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Fetch metrics about the CPU load every 60 seconds,
# the sensu server has a handler called 'relay' which forwards stats to graphite
- name: Get cpu metrics
  community.general.sensu_check:
    name: cpu_load
    command: /etc/sensu/plugins/system/cpu-mpstat-metrics.rb
    metric: true
    handlers: relay
    subscribers: common
    interval: 60
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Check whether nginx is running
- name: Check nginx process
  community.general.sensu_check:
    name: nginx_running
    command: /etc/sensu/plugins/processes/check-procs.rb -f /var/run/nginx.pid
    handlers: default
    subscribers: nginx
    interval: 60
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Stop monitoring the disk capacity.
# Note that the check will still show up in the sensu dashboard,
# to remove it completely you need to issue a DELETE request to the sensu api.
- name: Check disk
  community.general.sensu_check:
    name: check_disk_capacity
    state: absent

Inputs

    
ttl:
    description:
    - Time to live in seconds until the check is considered stale
    type: int

name:
    description:
    - The name of the check
    - This is the key that is used to determine whether a check exists
    required: true
    type: str

path:
    default: /etc/sensu/conf.d/checks.json
    description:
    - Path to the json file of the check to be added/removed.
    - Will be created if it does not exist (unless O(state=absent)).
    - The parent folders need to exist when O(state=present), otherwise an error will
      be thrown
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Whether the check should be present or not
    type: str

backup:
    default: false
    description:
    - Create a backup file (if yes), including the timestamp information so
    - you can get the original file back if you somehow clobbered it incorrectly.
    type: bool

custom:
    description:
    - A hash/dictionary of custom parameters for mixing to the configuration.
    - You can't rewrite others module parameters using this
    type: dict

handle:
    description:
    - Whether the check should be handled or not
    - Default is V(false).
    type: bool

metric:
    default: false
    description:
    - Whether the check is a metric
    type: bool

source:
    description:
    - The check source, used to create a JIT Sensu client for an external resource (e.g.
      a network switch).
    type: str

command:
    description:
    - Path to the sensu check to run (not required when O(state=absent))
    type: str

publish:
    description:
    - Whether the check should be scheduled at all.
    - You can still issue it via the sensu api
    - Default is V(false).
    type: bool

refresh:
    description:
    - Number of seconds handlers should wait before taking second action
    type: int

timeout:
    description:
    - Timeout for the check
    - If not specified, it defaults to 10.
    type: int

handlers:
    description:
    - List of handlers to notify when the check fails
    elements: str
    type: list

interval:
    description:
    - Check interval in seconds
    type: int

aggregate:
    description:
    - Classifies the check as an aggregate check,
    - making it available via the aggregate API
    - Default is V(false).
    type: bool

standalone:
    description:
    - Whether the check should be scheduled by the sensu client or server
    - This option obviates the need for specifying the O(subscribers) option
    - Default is V(false).
    type: bool

subdue_end:
    description:
    - When to enable handling of check failures
    type: str

occurrences:
    description:
    - Number of event occurrences before the handler should take action
    - If not specified, defaults to 1.
    type: int

subscribers:
    description:
    - List of subscribers/channels this check should run for
    - See sensu_subscribers to subscribe a machine to a channel
    elements: str
    type: list

dependencies:
    description:
    - Other checks this check depends on, if dependencies fail handling of this check
      will be disabled
    elements: str
    type: list

subdue_begin:
    description:
    - When to disable handling of check failures
    type: str

low_flap_threshold:
    description:
    - The low threshold for flap detection
    type: int

high_flap_threshold:
    description:
    - The high threshold for flap detection
    type: int