Class: UWA::Widget::SysLoad

Inherits:
Handler
  • Object
show all
Defined in:
lib/uwa_sysload/config.rb,
lib/uwa_sysload/widget.rb

Constant Summary collapse

NAME =
'uwa_sysload'
VERSION =
'0.3'
'Copyright (C) 2007 Florent Solt'
DESC =
'UWA System Load Monitor widget'
AUTHOR =
'Florent Solt'
EMAIL =
'[email protected]'
HOMEPAGE =
'http://gnetvibes.rubyforge.org'
LICENSE =
'BSD'

Instance Method Summary collapse

Constructor Details

#initializeSysLoad

Returns a new instance of SysLoad.



7
8
9
10
11
12
13
14
# File 'lib/uwa_sysload/widget.rb', line 7

def initialize
	super
	@debugMode = true
	@author = 'Florent Solt'
	@title = 'My System Load'
	@values = []
	@autoRefresh = 1
end

Instance Method Details

#valuesObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/uwa_sysload/widget.rb', line 16

def values
	if @test # set through config
		@values = [ 0.5.to_f ]
		1.upto(200) { @values << @values.last.to_f + (rand(200) / 1000.to_f - 0.1.to_f)}
	else
		@values << File.read('/proc/loadavg').split.first
	end
	count = @query['count'].to_i
	count = @values.size if count > @values.size
	@values = @values[-(count)..-1]
	self << JSON.unparse(@values)
end