community.general.zabbix_host_events_info (0.1.1) — module

Get all triggers about a Zabbix host

Authors: Stéphane Travassac (@stravassac)

preview | supported by community

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

This module allows you to see if a Zabbix host have no active alert to make actions on it. For this case use module Ansible 'fail' to exclude host in trouble.

Length of "triggers_ok" allow if template's triggers exist for Zabbix Host


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: exclude machine if alert active on it
  zabbix_host_events_info:
      server_url: "{{ zabbix_url }}"
      login_user: "{{ lookup('env','ZABBIX_USER') }}"
      login_password: "{{ lookup('env','ZABBIX_PASSWORD') }}"
      host_identifier: "{{inventory_hostname}}"
      host_id_type: "hostname"
      timeout: 120
  register: zbx_host
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- fail:
    msg: "machine alert in zabbix"
  when: zbx_host['triggers_problem']|length > 0

Inputs

    
timeout:
    default: 10
    description:
    - The timeout of API request (seconds).
    type: int

login_user:
    description:
    - Zabbix user name.
    required: true
    type: str

server_url:
    aliases:
    - url
    description:
    - URL of Zabbix server, with protocol (http or https). C(url) is an alias for C(server_url).
    required: true
    type: str

host_id_type:
    choices:
    - hostname
    - visible_name
    - hostid
    default: hostname
    description:
    - Type of host_identifier
    required: false
    type: str

login_password:
    description:
    - Zabbix user password.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - If set to False, SSL certificates will not be validated. This should only be used
      on personally controlled sites using self-signed certificates.
    type: bool

host_identifier:
    description:
    - Identifier of Zabbix Host
    required: true
    type: str

http_login_user:
    description:
    - Basic Auth login
    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
    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: Host 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: Host Zabbix Triggers in problem state. See trigger and event objects
    in API documentation of your zabbix version for more
  returned: On success
  type: complex