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.
20 21 22 23 |
# File 'lib/osctl/cli/top/host.rb', line 20 def initialize(*_) super @time = Time.now end |
Instance Attribute Details
#guest ⇒ Object
Returns the value of attribute guest
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def guest @guest end |
#guest_nice ⇒ Object
Returns the value of attribute guest_nice
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def guest_nice @guest_nice end |
#idle ⇒ Object
Returns the value of attribute idle
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def idle @idle end |
#iowait ⇒ Object
Returns the value of attribute iowait
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def iowait @iowait end |
#irq ⇒ Object
Returns the value of attribute irq
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def irq @irq end |
#nice ⇒ Object
Returns the value of attribute nice
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def nice @nice end |
#softirq ⇒ Object
Returns the value of attribute softirq
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def softirq @softirq end |
#steal ⇒ Object
Returns the value of attribute steal
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def steal @steal end |
#system ⇒ Object
Returns the value of attribute system
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def system @system end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
18 19 20 |
# File 'lib/osctl/cli/top/host.rb', line 18 def time @time end |
#user ⇒ Object
Returns the value of attribute user
6 7 8 |
# File 'lib/osctl/cli/top/host.rb', line 6 def user @user end |
Instance Method Details
#diff(other) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/osctl/cli/top/host.rb', line 25 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
50 51 52 53 54 |
# File 'lib/osctl/cli/top/host.rb', line 50 def total return @total if @total @total = reduce(:+) end |
#total_used ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/osctl/cli/top/host.rb', line 36 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 |