... | ... |
@@ -2,8 +2,32 @@ module Rubysermon |
2 | 2 |
class Cpu < ModTemplate |
3 | 3 |
|
4 | 4 |
def initialize |
5 |
+ @y_axis = "CPU Load" |
|
6 |
+ @graph_name = "CPU Load In Time" |
|
5 | 7 |
|
8 |
+ @cpu_count = File.readlines("/proc/stat").select { |line| |
|
9 |
+ line =~ /^cpu[\d]/ |
|
10 |
+ }.length |
|
6 | 11 |
end |
7 | 12 |
|
13 |
+ def load_options |
|
14 |
+ |
|
15 |
+ end |
|
16 |
+ |
|
17 |
+ def results |
|
18 |
+ |
|
19 |
+ end |
|
20 |
+ |
|
21 |
+ def notify? |
|
22 |
+ |
|
23 |
+ end |
|
24 |
+ |
|
25 |
+ def y_axis_name |
|
26 |
+ @y_axis |
|
27 |
+ end |
|
28 |
+ |
|
29 |
+ def graph_name |
|
30 |
+ "#@graph_name (CPUs: #@cpu_count)" |
|
31 |
+ end |
|
8 | 32 |
end |
9 | 33 |
end |
10 | 34 |
\ No newline at end of file |
11 | 35 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,18 @@ |
0 |
+require_relative "../../../test_helper.rb" |
|
1 |
+require Rubysermon::MOD_PATH + "/cpu.rb" |
|
2 |
+ |
|
3 |
+class Cpu_test < MiniTest::Unit::TestCase |
|
4 |
+ |
|
5 |
+ def setup |
|
6 |
+ @cpu = Rubysermon::Cpu.new |
|
7 |
+ end |
|
8 |
+ |
|
9 |
+ def test_y_axis |
|
10 |
+ assert_equal("CPU Load", @cpu.y_axis_name) |
|
11 |
+ end |
|
12 |
+ |
|
13 |
+ def test_graph_name |
|
14 |
+ assert_match(/^CPU Load In Time \(CPUs: [\d]+\)$/, @cpu.graph_name) |
|
15 |
+ end |
|
16 |
+ |
|
17 |
+end |
|
0 | 18 |
\ No newline at end of file |