Introduction to Linux - A Hands on Guide | Linux Bible | Linux From Scratch | A Newbie's Getting Started Guide to Linux | Linux Command Line Cheat Sheet | More Linux eBooks



Thursday, 4 December 2014

Nagios Error - CHECK_NRPE: Received 0 bytes from daemon

Error:

$ /usr/local/nagios/libexec/check_nrpe -H 172.22.246.126 -c check_disk.sh -a '-p /volume1 -w 80 -c 90'
CHECK_NRPE: Received 0 bytes from daemon.  Check the remote server logs for error messages.
On the Remote Server:

$ tailf /var/log/messages
Dec  4 14:42:42 RemoteBox xinetd[659]: START: nrpe pid=5807 from=::ffff:128.9.45.202
Dec  4 14:42:42 RemoteBox nrpe[5807]: Error: Request contained command arguments!
Dec  4 14:42:42 RemoteBox nrpe[5807]: Client request was invalid, bailing out...
Dec  4 14:42:42 RemoteBox xinetd[659]: EXIT: nrpe status=0 pid=5807 duration=0(sec)

Reason:
The error "Request contained command arguments!" indicates that, by default, Nagios does not take any argument.

Solution:

Step 1: NRPE Re-Configuration
Download NRPE, extract the tar file and change to 'nrpe-x.xx' directory, 'nrpe-2.14' in my case. For NRPE to accept arguments from now on, run the 'configure' script with '--enable-command-args' as follows:

$ ./configure --enable-command-args

$ make all
$ make install-plugin
$ make install-daemon
$ make install-daemon-config
$ make install-xinetd
Output:

$ ./configure --enable-command-args

checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... gcc -E
....
....
$ make all

cd ./src/; make ; cd ..
make[1]: Entering directory `/tmp/linux-nrpe-agent/nrpe-2.14/src'
gcc -g -O2 -I/usr/include/openssl -I/usr/include -DHAVE_CONFIG_H -I ../include -I ./../include -o nrpe ./nrpe.c ./utils.c ./acl.c -L/usr/lib64  -lssl -lcrypto -lnsl
./nrpe.c: In function ‘main’:
./nrpe.c:223: warning: assignment discards qualifiers from pointer target type
gcc -g -O2 -I/usr/include/openssl -I/usr/include -DHAVE_CONFIG_H -I ../include -I ./../include -o check_nrpe ./check_nrpe.c ./utils.c -L/usr/lib64  -lssl -lcrypto -lnsl
./check_nrpe.c: In function ‘main’:
./check_nrpe.c:126: warning: assignment discards qualifiers from pointer target type
make[1]: Leaving directory `/tmp/linux-nrpe-agent/nrpe-2.14/src'

*** Compile finished ***
$ make install-plugin

cd ./src/ && make install-plugin
make[1]: Entering directory `/tmp/linux-nrpe-agent/nrpe-2.14/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/tmp/linux-nrpe-agent/nrpe-2.14/src'
$ make install-daemon

cd ./src/ && make install-daemon
make[1]: Entering directory `/tmp/linux-nrpe-agent/nrpe-2.14/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install -c -m 775 -o nagios -g nagios nrpe /usr/local/nagios/bin
make[1]: Leaving directory `/tmp/linux-nrpe-agent/nrpe-2.14/src'
$ make install-daemon-config

/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc
$ make install-xinetd

/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe
Step 2. Modify 'nrpe.cfg' file

Open the /usr/local/nagios/etc/nrpe.cfg file and search for the line 'dont_blame_nrpe=0'. Edit the line as follows:

dont_blame_nrpe=1
Now check from the server whether NRPE has started receiving arguments.

Result:

$ /usr/local/nagios/libexec/check_nrpe -H 172.22.246.126 -c check_disk.sh -a '-p /volume1 -w 80 -c 90'
OK- /Volume1 : Total Space= 468G, Used Space= 80G, Available Space= 365G i.e. 18% Usage | 'Usage'=18;80;90;0;100

0 comments:

Post a Comment