Line | |
---|
1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | |
---|
4 | import os, sys, re |
---|
5 | import urllib |
---|
6 | import json |
---|
7 | |
---|
8 | url = os.environ["url"] |
---|
9 | current = json.loads(urllib.urlopen(url).read()) |
---|
10 | |
---|
11 | configinfo = """\ |
---|
12 | graph_title Tahoe CPU Usage |
---|
13 | graph_vlabel CPU % |
---|
14 | graph_category tahoe |
---|
15 | graph_info This graph shows the 5min average of CPU usage for each process |
---|
16 | """ |
---|
17 | data = "" |
---|
18 | |
---|
19 | for (name, avg1, avg5, avg15) in current: |
---|
20 | dataname = re.sub(r'[^\w]', '_', name) |
---|
21 | configinfo += dataname + ".label " + name + "\n" |
---|
22 | configinfo += dataname + ".draw LINE2\n" |
---|
23 | if avg5 is not None: |
---|
24 | data += dataname + ".value %.2f\n" % (100.0 * avg5) |
---|
25 | |
---|
26 | if len(sys.argv) > 1: |
---|
27 | if sys.argv[1] == "config": |
---|
28 | print(configinfo.rstrip()) |
---|
29 | sys.exit(0) |
---|
30 | print(data.rstrip()) |
---|
Note: See
TracBrowser
for help on using the repository browser.