You need to be root before running thesekmartin2007 wrote: ozadmin@dalsrvitmon03:~$ su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
Password:
su: Authentication failure
ozadmin@dalsrvitmon03:~$ su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
Password:
su: Authentication failure
ozadmin@dalsrvitmon03:~$
(Return code of 127 is out of bounds - plugin may be missing
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: (Return code of 127 is out of bounds - plugin may be mis
-
- Posts: 66
- Joined: Thu Nov 14, 2019 3:31 pm
Re: (Return code of 127 is out of bounds - plugin may be mis
scottwilkerson wrote:You need to be root before running thesekmartin2007 wrote: ozadmin@dalsrvitmon03:~$ su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
Password:
su: Authentication failure
ozadmin@dalsrvitmon03:~$ su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
Password:
su: Authentication failure
ozadmin@dalsrvitmon03:~$
root@dalsrvitmon03:~# su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
sh: 1: cannot create tmp_res1: Permission denied
UNKNOWN: /usr/bin/wget --output-document=tmp_html --no-check-certificate -S returns no result!255
Re: (Return code of 127 is out of bounds - plugin may be mis
When I run the command as root, this is the error message that I get.
root@dalsrvitmon03:~# su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
sh: 1: cannot create tmp_res1: Permission denied
UNKNOWN: /usr/bin/wget --output-document=tmp_html --no-check-certificate -S returns no result!255
root@dalsrvitmon03:~# su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
sh: 1: cannot create tmp_res1: Permission denied
UNKNOWN: /usr/bin/wget --output-document=tmp_html --no-check-certificate -S returns no result!255
Re: (Return code of 127 is out of bounds - plugin may be mis
I believe, the "tmp_res1" file is creating in the "current" directory (the one in are in), so try switching to "/tmp":
and rerun your check:
Did it work now?
Code: Select all
cd /tmp
Code: Select all
su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 66
- Joined: Thu Nov 14, 2019 3:31 pm
Re: (Return code of 127 is out of bounds - plugin may be mis
lmiltchev wrote:I believe, the "tmp_res1" file is creating in the "current" directory (the one in are in), so try switching to "/tmp":and rerun your check:Code: Select all
cd /tmp
Did it work now?Code: Select all
su nagios -c '/usr/local/nagios/libexec/check_url.pl http://www.espdata.org.au/index.asp; echo $?'
Yes it does
root@dalsrvitmon03:~# cd /tmp
root@dalsrvitmon03:/tmp# su nagios -c '/usr/local/nagios/libexec/check_url.pl ht tp://www.espdata.org.au/index.asp; echo $?'
OK: 200 OK
0
root@dalsrvitmon03:/tmp#
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: (Return code of 127 is out of bounds - plugin may be mis
Looking over the code there is no directory set for the temp files and there is a modification in the reviews I'd like you to try
Please replace check_url.pl with the following
Please replace check_url.pl with the following
Code: Select all
#!/usr/bin/perl
# (C) Unknown author at https://exchange.nagios.org/directory/Plugins/Websites%2C-Forms-and-Transactions/check_url/details
#
# Changes:
# 2016-01-07: Stephan Ferraro
# Added PID number for temporary files, that the script can run in parallel with multiple processes.
# Added a check if one arguments is defined at script startup. -- Stephan Ferraro
use strict;
if ($#ARGV == -1)
{
print STDERR "usage: check_url.pl URL\n";
exit 1;
}
my $wget = '/usr/bin/wget --output-document=/tmp/tmp_'.$$.'.html --no-check-certificate -S';
my ($url) = @ARGV;
my @OK = ("200");
my @WARN = ("400", "401", "403", "404", "408");
my @CRITICAL = ("500", "501", "502", "503", "504");
my $TIMEOUT = 20;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my $state = "UNKNOWN";
my $answer = "";
$SIG{'ALRM'} = sub {
print ("ERROR: check_url Time-Out $TIMEOUT s \n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
system ("$wget $url 2>/tmp/tmp_".$$.".res1");
if (! open STAT1, "/tmp/tmp_".$$.".res1") {
print ("$state: $wget returns no result!");
exit $ERRORS{$state};
}
close STAT1;
`cat /tmp/tmp_$$.res1|grep 'HTTP/1'|tail -n 1 >/tmp/tmp_$$.res`;
open (STAT, "/tmp/tmp_".$$.".res");
my @lines = <STAT>;
close STAT;
if ($lines[0]=~/HTTP\/1\.\d+ (\d+)( .*)/) {
my $errcode = $1;
my $errmesg = $2;
$answer = $answer . "$errcode $errmesg";
if ('1' eq &chkerrwarn($errcode) ) {
$state = 'WARNING';
} elsif ('2' eq &chkerrcritical($errcode)) {
$state = 'CRITICAL';
} elsif ('0' eq &chkerrok($errcode)) {
$state = 'OK';
}
}
sub chkerrcritical {
my $err = $1;
foreach (@CRITICAL){
if ($_ eq $err) {
return 2;
}
}
return -1;
}
sub chkerrwarn {
my $err = $1;
foreach (@WARN){
if ($_ eq $err) {
return 1;
}
}
return -1;
}
sub chkerrok {
my $err = $1;
foreach (@OK){
if ($_ eq $err) {
return 0;
}
}
return -1;
}
`rm /tmp/tmp_$$.html /tmp/tmp_$$.res /tmp/tmp_$$.res1`;
print ("$state: $answer\n");
exit $ERRORS{$state};
-
- Posts: 66
- Joined: Thu Nov 14, 2019 3:31 pm
Re: (Return code of 127 is out of bounds - plugin may be mis
scottwilkerson wrote:Looking over the code there is no directory set for the temp files and there is a modification in the reviews I'd like you to try
Please replace check_url.pl with the followingCode: Select all
#!/usr/bin/perl # (C) Unknown author at https://exchange.nagios.org/directory/Plugins/Websites%2C-Forms-and-Transactions/check_url/details # # Changes: # 2016-01-07: Stephan Ferraro # Added PID number for temporary files, that the script can run in parallel with multiple processes. # Added a check if one arguments is defined at script startup. -- Stephan Ferraro use strict; if ($#ARGV == -1) { print STDERR "usage: check_url.pl URL\n"; exit 1; } my $wget = '/usr/bin/wget --output-document=/tmp/tmp_'.$$.'.html --no-check-certificate -S'; my ($url) = @ARGV; my @OK = ("200"); my @WARN = ("400", "401", "403", "404", "408"); my @CRITICAL = ("500", "501", "502", "503", "504"); my $TIMEOUT = 20; my %ERRORS = ('UNKNOWN' , '-1', 'OK' , '0', 'WARNING', '1', 'CRITICAL', '2'); my $state = "UNKNOWN"; my $answer = ""; $SIG{'ALRM'} = sub { print ("ERROR: check_url Time-Out $TIMEOUT s \n"); exit $ERRORS{"UNKNOWN"}; }; alarm($TIMEOUT); system ("$wget $url 2>/tmp/tmp_".$$.".res1"); if (! open STAT1, "/tmp/tmp_".$$.".res1") { print ("$state: $wget returns no result!"); exit $ERRORS{$state}; } close STAT1; `cat /tmp/tmp_$$.res1|grep 'HTTP/1'|tail -n 1 >/tmp/tmp_$$.res`; open (STAT, "/tmp/tmp_".$$.".res"); my @lines = <STAT>; close STAT; if ($lines[0]=~/HTTP\/1\.\d+ (\d+)( .*)/) { my $errcode = $1; my $errmesg = $2; $answer = $answer . "$errcode $errmesg"; if ('1' eq &chkerrwarn($errcode) ) { $state = 'WARNING'; } elsif ('2' eq &chkerrcritical($errcode)) { $state = 'CRITICAL'; } elsif ('0' eq &chkerrok($errcode)) { $state = 'OK'; } } sub chkerrcritical { my $err = $1; foreach (@CRITICAL){ if ($_ eq $err) { return 2; } } return -1; } sub chkerrwarn { my $err = $1; foreach (@WARN){ if ($_ eq $err) { return 1; } } return -1; } sub chkerrok { my $err = $1; foreach (@OK){ if ($_ eq $err) { return 0; } } return -1; } `rm /tmp/tmp_$$.html /tmp/tmp_$$.res /tmp/tmp_$$.res1`; print ("$state: $answer\n"); exit $ERRORS{$state};
Just to be clear you want me to replace the entire script (below) with this right?
#!/usr/bin/perl
use strict;
my $wget = '/usr/bin/wget --output-document=tmp_html --no-check-certificate -S';
my ($url) = @ARGV;
my @OK = ("200");
my @WARN = ("400", "401", "403", "404", "408");
my @CRITICAL = ("500", "501", "502", "503", "504");
my $TIMEOUT = 20;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my $state = "UNKNOWN";
my $answer = "";
$SIG{'ALRM'} = sub {
print ("ERROR: check_url Time-Out $TIMEOUT s \n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
system ("$wget $url 2>tmp_res1");
for (1..1000){
}
if (! open STAT1, "tmp_res1") {
print ("$state: $wget returns no result!");
exit $ERRORS{$state};
}
close STAT1;
`cat tmp_res1|grep 'HTTP/1'|tail -n 1 >tmp_res`;
open (STAT, "tmp_res");
my @lines = <STAT>;
close STAT;
if ($lines[0]=~/HTTP\/1\.\d+ (\d+)( .*)/) {
my $errcode = $1;
my $errmesg = $2;
$answer = $answer . "$errcode $errmesg";
if ('1' eq &chkerrwarn($errcode) ) {
$state = 'WARNING';
} elsif ('2' eq &chkerrcritical($errcode)) {
$state = 'CRITICAL';
} elsif ('0' eq &chkerrok($errcode)) {
$state = 'OK';
}
}
sub chkerrcritical {
my $err = $1;
foreach (@CRITICAL){
if ($_ eq $err) {
return 2;
}
}
return -1;
}
sub chkerrwarn {
my $err = $1;
foreach (@WARN){
if ($_ eq $err) {
return 1;
}
}
return -1;
}
sub chkerrok {
my $err = $1;
foreach (@OK){
if ($_ eq $err) {
return 0;
}
}
return -1;
}
`rm tmp_html tmp_res tmp_res1`;
print ("$state: $answer\n");
exit $ERRORS{$state};
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
-
- Posts: 66
- Joined: Thu Nov 14, 2019 3:31 pm
Re: (Return code of 127 is out of bounds - plugin may be mis
scottwilkerson wrote:Looking over the code there is no directory set for the temp files and there is a modification in the reviews I'd like you to try
Please replace check_url.pl with the followingCode: Select all
#!/usr/bin/perl # (C) Unknown author at https://exchange.nagios.org/directory/Plugins/Websites%2C-Forms-and-Transactions/check_url/details # # Changes: # 2016-01-07: Stephan Ferraro # Added PID number for temporary files, that the script can run in parallel with multiple processes. # Added a check if one arguments is defined at script startup. -- Stephan Ferraro use strict; if ($#ARGV == -1) { print STDERR "usage: check_url.pl URL\n"; exit 1; } my $wget = '/usr/bin/wget --output-document=/tmp/tmp_'.$$.'.html --no-check-certificate -S'; my ($url) = @ARGV; my @OK = ("200"); my @WARN = ("400", "401", "403", "404", "408"); my @CRITICAL = ("500", "501", "502", "503", "504"); my $TIMEOUT = 20; my %ERRORS = ('UNKNOWN' , '-1', 'OK' , '0', 'WARNING', '1', 'CRITICAL', '2'); my $state = "UNKNOWN"; my $answer = ""; $SIG{'ALRM'} = sub { print ("ERROR: check_url Time-Out $TIMEOUT s \n"); exit $ERRORS{"UNKNOWN"}; }; alarm($TIMEOUT); system ("$wget $url 2>/tmp/tmp_".$$.".res1"); if (! open STAT1, "/tmp/tmp_".$$.".res1") { print ("$state: $wget returns no result!"); exit $ERRORS{$state}; } close STAT1; `cat /tmp/tmp_$$.res1|grep 'HTTP/1'|tail -n 1 >/tmp/tmp_$$.res`; open (STAT, "/tmp/tmp_".$$.".res"); my @lines = <STAT>; close STAT; if ($lines[0]=~/HTTP\/1\.\d+ (\d+)( .*)/) { my $errcode = $1; my $errmesg = $2; $answer = $answer . "$errcode $errmesg"; if ('1' eq &chkerrwarn($errcode) ) { $state = 'WARNING'; } elsif ('2' eq &chkerrcritical($errcode)) { $state = 'CRITICAL'; } elsif ('0' eq &chkerrok($errcode)) { $state = 'OK'; } } sub chkerrcritical { my $err = $1; foreach (@CRITICAL){ if ($_ eq $err) { return 2; } } return -1; } sub chkerrwarn { my $err = $1; foreach (@WARN){ if ($_ eq $err) { return 1; } } return -1; } sub chkerrok { my $err = $1; foreach (@OK){ if ($_ eq $err) { return 0; } } return -1; } `rm /tmp/tmp_$$.html /tmp/tmp_$$.res /tmp/tmp_$$.res1`; print ("$state: $answer\n"); exit $ERRORS{$state};
I replaced it and looks like the website checks are now working!!!
ESPDATA.ORG.AU
Perform Extra Service Actions
OK 2019-11-19 14:32:50 0d 0h 2m 22s 1/2 OK: 200 OK
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: (Return code of 127 is out of bounds - plugin may be mis
Awesome!kmartin2007 wrote:I replaced it and looks like the website checks are now working!!!
ESPDATA.ORG.AU
Perform Extra Service Actions
OK 2019-11-19 14:32:50 0d 0h 2m 22s 1/2 OK: 200 OK
Locking thread