chris.naude

Audible Alerts

Discussion created by chris.naude on Dec 9, 2011
Latest reply on Jan 10, 2012 by chris.naude

I've been struggling with trying to figure out how to generate audible alerts whenever a new alert is generated in the enterprise console. The custom dashboard sound widget only generates a sound when the alert level changes. The NasSPY.exe does not have enough filtering options. So I built my own custom solution.

 

On the nas server i have this lua script that gets called from an AO profile. The script writes out to a file with information on the alarm that triggered the AO profile. The file is accessible via http.

 

-- -- Script: write-alarm-id -- Purpose: Save the alarm id to a file specified in the script agrument --  my_file ="E:\\Nimsoft\\install\\audible-alarm\\latest-prod-alarm.txt" my_file =SCRIPT_ARGUMENT  a = alarm.get() nimid = a.nimid hostname = a.hostname message = a.message severity = a.severity subsystem = a.subsys probe = a.prid group = a.custom_3 suppcount = a.suppcount if nimid == nil then    nimid = "NIL" end if hostname == nil then    hostname = "NIL" end if message == nil then    message = "NIL" end if severity == nil then    severity = "NIL" end if subsystem == nil then    subsystem = "NIL" end if probe == nil then    probe = "NIL" end if suppcount == nil then    suppcount = "0" end  alarm_body =               "Alarm ID : " .. nimid .. "\n" alarm_body = alarm_body .. "Host     : " .. hostname .. "\n" alarm_body = alarm_body .. "Time     : " .. os.date() .. "\n" alarm_body = alarm_body .. "Severity : " .. severity .. "\n" alarm_body = alarm_body .. "Probe    : " .. probe .. "\n" alarm_body = alarm_body .. "Message  : " .. message file.create (my_file, alarm_body)

 On the same http server I have this html page. The javascript continusouly scans the file created by the lua script. When the file changes the javascript plays the sound. The information on the alarm that generated the sound effect is displayed for good measure. This works great in Firefox and Chrome.

 

<html> <head> <script type="text/javascript">      var prevAlarm = "";      function play_single_sound() {           document.getElementById('audiotag1').play();           }      function createXMLHttpRequest() {              try { return new XMLHttpRequest(); } catch(e) {}              try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}              alert("XMLHttpRequest not supported");              return null;       }             function poll_alerts() {                                var xhReq = createXMLHttpRequest();            xhReq.open("GET", "latest-prod-alarm.txt", true);            xhReq.onreadystatechange = onResponse;            xhReq.send(null);           function onResponse() {                   if (xhReq.readyState != 4)  { return; }                   var serverResponse = xhReq.responseText;                   if (prevAlarm != serverResponse) {                        play_single_sound();                                               document.getElementById ("alarm_id").value = serverResponse;                        prevAlarm = serverResponse;                }                              }                       t=setTimeout("poll_alerts()",5000);      }       </script> <title>Nimsoft Audible Alarm Notification</title> </head> <body onLoad="poll_alerts();"> <H2 CLASS="title" >Nimsoft Audible Alarm Notification</H2>  <textarea rows="10" type="text" id="alarm_id" cols="80"></textarea> <p> <audio controls id="audiotag1" preload="auto" src="http://SERVER/SIREN.wav" autobuffer>  Your browser does not support the audio element. </audio>  </body> </html>

Outcomes