Solved

nagios + check_mongodb.py

Posted on 2011-02-15
12
1,779 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
  • 7
  • 3
  • 2
12 Comments
 
LVL 5

Expert Comment

by:stermeau
Comment Utility
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
Comment Utility
Thanks going to give a try and let you know the result
0
 

Author Comment

by:blah30
Comment Utility
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
 
LVL 5

Expert Comment

by:stermeau
Comment Utility
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
Comment Utility
yep that's it for the command and their is no file created so far
0
 

Author Comment

by:blah30
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 5

Expert Comment

by:group0
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Ok, disregard my last comment, I see our updates crossed in the night :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Creating and Managing Databases with phpMyAdmin in cPanel.
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…
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.:

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now