Browse code

FIX: Cpu mod: type conversion

Cinan Rakosnik authored on 16/12/2012 at 02:58:59
Showing 2 changed files
... ...
@@ -9,7 +9,7 @@ module Rubysermon
9 9
 				line =~ /^cpu[\d]/
10 10
 			}.length
11 11
 
12
-			@cpu_load = 0
12
+			@cpu_load = 0.00
13 13
 			@options = {notify_threshold: @cpu_count*0.90}
14 14
 		end
15 15
 
... ...
@@ -18,7 +18,7 @@ module Rubysermon
18 18
 		end
19 19
 
20 20
 		def results
21
-			@cpu_load = File.read("/proc/loadavg").split(" ").first.to_i
21
+			@cpu_load = File.read("/proc/loadavg").split(" ").first.to_f
22 22
 		end
23 23
 
24 24
 		def notify?
... ...
@@ -16,7 +16,7 @@ class Cpu_test < MiniTest::Unit::TestCase
16 16
 	end
17 17
 
18 18
 	def test_cpu_load
19
-		assert_match(/^\d\.\d{2}$/, @cpu.results())
19
+		assert_match(/^\d\.\d{1,2}$/, @cpu.results().to_s)
20 20
 	end
21 21
 
22 22
 	def test_notify?