nagios-plugin-mongodb icon indicating copy to clipboard operation
nagios-plugin-mongodb copied to clipboard

General MongoDB Error: name must be an instance of basestring

Open solarisfire opened this issue 7 years ago • 6 comments

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 avatar Nov 10 '17 16:11 solarisfire

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

solarisfire avatar Nov 10 '17 16:11 solarisfire

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)

merlyel avatar Dec 08 '17 15:12 merlyel

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

bvogel1509 avatar Jan 18 '18 18:01 bvogel1509

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

dbuelow avatar Nov 02 '18 12:11 dbuelow

I've created a pull request which solves this issue. See https://github.com/mzupan/nagios-plugin-mongodb/pull/245

kagahd avatar Jul 31 '19 09:07 kagahd

I have the same. Realy need this small fix!

akhmolina avatar May 25 '20 17:05 akhmolina