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 | |
---|
9 | import os, sys, urllib, json |
---|
10 | |
---|
11 | if len(sys.argv) > 1 and sys.argv[1] == "config": |
---|
12 | print("""\ |
---|
13 | graph_title Tahoe Disk Usage Measurement |
---|
14 | graph_vlabel bytes per second |
---|
15 | graph_category tahoe |
---|
16 | graph_info This graph shows the estimated disk usage per unit time, totalled across all storage servers |
---|
17 | graph_args --lower-limit 0 --rigid |
---|
18 | rate_1hr.label (one hour sample) |
---|
19 | rate_1hr.draw LINE1 |
---|
20 | rate_1day.label (one day sample) |
---|
21 | rate_1day.draw LINE1 |
---|
22 | rate_2wk.label (two week sample) |
---|
23 | rate_2wk.draw LINE2 |
---|
24 | rate_4wk.label (four week sample) |
---|
25 | rate_4wk.draw LINE2""") |
---|
26 | sys.exit(0) |
---|
27 | |
---|
28 | url = os.environ["url"] |
---|
29 | timespans = json.load(urllib.urlopen(url))["rates"] |
---|
30 | |
---|
31 | data = dict([(name, growth) |
---|
32 | for (name, timespan, growth, timeleft) in timespans]) |
---|
33 | # growth is in bytes per second |
---|
34 | if "1hr" in data: |
---|
35 | print("rate_1hr.value", data["1hr"]) |
---|
36 | if "1day" in data: |
---|
37 | print("rate_1day.value", data["1day"]) |
---|
38 | if "2wk" in data: |
---|
39 | print("rate_2wk.value", data["2wk"]) |
---|
40 | if "4wk" in data: |
---|
41 | print("rate_4wk.value", data["4wk"]) |
---|