2008-08-07 06:00:03 +00:00
|
|
|
#! /usr/bin/python
|
|
|
|
|
|
|
|
# This is a munin plugin which pulls data from the server in
|
|
|
|
# misc/spacetime/diskwatcher.tac . It produces a graph of how much time is
|
|
|
|
# left before the grid fills up. The plugin should be configured with
|
|
|
|
# env_url= pointing at the diskwatcher.tac webport.
|
|
|
|
|
|
|
|
import os, sys, urllib, simplejson
|
|
|
|
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
|
|
|
print """\
|
2008-08-27 21:30:13 +00:00
|
|
|
graph_title Tahoe Remaining Time Predictor
|
2008-08-07 06:00:03 +00:00
|
|
|
graph_vlabel days remaining
|
|
|
|
graph_category tahoe
|
|
|
|
graph_info This graph shows the estimated number of days left until storage space is exhausted
|
|
|
|
days_1hr.label days left (one hour sample)
|
|
|
|
days_1hr.draw LINE1
|
|
|
|
days_1day.label days left (one day sample)
|
|
|
|
days_1day.draw LINE1
|
|
|
|
days_2wk.label days left (two week sample)
|
|
|
|
days_2wk.draw LINE2
|
|
|
|
days_4wk.label days left (four week sample)
|
|
|
|
days_4wk.draw LINE2"""
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
url = os.environ["url"]
|
2008-08-07 20:12:14 +00:00
|
|
|
timespans = simplejson.load(urllib.urlopen(url))["rates"]
|
2008-08-07 06:00:03 +00:00
|
|
|
|
|
|
|
data = dict([(name, timeleft)
|
2008-09-30 20:20:51 +00:00
|
|
|
for (name, timespan, growth, timeleft) in timespans
|
|
|
|
if timeleft])
|
2008-08-07 06:00:03 +00:00
|
|
|
# timeleft is in seconds
|
|
|
|
DAY = 24*60*60
|
|
|
|
if "1hr" in data:
|
|
|
|
print "days_1hr.value", data["1hr"]/DAY
|
|
|
|
if "1day" in data:
|
2008-08-11 20:34:31 +00:00
|
|
|
print "days_1day.value", data["1day"]/DAY
|
2008-08-07 06:00:03 +00:00
|
|
|
if "2wk" in data:
|
2008-08-11 20:34:31 +00:00
|
|
|
print "days_2wk.value", data["2wk"]/DAY
|
2008-08-07 06:00:03 +00:00
|
|
|
if "4wk" in data:
|
2008-08-11 20:34:31 +00:00
|
|
|
print "days_4wk.value", data["4wk"]/DAY
|