city-watch 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/city_watch/commands/mpstat.rb +8 -7
- data/lib/city_watch/commands/ps.rb +10 -12
- data/lib/city_watch/watchmen/cpu_usage.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +1 -1
@@ -9,17 +9,18 @@ class MPstat
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def data
|
12
|
+
headers = false
|
12
13
|
command_output.split("\n").map {|line| line.split("\s") }.inject([]) do |output,line|
|
13
14
|
if line[1] == "CPU"
|
14
15
|
headers = line.map {|hdr| hdr.gsub(/%/,'').to_sym}
|
15
|
-
|
16
|
+
headers[0] = :run
|
17
|
+
elsif headers
|
18
|
+
pkt = {}
|
19
|
+
line.each_with_index do |itm,idx|
|
20
|
+
pkt[headers[idx]] = itm
|
21
|
+
end
|
22
|
+
output << pkt
|
16
23
|
end
|
17
|
-
next unless headers
|
18
|
-
pkt = {}
|
19
|
-
line.each_with_index do |itm,idx|
|
20
|
-
pkt[headers[idx]] = itm
|
21
|
-
end
|
22
|
-
output << pkt
|
23
24
|
output
|
24
25
|
end
|
25
26
|
end
|
@@ -10,22 +10,20 @@ class PS
|
|
10
10
|
|
11
11
|
def data
|
12
12
|
headers = false
|
13
|
-
|
14
|
-
command_output.split("\n").map {|line| line.split("\s") }.each do |line|
|
13
|
+
command_output.split("\n").map {|line| line.split("\s") }.inject([]) do |output,line|
|
15
14
|
if !headers
|
16
15
|
headers = line.map {|hdr| hdr.downcase.to_sym}
|
17
|
-
|
16
|
+
else
|
17
|
+
pkt = {}
|
18
|
+
cmd = line.slice!(10,line.size-1)
|
19
|
+
line << cmd.join(" ")
|
20
|
+
line.each_with_index do |itm,idx|
|
21
|
+
pkt[headers[idx]] = itm
|
22
|
+
end
|
23
|
+
output << pkt
|
18
24
|
end
|
19
|
-
|
20
|
-
pkt = {}
|
21
|
-
cmd = line.slice!(10,line.size-1)
|
22
|
-
line << cmd.join(" ")
|
23
|
-
line.each_with_index do |itm,idx|
|
24
|
-
pkt[headers[idx]] = itm
|
25
|
-
end
|
26
|
-
output << pkt
|
25
|
+
output
|
27
26
|
end
|
28
|
-
output
|
29
27
|
end
|
30
28
|
|
31
29
|
end
|
data/lib/version.rb
CHANGED