community.zabbix.zabbix_group_events_info (2.3.1) — module

Get all triggers about a Zabbix group

Authors: Martin Eiswirth (@meis4h)

Install collection

Install with ansible-galaxy collection install community.zabbix:==2.3.1


Add to requirements.yml

  collections:
    - name: community.zabbix
      version: 2.3.1

Description

This module allows you to check the state of triggers of all hosts in a Zabbix hostgroup.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# If you want to use Username and Password to be authenticated by Zabbix Server
- name: Set credentials to access Zabbix Server API
  set_fact:
    ansible_user: Admin
    ansible_httpapi_pass: zabbix
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# If you want to use API token to be authenticated by Zabbix Server
# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens
- name: Set API token
  set_fact:
    ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Fail if alert active in hostgroup
  # set task level variables as we change ansible_connection plugin here
  vars:
      ansible_network_os: community.zabbix.zabbix
      ansible_connection: httpapi
      ansible_httpapi_port: 443
      ansible_httpapi_use_ssl: true
      ansible_httpapi_validate_certs: false
      ansible_zabbix_url_path: "zabbixeu"  # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
      ansible_host: zabbix-example-fqdn.org
  community.zabbix.zabbix_group_events_info:
      hostgroup_name: "{{ inventory_hostname }}"
  register: zbx_hostgroup
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- fail:
    msg: "Active alert in zabbix"
  when: zbx_hostgroup["triggers_problem"] | length > 0

Inputs

    
hostgroup_name:
    description:
    - Name of the hostgroup in Zabbix.
    elements: str
    required: true
    type: list

http_login_user:
    description:
    - Basic Auth login
    required: false
    type: str

trigger_severity:
    choices:
    - not_classified
    - information
    - warning
    - average
    - high
    - disaster
    default: average
    description:
    - Zabbix severity for search filter
    required: false
    type: str

http_login_password:
    description:
    - Basic Auth password
    required: false
    type: str

Outputs

triggers_ok:
  contains:
    comments:
      description: Additional description of the trigger
      type: str
    description:
      description: Name of the trigger
      type: str
    error:
      description: Error text if there have been any problems when updating the state
        of the trigger
      type: str
    expression:
      description: Reduced trigger expression
      type: str
    flags:
      description: Origin of the trigger
      type: int
    lastchange:
      description: Time when the trigger last changed its state (timestamp)
      type: int
    priority:
      description: Severity of the trigger
      type: int
    state:
      description: State of the trigger
      type: int
    status:
      description: Whether the trigger is enabled or disabled
      type: int
    templateid:
      description: ID of the parent template trigger
      type: int
    triggerid:
      description: ID of the trigger
      type: int
    type:
      description: Whether the trigger can generate multiple problem events
      type: int
    url:
      description: URL associated with the trigger
      type: str
    value:
      description: Whether the trigger is in OK or problem state
      type: int
  description: Zabbix Triggers in OK state
  returned: On success
  type: complex
triggers_problem:
  contains:
    comments:
      description: Additional description of the trigger
      type: str
    description:
      description: Name of the trigger
      type: str
    error:
      description: Error text if there have been any problems when updating the state
        of the trigger
      type: str
    expression:
      description: Reduced trigger expression
      type: str
    flags:
      description: Origin of the trigger
      type: int
    last_event:
      contains:
        acknowledged:
          description: If set to true return only acknowledged events
          type: int
        acknowledges:
          contains:
            alias:
              description: Account who acknowledge
              type: str
            clock:
              description: Time when the event was created (timestamp)
              type: int
            message:
              description: Text of the acknowledgement message
              type: str
          description: acknowledges informations
          type: complex
        clock:
          description: Time when the event was created (timestamp)
          type: int
        eventid:
          description: ID of the event
          type: int
        value:
          description: State of the related object
          type: int
      description: last event informations
      type: complex
    lastchange:
      description: Time when the trigger last changed its state (timestamp)
      type: int
    priority:
      description: Severity of the trigger
      type: int
    state:
      description: State of the trigger
      type: int
    status:
      description: Whether the trigger is enabled or disabled
      type: int
    templateid:
      description: ID of the parent template trigger
      type: int
    triggerid:
      description: ID of the trigger
      type: int
    type:
      description: Whether the trigger can generate multiple problem events
      type: int
    url:
      description: URL associated with the trigger
      type: str
    value:
      description: Whether the trigger is in OK or problem state
      type: int
  description: Zabbix Triggers in problem state. See trigger and event objects in
    API documentation of your zabbix version for more
  returned: On success
  type: complex