NRPE: Unable to read output

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
ae07177
Posts: 6
Joined: Fri Mar 27, 2015 5:13 am

Re: NRPE: Unable to read output

Post by ae07177 »

Hi,
I have a similar problem. I have a perl script to check the status of postgres database.
NRPE client runs off xinetd service and not as a seperate daemon and firewall is disabled.

On the client when i run the check status using the script it works fine.

/usr/local/nagios/libexec/check_postgres.pl --action=connection --db=DB_NAME --port=5432 --dbuser=DB_USER
POSTGRES_CONNECTION OK: DB "DB_NAME" version 9.3.4 | time=0.04s

But when i run the same check using the command alias it doesn't work and gives the following error.
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 0 -c check_postgres_connection
NRPE: Unable to read output

grep check_postgres_connection ../etc/nrpe.cfg
command[check_postgres_connection]=/usr/local/nagios/libexec/check_postgres.pl --action=connection --db=DB_NAME --port=5432 --dbuser=DB_USER

I haven't setup any sudo rules as nagios user has permissions to execute these scripts and is used by nagios user.
ls -l check_postgres.pl
-rwxr-xr-x. 1 nagios nagios 372014 Feb 11 16:00 check_postgres.pl

I have even checked as nagios user and it works absolutely fine. Command check alias works absolutely fine on another host, But not on this one. I am running out of ideas. Please suggest a solution.
su - nagios -s /bin/bash -c "/usr/local/nagios/libexec/check_postgres.pl --action=connection --db=DB_NAME--port=5432 --dbuser=DB_USER"
POSTGRES_CONNECTION OK: DB "postgres" version 9.3.4 | time=0.01s
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: NRPE: Unable to read output

Post by jolson »

ae07177,

If you run check_nrpe with no arguments, does it work properly?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
This is very commonly caused by permissions problems. Is selinux running?

Code: Select all

sestatus
Check your default requiretty setting:

Code: Select all

cat /etc/sudoers | grep tty
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
ae07177
Posts: 6
Joined: Fri Mar 27, 2015 5:13 am

Re: NRPE: Unable to read output

Post by ae07177 »

Hi Jolson,
Thanks for the reply.

Yes, check_nrpe works properly and alia for several others apart from Postgres DB check works fine.
eg::
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_disk_/
DISK OK - free space: / 980 MB (68% inode=88%);| /=454MB;1359;1435;0;1511
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_swap
SWAP OK - 100% free (4091 MB out of 4091 MB) |swap=4091MB;818;409;0;4091

Selinux status, although i dont think it is causing the problem.

sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: permissive
Mode from config file: disabled
Policy version: 24
Policy from config file: targeted

Coming to tty setting in /etc/sudoers, User "nagios" already has permissions for "check_postgres.pl" script. And it runs properly when executed as nagios user.
I havent setup any sudo rules. Would it still matter?

grep tty /etc/sudoers | grep -v ^#
Defaults requiretty
ls -l /usr/local/nagios/libexec/check_postgres.pl
-rwxr-xr-x. 1 nagios nagios 372014 Feb 11 16:00 /usr/local/nagios/libexec/check_postgres.pl

"nagios" user appears to be able to execute "postgres" check script properly.
su - nagios -s /bin/bash -c "/usr/local/nagios/libexec/check_postgres.pl --action=connection --db=DB_NAME --port=5432 --dbuser=DB_USER"
POSTGRES_CONNECTION OK: DB "DB_NAME" version 9.3.4 | time=0.03s

Please advise
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE: Unable to read output

Post by ssax »

Can you try it with selinux disabled, we recommend that it be disabled.

You can run the command below to temporarily turn it off:

Code: Select all

setenforce 0
You can turn it off permanently with by editing /etc/sysconfig/selinux and changing the line from:

Code: Select all

SELINUX=enforcing
To:

Code: Select all

SELINUX=disabled
ae07177
Posts: 6
Joined: Fri Mar 27, 2015 5:13 am

Re: NRPE: Unable to read output

Post by ae07177 »

Hi,
It is already disabled.

getenforce
Permissive

grep ^SELINUX /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: NRPE: Unable to read output

Post by jdalrymple »

ae07177 wrote: getenforce
Permissive

Permissive != Disabled

I think selinux is your problem. Please test with it disabled.

Once you have the following:

Code: Select all

[jdalrymple@localhost ~]$ sestatus
SELinux status:                 disabled
Then try your command again.
ae07177
Posts: 6
Joined: Fri Mar 27, 2015 5:13 am

Re: NRPE: Unable to read output

Post by ae07177 »

Hi,
I tried copying a new postgres check script. But it is giving me another error. I have set the path in "/etc/profile" as well. But it doesnt work.
Please help.

[root@Fillet etc]# grep postgres nrpe.cfg
command[check_postgres_connection_db-name]=/usr/local/nagios/libexec/check_postgres.pl --action=connection --db=db-name --port=5432 --dbuser=db_user 2>&1
[root@Fillet etc]# /usr/local/nagios/libexec/check_postgres.pl --action=connection --db=db-name --port=5432 --dbuser=db_user
POSTGRES_CONNECTION OK: DB "db-name" version 9.3.4 | time=0.02s
[root@Fillet etc]#
[root@Fillet etc]#
[root@Fillet etc]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_postgres_connection_db-name
which: no psql in (/sbin:/usr/sbin:/bin:/usr/bin)
ERROR: Could not find a suitable psql executable
[root@Fillet etc]#
[root@Fillet etc]# which psql
/home/data/PostgresPlus/9.3/bin/psql
[root@Fillet etc]#
ae07177
Posts: 6
Joined: Fri Mar 27, 2015 5:13 am

Re: NRPE: Unable to read output

Post by ae07177 »

Also not able to check oracle database tablespace usage on another server. Please help. Following are the error details.

Hi Team,
I have another issue where i can check the oracle tablespace usage by running the "check_oracle_tablespace" script. But get an error while checking with "check_nrpe" script. Please advise.

Doesnt work::
tntb-a:/usr/local/nagios/etc # /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_oracle_tablespace_ATLAS_ATLAS_DATA
Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
/usr/local/nagios/libexec/check_oracle: line 284: [: : integer expression expected
/usr/local/nagios/libexec/check_oracle: line 288: [: : integer expression expected
/usr/local/nagios/libexec/check_oracle: line 292: [: : integer expression expected
ATLAS : ATLAS_DATA OK - % used [ / MB available ]|ATLAS_DATA=%;85;95;0;100
tntb-a:/usr/local/nagios/etc #


This Works::
tntb-a:/usr/local/nagios/etc # /usr/local/nagios/libexec/check_oracle_tablespace ATLAS ATLAS_DATA
ATLAS : ATLAS_DATA OK - 84.50% used [ 3893 / 25000 MB available ]|ATLAS_DATA=84.50%;85;95;0;100
tntb-a:

Thanks
Arvind
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NRPE: Unable to read output

Post by lmiltchev »

[root@Fillet etc]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_postgres_connection_db-name
which: no psql in (/sbin:/usr/sbin:/bin:/usr/bin)
The check_nrpe is usually used to run checks on a remote server... Are you running this check locally (with check_nrpe)? What is the output of the following command?

Code: Select all

echo $PATH
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked