[hobbit] play sound

Tod Hansmann thansmann at directpointe.com
Fri Nov 9 18:26:05 CET 2007


I wrote a custom script to do this via javascript.  It's a bit
over-complicated I think, but I haven't had time to go back and optimize
it.  It works, and well enough.  We keep the non-sound version of
bb2.html separate, and thus I had to create a separate page.  If you
don't need to keep it separate, you could just modify the bb2_header
file and include the tag we're adding with the php script.  We also
added a menu link to the bb2.php page via the menu_items.js file.
Replace the sound with whatever you want to be played.  Here are the
files I wrote:

 

bb2.php:

---------------------------------------------------------------

 

<?

        $bb2file = fopen("bb2.html", "r") or die("Can't open bb2.html");

        if ($bb2file)

        {

        while (!feof($bb2file))

        {

                $daline = fgets($bb2file);

                if ($daline === "</head>\n" || $daline === "</HEAD>\n")

                {

                        echo "<script type=\"text/javascript\"
language=\"javascript\" src=\"playsound.js\"></script>\n";

                }

                if (preg_match("$<[bB][oO][dD]$", $daline))

                {

                        echo $daline;

                        echo "<input type=\"hidden\" name=\"sounds_on\"
id=\"sounds_on\" value=\"true\" />";

                        break;

                }

                echo $daline;

        }

        }

        while (!feof($bb2file))

        {

                $daline = fgets($bb2file);

                echo $daline;

        }

        flcose($bb2file);

 

?>

---------------------------------------------------------------

 

 

 

The Javascript "playsound.js":

 

---------------------------------------------------------------

 

function doAlarm()

{

        var casdf = document.getElementsByTagName("body");

        var dasdf = casdf[0].innerHTML;

        var myEmbed = document.createElement('embed');

        myEmbed.setAttribute('src','giddyupthing.mp3');

        myEmbed.setAttribute('hidden','true');

        myEmbed.setAttribute('autostart','true');

        myEmbed.setAttribute('loop','false');

        myEmbed.setAttribute('id','theAlarm');

        casdf[0].appendChild(myEmbed);

}

 

function check_table(aasdf)

{

        var basdf = aasdf.getElementsByTagName("img")

        var buh = false;

        for (i=0;i<=basdf.length;i++)

        {

                if (basdf[i] != undefined)

                {

                if (basdf[i].title != undefined)

                {

                        var broken = basdf[i].title.split(":");

                        if (broken[1] == "red" || broken[1] == "yellow")

                        {

                                if (broken[2] != "acked")

                                {

                                        var minsasdf = broken[2];

                                        var testit =
minsasdf.substr(0,1);

                                        if (isFinite(testit))

                                        {

                                          testit = minsasdf.substr(0,2);

                                          if (isFinite(testit))

                                          {

                                            buh = true;

                                          }

                                          else if (
parseInt(minsasdf.substr(0,1)) >= 4)

                                          {

                                            buh = true;

                                          }

                                          else if ( minsasdf.substr(1,1)
== 'd' || minsasdf.substr(1,1) == 'h')

                                          {

                                            buh = true;

                                          }

                                        }

                                }

                        }

                }

                }

        }

        if (buh)

        {       doAlarm(); }

}

 

function checkAcks()

{

        var xasdf=document.getElementsByTagName("table");

        for (i=0;i<=xasdf.length;i++)

        {

                if(xasdf[i] != undefined)

                {

                        if(xasdf[i].summary != undefined)

                        {

                                if(xasdf[i].summary == "Group Block")

                                {

                                        check_table(xasdf[i]);

                                        break;

                                }

                        }

                }

        }

}

 

var snd = document.getElementById("sounds_on");

if ( snd != undefined)

{

        if ( snd.value = "true" )

        {

                checkAcks();

        }

}

 

---------------------------------------------------------------

 

 

 

Tod Hansmann

Network Engineer

 

  <http://www.directpointe.com/>  

________________________________

From: Josh Luthman [mailto:josh at imaginenetworksllc.com] 
Sent: Friday, November 09, 2007 8:21 AM
To: hobbit at hswn.dk
Subject: Re: [hobbit] play sound

 

You could use BBtray and stick in the wave file accordingly.

http://www.deadcat.net/viewfile.php?fileid=233

If you want it to be embedded on the WWW pages then you'll have find out
what outputs the red/yellow/green/purple backgrounds and title and embed
flash (at least I suggest flash) file along side that. 

On 11/9/07, Matthew Tice <mjtice at gmail.com> wrote:

Is it possible to play a sound (through bbdisplay) when an alert it
triggered (red, purple, whatever)?  This feature is used in Sitescope
. . . but  Sitescope doesn't hold a flame to hobbit.

Matt

To unsubscribe from the hobbit list, send an e-mail to 
hobbit-unsubscribe at hswn.dk






-- 
Josh Luthman
Office: 937-552-2340
Direct: 937-552-2343
1100 Wayne St
Suite 1337
Troy, OH 45373

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20071109/9382d34d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 1744 bytes
Desc: image001.gif
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20071109/9382d34d/attachment.gif>


More information about the Xymon mailing list