Open fuqqer opened 7 years ago
Same problem here and only for for the replication_lag check. Any solution? Using python 2.7.6 on Ubuntu 14.04 and pymongo 2.6.3.
Any thoughts or ideas?
Yep, it will be the read preference that it is trying to set. Either your pymongo driver or mongodb instance is low rev and has a problem setting read preference to secondary. Initially try commenting out the line "set_read_preference(con.admin)" on line 961 of the check mongodb script to see if it runs ok, then let us know version of pymongo driver and mongodb
...also is this a standalone db or a replica set, and if it IS an RS, how many nodes?
Hi, i commented "set_read_preference(con.admin)" in line 119 (961 does not have the mentioned value). python-pymongo is 2.6.3-1build1 and mongodb 3.2.4. The setup is a master with one replicate set and I run the scrip against the replicate.
/usr/lib/nagios/plugins/check_mongodb.py -H $ADDRESS -A replication_lag
Argh. Just used the latest version of the plugin and it seems to work:
python check_mongodb.py -H $ADDRESS -A replication_lag OK - State: 7 (Arbiter on port 27017)
Be aware that you cannot do stat quries on Arbiters. This code in the mongo_connect function just returns that message:
if 'arbiterOnly' in result and result['arbiterOnly'] == True:
print "OK - State: 7 (Arbiter on port %s)" % (port)
sys.exit(0)
So to get a valid result for the repl lag, you will need to query a secondary or primary, not an arbiter
Ohhh thats a good point. When I query a primary I get this:
/usr/lib/nagios/plugins/check_mongodb.py -H $ADDRESS -A replication_lag OK - This is the primary.
Looks much better now :) Thx for pointing this out.
Trying to run check_mongodb.py against a replica set with this - check_mongodb.py -H mongohostX -A database_indexes -P 27017 -d database -u mongouser -p secret
it returns - CRITICAL - General MongoDB Error: 'module' object has no attribute 'Secondary'
I have tried connecting to both my primary and secondary servers in a replica set and get the same failure.