Line | |
---|
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 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 | |
---|
9 | import os, sys, urllib, json |
---|
10 | |
---|
11 | if len(sys.argv) > 1 and sys.argv[1] == "config": |
---|
12 | print("""\ |
---|
13 | graph_title Tahoe Remaining Time Predictor |
---|
14 | graph_vlabel days remaining |
---|
15 | graph_category tahoe |
---|
16 | graph_info This graph shows the estimated number of days left until storage space is exhausted |
---|
17 | days_1hr.label days left (one hour sample) |
---|
18 | days_1hr.draw LINE1 |
---|
19 | days_1day.label days left (one day sample) |
---|
20 | days_1day.draw LINE1 |
---|
21 | days_2wk.label days left (two week sample) |
---|
22 | days_2wk.draw LINE2 |
---|
23 | days_4wk.label days left (four week sample) |
---|
24 | days_4wk.draw LINE2""") |
---|
25 | sys.exit(0) |
---|
26 | |
---|
27 | url = os.environ["url"] |
---|
28 | timespans = json.load(urllib.urlopen(url))["rates"] |
---|
29 | |
---|
30 | data = dict([(name, timeleft) |
---|
31 | for (name, timespan, growth, timeleft) in timespans |
---|
32 | if timeleft]) |
---|
33 | # timeleft is in seconds |
---|
34 | DAY = 24*60*60 |
---|
35 | if "1hr" in data: |
---|
36 | print("days_1hr.value", data["1hr"]/DAY) |
---|
37 | if "1day" in data: |
---|
38 | print("days_1day.value", data["1day"]/DAY) |
---|
39 | if "2wk" in data: |
---|
40 | print("days_2wk.value", data["2wk"]/DAY) |
---|
41 | if "4wk" in data: |
---|
42 | print("days_4wk.value", data["4wk"]/DAY) |
---|
Note: See
TracBrowser
for help on using the repository browser.