2008-11-05 01:03:06 +00:00
|
|
|
#!/usr/bin/env python
|
2008-05-07 20:19:08 +00:00
|
|
|
|
2019-03-22 10:40:58 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2008-05-07 20:19:08 +00:00
|
|
|
import os, sys, re
|
|
|
|
import urllib
|
2017-01-19 22:39:53 +00:00
|
|
|
import json
|
2008-05-07 20:19:08 +00:00
|
|
|
|
|
|
|
url = os.environ["url"]
|
2017-01-19 22:39:53 +00:00
|
|
|
current = json.loads(urllib.urlopen(url).read())
|
2008-05-07 20:19:08 +00:00
|
|
|
|
|
|
|
configinfo = """\
|
|
|
|
graph_title Tahoe CPU Usage
|
|
|
|
graph_vlabel CPU %
|
|
|
|
graph_category tahoe
|
|
|
|
graph_info This graph shows the 5min average of CPU usage for each process
|
|
|
|
"""
|
|
|
|
data = ""
|
|
|
|
|
|
|
|
for (name, avg1, avg5, avg15) in current:
|
|
|
|
dataname = re.sub(r'[^\w]', '_', name)
|
|
|
|
configinfo += dataname + ".label " + name + "\n"
|
|
|
|
configinfo += dataname + ".draw LINE2\n"
|
|
|
|
if avg5 is not None:
|
|
|
|
data += dataname + ".value %.2f\n" % (100.0 * avg5)
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
if sys.argv[1] == "config":
|
2019-03-22 10:40:58 +00:00
|
|
|
print(configinfo.rstrip())
|
2008-05-07 20:19:08 +00:00
|
|
|
sys.exit(0)
|
2019-03-22 10:40:58 +00:00
|
|
|
print(data.rstrip())
|