Sha256: b498ce99e1c4e97f032e3354ec264de31489fdc07adfb11c3753256f4719a13d
Contents?: true
Size: 547 Bytes
Versions: 1
Compression:
Stored size: 547 Bytes
Contents
class Uptime include Watchman set_default :uptime_file, '/proc/uptime' def self.data return {} if !File.exists?(option(:uptime_file)) out = {} out[:uptime], out[:idle] = File.read(option(:uptime_file)).strip.split.map {|t| Float(t) } base = out.dup [[:minutes,Proc.new{|t| t / 60 }],[:hours,Proc.new{|t| t / (60*60) }],[:days,Proc.new{|t| t / (60*60*24) }]].each do |(id,func)| base.each do |k,v| out["#{k.to_s}_#{id.to_s}".to_sym] = func.call(v).round(2) end end out.merge({:summary => [:uptime_days]}) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
city-watch-0.5.7 | lib/city_watch/watchmen/uptime.rb |