lib/city_watch/watchmen/disk_usage.rb in city-watch-0.5.2 vs lib/city_watch/watchmen/disk_usage.rb in city-watch-0.5.3

- old
+ new

@@ -1,11 +1,24 @@ class DiskUsage include Watchman + set_default :usage_threshold, 60 + def self.data dat = DF.data sum = dat.select {|d| d[:mounted]=="/"}.first {:partitions => dat, :summary => sum[:capacity] || sum["use%".to_sym]} + end + + add_rule(:root_usage_high) do |data| + + if (usage = data[:summary].to_i) && usage > option(:usage_threshold) + send_alert "Root disk usage is over #{option(:usage_threshold)}% (#{usage}%)", data[:partitions].select {|d| d[:mounted]=="/"}.first + set_flag :root_disk_over_quota + else + clear_flag :root_disk_over_quota + end + end end \ No newline at end of file