negate plug-in - No data returned from command

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
disarm76
Posts: 13
Joined: Wed Nov 05, 2014 1:18 pm

negate plug-in - No data returned from command

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: negate plug-in - No data returned from command

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
disarm76
Posts: 13
Joined: Wed Nov 05, 2014 1:18 pm

Re: negate plug-in - No data returned from command

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: negate plug-in - No data returned from command

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
disarm76
Posts: 13
Joined: Wed Nov 05, 2014 1:18 pm

Re: negate plug-in - No data returned from command

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: negate plug-in - No data returned from command

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

Code: Select all

echo $?
Please post the output of both commands for us to take a look at.
Former Nagios Employee
disarm76
Posts: 13
Joined: Wed Nov 05, 2014 1:18 pm

Re: negate plug-in - No data returned from command

Post 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]$
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: negate plug-in - No data returned from command

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

Code: Select all

ls -l /usr/local/nagios/libexec
Be sure to check out our Knowledgebase for helpful articles and solutions!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: negate plug-in - No data returned from command

Post 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
Former Nagios Employee
disarm76
Posts: 13
Joined: Wed Nov 05, 2014 1:18 pm

Re: negate plug-in - No data returned from command

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

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
Locked