go-zabbix icon indicating copy to clipboard operation
go-zabbix copied to clipboard

Use session.GetHosts

Open modogo2000 opened this issue 6 years ago • 1 comments

Hello

Is it possible to have an example on how use GetHostt ?

I have hard time to use it.

Best regards

modogo2000 avatar Oct 25 '18 14:10 modogo2000

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.

fabiang avatar Dec 13 '18 13:12 fabiang