bin/check-mongodb.py in sensu-plugins-mongodb-1.1.0 vs bin/check-mongodb.py in sensu-plugins-mongodb-1.2.0
- old
+ new
@@ -317,11 +317,13 @@
print "CRITICAL - General MongoDB Error:", e
return 2
def set_read_preference(db):
- if pymongo.version >= "2.1":
+ if pymongo.version >= "2.2":
+ pymongo.read_preferences.Secondary
+ else:
db.read_preference = pymongo.ReadPreference.SECONDARY
def check_connect(host, port, warning, critical, perf_data, user, passwd, conn_time):
warning = warning or 3
@@ -423,11 +425,11 @@
lastSlaveOpTime = member['optimeDate']
replicationLag = abs(primary_node["optimeDate"] - lastSlaveOpTime).seconds - slaveDelays[member['name']]
data = data + member['name'] + " lag=%d;" % replicationLag
maximal_lag = max(maximal_lag, replicationLag)
if percent:
- err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), False, user, passwd)
+ err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), False, user=user, passwd=passwd)
if err != 0:
return err
primary_timediff = replication_get_time_diff(con)
maximal_lag = int(float(maximal_lag) / float(primary_timediff) * 100)
message = "Maximal lag is " + str(maximal_lag) + " percents"
@@ -455,10 +457,10 @@
lag = optime_lag.total_seconds()
except:
lag = float(optime_lag.seconds + optime_lag.days * 24 * 3600)
if percent:
- err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), False, user, passwd)
+ err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), False, user=user, passwd=passwd)
if err != 0:
return err
primary_timediff = replication_get_time_diff(con)
if primary_timediff != 0:
lag = int(float(lag) / float(primary_timediff) * 100)