mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-14 06:06:40 +00:00
munin: add tahoe_diskleft plugin, update spacetime/diskwatcher.tac to support it
This commit is contained in:
parent
670a50c394
commit
be11bfe812
22
misc/munin/tahoe_diskleft
Normal file
22
misc/munin/tahoe_diskleft
Normal file
@ -0,0 +1,22 @@
|
||||
#! /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 free space
|
||||
# is left on all disks across the grid. 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 """\
|
||||
graph_title Tahoe Remaining Disk Space
|
||||
graph_vlabel bytes remaining
|
||||
graph_category tahoe
|
||||
graph_info This graph shows the total amount of disk space left available in the grid
|
||||
disk_left.label disk left
|
||||
disk_left.draw LINE1"""
|
||||
sys.exit(0)
|
||||
|
||||
url = os.environ["url"]
|
||||
data = simplejson.load(urllib.urlopen(url))["available"]
|
||||
print "disk_left.value", data
|
@ -152,7 +152,7 @@ class DiskWatcher(service.MultiService, resource.Resource):
|
||||
|
||||
def calculate_growth_timeleft(self):
|
||||
timespans = []
|
||||
total_avail_space = self.find_total_avail_space()
|
||||
total_avail_space = self.find_total_available_space()
|
||||
pairs = [ (timespan,name)
|
||||
for name,timespan in self.AVERAGES.items() ]
|
||||
pairs.sort()
|
||||
@ -166,7 +166,7 @@ class DiskWatcher(service.MultiService, resource.Resource):
|
||||
timespans.append( (name, timespan, growth, timeleft) )
|
||||
return timespans
|
||||
|
||||
def find_total_avail_space(self):
|
||||
def find_total_available_space(self):
|
||||
# this returns the sum of disk-avail stats for all servers that 1)
|
||||
# are listed in urls.txt and 2) have responded recently.
|
||||
now = extime.Time()
|
||||
@ -293,6 +293,7 @@ class DiskWatcher(service.MultiService, resource.Resource):
|
||||
elif t == "json":
|
||||
current = {"rates": self.calculate_growth_timeleft(),
|
||||
"used": self.find_total_used_space(),
|
||||
"available": self.find_total_available_space(),
|
||||
}
|
||||
data = simplejson.dumps(current, indent=True)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user