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

General MongoDB Error: name must be an instance of basestring #232

Open
solarisfire opened this issue Nov 10, 2017 · 6 comments
Open

General MongoDB Error: name must be an instance of basestring #232

solarisfire opened this issue Nov 10, 2017 · 6 comments

Comments

@solarisfire
Copy link

Running the following command:

/usr/lib64/nagios/plugins/check_mongodb.py -H mongo-2 -P 10000 -D -A replication_lag_percent -u *** -p *** -W 50 -C 75

Returns:
CRITICAL - General MongoDB Error: name must be an instance of basestring

@solarisfire
Copy link
Author

This doesn't happen when run against a primary, which returns: "OK - This is the primary.", but only against a secondary node.

@merlyel
Copy link

merlyel commented Dec 8, 2017

Confirming this one
The problem happens in here:

if percent:
     err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), False, user, passwd)

@bvogel1509
Copy link

bvogel1509 commented Jan 18, 2018

Hi,

I have the same issue but as i'm running mongodb 3.0, the problem happens here :

if percent: err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), ssl, user, passwd, None, None, insecure, ssl_ca_cert_file, cert_file)

None, None means replicaset=None, authdb=None. This is not valid as you must supply a valid database name to authenticate.

A correct call is :

if percent: err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), ssl, user, passwd, replica, authdb, insecure, ssl_ca_cert_file, cert_file)

but you have to change the prototype of function check_rep_lag

def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_lag, user, passwd, ssl=None, insecure=None, ssl_ca_cert_file=None, cert_file=None)

with

def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_lag, user, passwd, replica=None, authdb="admin", ssl=None, insecure=None, ssl_ca_cert_file=None, cert_file=None)

Hope this help

@dbuelow
Copy link

dbuelow commented Nov 2, 2018

Same issue.
this is really a great script, but it looks like there is no further development here?

@kagahd
Copy link

kagahd commented Jul 31, 2019

I've created a pull request which solves this issue. See #245

@akhmolina
Copy link

I have the same.
Realy need this small fix!

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

6 participants