forked from outlyerapp/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongodb.py
More file actions
executable file
·55 lines (51 loc) · 1.38 KB
/
mongodb.py
File metadata and controls
executable file
·55 lines (51 loc) · 1.38 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import sys
import subprocess
try:
ps = subprocess.Popen(('mongostat', '-n', '1', '--noheaders'), stdout=subprocess.PIPE)
output = subprocess.check_output(('tail', '-1'), stdin=ps.stdout)
ps.wait()
except:
print "Plugin Failed!"
sys.exit(2)
metrics = output.split()
insert = metrics[0].replace('*', '')
query = metrics[1].replace('*', '')
update = metrics[2].replace('*', '')
delete = metrics[3].replace('*', '')
getmore = metrics[4]
command = metrics[5].split('|')[0]
flushes = metrics[6]
mapped = metrics[7]
vsize = metrics[8]
res = metrics[9]
faults = metrics[10]
locked = metrics[11].replace('local:', '')
miss = metrics[12]
qrqw = metrics[13].split('|')[0]
araw = metrics[14].split('|')[0]
net_in = metrics[15]
net_out = metrics[16]
connections = metrics[17]
print "OK | insert=%s;;;; query=%s;;;; update=%s;;;; delete=%s;;;; getmore=%s;;;; command=%s;;;; " \
"flushes=%s;;;; mapped=%s;;;; vsize=%s;;;; res=%s;;;; faults=%s;;;; locked=%s;;;; " \
"miss=%s;;;; qrqw=%s;;;; araw=%s;;;; net_in=%s;;;; net_out=%s;;;; connections=%s;;;;" \
% (insert,
query,
update,
delete,
getmore,
command,
flushes,
mapped,
vsize,
res,
faults,
locked,
miss,
qrqw,
araw,
net_in,
net_out,
connections)
sys.exit(0)