Page 2 of 3

Re: NRPE response not found

Posted: Thu Jul 31, 2014 10:45 am
by turboscrew
I should be sorry for bothering people. :-)

Sometimes quick fixes don't exist and sometimes they hide themselves very well. :-)
I already have a lot of splinters under my finger nails from scratching my head. :-)

Anyway, I guess I have to leave for home anyway.
Back as a hawk tomorrow. :-)

Re: NRPE response not found

Posted: Fri Aug 01, 2014 6:20 am
by turboscrew
Some additional info (if it's of any use):
Added these to nrpe.cfg:

Code: Select all

command[whoami]=whoami
command[getenv]=env
Running them locally gave:

Code: Select all

[root@elukancompute nagios]# /usr/lib64/nagios/plugins/check_nrpe -H localhost -c whoami
nrpe
[root@elukancompute nagios]# /usr/lib64/nagios/plugins/check_nrpe -H localhost -c getenv
NRPE_PROGRAMVERSION=2.15
USER=nrpe
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PWD=/
LANG=en_US.UTF-8
SHLVL=1
HOME=/var/run/nrpe
LOGNAME=nrpe
NRPE_SSL_OPT=
NRPE_MULTILINESUPPORT=1
_=/usr/bin/env

Re: NRPE response not found

Posted: Fri Aug 01, 2014 8:57 am
by eloyd
This is beginning to sound as though the nrpe user on localhost is unable to execute the check_omat script. Can you paste the output of:

Code: Select all

ls -la /etc/nagios/check_omat
And would it be possible to actually see the check_omat script?

Re: NRPE response not found

Posted: Fri Aug 01, 2014 9:40 am
by turboscrew
# ls -la /etc/nagios/check_omat
-rwxrwxrwx. 1 root root 178 Jul 25 22:03 /etc/nagios/check_omat

The script was there in the first posting, but here:

Code: Select all

# cat /etc/nagios/check_omat
#!/bin/sh
#if [ ! -e /etc/nagios/outfile.txt ]
#then
#touch /etc/nagios/outfile.txt
#fi

echo $1 $2 $3 $4 $5 $6 $7 $8 > /etc/nagios/outfile.txt
echo SERVICE STATUS: OK
exit 0

Oh, and:

Code: Select all

[root@elukancompute nagios]# /etc/nagios/check_omat 10 5;echo $?
SERVICE STATUS: OK
0
The funny thing is:

Code: Select all

[root@elukancompute ~]# su -c "/etc/nagios/check_omat 20% 10% 2>/dev/null" nrpe
SERVICE STATUS: OK
[root@elukancompute ~]# su -c "/etc/nagios/check_omat 20% 10% 1>/dev/null" nrpe
[root@elukancompute ~]#

Code: Select all

[root@elukancompute ~]# su -c "/usr/lib64/nagios/plugins/check_nrpe -H localhost -c check_omat -a '20% 10%'" nrpe
NRPE: Unable to read output

Code: Select all

Jul 26 06:33:19 elukancompute su[11761]: pam_unix(su:session): session opened for user nrpe by ec2-user(uid=0)
Jul 26 06:33:19 elukancompute nrpe[11764]: Connection from 127.0.0.1 port 48043
Jul 26 06:33:19 elukancompute nrpe[11764]: Host address is in allowed_hosts
Jul 26 06:33:19 elukancompute nrpe[11764]: Handling the connection...
Jul 26 06:33:19 elukancompute nrpe[11764]: Host is asking for command 'check_omat' to be run...
Jul 26 06:33:19 elukancompute nrpe[11764]: Running command: /etc/nagios/check_omat 20% 10%
Jul 26 06:33:19 elukancompute nrpe[11764]: Command completed with return code 3 and output:
Jul 26 06:33:19 elukancompute nrpe[11764]: Return Code: 3, Output: NRPE: Unable to read output
Jul 26 06:33:19 elukancompute nrpe[11764]: [30B blob data]
Jul 26 06:33:19 elukancompute su[11761]: pam_unix(su:session): session closed for user nrpe

Re: NRPE response not found

Posted: Fri Aug 01, 2014 9:45 am
by eloyd
Please remove the "2>/dev/null" from your commands. Try this:

Code: Select all

su -c "/etc/nagios/check_omat this is a test" nrpe

Re: NRPE response not found

Posted: Fri Aug 01, 2014 9:52 am
by turboscrew
That '2>/dev/null' was there only to make sure the output came from stdout and not stderr.

Code: Select all

[root@elukancompute nagios]# su -c "/etc/nagios/check_omat this is a test" nrpe
SERVICE STATUS: OK
As you see, the variables were not used for output (except to be written in a file)
The string "SERVICE STATUS: OK" is always returned.

Maybe you wanted to see this?

Code: Select all

[root@elukancompute nagios]# cat /etc/nagios/outfile.txt
this is a test
BUT:

Code: Select all

[root@elukancompute nagios]# /usr/lib64/nagios/plugins/check_nrpe -H localhost -c check_omat -a "AARGHH"
NRPE: Unable to read output
[root@elukancompute nagios]# cat /etc/nagios/outfile.txt
this is a test
So it is not run - not even as root.

Re: NRPE response not found

Posted: Fri Aug 01, 2014 9:59 am
by eloyd
No, I wanted to see if any messages were being written to STDERR, which is what you were redirecting with the 2>/dev/null statement

For fun, move the check_omat script to the same directory as all the other plugins. I can't see that this would make a difference, but I'm almost out of ideas.

Re: NRPE response not found

Posted: Fri Aug 01, 2014 10:21 am
by turboscrew
Actually, I tried that with no change. Maybe if I changed the path in the config too...

Code: Select all

[root@elukancompute nagios]# ls /usr/lib64/nagios/plugins/
check_breeze    check_game       check_mrtgtraf     check_oracle   check_ssmtp
check_by_ssh    check_hpjd       check_mysql        check_overcr   check_swap
check_clamd     check_http       check_mysql_query  check_pgsql    check_tcp
check_cluster   check_icmp       check_nagios       check_ping     check_time
check_dhcp      check_ide_smart  check_nntp         check_pop      check_udp
check_dig       check_imap       check_nntps        check_procs    check_ups
check_disk      check_ircd       check_nrpe         check_real     check_users
check_disk_smb  check_jabber     check_nt           check_rpc      check_wave
check_dns       check_ldap       check_ntp          check_sensors  negate
check_dummy     check_ldaps      check_ntp_peer     check_simap    urlize
check_file_age  check_load       check_ntp.pl       check_smtp     utils.pm
check_flexlm    check_log        check_ntp_time     check_snmp     utils.sh
check_fping     check_mailq      check_nwstat       check_spop
check_ftp       check_mrtg      [b] check_omat[/b]         check_ssh

Code: Select all

[root@elukancompute nagios]# tail /etc/nagios/nrpe.cfg
        command[check_users]=/usr/lib64/nagios/plugins/check_users -w 10 -c 20
        command[df_var]=df /var/ | sed -re 's/.* ([0-9]+)%.*/\1/' | grep -E '^[0-9]'
        command[check_swap]=/usr/lib64/nagios/plugins/check_swap -w $ARG1$ -c $ARG2$
        command[load5]=cut /proc/loadavg -f 1 -d " "
        command[xinetd]=/usr/lib64/nagios/plugins/check_procs -c 1: -a xinetd
        command[httpd]=/usr/lib64/nagios/plugins/check_procs -c 1: -a httpd
        command[check_omat]=/usr/lib64/nagios/plugins//check_omat $ARG1$ $ARG2$
        command[whoami]=whoami
        command[getenv]=env
[root@elukancompute nagios]# !ser
service nrpe restart
Redirecting to /bin/systemctl restart  nrpe.service
Now this is getting very weird:

Code: Select all

[root@elukancompute nagios]# su -c "/usr/lib64/nagios/plugins/check_nrpe -H localhost -c check_omat -a 'AARGHH'" nrpe
SERVICE STATUS: OK - Sun Jul 27 08:59:46 EEST 2014
[root@elukancompute nagios]# cat /etc/nagios/outfile.txt
this is a test
[root@elukancompute nagios]# cat /usr/lib64/nagios/plugins/check_omat
#!/bin/sh
if [ ! -e /etc/nagios/outfile.txt ]
then
touch /etc/nagios/outfile.txt
fi

echo $1 $2 $3 $4 $5 $6 $7 $8 >> /etc/nagios/outfile.txt
echo "SERVICE STATUS: OK - `date`"
exit 0

Now I have to get home (and shops). It's almost 18:30 local time.
Have to continue on Monday.

Don't think about this too hard. Instead, have a nice weekend.

Re: NRPE response not found

Posted: Fri Aug 01, 2014 2:45 pm
by lmiltchev
command[check_omat]=/usr/lib64/nagios/plugins//check_omat $ARG1$ $ARG2$
This doesn't seem right (the two forward slashes)...

Re: NRPE response not found

Posted: Fri Aug 01, 2014 3:12 pm
by eloyd
It shouldn't matter but it's worth checking out.