I finally got around to adding sound into mon.cgi.  The patch (attached)
lets you specify sounds to play whenever there are unACKed alarms.  You
can play a different noise for red and yellow conditions, and there's also
an alarm if the browser's not logged into Mon.  Each of the sounds (red,
yellow, and not logged in) is individually configurable.

It occurs to me that this feature could be improved by using cookies to
save state - that way an "all's well" sound could play when all alarms
clear up, and you could have a "grace period" before starting to play
alarms.  Perhaps someone else will take this up.

Below are the patch (against mon.cgi-1.52) and some sample additions to
the mon.cgi.cf file to define the noises.  I'm also attaching the
patch to avoid email munging.

        -- Ed

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

# sample sound config for mon.cgi.cf

# delete 'playcount="4"' to have IE misinterpet 'loop="4"' and play the
# sound as if you said 'loop=true"'.  instead of 4 times.  I'm told
# Netscape only honors the 'loop=' attribute.  Tested with Mozilla and
# Opera, which seem to act like Netscape, but in my testing so far only
# IE plays anything more than once - Opera and Mozilla only played sounds
# exactly once.  This can probably be worked around with some extra
# Javascript in the sound definition.

# sound to play when there are any RED (failed with alerts) conditions
# that have not been acknowledged
# redalert_sound = <embed src="/sounds/redalert.wav" height=1 width=1 autostart="true" 
loop="4" playcount="4" hidden="true">

# sound to play when there are any YELLOW (ok, orange) conditions that
# have failed but no alerts have been sent
# yellowalert_sound = <embed src="/sounds/yellowalert.wav" height=1 width=1 
autostart="true" loop="false" hidden="true">

# sound to play when the browser isn't logged in.  This is to avoid
# silent failure of your browsing terminal - you might get logged out
# and not realize that the terminal that you depend upon to make noise
# if something breaks isn't going to work until you log back in.

# nologin_sound = <embed src="/sounds/notloggedin.wav" height=1 width=1 
autostart="true" loop="4" playcount="4" hidden="true">


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

--- mon.cgi.pl  Tue Apr 13 19:32:06 2004
+++ ../../mon.cgi/mon.cgi-1.52/mon.cgi  Tue May 22 17:28:00 2001
@@ -147,7 +147,6 @@
 # Formatting-related global vars
 use vars qw($BGCOLOR $TEXTCOLOR $LINKCOLOR $VLINKCOLOR 
            $greenlight_color $redlight_color $unchecked_color 
-               $yellowalert_sound $redalert_sound $nologin_sound
            $yellowlight_color $disabled_color 
            $fixed_font_face $sans_serif_font_face 
            $dtlog_max_failures_per_page);
@@ -240,10 +239,6 @@
     $disabled_color="#999999";                  # color of "disabled" items
     $yellowlight_color = "#FF9933";             # color of "going bad" status events
 
-       $redalert_sound= "";                            # sound to play for unack'ed 
bad events
-       $yellowalert_sound= "";                         # sound to play for unack'ed 
warning events
-       $nologin_sound= "";                                     # sound to play when 
not logged in
-
     # Maximum dtlog entries to show per page
     $dtlog_max_failures_per_page = "100";
 }
@@ -935,11 +930,9 @@
        if ($scheduler_status[1] != 0) {
            $webpage->print
                ("<br>The scheduler has been <font 
color=$redlight_color>stopped</font> since $pretty_sched_down_time.<br>\n");
-               $webpage->print($nologin_sound);
        } else {    #value is undef, scheduler cannot be contacted (or auth failure)
            $webpage->print
                ("<br><font color=$redlight_color>The scheduler cannot be contacted at 
this time.</font><br>\n");
-               $webpage->print($nologin_sound);
        }
     }
 
@@ -1043,7 +1027,6 @@
     my $host_disabled_string ;
     my $watch_disabled_string ;
     my $failure_string;
-       my $sound2play= "";
     my $desc_string ;
     my %saw ;      #used for sorting
     my @disabled_hosts;
@@ -1139,16 +1122,11 @@
                if ( $s->{"alerts_sent"} == 0 ) {
                    $td_bg_color = $bg_fail_noalerts ;
                    $failure_string = "FAILED,NOALERTS" ;
-                       if ($s->{'ack'} != 1 and $sound2play eq "") # don't override a 
red
-                       {
-                               $sound2play= $yellowalert_sound;
-                       }
                } else {
                    $td_bg_color = $bg_fail ;
                    $failure_string = "FAILED" ;
                    # Also give the # of alerts if "full" view was selected
                    $failure_string .= ",alerts_sent=" . $s->{"alerts_sent"} if 
$detail_level eq "full";
-                       $sound2play= $redalert_sound unless ($s->{'ack'} == 1);
                }
                $td_bg_color = ($service_disabled_string eq "") ? $td_bg_color : 
$disabled_color ;
                $webpage->print("<td align=left bgcolor=\"$td_bg_color\">");
@@ -1232,8 +1210,6 @@
            #printf("%.2d:%.2d:%.2d\n", @time[2, 1, 0] );
             #$webpage->print("</font></td>\n");
             $webpage->print("</tr>");
-
-                       $webpage->print($sound2play) unless $sound2play eq "";
            
         } # end $service loop
 #
@@ -3591,12 +3567,6 @@
                    $redlight_color = $val;
                } elsif ($key eq "yellowlight_color") {
                    $yellowlight_color = $val;
-               } elsif ($key eq "redalert_sound") {
-                   $redalert_sound = $val;
-               } elsif ($key eq "yellowalert_sound") {
-                   $yellowalert_sound = $val;
-               } elsif ($key eq "nologin_sound") {
-                   $nologin_sound = $val;
                } elsif ($key eq "unchecked_color") {
                    $unchecked_color = $val;
                } elsif ($key eq "dtlog_max_failures_per_page") {
--- mon.cgi.pl  Tue Apr 13 19:32:06 2004
+++ ../../mon.cgi/mon.cgi-1.52/mon.cgi  Tue May 22 17:28:00 2001
@@ -147,7 +147,6 @@
 # Formatting-related global vars
 use vars qw($BGCOLOR $TEXTCOLOR $LINKCOLOR $VLINKCOLOR 
            $greenlight_color $redlight_color $unchecked_color 
-               $yellowalert_sound $redalert_sound $nologin_sound
            $yellowlight_color $disabled_color 
            $fixed_font_face $sans_serif_font_face 
            $dtlog_max_failures_per_page);
@@ -240,10 +239,6 @@
     $disabled_color="#999999";                  # color of "disabled" items
     $yellowlight_color = "#FF9933";             # color of "going bad" status events
 
-       $redalert_sound= "";                            # sound to play for unack'ed 
bad events
-       $yellowalert_sound= "";                         # sound to play for unack'ed 
warning events
-       $nologin_sound= "";                                     # sound to play when 
not logged in
-
     # Maximum dtlog entries to show per page
     $dtlog_max_failures_per_page = "100";
 }
@@ -935,11 +930,9 @@
        if ($scheduler_status[1] != 0) {
            $webpage->print
                ("<br>The scheduler has been <font 
color=$redlight_color>stopped</font> since $pretty_sched_down_time.<br>\n");
-               $webpage->print($nologin_sound);
        } else {    #value is undef, scheduler cannot be contacted (or auth failure)
            $webpage->print
                ("<br><font color=$redlight_color>The scheduler cannot be contacted at 
this time.</font><br>\n");
-               $webpage->print($nologin_sound);
        }
     }
 
@@ -1043,7 +1027,6 @@
     my $host_disabled_string ;
     my $watch_disabled_string ;
     my $failure_string;
-       my $sound2play= "";
     my $desc_string ;
     my %saw ;      #used for sorting
     my @disabled_hosts;
@@ -1139,16 +1122,11 @@
                if ( $s->{"alerts_sent"} == 0 ) {
                    $td_bg_color = $bg_fail_noalerts ;
                    $failure_string = "FAILED,NOALERTS" ;
-                       if ($s->{'ack'} != 1 and $sound2play eq "") # don't override a 
red
-                       {
-                               $sound2play= $yellowalert_sound;
-                       }
                } else {
                    $td_bg_color = $bg_fail ;
                    $failure_string = "FAILED" ;
                    # Also give the # of alerts if "full" view was selected
                    $failure_string .= ",alerts_sent=" . $s->{"alerts_sent"} if 
$detail_level eq "full";
-                       $sound2play= $redalert_sound unless ($s->{'ack'} == 1);
                }
                $td_bg_color = ($service_disabled_string eq "") ? $td_bg_color : 
$disabled_color ;
                $webpage->print("<td align=left bgcolor=\"$td_bg_color\">");
@@ -1232,8 +1210,6 @@
            #printf("%.2d:%.2d:%.2d\n", @time[2, 1, 0] );
             #$webpage->print("</font></td>\n");
             $webpage->print("</tr>");
-
-                       $webpage->print($sound2play) unless $sound2play eq "";
            
         } # end $service loop
 #
@@ -3591,12 +3567,6 @@
                    $redlight_color = $val;
                } elsif ($key eq "yellowlight_color") {
                    $yellowlight_color = $val;
-               } elsif ($key eq "redalert_sound") {
-                   $redalert_sound = $val;
-               } elsif ($key eq "yellowalert_sound") {
-                   $yellowalert_sound = $val;
-               } elsif ($key eq "nologin_sound") {
-                   $nologin_sound = $val;
                } elsif ($key eq "unchecked_color") {
                    $unchecked_color = $val;
                } elsif ($key eq "dtlog_max_failures_per_page") {
_______________________________________________
mon mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/mon

Reply via email to