#!/usr/bin/env python

## GENERATED FILE - DO NOT EDIT

import urllib2
import sys
import os  
import pymongo

def getServerStatus():
    if 'MONGO_DB_URI' in os.environ:
      c = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
    else:
      c = pymongo.MongoClient()

    return c.admin.command('serverStatus', workingSet=True)

name = "page_faults"

def get():
    return getServerStatus()["extra_info"][name]


def doData():
    print(name + ".value " + str(get()))


def doConfig():

    print "graph_title MongoDB page faults"
    print "graph_args --base 1000 -l 0"
    print "graph_vlabel faults / ${graph_period}"
    print "graph_category MongoDB"
    print "graph_total total"

    print name + ".label " + name
    print name + ".min 0"
    print name + ".type COUNTER"
    print name + ".max 10000"
    print name + ".draw LINE1"

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()
