MarsRover wrote: ↑Tue Jul 08, 2025 7:06 pm
I want to accomplish very simple task via API:
get the list of last N events for a given monitor, including incomplete one (the current one being recorded).
It all worked fine until recent updates.
I don't want to mess-up with DB directly to achieve such a simple task.
OK, here's my solution
this bash code gives me 3 last events for MonitorID 1
)))
Code: Select all
#!/bin/bash
monId=1
nLastEvents=3
curl -sS --noproxy '*' -XGET "http://localhost/zm/api/events/index/MonitorId:${monId}/StartDateTime%20>=:$(mysql --batch --skip-column-names --skip-pager --execute="select REPLACE(StartDateTime, ' ', '%20') AS EncodedSDT from zm.Events where MonitorId = ${monId} ORDER BY Id DESC LIMIT $(( nLastEvents-1 )),1;").json"
All this instead of simple
Code: Select all
zm/api/events/index/MonitorId:1.json?sort=StartDateTime&direction=desc&limit=3
which worked fine at least in May (and still works in 1.37.66~20250520.297).
Maybe it's time to make my own events API, but I'm facing the risk of DB schema changes.