Webinterface Sound files

Ben Garcia bgarcia at p-inet.net
Fri Apr 4 19:29:19 CEST 2003


Technically anything is possible (although divine intervention may sometimes be required to do so :-)

What I did was took one of the plugins I wrote and added <BR>TESTING<BR> to the end of the return string which is passed to nagios.  Listed below is the relevant portion of the HTML from the "Service Status Details":

== html output =
<TD CLASS='statusOdd'>AICL OK - [HTTP] Total of 0 SMA(s) (/var/log/httpd/error_log)<br>TESTING<br> </TD>


Here is the perl function that returned the state:

== perl function ===
sub retState
{
   ($state, $status) = @_;
   print STDOUT "$PLUGID $stateArr[$state] - [$ltype] $status<br>TESTING<br>\n";
   exit $state;
}


What you would have to do is write a "wrapper" that would execute the plugin you would want to do an audio alert off of and have the wrapper add the <EMBED> tag to the results returned to Nagios.

Here are some sample configs that illustrate how to setup things in Nagios:

== services.cfg ==

define service{
   use                   generic-service
   host_name             your_host
   service_description   SAMPLE_SERVICE
   is_volatile           0
   check_period          24x7
   max_check_attempts    3
   normal_check_interval 60
   retry_check_interval  60
   contact_groups        your_groups
   notification_interval 900
   notification_period   24x7
   notification_options  w,c,r
   check_command         psnd_ping![sound file]!40.0,33%!100.0,100%
   }

== checkcommands.cfg ==

define command{
        command_name    psnd_ping
        command_line    $USER1$/psnd "$ARG1$" "check_ping -H $HOSTNAME$ -w $ARG2$ -c $ARG3$ -p 3"
        }

Here's a quick and dirty bash script to do the job:

== psnd ==
#!/bin/bash

## Command line arguments
SNDFILE=$1
CHKCMD=$2

## Execute command
RETSTR=`$CHKCMD`

## get exit code
ECODE=$?

## If critical then add tag
if [ $ECODE -eq 2 ];
then
   RETSTR="$RETSTR <EMBED SRC='$SNDFILE'>"
fi

## Return result to nagios
echo $RETSTR

## Exit with original exit code
exit $ECODE


The result would be something like:

PING CRITICAL - Packet loss = 0%, RTA = 201.23 ms <EMBED SRC='[sound file]'>

If you wanted to play different sounds for the same service depending on if it's a warning or a critical (exit codes 1 or 2) you'll have to add more logic to it.  Maybe have it read in a standard config file or something to that extent.  If multiple services are encountering warning/criticals you'll probably get one sound per embed tag.  

Does that make sense?

HTH!

--Ben

-----Original Message-----
From: Jan van den Berg [mailto:jan at e-commercepark.com]
Sent: Friday, April 04, 2003 10:04 AM
To: Ben Garcia; 'Nagios-Users (E-mail)'
Subject: RE: [Nagios-users] Webinterface Sound files


So the bottomline is, that it is possible? :)

I definitely want to give it a try then, because it can be pretty
valuable.
I do have a little trouble understanding what your saying: could you
just elaborate on it a little?

Regards,

Jan van den Berg



-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of Ben
Garcia
Sent: Thursday, April 03, 2003 5:58 PM
To: Nagios-Users (E-mail)
Subject: RE: [Nagios-users] Webinterface Sound files

You could modify the output that is passed to Nagios in such a way that
a HTML <EMBED> tag is passed through.  That way when the page refreshes
it would automatically pass the tag and play (unless HTML is filtered
from the return string?).

Could be VERY annoying -- esp. if you got lots of devices in a non-ok
state, but that may do the trick for ya.  You'd have to write a
"wrapper" that would take the exit code and return string from the
plug-in, concat the tag to the return string and then well..  return
it...  :-)  

If you wanted to be able to choose what files to play for which services
you could just pass it as an argument to your wrapper and then code it
to put the passed argument into SRC attribute of the tag.

Just a thought...

--Ben

-----Original Message-----
From: Subhendu Ghosh [mailto:sghosh at sghosh.org]
Sent: Thursday, April 03, 2003 3:13 PM
To: Nagios-Users (E-mail)
Subject: Re: [Nagios-users] Webinterface Sound files


On Thu, 3 Apr 2003, Jan van den Berg wrote:

> Hi there,
> 
>  
> 
> I was wondering what the possibilities are when writing a plugin that
> this plugin has its own custom sound files played.
> 
>  
> 
> I understand that there are only so few return codes for a plugin
> (warning, critical etc.) but how about the soundfiles?


Plugins are not executed by the web interface so the possiblility of 
knowing what sound to execute for which service would be pretty 
complicated...


-- 

-sg



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when
reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when
reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null




-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list