Adding a link to a service

Tedman Eng teng at dataway.com
Wed Nov 19 07:18:40 CET 2003


You would need a simple ping.cgi script (see below)
Then, wrap the standard ping command definition using the "urlize" plugin,
referencing the ping.cgi and using Nagios built-in macros to tell the cgi
who to ping.  This makes the service status output "clickable" to run
on-demand pings.  Similar idea can be applied to perform traceroute,
path-ping, or even problem-ticket creation (we're super lazy!).


checkcommands.cfg:
---------------------------------------
define command{
        command_name    check_ping_url
        command_line    $USER1$/urlize
http://nagioshost/cgi-bin/ping.cgi?host=$HOSTADDRESS$ $USER1$/check_ping -H
$HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
        }


services.cfg:
---------------------------------------
define service{
        use                             generic host
        host_name                       foobar
        check_command                   check_ping_url!100.0,20%!500.0,50%
        }


ping.cgi (put into your .../sbin directory):
---------------------------------------
#!/bin/sh
HOST=`echo $QUERY_STRING|cut -d "&" -f 1|cut -d "=" -f 2`
if [ "$HOST" != "" ]; then
        ping_result=`/bin/ping -c 5 $HOST`
fi
echo "Content-type: text/html"
echo ""
echo "<HTML><HEAD></HEAD><BODY>"
echo "<H2>Ping results for $HOST</H2>"
echo "<HR>"
echo "<PRE>$ping_result</PRE>"
echo "</BODY></HTML>"



"Tory Skyers" <tskyers at foxroach.com> wrote in message
news:E1AMAPj-0004ur-7M at sc8-sf-mx1.sourceforge.net...
I've been researching how to add a "ping me" link to the services page of
nagios. From what I have found all I have to do is edit the templates and
use the existing variable schema to pull the hostname/ip and ping it. It
sounds straight forward but I've yet to be able to get this to work ?.


Tory Skyers
Network Administrator
Prudential Fox & Roach
610-993-1327
tskyers at foxroach.com




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
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: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
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