]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/munin/tahoe_doomsday
quickstart.html: link to snapshots page, sorted with most recent first.
[tahoe-lafs/tahoe-lafs.git] / misc / munin / tahoe_doomsday
1 #!/usr/bin/env python
2
3 # This is a munin plugin which pulls data from the server in
4 # misc/spacetime/diskwatcher.tac . It produces a graph of how much time is
5 # left before the grid fills up. The plugin should be configured with
6 # env_url= pointing at the diskwatcher.tac webport.
7
8 import os, sys, urllib, simplejson
9
10 if len(sys.argv) > 1 and sys.argv[1] == "config":
11     print """\
12 graph_title Tahoe Remaining Time Predictor
13 graph_vlabel days remaining
14 graph_category tahoe
15 graph_info This graph shows the estimated number of days left until storage space is exhausted
16 days_1hr.label days left (one hour sample)
17 days_1hr.draw LINE1
18 days_1day.label days left (one day sample)
19 days_1day.draw LINE1
20 days_2wk.label days left (two week sample)
21 days_2wk.draw LINE2
22 days_4wk.label days left (four week sample)
23 days_4wk.draw LINE2"""
24     sys.exit(0)
25
26 url = os.environ["url"]
27 timespans = simplejson.load(urllib.urlopen(url))["rates"]
28
29 data = dict([(name, timeleft)
30              for (name, timespan, growth, timeleft) in timespans
31              if timeleft])
32 # timeleft is in seconds
33 DAY = 24*60*60
34 if "1hr" in data:
35     print "days_1hr.value", data["1hr"]/DAY
36 if "1day" in data:
37     print "days_1day.value", data["1day"]/DAY
38 if "2wk" in data:
39     print "days_2wk.value", data["2wk"]/DAY
40 if "4wk" in data:
41     print "days_4wk.value", data["4wk"]/DAY