import repository from arizona
[raven.git] / owl / client / scripts.d / memory
1 #!/usr/bin/python
2
3 import subprocess
4
5 TEMPESTD_CMD="python /usr/local/stork/bin/tempestd.py"
6 TEMPEST_CMD="python /usr/local/stork/bin/tempest.py"
7 STORK_CMD="python /usr/local/stork/bin/stork.py"
8 STORKREPOSYNC_CMD="python /usr/local/stork/bin/storkreposync.py"
9 OWL_CMD="python /usr/local/bin/owld"
10
11 TEMPEST_CMD2="python /usr/bin/tempest"
12 STORK_CMD2="python /usr/bin/stork"
13 STORKREPOSYNC_CMD2="python /usr/bin/storkreposync"
14
15 ps = subprocess.Popen("ps --no-headers -aeo rss,cmd", shell=True, stdout=subprocess.PIPE)
16 output = ps.communicate()[0].split('\n')
17
18 total = 0
19 tempestd = 0
20 tempest = 0
21 stork = 0
22 storkreposync = 0
23 owl = 0
24
25 for line in output:
26     line = line.strip()
27     parts = line.split(" ", 1)
28     if len(parts)>=2:
29        rss = int(parts[0])
30        name = parts[1]
31        total = total + rss
32        if name.startswith(TEMPESTD_CMD):
33            tempestd = tempestd + rss
34        elif name.startswith(TEMPEST_CMD) or name.startswith(TEMPEST_CMD2):
35            tempest = tempest + rss
36        elif name.startswith(STORK_CMD) or name.startswith(STORK_CMD2):
37            stork = stork + rss
38        elif name.startswith(STORKREPOSYNC_CMD) or name.startswith(STORKREPOSYNC_CMD2):
39            storkreposync = storkreposync + rss
40        elif name.startswith(OWL_CMD):
41            owl = owl + rss
42
43 print "[memory]"
44 print "total="+str(total)
45 print "tempestd="+str(tempestd)
46 print "tempest="+str(tempest)
47 print "stork="+str(stork)
48 print "storkreposync="+str(storkreposync)
49 print "owl="+str(owl)