I am trying to get an Event
with a given event_id
from Zabbix via the library github.com/cavaliercoder/go-zabbix
.
An event with this id exists and is currently active. Connection to Zabbix is successful. Moreover, if I remove the EventIDs
filter, it finds more than 600 events. But (!) I cannot access some of them directly from the Zabbix web interface under the same user.
Code:
session, err := zabbix.NewSession("zabbix_url/api_jsonrpc.php", "user", "password")
if err != nil {
panic(err)
}
var event_ids []string = []string{"2589270"}
params := zabbix.EventGetParams{
EventIDs: event_ids,
}
events, err := session.GetEvents(params)
fmt.Println(events)
Output:
[]
Errors:
2021/07/06 18:49:09 Error getting events: No results were found matching the given search
parameters
2021/07/06 18:49:09 No events found
2021/07/06 18:49:09 Validated 0 Events
Maybe I somehow incorrectly enter the id
in the library?
In the source code of the library, the EventIDs
parameter looks like this:
EventIDs []string `json:"eventids,omitempty"`
At the same time, everything works correctly from curl.
UPD
Code:
jparams, err := json.Marshal(params)
os.Stdout.Write(jparams)
Returns:
{"eventids":["2589270"],"object":0,"acknowledged":false}
UPD2:
It has been empirically established that the problem lies in the acknowledged
parameter. If it is set to false
, the event is not found. If it is set to true
, the event is found. Curl
exhibits the same behavior.
The problem is that the acknowledged
parameter is set by default to either true
or false
. And I cannot remove it.
As planned by zabbix api (I guess), if this parameter is set to false
, all events should be returned. If the parameter is set to true
, then only acknowledged events should be returned. But it doesn't work as intended.