Class: OsCtl::Cli::Top::Host::Cpu
- Inherits:
-
Struct
- Object
- Struct
- OsCtl::Cli::Top::Host::Cpu
- Defined in:
- lib/osctl/cli/top/host.rb
Instance Attribute Summary collapse
-
#guest ⇒ Object
Returns the value of attribute guest.
-
#guest_nice ⇒ Object
Returns the value of attribute guest_nice.
-
#idle ⇒ Object
Returns the value of attribute idle.
-
#iowait ⇒ Object
Returns the value of attribute iowait.
-
#irq ⇒ Object
Returns the value of attribute irq.
-
#nice ⇒ Object
Returns the value of attribute nice.
-
#softirq ⇒ Object
Returns the value of attribute softirq.
-
#steal ⇒ Object
Returns the value of attribute steal.
-
#system ⇒ Object
Returns the value of attribute system.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #diff(other) ⇒ Object
-
#initialize(*_) ⇒ Cpu
constructor
A new instance of Cpu.
- #total ⇒ Object
- #total_used ⇒ Object
Constructor Details
#initialize(*_) ⇒ Cpu
Returns a new instance of Cpu.
19 20 21 22 |
# File 'lib/osctl/cli/top/host.rb', line 19 def initialize(*_) super @time = Time.now end |
Instance Attribute Details
#guest ⇒ Object
Returns the value of attribute guest
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def guest @guest end |
#guest_nice ⇒ Object
Returns the value of attribute guest_nice
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def guest_nice @guest_nice end |
#idle ⇒ Object
Returns the value of attribute idle
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def idle @idle end |
#iowait ⇒ Object
Returns the value of attribute iowait
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def iowait @iowait end |
#irq ⇒ Object
Returns the value of attribute irq
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def irq @irq end |
#nice ⇒ Object
Returns the value of attribute nice
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def nice @nice end |
#softirq ⇒ Object
Returns the value of attribute softirq
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def softirq @softirq end |
#steal ⇒ Object
Returns the value of attribute steal
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def steal @steal end |
#system ⇒ Object
Returns the value of attribute system
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def system @system end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
17 18 19 |
# File 'lib/osctl/cli/top/host.rb', line 17 def time @time end |
#user ⇒ Object
Returns the value of attribute user
5 6 7 |
# File 'lib/osctl/cli/top/host.rb', line 5 def user @user end |
Instance Method Details
#diff(other) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/osctl/cli/top/host.rb', line 24 def diff(other) ret = self.class.new delta = time - other.time other.each_pair do |k, v| ret[k] = (self[k] - v) / delta.to_f end ret end |
#total ⇒ Object
48 49 50 51 |
# File 'lib/osctl/cli/top/host.rb', line 48 def total return @total if @total @total = reduce(:+) end |
#total_used ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/osctl/cli/top/host.rb', line 35 def total_used return @total_used if @total_used sum = 0 each_pair do |k, v| next if k == :idle sum += v end @total_used = sum end |