mongo-munin icon indicating copy to clipboard operation
mongo-munin copied to clipboard

mongo_lock throws an error

Open ebeyrent opened this issue 11 years ago • 4 comments

I am running mongo 2.4.8, and with the latest code from this repo, I get a key error when running the mongo_lock plugin:

$ ./mongo_lock Traceback (most recent call last): File "./mongo_lock", line 54, in doData() File "./mongo_lock", line 34, in doData print name + ".value " + str( 100 * getServerStatus()["globalLock"]["ratio"] ) KeyError: 'ratio'

ebeyrent avatar Jan 16 '14 15:01 ebeyrent

@ebeyrent take a look here: http://munin-monitoring.org/browser/munin-contrib/plugins/mongodb/mongo_lock

danvaida avatar Apr 10 '14 10:04 danvaida

@ebeyrent I've forked this some time ago, merged in some of the other forks and added some more stuff. Can't guarantee I'll keep developing on it, but feel free to have a look :-p

meersjo avatar Apr 10 '14 10:04 meersjo

Seems to be easy to solve. The command "curl http://127.0.0.1:28017/_status" doesn't return any "ratio" in "globalLock" variable, but returns lockTime and totalTime. The ratio (I think that this is the question) is lock/total. The only change is in the doData() function below.

def doData(): lock = getServerStatus()["globalLock"]["lockTime"] total = getServerStatus()["globalLock"]["totalTime"] print name + ".value " + str( 100.000 * lock / total)

I will send a pull request soon. Best regards,

jrborbars avatar Jan 15 '15 21:01 jrborbars

Just a quick patch for the similar issue. It just happened that we got these plugins on mongo router, which has mongos process and does not return indexCounters on db.serverStatus() call:

OLD: def get(): return getServerStatus()["indexCounters"]

NEW: def get(): if getServerStatus()["process"] == "mongos": print "This is mongo router. Please use this script on mongod servers ONLY" exit() return 0

gregpolevoy avatar Apr 07 '15 19:04 gregpolevoy