Help - I am unable to send notifications
jonathan williams
jonathan.williams at us.g4s.com
Wed Jul 23 21:23:13 CEST 2008
On Wed, 2008-07-23 at 05:03 -0700, Andreas Ericsson wrote:
> jonathan williams wrote:
> > [1216749581] Warning: Attempting to execute the command
> > "/usr/local/nagios/libexec/send_mail.pl -n "SERVICE RECOVERY" -h
> > "jwilliamspc" -s "OK" -a "10.10.113.51" -i "PrintSpooler - Spooler:
> > Started - check_nt!SERVICESTATE!-d SHOWALL -l Spooler" -d "Tue Jul
> 22
> > 10:59:41 PDT 2008" -e "jonathan.williams at us.g4s.com"" resulted in a
> > return code of 126. Make sure the script or binary you are trying
> to
> > execute actually exists..."
> >
>
> Due to some weird and slightly bent way of passing errors between
> processes, return code 126 means "Operation not permitted". In
> english, that means the script is not executable, or one of the
> directories leading up to it isn't readable by the Nagios user.
>
> Run this command (as root):
>
> chmod 0755 /usr/local/nagios/libexec/send_mail.pl
>
> (correct the path if necessary)
> and things just might start working a little better.
>
> --
> Andreas Ericsson andreas.ericsson at op5.se
> OP5 AB www.op5.se
> Tel: +46 8-230225 Fax: +46 8-230231
>
> If this is a double post I apologize, I just did not ever see it go
> through and do not see it in my sent items or drafts. The error code
> 126 is gone and see what appears to be a successfull notification in
> the nagios log:
[1216840237] SERVICE NOTIFICATION:
nagiosadmin;jwilliamspc;PrintSpooler;CRITICAL;service-notify-by-email;Spooler: Stopped
Still no email though so the issue may be something in the send_mail
script or one of the configs, although they look good to me. Here's
what I have so far. send_mail.pl (at least the part I am supposed to
edit:
#!/usr/bin/perl -w
# There are commented examples here of the commands.cfg and contacts.cfg
files
use strict;
use Net::SMTP;
use Getopt::Std;
my $mailhost = 192.168.1.9 ;
my $maildomain = us.g4s.com ;
my $mailfrom = nagios at us.g4s.com;
my $mailto = jonathan.williams at us.g4s.com;
my $timeout = 30;
my $mailsubject = ''; # Leave blank
my $mailbody = ''; # Leave blank
my $logfile = '/var/log/mail.log; # Put somewhere better
my $debug = 1; # To enable SMTP session debugging to logfile
Here is the commands.cfg:
define command{
command_name service-notify-by-email
command_line $USER1$/send_mail.pl -n "SERVICE $NOTIFICATIONTYPE$" -h
"$HOSTNAME$" -s "$SERVICESTATE$" -a "$HOSTADDRESS$" -i "$SERVICEDESC$ -
$SERVICEOUTPUT$ - $SERVICECHECKCOMMAND$" -d "$LONGDATETIME$" -e
"$CONTACTEMAIL$"
}
and the contacts.cfg:
define contact{
contact_name nagiosadmin ; Short name of
user
use generic-contact ; Inherit default values from generic-contact
template (defined above)
alias nagiosadmin ; Full name of user
host_notification_commands host-notify-by-email
service_notification_commands service-notify-by-email
email jonathan.williams at us.g4s.com ;
<<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
service template in templates.cfg
define service{
name generic-service ; The 'name' of
this service template
active_checks_enabled 1 ; Active service
checks are enabled
passive_checks_enabled 1 ; Passive service
checks are enabled/accepted
parallelize_check 1 ; Active service
checks should be parallelized (disabling this can lead to major
performance problems)
obsess_over_service 1 ; We should obsess
over this service (if necessary)
check_freshness 0 ; Default is to NOT
check service 'freshness'
notifications_enabled 1 ; Service
notifications are enabled
event_handler_enabled 1 ; Service event
handler is enabled
flap_detection_enabled 1 ; Flap detection is
enabled
failure_prediction_enabled 1 ; Failure prediction
is enabled
process_perf_data 1 ; Process performance
data
retain_status_information 1 ; Retain status
information across program restarts
retain_nonstatus_information 1 ; Retain non-status
information across program restarts
is_volatile 0 ; The service is not
volatile
check_period 24x7 ; The service can be
checked at any time of the day
max_check_attempts 5 ; Re-check the service up to
5 times in order to determine its final (hard) state
normal_check_interval 1 ; Check the service every 1
minutes under normal conditions
retry_check_interval 1 ; Re-check the service every
one minute until a hard state can be determined
contact_groups admins ; Notifications get
sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning,
unknown, critical, and recovery events
notification_interval 5 ; Re-notify about service
problems every 5 minutes
notification_period 24x7 ; Notifications can be
sent out at any time
register 0 ; DONT REGISTER THIS
DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
These are all the variables I can think of unless for some reason
send_mail.pl cannot execute the perl binary or there is another file or
binary missing from this equation that I can't think of.
Again sorry for the double post if you have already received this.
Jon
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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