summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatthew Bloch <matthew@bytemark.co.uk>2014-11-20 10:45:49 +0000
committerMatthew Bloch <matthew@bytemark.co.uk>2014-11-20 10:45:49 +0000
commit1249ecead709465ac035058fa749ebcf80a14bb5 (patch)
treee66ef4946c8acc19b3bdd86daa3cae8d713a9594 /lib
parent03a72c4f805ed68552520e1695ff0c794f30fa6d (diff)
Added extra attributes to DiskFreeHistory (needed by byteback-prune).
Diffstat (limited to 'lib')
-rwxr-xr-xlib/byteback/disk_free_history.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/byteback/disk_free_history.rb b/lib/byteback/disk_free_history.rb
index daa68bc..6be8143 100755
--- a/lib/byteback/disk_free_history.rb
+++ b/lib/byteback/disk_free_history.rb
@@ -20,6 +20,8 @@ module Byteback
# point's disk space history.
#
class DiskFreeHistory
+ attr_reader :mountpoint, :history_file
+
MINIMUM_INTERVAL = 5*60 # don't take readings more than 5 mins apart
MAXIMUM_AGE = 7*24*60*60 # delete readings after a week
@@ -71,11 +73,13 @@ module Byteback
value_from_reading.call(later_reading)
total += difference
end
- break if reading.time < earliest
readings += 1
+ break if reading.time < earliest
later_reading = reading
end
+ return 0 if readings == 0
+
total / readings
end