go-zabbix
go-zabbix copied to clipboard
Use session.GetHosts
Hello
Is it possible to have an example on how use GetHostt ?
I have hard time to use it.
Best regards
Get a list of hosts by their hostname:
// ...
filter := make(map[string]interface{})
filter["host"] = "MyComputerName"
hosts, err := session.GetHosts(zabbix.HostGetParams{
GetParameters: zabbix.GetParameters{
Filter: filter,
}})
if err != nil {
log.Fatalf("%v\n", err)
}
log.Printf("%v\n", hosts)
Of cause hostname should be unique and the list only contain on element.