Page 1 of 2
negate plug-in - No data returned from command
Posted: Wed Dec 23, 2015 6:57 am
by disarm76
Hi,
I'm trying to use the negate plug-in to change CRITICAL to OK. It is, according to the plug-in help, a default feature so no need to specify.
However, as you can see below, I can run the plug-in I need (check_as400) and it works fine, but not with negate.
Code: Select all
[root@nagios libexec]# ./check_as400 -H trqvida -u nagiosc -p ******** -v CJ TEMPBATCH
CRITICAL - job(TEMPBATCH) NOT IN SYSTEM
Code: Select all
[root@nagios libexec]# ./negate /usr/local/nagios/libexec/check_as400 -H trqvida -u nagiosc -p ******** -v CJ TEMPBATCH
No data returned from command
I even changed the timeout time, since check_as400 is on a 60s timeout but I get the same result. And the 'No date returned..." return is instantaneous.
Code: Select all
[root@nagios libexec]# ./negate -t 70 /usr/local/nagios/libexec/check_as400 -H trqvida -u nagiosc -p ******** -v CJ TEMPBATCH
No data returned from command
On other hand I can create my own script that manipulates the results and concatenate it. Anyone know how to do that?
Can you help me with this problem? Thanks.
Using:
NagiosXI 5.2.3
CentosOS 6.6 64bit
Re: negate plug-in - No data returned from command
Posted: Wed Dec 23, 2015 9:49 am
by Box293
What is the output of:
Code: Select all
/usr/local/nagios/libexec/negate /usr/local/nagios/libexec/check_dummy 0 OK
echo $?
Does your password have any special characters? Perhaps try putting the password in single quotes.
Code: Select all
./negate /usr/local/nagios/libexec/check_as400 -H trqvida -u nagiosc -p '********' -v CJ TEMPBATCH
Re: negate plug-in - No data returned from command
Posted: Wed Dec 23, 2015 10:19 am
by disarm76
Thanks for helping!
OK the first:
Code: Select all
[root@nagios libexec]# /usr/local/nagios/libexec/negate /usr/local/nagios/libexec/check_dummy 0 OK
OK: OK
[root@nagios libexec]# echo $?
2
The password is alphanumeric but tried the quotes getting the same result.
Re: negate plug-in - No data returned from command
Posted: Wed Dec 23, 2015 11:56 am
by Box293
The check_as400 plugin is going to be the source of the problem.
Does the check_as400 plugin have a verbose argument to show what is happening?
What happens when you test as the nagios user?
Code: Select all
su nagios
./negate /usr/local/nagios/libexec/check_as400 -H trqvida -u nagiosc -p '********' -v CJ TEMPBATCH
Re: negate plug-in - No data returned from command
Posted: Mon Dec 28, 2015 5:28 am
by disarm76
OK, so the check_as400 connects via telnet and with verbose active:
Code: Select all
[root@nagios libexec]# ./check_as400 -d -H trqvida -u nagiosc -p ********** -v CJ TEMPBATCH
Establishing connection to server...done.
Logging in...
waiting for screen...
waiting for token IBM CORP...
token received.
sending login information for nagiosc...
waiting for login to process...
waiting for token ===>...
token received.
Login completed.
Sending command (4)...
waiting for token F3=...
token received.
waiting for token Selection...
CRITICAL - job(TEMPBATCH) NOT IN SYSTEM
Logging out...
sending F3...
waiting for token ===>...
token received.
requesting signoff...
waiting for token stem...
token received.
Job ending immediately
waiting for token stem...
token received.
terminating connection...
Logged out.
As nagios, I get the same:
Code: Select all
[nagios@nagios libexec]$ ./negate /usr/local/nagios/libexec/check_as400 -d -H trqvida -u nagiosc -p ********** -v CJ TEMPBATCH
No data returned from command
Re: negate plug-in - No data returned from command
Posted: Mon Dec 28, 2015 11:04 am
by rkennedy
Can you try running the check as the Nagios user and then the echo command? This will show us if the script is exiting properly or not.
Code: Select all
./check_as400 -d -H trqvida -u nagiosc -p ********** -v CJ TEMPBATCH
then run -
Please post the output of both commands for us to take a look at.
Re: negate plug-in - No data returned from command
Posted: Mon Dec 28, 2015 11:26 am
by disarm76
Code: Select all
[nagios@nagios libexec]$ ./check_as400 -d -H trqvida -u nagiosc -p ******** -v CJ TEMPBATCH
Establishing connection to server...done.
Logging in...
waiting for screen...
waiting for token IBM CORP...
token received.
sending login information for nagiosc...
waiting for login to process...
waiting for token ===>...
token received.
Login completed.
Sending command (4)...
waiting for token F3=...
token received.
waiting for token Selection...
CRITICAL - job(TEMPBATCH) NOT IN SYSTEM
Logging out...
sending F3...
waiting for token ===>...
token received.
requesting signoff...
waiting for token stem...
token received.
Job ending immediately
waiting for token stem...
token received.
terminating connection...
Logged out.
[nagios@nagios libexec]$ echo $?
2
[nagios@nagios libexec]$
Re: negate plug-in - No data returned from command
Posted: Mon Dec 28, 2015 1:04 pm
by tgriep
Can you post your check_as400 plugin that you are using here so we can review it?
The check_as400 plugin I found uses a .as400 file that is stores on the system to get the username and password to login to the AS400 server and I am thinking that when the negate plugin runs the check_as400 check, it doesn't have the correct permissions to open the text file it uses for the login credentials.
Also, can you run the following and post the output here?
Re: negate plug-in - No data returned from command
Posted: Mon Dec 28, 2015 1:46 pm
by rkennedy
As @tgriep posted above - the issue may be the permissions with that file. Please do post the output of what he mentioned.
I did create a simple bash script to change the exit codes as needed. Change the password in the -p parameter. If permissions are the issue though, then this script will not work either.
Code: Select all
#!/bin/bash
# define vars
script=$(/usr/local/nagios/libexec/check_as400 -d -H trqvida -u nagiosc -p password CJ TEMPBATCH)
# switch CRITICAL to OK
if [[ $script == *"CRITICAL"* ]]
then
echo "OK"
exit 0
# WARNING stays the same
elif [[ $script == *"WARNING"* ]]
then
echo "WARNING"
exit 1
# switch OK to CRITICAL
elif [[ $script == *"OK"* ]]
then
echo "CRITICAL"
exit 2
# catchall UNKNOWN
else
echo "UNKNOWN"
exit 3
fi
Re: negate plug-in - No data returned from command
Posted: Tue Dec 29, 2015 5:25 am
by disarm76
OK, it's working! Well, it's one script for one alert but these kind of alerts are rare.
Thank you for your help!
Code: Select all
[root@nagios libexec]# ./check_as400 -H trqvida -u nagiosc -p ******** -v CJ TEMPBATCH
CRITICAL - job(TEMPBATCH) NOT IN SYSTEM
[root@nagios libexec]# ./check_as400_job_TEMPBATCH_negated.sh
OK - BATCH Terminado
As a test I gave full permissions to all as400 files and still got the same result:
Code: Select all
[root@nagios libexec]# ls -la *as400*
-rwxrwxrwx 1 apache nagios 225 Nov 18 17:42 check_as400
-rwxrwxrwx 1 apache nagios 225 Nov 18 17:37 check_as400_BK
-rwxrwxrwx 1 apache nagios 35004 Nov 20 17:41 check_as400.class
-rwxrwxrwx 1 apache nagios 787 Nov 20 17:41 check_as400_cmd_vars.class
-rwxrwxrwx 1 apache nagios 1517 Nov 20 17:41 check_as400_lang.class
-rwxrwxrwx 1 apache nagios 11646 Nov 28 2013 check_as400sql.php
-rwxrwxrwx 1 root nagios 474 Dec 29 09:36 check_as400_trqvida_job_TEMPBATCH_negated.sh
[root@nagios libexec]# ls -la .as400*
-rwxrwxrwx 1 apache nagios 12 Nov 20 11:26 .as400
[root@nagios libexec]# /usr/local/nagios/libexec/negate /usr/local/nagios/libexec/check_as400 -H trqvida -u nagiosc -p ******* -v CJ TEMPBATCH
No data returned from command