Page 1 of 1

Mongo DB monitoring Error

Posted: Wed Feb 27, 2019 4:09 am
by lrnnetops
Hi Team,

We are trying to monitor our Mongo DB servers which are in cluster.

Nagios XI = 5.5.7
Python version on Nagios Xi server = 2.6.6
Mongo DB server Version = v3.6.5

Tested connectivity from Nagios Xi server to Mongo DB server using telnet & its working.
We created user with "clusterAdmin" role. tested login from Nagios XI server using mongo shell & able to successfully login on mongo DB server.

However when we trying to monitor mongo DB server using below command we are getting below error.

================
/usr/local/nagios/libexec/check_mongodb.py -H xxx.xxx.xxx.xxx -A connect -P xxxxx -W 2 -C 4 -u xxxxxxxx -p xxxxxxxx -D --all-databases
Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'OperationFailure' object has no attribute 'strip'
================

Note = we are using backdated version of "check_mongodb.py" as we are not planning to upgrade python version & upgraded "check_mongodb.py" i guess required python 2.7.x. so we using backdated version of "check_mongodb.py" from which we are able to successfully monitor other mongo servers which are not in cluster.

when we tried with upgraded "check_mongodb.py" we got below error.

=============
/usr/local/nagios/libexec/check_mongodb_upgrade.py -H xxx.xxx.xxx.xxx -A connect -P xxxxx -W 2 -C 4 -u xxxxxxxx -p xxxxxxxx -D --all-databases
Username/Password incorrect
=============

Attached (
mondo_db_monitoring_error.jpg
) for the error we are getting on XI.

Please suggest the fix for the same.

Re: Mongo DB monitoring Error

Posted: Wed Feb 27, 2019 3:03 pm
by cdienger
It's likely failing for both versions for the same reasons but the newer one handles it a bit better. Are there any special characters in the username or password? Can you try simple credentials as a test? The message indicates a failure to login - are there any logs on the mongo db side regarding this failure?

Re: Mongo DB monitoring Error

Posted: Wed Apr 03, 2019 12:21 pm
by lrnnetops
Hi cdienger,

No Special characters in username as well as password.

We tested login to Mongo DB server by installing mongo client on Nagios server (Output as below).
mongo_cli_login.jpg
Using same credentials we tried old version check_mongodb.py plugin but got below error.
output_of_old_check_mongodb_py.jpg
We also tested with updated check_mongodb_upgrade.py plugin & got below error.
output_of_updated_check_mongodb_py.jpg
Please check & let us know the fix on it.

Re: Mongo DB monitoring Error

Posted: Wed Apr 03, 2019 4:07 pm
by npolovenko
@ lrnnetops, Can you check and let us know which version of pymongo you have installed on the Nagios server?
[root@centos7x64 libexec]# pip list installed | grep pymongo
pymongo (3.7.2)
What version of MongoDB and what kind of authentication schema is being used? MONGODB-CR, SCRAM-SHA-1 or another one?

Re: Mongo DB monitoring Error

Posted: Thu Apr 04, 2019 8:21 am
by lrnnetops
Hi npolovenko,

Pymongo version is = pymongo (2.5.2)

Mongo server version as below =

================
db version v3.6.5
allocator: tcmalloc
modules: enterprise
build environment:
distmod: amzn64
distarch: x86_64
target_arch: x86_64
================

We are not sure about authentication schema. if possible can you share the db query which can fetch this data. We are sharing our mongo config as below.

================
# network interfaces
net:
port: <PORT>
bindIp: <PRIVATE IP>,127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.


#security:
security:
authorization: enabled
keyFile: /etc/mongod/<KEYFILENAME>

enableEncryption: true
encryptionCipherMode: AESXXX-XXX
encryptionKeyFile: /etc/mongod/<ENCRYPTION KEY FILE>

#operationProfiling:

replication:
replSetName: "<REPL NAME>"

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:
================

Let me know if you require any details.

Re: Mongo DB monitoring Error

Posted: Thu Apr 04, 2019 9:11 am
by npolovenko
@lrnnetops, Can you update pymongo to the version 3.7.2 and let me know if it fixes the issue?

Re: Mongo DB monitoring Error

Posted: Thu Apr 04, 2019 11:26 am
by lrnnetops
Hi npolovenko,

We are using old version of plugin "check_mongodb.py" for mongo DB monitoring as newer version of plugin requires python 2.7.
Our server currently running with python 2.6.6.

Please confirm upgrading pymongo to the version 3.7.2 wont affect our current mongo DB monitoring.

Re: Mongo DB monitoring Error

Posted: Thu Apr 04, 2019 2:34 pm
by npolovenko
@lrnnetops, Do you happen to have a linux box or a VM with a newer python version? That way you could upload the new plugin there, upgrade pymongo and test it out with your MongoDB database. That way we'll know for sure if python version is the issue.