From 271a38f0badf113746c441ae28ff983c11b6d06f Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Mon, 13 May 2013 16:54:57 -0400 Subject: [PATCH] Fix indexcounters and globallock in 2.2 and 2.4 version --- plugins/mongodb/mongo_btree | 6 +++++- plugins/mongodb/mongo_lock | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/mongodb/mongo_btree b/plugins/mongodb/mongo_btree index 81da375b..820b2f04 100755 --- a/plugins/mongodb/mongo_btree +++ b/plugins/mongodb/mongo_btree @@ -16,7 +16,11 @@ def getServerStatus(): return json.loads( raw )["serverStatus"] def get(): - return getServerStatus()["indexCounters"]["btree"] + status = getServerStatus() + if status["version"] >= "2.4.0": + return getServerStatus()["indexCounters"] + else: + return getServerStatus()["indexCounters"]["btree"] def doData(): for k,v in get().iteritems(): diff --git a/plugins/mongodb/mongo_lock b/plugins/mongodb/mongo_lock index 5a846f50..af093a0e 100755 --- a/plugins/mongodb/mongo_lock +++ b/plugins/mongodb/mongo_lock @@ -18,7 +18,12 @@ def getServerStatus(): name = "locked" def doData(): - print name + ".value " + str( 100 * getServerStatus()["globalLock"]["ratio"] ) + status = getServerStatus() + if status["version"] >= "2.2.0": + ratio = status["globalLock"]["lockTime"] / status["globalLock"]["totalTime"] + else: + ratio = status["globalLock"]["ratio"] + print name + ".value " + str( 100 * ratio ) def doConfig():