Skip to content
This repository has been archived by the owner on Nov 14, 2019. It is now read-only.

Commit

Permalink
zcollective: Also set a notes entry for auto inventory hosts.
Browse files Browse the repository at this point in the history
This is mostly a workaround due to Zabbix not paying attention to the
`inventory_mode` unless an `inventory` item is also set at the same
time.
  • Loading branch information
phyber committed Jul 28, 2017
1 parent 488d862 commit 02e92bb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/zcollective
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,16 @@ hosts.each do |host,data|
}

# If we've asked or auto-zabbix-inventory mode, set that. Otherwise
# leave it unset
host_create_hash['inventory_mode'] = 1 if options[:auto_zabbix_inventory]
# leave it unset.
# We also set a note on the host saying when it was discovered.
# This is needed, otherwise Zabbix will ignore the request to
# enable the auto inventory mode.
if options[:auto_zabbix_inventory]
host_create_hash['inventory_mode'] = '1'
host_create_hash['inventory'] = {
'notes' => "Discovered by ZCollective at #{Time.now}",
}
end

resp = zabbix_client.request('host.create', host_create_hash)

Expand Down

0 comments on commit 02e92bb

Please sign in to comment.