Page 1 of 1

getting NRPE: Unable to read output when running from server

Posted: Fri Jul 07, 2017 8:49 am
by putharekulu
Hi,

I am getting NRPE: Unable to read output when trying to connect to the docker container using nagios.
When i run this script directly on the client machine it is successfully returning me the number of rows in mongo db. But when i run it remotely from the server i am getting unable to read output.

executing from nagios server
/usr/lib64/nagios/plugins/check_nrpe -H hostipaddress -c check_mongocount
NRPE: Unable to read output

check_mongocount script is basically conneccting to the docker container and counting the number of rows for a particular customer for a date

count=`sudo /bin/docker exec -it container mongo dbname --quiet -u "test" -p "test" --authenticationDatabase "test" --eval '(db.test.count( { $and: [{create_at: {$gte: NumberLong("1499227200"), $lt: NumberLong("1499313599")}},{customerid:1}]}))'

/etc/nagios/nrpe.cfg has the following line added.
command[check_mongocount]=sudo /usr/lib64/nagios/plugins/test.sh

i have nrpe ALL=(ALL) NOPASSWD:ALL in my /etc/sudoers file.

Re: getting NRPE: Unable to read output when running from se

Posted: Fri Jul 07, 2017 12:12 pm
by scottwilkerson
Is NRPE running as the user nrpe in your docker container?

Is it using the standard port?

To verify you can make a basic connection can you run the following and get back the version?

Code: Select all

/usr/lib64/nagios/plugins/check_nrpe -H hostipaddress

Re: getting NRPE: Unable to read output when running from se

Posted: Fri Jul 07, 2017 12:22 pm
by putharekulu
Thanks for your reply scott. My issue is resolved just now.

the only change i did was removing the -it in the below command.

count=`sudo /bin/docker exec -it container mongo dbname --quiet -u "test" -p "test" --authenticationDatabase "test" --eval '(db.test.count( { $and: [{create_at: {$gte: NumberLong("1499227200"), $lt: NumberLong("1499313599")}},{customerid:1}]}))'

Re: getting NRPE: Unable to read output when running from se

Posted: Fri Jul 07, 2017 12:36 pm
by lmiltchev
I am glad your issue has been resolved! I am closing the topic now. If you have any more questions/issues, please start a new thread.