ePN: notification script
Stanley.Hopcroft at Dest.gov.au
Stanley.Hopcroft at Dest.gov.au
Mon Mar 6 06:56:09 CET 2006
Dear Folks,
I am writing to thank you for your letters and say,
>-----Original Message-----
>Message: 8
>To: Nagios-users at lists.sourceforge.net
>From: "John R. Daily" <jdaily at apparatus.net>
>Date: Sun, 5 Mar 2006 19:51:35 -0500
>Subject: [Nagios-users] ePN: notification script
>
>I've been trying to get a Perl script to work as part of the notify-
>by-email command as defined in minimal.cfg, and it's finally dawned
>on me that the RPM package I'm using has the embedded Perl
>interpreter compiled in.
>
I am using a home-cooked one with a spec file pretty well copied from
the
Dag Wieers EL3 RPM. Works fine for me.
>(Is there a replacement for nagios -m in v2.0? The documentation
>still refers to it, but it doesn't seem to work.)
>
>Anyway, I'm not thrilled about having to deal with ePN for simple
>Perl utilities that aren't plugins, but I figured I could get it to
>work anyway. However, now I'm less confident.
>
It can be a great pain in the proverbial to get going. However, the
docco suggests (perldoc p1.pl) that you can enable some debug/verbose
output to find where the plugin/Perl code is blowing up.
Here's my debug p1.pl header.
[sh1517 at acisf011 Nagios-Report-0.016]$ more /usr/bin/p1.pl_debug-epn
package Embed::Persistent;
# p1.pl for Nagios 2.0
use strict ;
use Text::ParseWords qw(parse_line) ;
use constant LEAVE_MSG => 1 ;
use constant CACHE_DUMP => 2 ;
use constant PLUGIN_DUMP => 4 ;
use constant DEBUG_LEVEL => LEAVE_MSG ;
use constant DEBUG_LOG_PATH => '/var/log/nagios/' ;
# use constant DEBUG_LOG_PATH => './' ;
You could try backing up your p1.pl, editing it as above and then
restart Nagios (its prob good to have a second devel installation - in
a second path for this). This will leave messages like
Thu Feb 9 11:31:30 2006 eval_file: successfully compiled
"/usr/lib/nagios/plugins/eventhandlers/global_host_event_handler
acisf011
DOWN HARD 1139444865 1139445090 0 0".
Thu Feb 9 11:31:30 2006 run_package:
"/usr/lib/nagios/plugins/eventhandlers/global_host_event_handler
acisf011 DOWN HARD 1139444865
1139445090 0 0" returning (3, "**ePN
/usr/lib/nagios/plugins/eventhandlers/global_host_event_handler: "Can't
open /usr/lib/nagios/p
lugins/eventhandlers/global_event_handler-debug.log for output in append
mode: Permission denied at (eval 1) line 61,".
").
in the log.
The other suggestion for debugging ePN probs is have a look at
new_mini_epn.
(Unfortch as I have just now found out, it doesn't appear to have the
correct path to
p1.pl in it so it doesn't work. This is very useful for debugging Perl
scripts for
use with ePN).
>Here's the pipeline as originally defined in minimal.cfg:
>
> /usr/bin/printf ... | /bin/mail -s ...
(I have been happily using such pipelines for years with ePN eg
# 'notify-by-epager' command definition
define command{
command_name notify-by-epager
command_line /usr/bin/printf "%b" "$SERVICEDESC$ $HOSTNAME$
$SERVICESTATE$ $SERVICEOUTPUT$ $SHORTDATETIME$" | /bin/mail $
CONTACTPAGER$.sms
)
>
>It's the printf portion of the pipeline that I've been attempting to
>replace with a Perl script. Once I realized that ePN was mucking
>things up I hoped that it would be sufficient to exit with an OK
>"error", but that was apparently wishful thinking.
>
You should only need to exit with a return code known to Nagios although
it
is customary to write a line of text.
>Does anyone know what the shortest functional ePN script might be?
#!/usr/bin/perl
use lib q</path/to/utils.pm> ;
use utils ;
print "In the beginning was the word.\n" ;
exit $ERRORS{OK} ;
or more tersely
#!/usr/bin/perl
print "Foo.\n"; exit 0;
If you can't get it going, please post your problem script and someone
should be
able to spot the bug.
Good luck.
Yours sincerely.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
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