?
Solved

nagios + check_mongodb.py

Posted on 2011-02-15
12
Medium Priority
?
1,871 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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 2000 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

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this article, we’ll look at how to deploy ProxySQL.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

800 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