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

EventIDs filter not working

Open deqlz opened this issue 3 years ago • 1 comments

OS: Windows 10 Corporate (20H2)
Zabbix: 4.4.3
Сonnection: via Checkpoint VPN

I am trying to get an Event with a given event_id from 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)

Out:

[]

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

What could be the problem?

At the same time, everything works correctly from curl: screenshot

deqlz avatar Jul 06 '21 19:07 deqlz

Code:

jparams, err := json.Marshal(params)
os.Stdout.Write(jparams)

Returns:

{"eventids":["2589270"],"object":0,"acknowledged":false}

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.

deqlz avatar Jul 07 '21 11:07 deqlz