Class: Zabbix::ZabbixApi

Inherits:
Object
  • Object
show all
Defined in:
lib/zabbixapi/base.rb,
lib/zabbixapi/host.rb,
lib/zabbixapi/item.rb,
lib/zabbixapi/graph.rb,
lib/zabbixapi/group.rb,
lib/zabbixapi/screen.rb,
lib/zabbixapi/trigger.rb,
lib/zabbixapi/template.rb,
lib/zabbixapi/usermacro.rb,
lib/zabbixapi/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_url, api_user, api_password) ⇒ ZabbixApi

Returns a new instance of ZabbixApi.



28
29
30
31
32
33
34
# File 'lib/zabbixapi/base.rb', line 28

def initialize (api_url, api_user, api_password)
  @api_url = api_url
  @api_user = api_user
  @api_password = api_password

  @debug = false # Disable debug by default
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



26
27
28
# File 'lib/zabbixapi/base.rb', line 26

def debug
  @debug
end

Instance Method Details

#add_application(app_options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/zabbixapi/application.rb', line 4

def add_application(app_options)
  app_options_default = {
      'hostid' => nil,
      'name' => nil
  }
  application = merge_opt(app_options_default, app_options)
  message = {
      'method' => 'application.create',
      'params' => application
  }
  responce = send_request(message)
  responce.empty? ? nil : responce['applicationids'][0].to_i
end

#add_graph(graph) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/zabbixapi/graph.rb', line 4

def add_graph(graph)
  message = {
      'method' => 'graph.create',
      'params' => graph
  }
  response = send_request(message)
  return 0
end

#add_graph_to_screen(screen_id, graph_id, x, y) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/zabbixapi/screen.rb', line 76

def add_graph_to_screen(screen_id, graph_id, x, y)
  message = {
      'method' => 'screen.addItems',
      'params' => {
          'screenids' => [screen_id],
          'screenitems' => [
              {
                  'resourcetype' => 'graph',
                  'resourceid' => graph_id,
                  'width' => '800',
                  'height' => '200',
                  'x' => x,
                  'y' => y,
                  'valign' => 'Middle',
                  'halign' => 'Centre',
                  'colspan' => '0',
                  'rowspan' => '0',
                  'elements' => '0',
                  'dynamic' => '0',
                  'url' => '0',
                  'style' => '0'
              }
          ]
      }
  }
  response = send_request(message)
  return response
end

#add_group(groupname) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/zabbixapi/group.rb', line 22

def add_group(groupname)
  message = {
      'method' => 'hostgroup.create',
      'params' => {
          'name' => groupname
      }
  }
  response = send_request(message)
  response ? response['groupids'][0].to_i : nil
end

#add_host(host_options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/zabbixapi/host.rb', line 15

def add_host(host_options)
  host_default = {
      'host' => nil,
      'port' => 10050,
      'status' => 0,
      'useip' => 0,
      'dns' => '',
      'ip' => '0.0.0.0',
      'proxy_hostid' => 0,
      'groups' => [],
      'useipmi' => 0,
      'ipmi_ip' => '',
      'ipmi_port' => 623,
      'ipmi_authtype' => 0,
      'ipmi_privilege' => 0,
      'ipmi_username' => '',
      'ipmi_password' => ''
  }
  host_options['groups'].nil? || host_options['groups'].map! { |group_id| {'groupid' => get_group_id(group_id)} }
  host = merge_opt(host_default, host_options)
  message = {
      'method' => 'host.create',
      'params' => host
  }
  response = send_request(message)
  response.empty? ? nil : response['hostids'][0].to_i
end

#add_host_to_group(host_id, group_id) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/zabbixapi/group.rb', line 45

def add_host_to_group(host_id, group_id)
  message = {
      'method' => 'hostgroup.massAdd',
      'params' => {
          'groups' => [group_id],
          'hosts' => [host_id]
      }
  }
  response = send_request(message)
  response.empty? ?  false : true
end

#add_item(item) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/zabbixapi/item.rb', line 4

def add_item(item)
  # Default item options
  # See: http://www.zabbix.com/documentation/1.8/api/item
  ## Item types (see ./frontends/php/include/defines.inc.php in zabbix source)
  # ITEM_TYPE_ZABBIX              0
  # ITEM_TYPE_SNMPV1              1
  # ITEM_TYPE_TRAPPER             2
  # ITEM_TYPE_SIMPLE              3
  # ITEM_TYPE_SNMPV2C             4
  # ITEM_TYPE_INTERNAL            5
  # ITEM_TYPE_SNMPV3              6
  # ITEM_TYPE_ZABBIX_ACTIVE       7
  # ITEM_TYPE_AGGREGATE           8
  # ITEM_TYPE_HTTPTEST            9
  # ITEM_TYPE_EXTERNAL            10
  # ITEM_TYPE_DB_MONITOR          11
  # ITEM_TYPE_IPMI                12
  # ITEM_TYPE_SSH                 13
  # ITEM_TYPE_TELNET              14
  # ITEM_TYPE_CALCULATED          15
  item_options = {
      'description' => nil,
      'key_' => nil,
      'hostid' => nil,
      'delay' => 60,
      'history' => 60,
      'status' => 0,
      'type' => 7,
      'snmp_community' => '',
      'snmp_oid' => '',
      'value_type' => 3,
      'data_type' => 0,
      'trapper_hosts' => 'localhost',
      'snmp_port' => 161,
      'units' => '',
      'multiplier' => 0,
      'delta' => 0,
      'snmpv3_securityname' => '',
      'snmpv3_securitylevel' => 0,
      'snmpv3_authpassphrase' => '',
      'snmpv3_privpassphrase' => '',
      'formula' => 0,
      'trends' => 365,
      'logtimefmt' => '',
      'valuemapid' => 0,
      'delay_flex' => '',
      'authtype' => 0,
      'username' => '',
      'password' => '',
      'publickey' => '',
      'privatekey' => '',
      'params' => '',
      'ipmi_sensor' => '',
      'applications' => '',
      'templateid' => 0
  }
  item_options.merge!(item)
  message = {
      'method' => 'item.create',
      'params' => [item_options]
  }
  response = send_request(message)
  response.empty? ? nil : response['itemids'][0]
end

#add_macro(host_id, macro_name, macro_value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/zabbixapi/usermacro.rb', line 4

def add_macro(host_id, macro_name, macro_value)
  message = {
      'method' => 'Usermacro.create',
      'params' => {
          'hostid' => host_id,
          'macro' => macro_name,
          'value' => macro_value
      }
  }
  response = send_request(message)
  hostmacroids == response['hostmacroids'] ? hostmacroids : nil
end

#add_screen(screen_name, hsize, vsize) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/zabbixapi/screen.rb', line 105

def add_screen(screen_name, hsize, vsize)
  message = {
      'method' => 'screen.create',
      'params' => {
          'name' => screen_name,
          'hsize' => hsize,
          'vsize' => vsize
      }
  }
  response = send_request(message)
  response.empty? ? nil : response['screenids'][0]
end

#add_template(template_options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zabbixapi/template.rb', line 4

def add_template(template_options)
  template_default = {
      'host' => nil,
      'groups' => [],
  }
  template_options['groups'].map! { |group_id| {'groupid' => group_id} }
  template = merge_opt(template_default, template_options)
  message = {
      'method' => 'template.create',
      'params' => template
  }
  response = send_request(message)
  response.empty? ? nil : response['templateids'][0].to_i
end

#add_trigger(trigger) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/zabbixapi/trigger.rb', line 4

def add_trigger(trigger)
  message = {
      'method' => 'trigger.create',
      'params' => [trigger]
  }
  response = send_request(message)
  response.empty? ? nil : response['triggerids'][0]
end

#authObject



106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/zabbixapi/base.rb', line 106

def auth()
  auth_message = {
      'auth' => nil,
      'method' => 'user.authenticate',
      'params' => {
          'user' => @api_user,
          'password' => @api_password,
          '0' => '0'
      }
  }
do_request(auth_message)
end

#del_all_graphs_from_screen(screen_id) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/zabbixapi/screen.rb', line 65

def del_all_graphs_from_screen(screen_id)
  message = {
      'method' => 'screen.deleteItems',
      'params' => {
          'screenids' => [screen_id],
      }
  }
  response = send_request(message)
  response ? response : nil
end

#delete_group(groupname) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/zabbixapi/group.rb', line 33

def delete_group(groupname)
  group_id = get_group_id(groupname)
  message = {
      'method' => 'hostgroup.delete',
      'params' => {
          'groupid' => group_id
      }
  }
  response = send_request(message)
  response ? response['groupids'][0].to_i : nil
end

#delete_host(hostname) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/zabbixapi/host.rb', line 56

def delete_host(hostname)
  host_id = get_host_id(hostname)
  message = {
      'method' => 'host.delete',
      'params' => {
          'hostid' => host_id
      }
  }
  send_request(message)
end

#delete_item(item_ids) ⇒ Object

Don’t work with api < 1.8.4



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/zabbixapi/item.rb', line 104

def delete_item(item_ids)
  if item_ids.kind_of? Array
    message = {
        'method' => 'item.delete',
        'params' => item_ids
    }
  elsif item_ids.kind_of? Fixnum or item_ids.kind_of? String
    message = {
        'method' => 'item.delete',
        'params' => [item_ids]
    }
  else
    raise Zabbix::ArgumentError.new("Zabbix::ZabbixApi.delete_item() argument error. item_ids => #{item_ids.inspect}")
  end
  response = send_request(message)
  if response.empty?
    result = nil
  else
    response['itemids'].count == 1 ? result = response['itemids'][0] : result = response['itemids']
  end
  return result
end

#do_request(message) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/zabbixapi/base.rb', line 36

def do_request(message)

  id = rand 100_000

  message['id'] = id
  message['jsonrpc'] = '2.0'

  message_json = JSON.generate(message)

  uri = URI.parse(@api_url)
  http = Net::HTTP.new(uri.host, uri.port)

  if uri.scheme == "https"
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end

  request = Net::HTTP::Post.new(uri.request_uri)
  request.add_field('Content-Type', 'application/json-rpc')
  request.body=(message_json)

  begin
    puts "[ZBXAPI] : INFO : Do request. Body => #{request.body}" if @debug
    response = http.request(request)
  rescue ::SocketError => e
    puts "[ZBXAPI] : ERROR : SocketError => #{e.message}" if @debug
    raise Zabbix::SocketError.new(e.message)
  end

  if @debug
    puts "[ZBXAPI] : INFO : Response start"
    puts response
    puts "[ZBXAPI] : INFO : Response end"
  end

  if response.code != "200"
    raise Zabbix::ResponseCodeError.new("Responce code from [" + @api_url + "] is #{response.code}")
  end

  response_body_hash = JSON.parse(response.body)

  if @debug
    puts "[ZBXAPI] : INFO : Response body"
    puts response_body_hash.inspect
  end

  if error = response_body_hash['error']
    error_message = error['message']
    error_data = error['data']
    error_code = error['code']

    e_message = "Code: [" + error_code.to_s + "]. Message: [" + error_message +\
          "]. Data: [" + error_data + "]."

    case error_code.to_s
      when '-32602'
        raise Zabbix::AlreadyExist.new(e_message)
      else
        raise Zabbix::ResponseError.new(e_message)
    end
  end

  return response_body_hash['result']
end

#get_graph_id(host_id, graph_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zabbixapi/graph.rb', line 13

def get_graph_id(host_id, graph_name)
  message = {
      'method' => 'graph.get',
      'params' => {
          'filter' => {
              'name' => graph_name,
              'hostid' => host_id
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response[0]['graphid']
end

#get_graphs(host_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zabbixapi/graph.rb', line 27

def get_graphs(host_id)
  message = {
      'method' => 'graph.get',
      'params' => {
          'extendoutput' => '1',
          'filter' => {
              'hostid' => host_id
          }
      }
  }
  response = send_request(message)
  if response.empty?
    result = nil
  else
    result = {}
    response.each() do |graph|
      graph_id = graph['graphid']
      graph_name = graph['name']
      result[graph_id] = graph_name
    end
  end
  return result
end

#get_group_id(pattern) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/zabbixapi/group.rb', line 4

def get_group_id(pattern)
  message = {
      'method' => 'hostgroup.get',
      'params' => {
          'filter' => {
              'name' => pattern
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response[0]['groupid']
end

#get_host_id(hostname) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/zabbixapi/host.rb', line 43

def get_host_id(hostname)
  message = {
      'method' => 'host.get',
      'params' => {
          'filter' => {
              'host' => hostname
          }
      }
  }
  response = send_request(message)
  response.empty? ?  nil : response[0]['hostid'].to_i
end

#get_item_id(host_id, item_name) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/zabbixapi/item.rb', line 69

def get_item_id(host_id, item_name)
  message = {
      'method' => 'item.get',
      'params' => {
          'filter' => {
              'hostid' => host_id,
              'description' => item_name
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response[0]['itemid']
end

#get_macro(host_id, macro_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/zabbixapi/usermacro.rb', line 17

def get_macro(host_id, macro_name)
  message = {
      'method' => 'Usermacro.get',
      'params' => {
          'hostids' => host_id,
          'macros' => macro_name,
          'extendoutput' => '1'
      }
  }
  response = send_request(message)
  if response.empty?
    result = nil
  else
    if hostmacroid == response[0]['hostmacroid']
      macro_id = hostmacroid
      macro_value = response[0]['value']

      result = {
          'id' => macro_id,
          'value' => macro_value
      }
    else
      result = nil
    end
  end
  return result
end

#get_screen_graph_ids(screen_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/zabbixapi/screen.rb', line 31

def get_screen_graph_ids(screen_id)
  message = {
      'method' => 'screen.get',
      'params' => {
          'extendoutput' => '1',
          'select_screenitems' => '1',
          'screenids' => [screen_id]
      }
  }
  response = send_request(message)
  if response.empty?
    result = nil
  else
    result = []
    screenitems = response[0]['screenitems']
    screenitems.each() do |item|
      result << item['resourceid'] if item['resourcetype'].to_i == 0
    end
  end
  return result
end

#get_screen_id(screen_name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/zabbixapi/screen.rb', line 4

def get_screen_id(screen_name)
  message = {
      'method' => 'screen.get',
      'params' => {
          'filter' => {
              'name' => screen_name
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response[0]['screenid']
end

#get_screen_parameter(screen_name, param_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/zabbixapi/screen.rb', line 17

def get_screen_parameter(screen_name, param_name)
  message = {
      'method' => 'screen.get',
      'params' => {
          'extendoutput' => '1',
          'filter' => {
              'name' => screen_name
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response[0][param_name]
end

#get_template_id(template_name) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/zabbixapi/template.rb', line 65

def get_template_id(template_name)
  message = {
      'method' => 'template.get',
      'params' => {
          'filter' => {
              'host' => template_name
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response.keys[0]
end

#get_template_ids_by_host(host_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/zabbixapi/template.rb', line 19

def get_template_ids_by_host(host_id)
  message = {
      'method' => 'template.get',
      'params' => {
          'hostids' => [host_id]
      }
  }
  response = send_request(message)
  if response.empty?
    result = nil
  else
    result = []
    response.each_key() do |template_id|
      result << template_id
    end
  end
  return result
end

#get_templatesObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/zabbixapi/template.rb', line 38

def get_templates()
  message = {
      'method' => 'template.get',
      'params' => {
          'extendoutput' => '0'
      }
  }
  response = send_request(message)
  if response.empty?
    result = nil
  else
    result = {}
    if response.kind_of? Hash
      template_ids = response.keys()
      template_ids.each() do |template_id|
        template_name = response[template_id]['host']
        result[template_id] = template_name
      end
    elsif response.kind_of? Array
      response.each do |template_info|
        result[template_info['hostid']] = template_info['host']
      end
    end
  end
  return result
end

#get_trigger_id(host_id, trigger_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zabbixapi/trigger.rb', line 13

def get_trigger_id(host_id, trigger_name)
  message = {
      'method' => 'trigger.get',
      'params' => {
          'filter' => {
              'hostid' => host_id,
              'description' => trigger_name
          }
      }
  }
  response = send_request(message)
  response.empty? ? nil : response[0]['triggerid']
end

#get_triggers_by_host(host_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zabbixapi/trigger.rb', line 27

def get_triggers_by_host(host_id)
  message = {
      'method' => 'trigger.get',
      'params' => {
          'filter' => {
              'hostid' => host_id,
          },
          'extendoutput' => '1'
      }
  }
  response = send_request(message)
  if response.empty?
    result = {}
  else
    result = {}
    response.each do |trigger|
      trigger_id = trigger['triggerid']
      description = trigger['description']
      result[trigger_id] = description
    end
  end
  return result
end

#group_exist?(pattern) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/zabbixapi/group.rb', line 17

def group_exist?(pattern)
  group_id = get_groups_id(pattern)
  group_id ? true : false
end

#item_exist?(host_id, item_name) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
90
91
# File 'lib/zabbixapi/item.rb', line 83

def item_exist?(host_id, item_name)
  item_id = get_item_id(host_id, item_name)
  if item_id
    result = true
  else
    result = false
  end
  return result
end


78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/zabbixapi/template.rb', line 78

def link_templates_with_hosts(templates_id, hosts_id)
  templates_id.class == Array ? message_templates_id = templates_id : message_templates_id = [templates_id]
  hosts_id.class == Array ? message_hosts_id = hosts_id : message_hosts_id = [hosts_id]
  message = {
      'method' => 'template.massAdd',
      'params' => {
          'hosts' => message_hosts_id.map { |t| {"hostid" => t} },
          'templates' => message_templates_id.map { |t| {"templateid" => t} }
      }
  }
  response = send_request(message)
  return response
end

#merge_opt(a, b) ⇒ Object

Utils.



121
122
123
124
125
126
127
128
129
# File 'lib/zabbixapi/base.rb', line 121

def merge_opt(a, b)
  c = {}
  b.each_pair do |key, value|
    if a.has_key?(key) then
      c[key] = value
    end
  end
  return a.merge(c)
end

#send_request(message) ⇒ Object



101
102
103
104
# File 'lib/zabbixapi/base.rb', line 101

def send_request(message)
  message['auth'] = auth()
  do_request(message)
end

#set_macro_value(host_id, macro_name, macro_value) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/zabbixapi/usermacro.rb', line 45

def set_macro_value(host_id, macro_name, macro_value)
  message = {
      'method' => 'usermacro.updateValue',
      'params' => {
          'hostid' => host_id,
          'macro' => macro_name,
          'value' => macro_value
      }
  }
  response = send_request(message)
  return true
end

#set_screen_parameter(screen_id, param_name, param_value) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/zabbixapi/screen.rb', line 53

def set_screen_parameter(screen_id, param_name, param_value)
  message = {
      'method' => 'screen.update',
      'params' => {
          param_name => param_value,
          'screenid' => screen_id
      }
  }
  response = send_request(message)
  response.empty? ? false : true
end


92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/zabbixapi/template.rb', line 92

def unlink_templates_from_hosts(templates_id, hosts_id)
  templates_id.class == Array ? message_templates_id = templates_id : message_templates_id = [templates_id]
  hosts_id.class == Array ? message_hosts_id = hosts_id : message_hosts_id = [hosts_id]
  message = {
      'method' => 'template.massRemove',
      'params' => {
          'hostids' => message_hosts_id,
          'templateids' => message_templates_id,
          'force' => '1'
      }
  }
  response = send_request(message)
  return response
end

#update_host(host_id, host_options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/zabbixapi/host.rb', line 4

def update_host(host_id, host_options)
  host = host_options
  host['hostid'] = host_id
  message = {
      'method' => 'host.update',
      'params' => host
  }
  responce = send_request(message)
  responce.empty? ?  nil : responce['hostids'][0].to_i
end

#update_item(item_id, options) ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/zabbixapi/item.rb', line 93

def update_item(item_id, options)
  options["item_id"]
  message = {
      'method' => 'item.update',
      'params' => options
  }
  response = send_request(message)
  response.empty? ? nil : response['itemids'][0]
end

#update_trigger_status(trigger_id, status) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/zabbixapi/trigger.rb', line 51

def update_trigger_status(trigger_id, status)
  message = {
      'method' => 'trigger.update_status',
      'params' => {
          'triggerid' => trigger_id,
          'status' => status
      }
  }
  response = send_request(message)
  response.empty? ? nil : response['triggerids'][0]
end