vidibus-sysinfo 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/vidibus/sysinfo/cpu.rb +27 -16
- data/lib/vidibus/sysinfo/version.rb +1 -1
- metadata +3 -3
data/lib/vidibus/sysinfo/cpu.rb
CHANGED
@@ -13,7 +13,20 @@ module Vidibus
|
|
13
13
|
extend Base
|
14
14
|
|
15
15
|
class Result < Vidibus::Sysinfo::Result
|
16
|
-
|
16
|
+
KEYS = {
|
17
|
+
usr: :user,
|
18
|
+
user: :user,
|
19
|
+
nice: :nice,
|
20
|
+
sys: :system,
|
21
|
+
system: :system,
|
22
|
+
iowait: :iowait,
|
23
|
+
irq: :irq,
|
24
|
+
soft: :soft,
|
25
|
+
steal: :steal,
|
26
|
+
guest: :guest,
|
27
|
+
idle: :idle
|
28
|
+
}
|
29
|
+
attrs *KEYS.values.uniq + [:used]
|
17
30
|
|
18
31
|
def to_i
|
19
32
|
round(used, 0).to_i
|
@@ -26,24 +39,22 @@ module Vidibus
|
|
26
39
|
|
27
40
|
class << self
|
28
41
|
def command
|
29
|
-
|
42
|
+
'mpstat 1 5'
|
30
43
|
end
|
31
44
|
|
45
|
+
# user system missing
|
32
46
|
def parse(output)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
guest: matches[7].to_f,
|
45
|
-
idle: matches[8].to_f
|
46
|
-
}
|
47
|
+
lines = output.split(/\r?\n/)
|
48
|
+
values = lines[-1].scan(/([\d\.]+)/)
|
49
|
+
if values.any?
|
50
|
+
values.flatten!
|
51
|
+
data = {}
|
52
|
+
labels = lines[2].scan(/%([^\s]+)/).flatten
|
53
|
+
labels.each_with_index do |label, index|
|
54
|
+
key = Result::KEYS[label.to_sym]
|
55
|
+
next unless key
|
56
|
+
data[key] = values[index].to_f
|
57
|
+
end
|
47
58
|
data[:used] = round(100.0 - data[:idle])
|
48
59
|
Result.new(data)
|
49
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vidibus-sysinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
segments:
|
147
147
|
- 0
|
148
|
-
hash:
|
148
|
+
hash: 1223332183346536001
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|