Solved

nagios + check_mongodb.py

Posted on 2011-02-15
12
1,835 Views
Last Modified: 2016-02-10
Hi
I have installed nagios 3.2.2 and the plug-ins check_mongo.py for some reason the plug-ins show some server in critical state with this message: CRITICAL - Connection to MongoDB failed!
its in a secure env so no authentication, I ran each check command that i have in my nrpe,cfg i.e:
command[check_mongo_connect]=/usr/local/nagios/libexec/check_mongodb.py -A connect -W 2 -C 4
command[check_mongo_free]=/usr/local/nagios/libexec/check_mongodb.py -A connections -W 70 -C 80
command[check_mongo_rep]=/usr/local/nagios/libexec/check_mongodb.py -A check_rep_lag -W 2 -C 80

on the client and the nagios host (with -H) it all returned connection ok but still nagios show them as critical, nrpe is running in xinetd.
Thanks
0
Comment
Question by:blah30
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
12 Comments
 
LVL 5

Expert Comment

by:stermeau
ID: 34905023
Hi,

Sometime I ran into problems because the scripts are running using the user nagios and this can cause a problem if you use some temporary files etc.
You can try to redirect stout and stderr to a file to get more information by adding the following at the end of the command line
   >> /tmp/check_mongodb.log 2>&1
0
 

Author Comment

by:blah30
ID: 34908432
Thanks going to give a try and let you know the result
0
 

Author Comment

by:blah30
ID: 34910611
Nothing is being logged in if i run the command manually it just say connection ok for the first command, no error message but still show this command as critical on nagios GUI
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 5

Expert Comment

by:stermeau
ID: 34910676
If you ran the command by hand, remove the file otherwise nagios would not be able to write to it.
Your commands looks lime this?
command[check_mongo_connect]=/usr/local/nagios/libexec/check_mongodb.py -A connect -W 2 -C 4 >> /tmp/check_mongodb.log 2>&1
command[check_mongo_free]=/usr/local/nagios/libexec/check_mongodb.py -A connections -W 70 -C 80 >> /tmp/check_mongodb.log 2>&1
command[check_mongo_rep]=/usr/local/nagios/libexec/check_mongodb.py -A check_rep_lag -W 2 -C 80 >> /tmp/check_mongodb.log 2>&1

But there is nothing in this file /tmp/check_mongodb.log ?
0
 

Author Comment

by:blah30
ID: 34911841
yep that's it for the command and their is no file created so far
0
 

Author Comment

by:blah30
ID: 34912519
Also I did /usr/local/nagios/libexec/check_nrpe -H xx.xx.xx.xx and the socket is timing out after 10 secondes, I have checked the linux iptables no rules here and checked the firewall the port 5666 is open as well as others that might be needed by it. Not sure where to look as I cannot find any infos on this issue.
0
 
LVL 5

Expert Comment

by:group0
ID: 34966223
I think you need to add -H x.x.x.x to each of your NRPE commands, even if it's just localhost, otherwise the check_mongo.py plugin won't know which server to contact.

The fact that you're getting "CRITICAL - Connection to MongoDB failed!" with a critical severity indicates that NRPE is running the command properly, as that's the what happens when pymongo.errors.ConnectionFailure is thrown inside the script.
0
 

Author Comment

by:blah30
ID: 34974269
HI group0 thanks for the answer,
I tried with the -H but to no avail i tried both public and private ip public will not work and the private does look like it work, now if i do from the nagios server  /usr/local/nagios/libexec/check_nrpe -H xx.xx.xx.xx then i get a CHECK_NRPE: Socket timeout after 10 seconds.
0
 

Author Comment

by:blah30
ID: 34975358
Strange thing is if i do the -H <10.xx.xx.xx>manually from the nagios server i will get the result expected
but so far i made the changes on the client and still no go.
Thanks.

nrpe command
command[check_mongo_connect]=/usr/local/nagios/libexec/check_mongodb.py -H localhost -A connect -W 2 -C 4                                                  
command[check_mongo_free]=/usr/local/nagios/libexec/check_mongodb.py -H localhost -A connections -W 70 -C 80                                                
command[check_mongo_rep]=/usr/local/nagios/libexec/check_mongodb.py -H localhost -A check_rep_lag -W 2 -C 80

like i said tried with the private ip as well to no avail
0
 

Author Comment

by:blah30
ID: 34975539
found the reason, someone took off the active check on nagios this does resolve this issue, thanks to everyone that helped i will distribute the point soon
0
 
LVL 5

Accepted Solution

by:
group0 earned 500 total points
ID: 34975567
Ok, so you're running check_nrpe on your nagios server, which connects to an NRPE instance that is running on your mongodb server?
Running check_mongo.py directly from the nagios server succeeds with -H 10.x.x.x, but fails when run directly on the mongodb server with -H 127.0.0.1 (localhost)?

Check to make sure that mongod is bound to all interfaces:

# netstat -nap|grep mongod
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      13656/mongod    
tcp        0      0 0.0.0.0:28017           0.0.0.0:*               LISTEN      13656/mongod    
unix  2      [ ACC ]     STREAM     LISTENING     98030135 13656/mongod        /tmp/mongodb-28017.sock
unix  2      [ ACC ]     STREAM     LISTENING     98030139 13656/mongod        /tmp/mongodb-27017.sock

If you see something like 10.x.x.x:27017 instead, the process is only bound to that specific IP, and that's the one to use in your NRPE configuration.
0
 
LVL 5

Expert Comment

by:group0
ID: 34975583
Ok, disregard my last comment, I see our updates crossed in the night :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question