Skip to content
vadv edited this page Nov 20, 2012 · 3 revisions

Source code: hosts.rb

@host_default_options = {
  :host => nil,
  :port => 10050,
  :status => 1,
  :useip => 1,
  :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 => ''
}

Create host

zbx.hosts.add(
  :host => "hostname",
  :usedns => 1,
  :groups => [ :groupid => zbx.hostgroups.get_id(:name => "hostgroup") ]
)

Create or update:

zbx.hosts.create_or_update(
  :host => host,
  :usedns => 0,
  :ip => "10.20.48.89",
  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
)

Delete:

zbx.hosts.delete( zbx.hosts.get_id(:host => host) )
Clone this wiki locally