send a test page

Terry td3201 at gmail.com
Mon Sep 26 16:16:22 CEST 2005


I monitor the webmin service and write a script to take it down for 5
minutes and bring it back up.  This is a real test of the whole
system.  I also have links in the side bar to test both warning and
critical notifications:

#!/bin/bash

hostname=plaut01
output=TEST
state=$1

echo "Content-type: text/html"
echo ""
echo "<HTML>"
echo "<HEAD>"
echo "<TITLE></TITLE>"
echo "</HEAD>"
echo "<BODY BGCOLOR=#FFFFFF>"

if /usr/lib/nagios/plugins/eventhandlers/submit_check_result $hostname
"Test Notification" $state $output;then
        echo -n "<b>Test notification sent!</b><br>"
        echo -n "<a
href=/nagios/cgi-bin/status.cgi?hostgroup=all>Check it out</a>"
else
        echo -n "<b>Something wrong happened, try again</b>"
fi

/usr/lib/nagios/plugins/eventhandlers/submit_check_result $hostname
"Test Notification" 0 $output
echo "</body></html>"


It's pretty ugly but it works.

On 9/25/05, Greg King <wgking at shaw.ca> wrote:
> > From: Rossella Mariotti-Jones [mailto:rossella at chemeketa.edu]
> > Sent: Friday, September 23, 2005 12:33 PM
> > To: nagios-users at lists.sourceforge.net;
> > nagiosplug-help at lists.sourceforge.net
> > Subject: [Nagios-users] send a test page
> >
> >
> >
> > Hi all, does anybody how to send test pages to pagers from within
> > Nagios? I refuse to think that the only way to do it is setup a test
> > group and unplug
> > a box, there's gotta be another way! Thanks in advance.
> >
> >
> Here is a manual way the test any command, as follows:
>
> 1. log into nagios web interface as an admin, and "View config", commands.
> 2. Find the command you want to test, and select all the code, and right click "copy" 3. ssh into the nagios server. Log in with the id that Nagios runs as, or issue "su - <nagios-id>" command after login as root.
> 4. enter command "vi testcmd.sh", go to insert mode and paste command to be tested. Remove all trailing "$" from the Nagios macros, and save command. Removing these training $ is only necessary for email or pager ids but it pretties up the test results (they will have trailing $ if you don't which will be ok for most things, except for email ids or pager #).
> 5. Set environment variables for each of the Nagios macros - ie SERVICEDESC=Myservice, NOTIFICATIONTYPE=Alert, etc.
> 6. >chmod +x testcmd.sh
> 7. >. testcmd.sh  - this will run the command as Nagios would. Be sure to source the command to keep environment variables (ie >source testcmd.sh or >. testcmd.sh)
>
> While this is not strictly "within Nagios" I have used it a few times to debug flakey Nagios commands.
>
> Good luck!
>
> Regards, Greg
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download it for free - -and be entered to win a 42" plasma tv or your very
> own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> 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
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
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