Help - I am unable to send notifications

Fulton, David dfulton at nuvox.com
Tue Jul 22 23:06:22 CEST 2008


> -----Original Message-----
> From: nagios-users-bounces at lists.sourceforge.net 
> [mailto:nagios-users-bounces at lists.sourceforge.net] On Behalf 
> Of jonathan williams
> Sent: Tuesday, July 22, 2008 2:36 PM
> To: Marc Powell
> Cc: Nagios User list
> Subject: Re: [Nagios-users] Help - I am unable to send notifications
> 
> 
> On Tue, 2008-07-22 at 11:14 -0700, Marc Powell wrote:
> > 
> > On Jul 22, 2008, at 12:26 PM, jonathan williams wrote:
> > >>
> > 
> > >> Umm..what can I say?  Wow.  OK.. I fixed that in the 
> send_mail.pl 
> > >> file.  Any other steps I need to take once I did that to make it 
> > >> work.
> > >> I did re-run the sed-i command and still get the same error:
> > >
> > 
> > Not unless you experience further errors.
> > 
> > > root at LOOKINIUM:/usr/local/nagios/libexec# sed -i 
> '1s,.*,#!/usr/bin/ 
> > > perl -w,' check_sendmail.pl
> > > sed: can't read check_sendmail.pl: No such file or directory
> > 
> > Ok. sed 101.
> > 
> > sed -i '1s,.*,#!/usr/bin/perl -w,' check_sendmail.pl
> > 
> > The above is a sed 1-liner. It performs an immediate action 
> and then 
> > exits. What action? Let's break it down --
> > 
> > sed : this is the command to be executed -i : this tells 
> sed that it's 
> > going to be editing an existing file 1s : the start of the 
> actual sed 
> > script. This means we're going to be doing 1 substitution
> > .* : this is what we're going to be looking for, essentially any 
> > content on the line #!/usr/bin/perl -w : what the previous 
> match will 
> > be replaced with check_sendmail.pl : The file that sed is 
> going to be 
> > editing
> > 
> > The end result is that sed would replace the entire first 
> line of the 
> > file check_sendmail.pl, located in your current directory, with the 
> > text '#!/usr/bin/perl -w'.
> > 
> > Your confusion is that the filename should have been check_mail.pl, 
> > not check_sendmail.pl.
> > 
> > --
> > Marc
> > 
> 
> 
> Thank you for that breakdown.  
> 
> I am still having the same error in my nagios.log:
> 
> "[1216749581] SERVICE NOTIFICATION:
> nagiosadmin;jwilliamspc;PrintSpooler;OK;service-notify-by-emai
l;Spooler:
> Started
> [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..."
> 
> The top line in the send_mail.pl script is indeed 
> "#!/usr/bin/perl -w".
> I am not sure what it does though.  Doesn't the # mean it is remarked?
> I guess my confusion is that there is no such file on my 
> system called check_sendmail.pl or check_mail.pl.  I was 
> unable to locate any of them.
> There is only a check_mailq.  That is why when you state:
> 
> #!/usr/bin/perl -w : what the previous match will be replaced with
> > check_sendmail.pl : The file that sed is going to be editing
> > 
> > The end result is that sed would replace the entire first 
> line of the 
> > file check_sendmail.pl, located in your current directory, with the 
> > text '#!/usr/bin/perl -w'.
> > 
> > Your confusion is that the filename should have been check_mail.pl, 
> > not check_sendmail.pl.
> 
> I get lost.

As Marc broke down the sed line I will break down the line above, the #
character is indeed a comment character, but only to PERL. PERL is not
what tries to load the file initially, the shell tries to load the file
as a compiled program(like /bin/ls is the compiled program that lists
the files in a directory: I ran this on my nagios server as an example):

[dfulton at nagios01 nagios]$ file /bin/ls
/bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for
GNU/Linux 2.4.0, dynamically linked (uses shared libs), stripped
[dfulton at nagios01 nagios]$

But since a PERL script is interpretted and not compiled (technically
that isn't true either but it might as well be), the loader normally
doesn't know what to do with it, so the gods of UNIX decided that the
characters #! Would have special signifigance to the loader at the
beginning of the file. They indicate the program that will interpret the
script. So when the loader sees it it then looks for the /usr/bin/perl
program and execs it with the -w command and the script path so that it
will interpret the script. If /usr/bin/perl does not exist you will have
problems. To verify the existence of it just "ls /usr/bin/perl". Most
systems have it there, but a few do not, instead they keep it in
/usr/local/bin/ so you might need to change that line to
"#!/usr/local/bin/perl -w" instead. But only if it is in that location,
if it isn't you will need to find it. Which may not be so hard since
nagios probably found it when you installed it and if you do a "file *"
in the plugin directory and then type "head " and the name of a perl
script you should see where it really is.

Hope this helps.


This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

-------------------------------------------------------------------------
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