-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo_network.py
executable file
·38 lines (28 loc) · 994 Bytes
/
mongo_network.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import sys
from pymongo import MongoClient
def get_status(topic=None):
mc = MongoClient()
status = mc.local.command('serverStatus')
return status[topic] if topic else status
def get_config():
print "graph_title MongoDB network stats"
print "graph_args --base 1000 --lower-limit 0"
print "graph_category MongoDB"
print "graph_vlabel bytes in (-) / out (+) per ${graph_period}"
print "bytesOut.label Out"
print "bytesOut.type COUNTER"
print "bytesOut.draw AREA"
print "bytesOut.min 0"
print "bytesOut.max 100000000"
print "bytesIn.label In"
print "bytesIn.type COUNTER"
print "bytesIn.draw LINE2"
print "bytesIn.min 0"
print "bytesIn.max 100000000"
# print "bytesIn.cdef 0,bytesIn,-"
def get_data():
data = get_status("network")
print "bytesIn.value " + str(data["bytesIn"])
print "bytesOut.value " + str(data["bytesOut"])
get_config() if sys.argv[-1] == "config" else get_data()