// Find and return a single host object by name func GetHost(api *zabbix.API, host string) (zabbix.ZabbixHost, error) { params := make(map[string]interface{}, 0) filter := make(map[string]string, 0) filter["host"] = host params["filter"] = filter params["output"] = "extend" params["select_groups"] = "extend" params["templated_hosts"] = 1 ret, err := api.Host("get", params) // This happens if there was an RPC error if err != nil { var r zabbix.ZabbixHost return r, err } // If our call was successful if len(ret) > 0 { return ret[0], err } // This will be the case if the RPC call was successful, but // Zabbix had an issue with the data we passed. var r zabbix.ZabbixHost return r, &zabbix.ZabbixError{0, "", "Host not found"} }