2008-11-05 01:03:06 +00:00
|
|
|
#!/usr/bin/env python
|
2008-08-07 06:00:03 +00:00
|
|
|
|
|
|
|
# This is a munin plugin which pulls data from the server in
|
2010-06-07 05:16:18 +00:00
|
|
|
# misc/operations_helpers/spacetime/diskwatcher.tac . It produces a graph of how much disk space
|
2008-08-07 06:00:03 +00:00
|
|
|
# is being used per unit time. The plugin should be configured with env_url=
|
|
|
|
# pointing at the diskwatcher.tac webport.
|
|
|
|
|
2019-03-22 10:40:58 +00:00
|
|
|
|
2017-01-19 22:39:53 +00:00
|
|
|
import os, sys, urllib, json
|
2008-08-07 06:00:03 +00:00
|
|
|
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
2019-03-22 10:40:58 +00:00
|
|
|
print("""\
|
2008-08-07 06:00:03 +00:00
|
|
|
graph_title Tahoe Disk Usage Measurement
|
|
|
|
graph_vlabel bytes per second
|
|
|
|
graph_category tahoe
|
|
|
|
graph_info This graph shows the estimated disk usage per unit time, totalled across all storage servers
|
2008-08-27 19:35:43 +00:00
|
|
|
graph_args --lower-limit 0 --rigid
|
2008-08-07 06:00:03 +00:00
|
|
|
rate_1hr.label (one hour sample)
|
|
|
|
rate_1hr.draw LINE1
|
|
|
|
rate_1day.label (one day sample)
|
|
|
|
rate_1day.draw LINE1
|
|
|
|
rate_2wk.label (two week sample)
|
|
|
|
rate_2wk.draw LINE2
|
|
|
|
rate_4wk.label (four week sample)
|
2019-03-22 10:40:58 +00:00
|
|
|
rate_4wk.draw LINE2""")
|
2008-08-07 06:00:03 +00:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
url = os.environ["url"]
|
2017-01-19 22:39:53 +00:00
|
|
|
timespans = json.load(urllib.urlopen(url))["rates"]
|
2008-08-07 06:00:03 +00:00
|
|
|
|
|
|
|
data = dict([(name, growth)
|
|
|
|
for (name, timespan, growth, timeleft) in timespans])
|
|
|
|
# growth is in bytes per second
|
|
|
|
if "1hr" in data:
|
2019-03-22 10:40:58 +00:00
|
|
|
print("rate_1hr.value", data["1hr"])
|
2008-08-07 06:00:03 +00:00
|
|
|
if "1day" in data:
|
2019-03-22 10:40:58 +00:00
|
|
|
print("rate_1day.value", data["1day"])
|
2008-08-07 06:00:03 +00:00
|
|
|
if "2wk" in data:
|
2019-03-22 10:40:58 +00:00
|
|
|
print("rate_2wk.value", data["2wk"])
|
2008-08-07 06:00:03 +00:00
|
|
|
if "4wk" in data:
|
2019-03-22 10:40:58 +00:00
|
|
|
print("rate_4wk.value", data["4wk"])
|