Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get DB/collection/index stats in a replica set. #206

Open
fuqqer opened this issue Nov 23, 2016 · 8 comments
Open

Can't get DB/collection/index stats in a replica set. #206

fuqqer opened this issue Nov 23, 2016 · 8 comments

Comments

@fuqqer
Copy link

fuqqer commented Nov 23, 2016

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.

@bert2002
Copy link

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.

@bert2002
Copy link

Any thoughts or ideas?

@wpowell-ossg
Copy link

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

@wpowell-ossg
Copy link

...also is this a standalone db or a replica set, and if it IS an RS, how many nodes?

@bert2002
Copy link

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

@bert2002
Copy link

bert2002 commented Jan 11, 2017

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)

@wpowell-ossg
Copy link

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

@bert2002
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants