Sha256: 3775d8c5ea44949abb54e2e73f0201d9977e01ac7bb4e8158538c8f05263270f

Contents?: true

Size: 1.75 KB

Versions: 11

Compression:

Stored size: 1.75 KB

Contents

module Zabbix

  class ZabbixApi
    def add_trigger(trigger)

      message = {
        'method' => 'trigger.create',
        'params' => [ trigger ]
      }

      response = send_request(message)

      unless response.empty? then
        result = response['triggerids'][0]
      else
        result = nil
      end

      return result

    end

    def get_trigger_id(host_id, trigger_name)

      message = {
        'method' => 'trigger.get',
        'params' => {
          'filter' => {
            'hostid' => host_id,
            'description' => trigger_name
          }
        }
      }

      response = send_request(message)

      unless response.empty? then
        result = response[0]['triggerid']
      else
        result = nil
      end
    
      return result
    end

    def get_triggers_by_host(host_id)

      message = {
        'method' => 'trigger.get',
        'params' => {
          'filter' => {
            'hostid' => host_id,
          },
          'extendoutput' => '1'
        }
      }

      response = send_request(message)

      unless response.empty? then
        result = {}
        response.each do |trigger|
          trigger_id = trigger['triggerid']
          description = trigger['description']
          result[trigger_id] = description
        end
      else
        result = {}
      end

      return result
    end

    def update_trigger_status(trigger_id, status)

      message = {
        'method' => 'trigger.update_status',
        'params' => {
          'triggerid' => trigger_id,
          'status' => status
        }
      }

      response = send_request(message)

      unless response.empty? then
        result = response['triggerids'][0]
      else
        result = nil
      end

      return result
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
zabbixapi-0.1.6 lib/zabbixapi/trigger.rb
zabbixapi-0.1.5b lib/zabbixapi/trigger.rb
zabbixapi-0.1.5a6 lib/zabbixapi/trigger.rb
zabbixapi-0.1.5a5 lib/zabbixapi/trigger.rb
zabbixapi-0.1.5a4 lib/zabbixapi/trigger.rb
zabbixapi-0.1.5a3 lib/zabbixapi/trigger.rb
zabbixapi-0.1.5a2 lib/zabbixapi/trigger.rb
zabbixapi-0.1.5a1 lib/zabbixapi/trigger.rb
iteh-zabbixapi-0.2.4 lib/zabbixapi/trigger.rb
iteh-zabbixapi-0.2.3 lib/zabbixapi/trigger.rb
iteh-zabbixapi-0.2.2 lib/zabbixapi/trigger.rb