erh / mongo-munin

Munin plugins for MongoDB
144 stars 59 forks source link

mongo_lock throws an error #12

Open ebeyrent opened 10 years ago

ebeyrent commented 10 years ago

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'

danvaida commented 10 years ago

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

meersjo commented 10 years ago

@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

jrborbars commented 9 years ago

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,

gregpolevoy commented 9 years ago

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