Class: RorVsWild::Metrics::Cpu::Stat
- Inherits:
-
Object
- Object
- RorVsWild::Metrics::Cpu::Stat
- Defined in:
- lib/rorvswild/metrics/cpu.rb
Instance Attribute Summary collapse
-
#guest ⇒ Object
readonly
Returns the value of attribute guest.
-
#guest_nice ⇒ Object
readonly
Returns the value of attribute guest_nice.
-
#idle ⇒ Object
readonly
Returns the value of attribute idle.
-
#iowait ⇒ Object
readonly
Returns the value of attribute iowait.
-
#irq ⇒ Object
readonly
Returns the value of attribute irq.
-
#nice ⇒ Object
readonly
Returns the value of attribute nice.
-
#softirq ⇒ Object
readonly
Returns the value of attribute softirq.
-
#steal ⇒ Object
readonly
Returns the value of attribute steal.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice) ⇒ Stat
constructor
A new instance of Stat.
Constructor Details
#initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice) ⇒ Stat
Returns a new instance of Stat.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rorvswild/metrics/cpu.rb', line 31 def initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice) @user = user @nice = nice @system = system @idle = idle @iowait = iowait @irq = irq @softirq = softirq @steal = steal @guest = guest @guest_nice = guest_nice @total = user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice end |
Instance Attribute Details
#guest ⇒ Object (readonly)
Returns the value of attribute guest.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def guest @guest end |
#guest_nice ⇒ Object (readonly)
Returns the value of attribute guest_nice.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def guest_nice @guest_nice end |
#idle ⇒ Object (readonly)
Returns the value of attribute idle.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def idle @idle end |
#iowait ⇒ Object (readonly)
Returns the value of attribute iowait.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def iowait @iowait end |
#irq ⇒ Object (readonly)
Returns the value of attribute irq.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def irq @irq end |
#nice ⇒ Object (readonly)
Returns the value of attribute nice.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def nice @nice end |
#softirq ⇒ Object (readonly)
Returns the value of attribute softirq.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def softirq @softirq end |
#steal ⇒ Object (readonly)
Returns the value of attribute steal.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def steal @steal end |
#system ⇒ Object (readonly)
Returns the value of attribute system.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def system @system end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def total @total end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
29 30 31 |
# File 'lib/rorvswild/metrics/cpu.rb', line 29 def user @user end |
Class Method Details
.parse(string) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rorvswild/metrics/cpu.rb', line 45 def self.parse(string) for row in string.lines if row.start_with?("cpu ") array = row.split[1..-1].map(&:to_i)[0,10] array.fill(0, array.size, 10 - array.size) if array.size < 10 return new(*array) end end nil end |
.read ⇒ Object
56 57 58 |
# File 'lib/rorvswild/metrics/cpu.rb', line 56 def self.read parse(File.read("/proc/stat")) if File.readable?("/proc/stat") end |