Closed svdasein closed 3 years ago
get() is nothing more than an alias to get_full_data() for most objects, and the default is to return the full extended output from Zabbix:
# Get full/extended Zabbix object data from API
#
# @param data [Hash] Should include object's id field name (indentify) and id value
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
# @return [Hash]
def get_full_data(data)
log "[DEBUG] Call get_full_data with parameters: #{data.inspect}"
@client.api_request(
:method => "#{method_name}.get",
:params => {
:filter => {
indentify.to_sym => data[indentify.to_sym],
},
:output => 'extend',
}
)
end
I'll see what I can do about updating the examples to include get() usage and output, but it'll look something like this for the majority of objects:
zbx.actions.get(:name => "action name")
[output]
An example: how do I get a list of interfaces for a host?
How can I get IP address of a host already created?
for posterity..
at the moment, the only way I see to get interfaces for existing hosts is to use query
method
hosts = zbx.query(
method: 'host.get',
params: {
output: ["name"],
selectInterfaces: "extend"
}
)
hosts.each do |host|
host["interfaces"].each do |iface|
puts "#{host["name"]} #{iface["ip"]} (id #{iface["interfaceid"]})"
end
end
For more details, see https://www.zabbix.com/documentation/current/manual/api/reference/host/get
I'm really struggling trying to figure out what to pass into the get() methods to get anything other than "everything". Would you please provide an example or two of what to actually pass into these methods? I've looked through your examples - they seem all to do with creating and updating. I hate to have to resort to .query if you've already got something nice in place to handle it. Thanks.