Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

Recently, some customers approached us asking whether Iguana can This document provides steps on how to setup an Email alert when a production Iguana Iguana’s channels is 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 purposes. The answer is yes you can! You can use Iguana Monitoring and the Translator to achieve that goal.

How to use Translator to alert Iguana Monitoring

The main idea is utilize a polling channel to get the status of the channels using the iguana.status() or /status APIs every x amount of time. To set up a polling channel, do the following:

  1. From the dashboard, click on Add Channel. For the source select “From Translator” and for the Destination select “To Channel” and click Start Configuring.

  2. Add a channel name (for the sake of this example, we’ll choose “Channel Monitor”) and a description that will help you identify the channel later.

    1. Under source, input a polling time (how often is the script called - in other words, let’s say you start the channel at 3:00 PM and set the polling time to 1800000 ms which is 30 minutes, you the channel will check at 3:30 PM then again at 4:00 PM and so on… You will receive an email at most every 30 minutes or every x amount of time depending on how long you set the polling at).

    2. 1000 ms is 1 s.

How to Setup Email Notification in Iguana Monitoring

Considerations

...

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 these logs come in.

How to Monitor Channel Status in Translator

  1. 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).

  2. Update the poll time (default is 10 seconds) under Source in the channel settings appropriate to your email monitoring needs.

  3. 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).

Code Block
-- Get all channel status and log stopped channels in Iguana Log
function main()
   -- 1) Retrieve status
   local status = iguana.status()

   -- 2) Parsed status and count all channels
   local parsedStatus = xml.parse{data=status}
   local iguanaParsedStatus = parsedStatus.IguanaStatus
   local count = iguanaParsedStatus:childCount("Channel")

   -- 3) Find all the stopped channels
   local stopped = {}
   for i = 1, count do
      if iguanaParsedStatus:child("Channel", i).Status:nodeValue() == 'off' then
         table.insert(stopped, iguanaParsedStatus:child("Channel", i).Name:nodeValue())
      end
   end
   
   -- 4) Create a stopped channel warning in Iguana logs
   if (#stopped > 0) then
      local warningHeader = "The following channels are off:\n\n"
      local warningBody = table.concat(stopped, "\n")
      iguana.logWarning(warningHeader .. warningBody)
   end
end

This will generate logs that look like this:

...

The next step is to setup Iguana Monitoring to watch for these warnings and send out an email whenever they are detected.

How to Setup Email Notification in Iguana Monitoring

To set up email notifications, you can do the following:

  1. Go to settings then Monitoring. You may have to setup your email settings, please visit this page for more information. https://help.interfaceware.com/v6/monitoring#settings

  2. If your email settings are already setup, add a new notification Standard Rule.

  3. Select the source and channel to be your ‘Channel Monitor’ and note that you will be querying the logs of that channel for Warnings that contain the header ("The following channels are off” - Line 21 in the example code) then select your recipients. Your rule should look something like this:

...

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 however, please make sure you thoroughly test your Monitoring channel before deploying it:

...

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.