Solved

nagios + check_mongodb.py

Posted on 2011-02-15
12
1,813 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
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wipe a usb using python 5 44
LINUX backups with VEEAM 8 75
Querying data from 3 SQL tables 2 30
MySQL Query Using Up Memory 6 21
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

813 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

14 Experts available now in Live!

Get 1:1 Help Now