On Tue, 2008-07-22 at 14:06 -0700, Fulton, David wrote: > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] 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. > > > > > > > [EMAIL PROTECTED]:/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 "[EMAIL PROTECTED]"" > > 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): > > [EMAIL PROTECTED] 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 > [EMAIL PROTECTED] 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.
That helped a great deal in helping me understand what it is typing to do. That top line than of #!/usr/bin/perl -w does exist and the perl file does exist in /usr/bin so it should all be correct. Up until you pointed out my typo of the spelling of perl as "pearl" this obviously would not work and I was optimistic of this correcting the problem. However I fixed the spelling and am still getting the same error. It is just not seeing send_mail.pl as a valid script. The script of course is defined in the commands.cfg file as: 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$" } > > > ------------------------------------------------------------------------- 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@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