lib/ganymed/collector/uptime.rb in ganymed-0.1.0 vs lib/ganymed/collector/uptime.rb in ganymed-0.1.1

- old
+ new

@@ -2,12 +2,13 @@ module Ganymed class Collector class Uptime < Base def collect! - File.open('/proc/uptime') do |f| - uptime = f.read.chomp.split.first.to_f - boottime = Time.now - uptime + return if not File.readable?('/proc/stat') + File.open('/proc/stat').each do |line| + next if not line =~ /^btime / + boottime = Time.at(line.chomp.split[1].to_i) @processor.event("os.reboot", 1, :now => boottime) end end end end