Info |
---|
This document provides steps on how to setup an Email alert when a production Iguana’s channels are down/off. Note: we assume you have basic knowledge on how to setup a From Translator channel. All code below is intended for demo purposepurposes. |
The main idea is to utilize a From Translator polling channel to log a warning whenever a channel is down and for Iguana Monitoring to watch for such logs and send an email whenever a these logs come in.
How to Monitor Channel Status in Translator
From the dashboard, add a From - Translator channel (for this example, I will call it Channel Monitor) and for the Destination you can select To Channel (you can leave it empty).
Update the poll time (default is 10 seconds) under Source in the channel settings appropriate to your email monitoring needs.
Input the following snippet of code in the translator, the code works as follows:
It uses the iguana.status() API to retrieve the Iguana status (which includes channel status) and parse the data.
Next it will check for any stopped channels.
Finally it will log a warning message using iguana.logWarning with a header and the names of the channels. (The header will be used in Iguana monitoring to detect the warnings).
...
Your monitoring channel should be good to go! Go ahead and start the channel from the dashboard if you did not start it already and it should start monitoring and sending out emails when channels are down.
Once you’re done, you will receive an email that resembles the following in the case a channel is down:
...
Considerations
The previous monitoring example only works for local Iguana channels as the iguana.status() function only returns the status of local channels. One way to monitor external Iguana instances is by utilizing http calls to the /status API, it will returns the exact same data as the iguana.status() function.
This snippet of code will monitor ALL the channels in the instance. In the case you only need to monitor a small group, you may need to implement some changes to only monitor certain channels. A relatively easy way to do this would be by hardcoding some channel names in a “target” table, and add a check next to the “off” check to see if a channel is off AND is in the target table or not on line 14.