Solved

nagios + check_mongodb.py

Posted on 2011-02-15
12
1,854 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

728 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