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. Though nrpe has all rights to execute the docker command it is failing to return the count value.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.