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
35
# 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
  @auth_id = nil

  @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



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zabbixapi/application.rb', line 3

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)

  unless responce.empty? then
    result = responce['applicationids'][0].to_i
  else
    result = nil
  end 

  return result
end

#add_graph(graph) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# 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



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/zabbixapi/screen.rb', line 112

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



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

def add_group(groupname)

  message = {
    'method' => 'hostgroup.create',
    'params' => {
      'name' => groupname
    }
  }

  response = send_request(message)
  response ? response['groupids'] : nil
end

#add_host(host_options) ⇒ 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
# File 'lib/zabbixapi/host.rb', line 4

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' => [],
    'templates' => [],
    'useipmi' => 0,
    'ipmi_ip' => '',
    'ipmi_port' => 623,
    'ipmi_authtype' => 0,
    'ipmi_privilege' => 0,
    'ipmi_username' => '',
    'ipmi_password' => ''
  }

  host_options['groups'].map! { |group_id| {'groupid' => group_id} }
  host_options['templates'].map! { |template_id| {'templateid' => template_id} }

  host = merge_opt(host_default, host_options)

  message = {
    'method' => 'host.create',
    'params' => host
  }

  response = send_request(message)

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

  result
end

#add_host_to_group(host_id, group_id) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zabbixapi/group.rb', line 36

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



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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/zabbixapi/item.rb', line 22

def add_item(item)
  
  # Default item options
  # See: http://www.zabbix.com/documentation/1.8/api/item

  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)

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

  return result

end

#add_macro(host_id, macro_name, macro_value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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)

  if hostmacroids = response['hostmacroids'] then
    result = hostmacroids
  else
    result = nil
  end

  return result
end

#add_screen(screen_name, hsize, vsize) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/zabbixapi/screen.rb', line 144

def add_screen(screen_name, hsize, vsize)

  message = {
    'method' => 'screen.create',
    'params' => {
      'name' => screen_name,
      'hsize' => hsize,
      'vsize' => vsize
    }
  }

  response = send_request(message)

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

  return result
end

#add_template(template_options) ⇒ 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
# 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)

  if not ( response.empty? ) then
    result = response['templateids'][0].to_i
  else
    result = nil
  end

  return result
end

#add_trigger(trigger) ⇒ Object



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

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

#authObject



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

def auth()

  return @auth_id if @auth_id

  auth_message = {
    'auth' =>  nil,
    'method' =>  'user.authenticate',
    'params' =>  {
      'user' => @api_user,
      'password' => @api_password,
      '0' => '0'
    }
  }

  begin
    @auth_id = do_request(auth_message)
  rescue RuntimeError => e
    raise AuthError.new(e.message)
  end
end

#del_all_graphs_from_screen(screen_id) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/zabbixapi/screen.rb', line 94

def del_all_graphs_from_screen(screen_id)

  message = {
    'method' => 'screen.deleteItems',
    'params' => {
      'screenids' => [ screen_id ],
    }
  }

  response = send_request(message)

  if ( response ) then
    return response
  else
    return nil
  end
end

#do_request(message) ⇒ Object



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
# File 'lib/zabbixapi/base.rb', line 37

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" ) then
    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"
    response.each_header do |key,value|
      puts "#{key}:#{value}"
    end
    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 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

  result = response_body_hash['result']
  result
end

#get_graph_id(host_id, graph_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/zabbixapi/graph.rb', line 15

def get_graph_id(host_id, graph_name)

  message = {
    'method' => 'graph.get',
    'params' => {
      'filter' => {
        'name' => graph_name,
        'hostid' => host_id
      }
    }
  }

  response = send_request(message)

  unless ( response.empty? ) then
    result = response[0]['graphid']
  else
    result = nil
  end
end

#get_graphs(host_id) ⇒ 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
# File 'lib/zabbixapi/graph.rb', line 36

def get_graphs(host_id)

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

  response = send_request(message)

  unless ( response.empty? ) then
    result = {}

    response.each() do |graph|
      graph_id = graph['graphid']
      graph_name = graph['name']

      result[graph_id] = graph_name
    end
  else
    result = nil
  end

  return result
end

#get_group_id(pattern) ⇒ Object



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

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(params) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/zabbixapi/host.rb', line 68

def get_host(params)

  message = {
    'method' => 'host.get',
    'params' => params
  }

  response = send_request(message)

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

  result
end

#get_host_id(hostname) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/zabbixapi/host.rb', line 46

def get_host_id(hostname)
  
  message = {
    'method' => 'host.get',
    'params' => {
      'filter' => {
        'host' => hostname
      }
    }
  }

  response = send_request(message)

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

  result
end

#get_item_id(host_id, item_name) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/zabbixapi/item.rb', line 108

def get_item_id(host_id, item_name)
  message = {
    'method' => 'item.get',
    'params' => {
      'filter' => {
        'hostid' => host_id,
        'description' => item_name
      }
    }
  }

  response = send_request(message)
  
  unless ( response.empty? ) then
    result = response[0]['itemid']
  else
    result = nil
  end

  return result

end

#get_macro(host_id, macro_name) ⇒ Object



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
# File 'lib/zabbixapi/usermacro.rb', line 26

def get_macro(host_id, macro_name)

  message = {
    'method' => 'Usermacro.get',
    'params' => {
      'hostids' => host_id,
      'macros' => macro_name,
      'extendoutput' => '1'
    }
  }

  response = send_request(message)

  unless response.empty? then
    if hostmacroid =  response[0]['hostmacroid'] then
      macro_id = hostmacroid
      macro_value = response[0]['value']

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

  return result
end

#get_screen_graph_ids(screen_id) ⇒ Object



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
# File 'lib/zabbixapi/screen.rb', line 45

def get_screen_graph_ids(screen_id)

  message = {
    'method' => 'screen.get',
    'params' => {
      'extendoutput' => '1',
      'select_screenitems' => '1',
      'screenids' => [ screen_id ]
    }
  }

  response = send_request(message)

  unless ( response.empty?) then
    result = []
    screenitems = response[0]['screenitems']
    screenitems.each() do |item|
      if ( item['resourcetype'].to_i == 0 ) then
        result << item['resourceid']
      end
    end
  else
    result = nil
  end

  return result
end

#get_screen_id(screen_name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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)

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

#get_screen_parameter(screen_name, param_name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/zabbixapi/screen.rb', line 24

def get_screen_parameter(screen_name, param_name)

  message = {
    'method' => 'screen.get',
    'params' => {
      'extendoutput' => '1',
      'filter' => {
        'name' => screen_name
      }
    }
  }

  response = send_request(message)

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

#get_template_id(template_name) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/zabbixapi/template.rb', line 80

def get_template_id(template_name)

  message = {
    'method' => 'template.get',
    'params' => {
      'filter' => {
        'host' => template_name
      }
    }
  }

  response = send_request(message)
  result = nil
  result = response.first["templateid"] if (response.is_a?(Array) && response.first.is_a?(Hash)) # API > 1.8.3
  result = response[response.keys.first]["templateid"] if (response.is_a?(Hash) && response[response.keys.first].is_a?(Hash)) # API <= 1.8.3
  result
end

#get_template_ids_by_host(host_id) ⇒ Object



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

def get_template_ids_by_host(host_id)

  message = {
    'method' => 'template.get',
    'params' => {
      'hostids' => [ host_id ]
    }
  }

  response = send_request(message)

  unless ( response.empty? ) then
    result = []
    response.each_key() do |template_id|
      result << template_id
    end
  else
    result = nil
  end

  return result
end

#get_templatesObject



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
# File 'lib/zabbixapi/template.rb', line 54

def get_templates()

  message = {
    'method' => 'template.get',
    'params' => {
      'extendoutput' => '0'
    }
  }

  response = send_request(message)

  unless response.empty? then
    template_ids = response.keys()
    result = {}

    template_ids.each() do |template_id|
      template_name = response[template_id]['host']
      result[template_id] = template_name
    end
  else
    result = nil
  end

  return result
end

#get_trigger_id(host_id, trigger_name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/zabbixapi/trigger.rb', line 23

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

#get_triggers_by_host(host_id) ⇒ Object



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
# File 'lib/zabbixapi/trigger.rb', line 46

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

#get_webitem_id(host_id, item_name) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/zabbixapi/item.rb', line 84

def get_webitem_id(host_id, item_name)
  message = {
    'method' => 'item.get',
    'params' => {
      'filter' => {
        'hostid' => host_id,
        'type' => 9,
        'key_' => "web.test.time[eva.ru,Get main page,resp]"
      },
      'webitems' => 1
    }
  }

  response = send_request(message)

  unless ( response.empty? ) then
    result = response[0]['itemid']
  else
    result = nil
  end

  return result
end

#group_exist?(pattern) ⇒ Boolean

Returns:

  • (Boolean)


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

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


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/zabbixapi/template.rb', line 98

def link_templates_with_hosts(templates_id, hosts_id)

  if templates_id.class == Array then
    message_templates_id = templates_id
  else
    message_templates_id = [ templates_id ]
  end

  if hosts_id == Array then
    message_hosts_id = hosts_id
  else
    message_hosts_id = [ hosts_id ]
  end

  message = {
    'method' => 'template.massAdd',
    'params' => {
      'hosts' => message_hosts_id,
      'templates' => message_templates_id
    }
  }

  response = send_request(message)

  return response
end

#merge_opt(a, b) ⇒ Object

Utils.



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/zabbixapi/base.rb', line 127

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



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

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

#set_macro_value(host_id, macro_name, macro_value) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/zabbixapi/usermacro.rb', line 58

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/zabbixapi/screen.rb', line 73

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)

  if not ( response.empty? ) then
    result = true
  else
    result = false
  end

  return result
end


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/zabbixapi/template.rb', line 125

def unlink_templates_from_hosts(templates_id, hosts_id)

  if templates_id.class == Array then
    message_templates_id = templates_id
  else
    message_templates_id = [ templates_id ]
  end

  if hosts_id == Array then
    message_hosts_id = hosts_id
  else
    message_hosts_id = [ hosts_id ]
  end

  message = {
    'method' => 'template.massRemove',
    'params' => {
      'hosts' => message_hosts_id,
      'templates' => message_templates_id,
      'force' => '1'
    }
  }

  response = send_request(message)

  return response
end

#update_item(item_id) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/zabbixapi/item.rb', line 131

def update_item(item_id)

  message = {
    'method' => 'item.update',
    'params' => {
        'itemid' => item_id,
        'status' => 0 
    }
  }

  response = send_request(message)

end

#update_trigger_status(trigger_id, status) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/zabbixapi/trigger.rb', line 74

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