Class: Uptime

Inherits:
Object
  • Object
show all
Includes:
Watchman
Defined in:
lib/city_watch/watchmen/uptime.rb

Class Method Summary collapse

Methods included from Watchman

#data, included

Class Method Details

.dataObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/city_watch/watchmen/uptime.rb', line 7

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