1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00
awx/tools/munin_monitors/mongo_conn
2015-06-08 16:23:37 -04:00

52 lines
1009 B
Python
Executable File

#!/usr/bin/env python
## GENERATED FILE - DO NOT EDIT
import urllib2
import sys
import os
import pymongo
def getServerStatus():
host = "127.0.0.1"
port = 27017
c = pymongo.MongoClient(host, port)
return c.admin.command('serverStatus', workingSet=True)
name = "connections"
def doData():
print name + ".value " + str( getServerStatus()["connections"]["current"] )
def doConfig():
print "graph_title MongoDB current connections"
print "graph_args --base 1000 -l 0"
print "graph_vlabel connections"
print "graph_category MongoDB"
print name + ".label " + name
if __name__ == "__main__":
from os import environ
if 'HOST' in environ:
host = environ['HOST']
if 'PORT' in environ:
port = environ['PORT']
if 'USER' in environ:
user = environ['USER']
if 'PASSWORD' in environ:
password = environ['PASSWORD']
if len(sys.argv) > 1 and sys.argv[1] == "config":
doConfig()
else:
doData()