Sha256: 7b1c3f1a29eb7316a3fce47cdd010ba4b5166186a1615ad99f13d33fc98a2d1f
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
module Zabbix class ZabbixApi 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 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 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 def delete_host(hostname) host_id = get_host_id(hostname) message = { 'method' => 'host.delete', 'params' => { 'hostid' => host_id } } send_request(message) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zabbixapi-0.1.6.1 | lib/zabbixapi/host.rb |