We have a number of gateways which need to be monitored. All of them are the Mikrotik LR8 model. I am looking for a simple way to get an indication as soon as any gateway is offline. Is there a way to query the TTN stack / Gateways to read the status?
Yes. There are answers all over the forum and in the API documentation. You may benefit from using the search tools.
However you will hit limits if you query too often so not so good for “as soon as”.
The canonical way is to monitor your devices to detect an absence of a gateway normally present in the meta data - with enough devices deployed you can get notification under a minute, with even more you can get under a second.
@Qmick Remembering always that sometimes a GW can show as ‘offline’ even when still alive and able to pass traffic if internet connection and association with back end dropped for a brief time (say in abscence of any traffic or unstable connection)- will often then ‘wake-up’ and show as live with the passing of a message showing then as online. That is also the purpose of the status/keep alive message that is sent by the GW, depending on device and how configured this is typically every 30 seconds (up to 1min or even 2 min in extremis can be ok) as it is actually the abscence of such status messages over a period that the LNS then uses to declare as offline (LNS needs to know if GW available to e.g. send Downlinks, Join AcKs etc.) - so in reality your ‘as soon as’ is nowhere near real-time (could be 2-20mins or more). Best practice is therefore have a canary in close -but not too close - proximity such that it can operate on shortest SF and very low power and still be heard by target GW (SF 7 and <<0dBm). If say Txing every 5 mins that would be well below FUP limits and would also serve to confirm RF path operational (Status tells you the ‘Digits’ are ok but how do you know its not got an ineffective or even dead RF front end in the abscence of node traffic in the area?!). You then monitor that node and if messages missed you alarm by your chosen method (a simple ITTT scenario?). Your other option on some GW’s (depending on OS/firmware etc.) is have the GW send a heart beat to another external (dont hammer TTN!) server saying ‘I’m here’ using e.g. a heartbeat daemon or whatever… (still doesnt tell you if RF knackered - so Canary for the win! )