NewsBlur/vendor/python-munin/plugins/mongodb_lock_time
2016-11-11 11:06:33 -08:00

29 lines
797 B
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from vendor.munin.mongodb import MuninMongoDBPlugin
class MongoDBLockTime(MuninMongoDBPlugin):
args = "-l 0 --base 1000"
vlabel = "time"
title = "MongoDB global lock time"
info = "How long the global lock has been held"
fields = (
('locktime', dict(
label = "Global lock time",
info = "How long the global lock has been held",
type = "COUNTER",
min = "0",
)),
)
def execute(self):
status = self.connection.admin.command('serverStatus')
try:
value = int(status["globalLock"]["lockTime"])
except KeyError:
value = "U"
return dict(locktime=value)
if __name__ == "__main__":
MongoDBLockTime().run()