I'm running into an issue with monitoring and alarming on the Gateway Network and the local gateway shutting down.
We have a few gateways connected on a Gateway Network, and I'm trying to monitor the other gateway from a "main" one and send email alerts if the remote connections drop. I added a tag change script to the [System]Gateway/Gateway Network/<gatewayName>/IsAvailable
tags to trigger the emails and this works except for when the local gateway shuts down.
From some testing and looking at the logs, one of first thing that happens when the Ignition service is stopped is the WebSocketConnections to the remote GAN gateways switches to faulted (which triggers the status emails on all gateways), then the local gateway status changes to STOPPING
. Because of the order of these, I haven't found a good way to detect if the GAN connection dropping is because of a connection issue or the local gateway stopping. Checking
GatewayContext.getState()
in the tag change script doesn't work because at that point the gateway is still RUNNING
.
The best I have come up with is to check all the GAN connections in the tag change script using GatewayContext.getGatewayAreaNetworkManager().getAvailableConnections()
and assume that if all the remote gateways are down that it's actually the local gateway restarting and don't send the status change emails (we have a separate alert that the local gateway is shutting down). This is obviously not a super robust solution, especially with a small number of gateways on the GAN.
Is there is better way to detect that the local gateway is shutting down given that the GAN connections drop before the gateway switches to STOPPING
?