Antwort: RE: Antwort: RE: script giving plugin missing error.

h.baecker at ecofis.de h.baecker at ecofis.de
Tue Mar 2 14:43:47 CET 2004


Hi again,

First: I don't know if it is a good idea to let nagios be "root"...
Second: What do you think about this Perl Script? I think this will do 
what you want. BEWARE this ist NOT testet.

#### cut ####
#!/usr/bin/perl
#
#
##

# Check for enough Arguments, such like the IP Address out of $HOSTADDRESS
if (!@ARGV[0]){
        print "\n\tWe need more arguments!\n\t";
        exit -1;
}

# Nagios Return Code Definition
#
my %ERRORS = ('UNKNOWN', '-1',
                'OK', '0',
                'WARNING', '1',
                'CRITICAL', '2');


system=`/bin/ping -c 2 -w 2 @ARGV[0] > /path/to/out`;
open (FILE,"<out");
while(<FILE>)
{
 if ($_ =~ /0 received/) 
 {
 print ("CRITICAL - Plugin timed out after 10 seconds\n");
 exit $ERRORS{CRITICAL}
 }
 if ($_=~ /2 received/) 
 {
 print ("PING -OK\n");
 exit $ERRORS{OK}
 }
### paste ###

Hope this will help.
Hendrik




<prabhu.anandh at wipro.com> 
Gesendet von: nagios-users-admin at lists.sourceforge.net
02.03.2004 14:23

An
<h.baecker at ecofis.de>, <nagios-users at lists.sourceforge.net>
Kopie

Thema
RE: Antwort: RE: [Nagios-users] script giving plugin missing error.






hi hendrik,
I am running in root only.and for your information if i run that script 
manually i get the output.the problem i beleive that i  have is ,if i 
given the hostaddress in checkcommands.cfg and i have made no provision 
for getting this variable in my script maybe this causes problems.any 
ideas??????? will it be the problem???but  even if i type the address 
manually in the script and then run nagios........it still doesnt work. i 
have given the full path for every check_new(shell script), new.pl and 
also for out file.
if i run manually the script alone,it works.strange...........
thanks in advance.
 
regards,
Prabhu Anandh S.
-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net 
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of 
h.baecker at ecofis.de
Sent: Tuesday, March 02, 2004 6:33 PM
To: Prabhu Anandh (WT01 - TELECOM & INTER-NETWORKING SOLUTIONS); 
nagios-users at lists.sourceforge.net
Subject: Antwort: RE: [Nagios-users] script giving plugin missing error.


Hi Prabhu, 

Did you try to execute your script as "nagios-user" or just as root? 
Perhaps the nagios user is not permitted to write files in the working 
directory of your script? 

Regards 
Hendrik 




<prabhu.anandh at wipro.com> 
Gesendet von: nagios-users-admin at lists.sourceforge.net 
02.03.2004 13:48 


An
<fredrik.wanglund at mobeon.com> 
Kopie
<nagios-users at lists.sourceforge.net> 
Thema
RE: [Nagios-users] script giving plugin missing error.








Hi fredrik,
I have checked it and the problem is not with the nagios.when it tries to 
execute check_new and the shell script does not create the "out " file.
Any ideas of how to solve the problem.i have given the full path for 
new.pl ,but it is not working.
If I try to execute manually by changing the $HOSTADDRESS in shell script 
with the exact address,it create out file.otherwise not????????why??
Thanks in advance.

regards,
Prabhu Anandh S.


-----Original Message-----
From: Fredrik Wänglund [mailto:fredrik.wanglund at mobeon.com] 
Sent: Tuesday, March 02, 2004 5:28 PM
To: Prabhu Anandh (WT01 - TELECOM & INTER-NETWORKING SOLUTIONS)
Cc: nagios-users at lists.sourceforge.net
Subject: Re: [Nagios-users] script giving plugin missing error.


The problem is the line './new.pl'

Nagios is not executed from the libexec-directory, so you need the full 
path to the secondary script (and to the outfile).

/FredrikW



prabhu.anandh at wipro.com wrote:

> Hi folks this is what I tried and I get the following error
> (127 out of bounds plugin may be missing.)<---from status.log file
> 
> This is the shell script that invokes perl script since I don't know 
> how to check strings in shell script.
> 
> #!/bin/sh
> RES1= `/bin/ping -c 2 -w 2 $HOSTADDRESS > out`   <-----------------I am
> sending only 2 packets.
> RET=$?
> echo $RES1
> ./new.pl
> exit $RET
> 
> Perl script reads as follows:
> 
> #!/usr/bin/perl
> open (FILE,"<out");
> while(<FILE>)
> {
> if ($_ =~ /0 received/)          <-----------------if no packets are
> received ,I will give it as critical or warning.
> {
> print ("CRITICAL - Plugin timed out after 10 seconds\n");
> }
> if ($_=~ /2 received/)           <-------------if both are received ,I
> assume that host is up.
> {
> print ("PING -OK\n");
> }
> }
> #print "$_";
> close (FILE);
> 
> 
> In hosts.cfg
> I have given check_command as check_new <----name of the shell file.
> 
> In checkcommands.cfg
> Command_line /home/var/check_new $HOSTADDRESS
> 
> 
> How do I make the following to take effect in the web interface. Or 
> where and what mistake I did.
> 
> Thanks in advance.
> 
> Regards,
> Prabhu Anandh
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and 
> deploy apps & Web services for Linux with a free DVD software kit from 
> IBM. Click Now! http://ads.osdn.com/?ad_id56&alloc_id438&op=click
> _______________________________________________
> 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 is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&opÌk
_______________________________________________
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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20040302/14b900f0/attachment.html>


More information about the Users mailing list