]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/operations_helpers/munin/tahoe_diskusage
setup: organize misc/ scripts and tools and remove obsolete ones
[tahoe-lafs/tahoe-lafs.git] / misc / operations_helpers / munin / tahoe_diskusage
1 #!/usr/bin/env python
2
3 # This is a munin plugin which pulls data from the server in
4 # misc/operations_helpers/spacetime/diskwatcher.tac . It produces a graph of how much disk space
5 # is being used per unit time. The plugin should be configured with env_url=
6 # 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 Disk Usage Measurement
13 graph_vlabel bytes per second
14 graph_category tahoe
15 graph_info This graph shows the estimated disk usage per unit time, totalled across all storage servers
16 graph_args --lower-limit 0 --rigid
17 rate_1hr.label (one hour sample)
18 rate_1hr.draw LINE1
19 rate_1day.label (one day sample)
20 rate_1day.draw LINE1
21 rate_2wk.label (two week sample)
22 rate_2wk.draw LINE2
23 rate_4wk.label (four week sample)
24 rate_4wk.draw LINE2"""
25     sys.exit(0)
26
27 url = os.environ["url"]
28 timespans = simplejson.load(urllib.urlopen(url))["rates"]
29
30 data = dict([(name, growth)
31              for (name, timespan, growth, timeleft) in timespans])
32 # growth is in bytes per second
33 if "1hr" in data:
34     print "rate_1hr.value", data["1hr"]
35 if "1day" in data:
36     print "rate_1day.value", data["1day"]
37 if "2wk" in data:
38     print "rate_2wk.value", data["2wk"]
39 if "4wk" in data:
40     print "rate_4wk.value", data["4wk"]