Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Recently, some customers approached us asking whether Iguana can alert when a production Iguana channels is down/off. The answer is yes you can! You can use Iguana Monitoring and the Translator to achieve that goal very easily.

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 main function script called - to explain, let’s say you start the channel at 3:00 PM and set the polling time to 1800000 milliseconds (ms) which is 30 minutes, you the channel will check for off channels at 3:30 PM then again at 4:00 PM and so on… You will receive an email every 30 minutes or every x amount of time depending on how long you set the polling at in the case a channel was off for a long time).

      1. For your reference, 1,000 ms = 1 second, 900,000 ms = 15 minutes, 180,000 = 30 minutes and so on… You can set the polling time to any number you prefer (minimum is 1000)

  3. Once the channel is created, go to the Source tab and click on Edit Script to start coding in the monitoring functionality. The “Import Project” channel will come up, you can select “Use a blank project” and click “Import”.

  4. Below is the sample code I used to create a simple monitoring channel, in a nutshell, it calls the iguana.status() function which returns a lot of useful information about the current Iguana instance including channel status (on/off). The channel then finds all the channels that are “off” and puts them in a list, if this list is not empty, it logs a warning message so Iguana Monitoring can read it and send out an email accordingly.

Please note that this is only an example intended to show Iguana’s capabilities. You may need to modify this code or do some further testing to make sure this fit your requirements.

function main()

   -- Retrieve status
   local status = iguana.status()

   -- Parsed status
   local parsedStatus = xml.parse{data=status}
   local iguanaParsedStatus = parsedStatus.IguanaStatus
   -- Number of channels in instance
   local count = iguanaParsedStatus:childCount("Channel")

   -- List (table) to hold all stopped channel names
   local stopped = {}
   -- Loop over the status page of Iguana and find all the stopped channels and insert them to table
   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
   
   -- If there are channels stopped then create a warning log
   if (#stopped > 0) then
      -- The header will be at the top of the warning
      local warningHeader = "The following channels are off:\n\n"
      -- Followed by all the channel names
      local warningBody = table.concat(stopped, "\n")
      -- Finally call the function and concatenate the header and the body
      iguana.logWarning(warningHeader .. warningBody)
   end
   
end
  1. Then click on commit to source then add a note message at the bottom then click on “Commit Files”. Check “Update to run from new commit” if it pops up and click “Update”.

Screen Shot 2024-01-19 at 10.48.25 AM.png

The channel is now ready to start monitoring. You can start it now, or feel free to start it once you setup Iguana monitoring as it is only logging alert messages if Iguana Monitoring is not set up.

How to Setup Email Notification in Iguana Monitoring

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

  1. From your dashboard, go to settings in the top right corner.

  2. Scroll down to “Monitoring” under “System Settings”, you may have to setup your email settings, please visit this page for more information: https://help.interfaceware.com/v6/monitoring#settings

  3. Click on Notification Rules then Add a Rule, input the following settings (please note that if you change the code above, you may have to change the rule accordingly):

Screen Shot 2024-01-19 at 11.10.28 AM.png
  1. Select your email recipients under “Recipients” and click on Save Changes.

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.

Considerations

  • The previous monitoring example only works for local Iguana channels as the iguana.status() function returns the status of all Iguana channels that are currently on the same instance as the translator calling the function. 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.

  • Another consideration to keep in mind is that 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 adding another target check next to the “off” check to see if a channel is off AND is in the target table or not.

  • No labels