summaryrefslogtreecommitdiff
path: root/lib/byteback/disk_free_history.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/byteback/disk_free_history.rb')
-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