struct Hardware::CPU
- Hardware::CPU
- Struct
- Value
- Object
Overview
CPU related informations of your system.
cpu = Hardware::CPU.new
loop do
sleep 1
p cpu.usage!.to_i # => 17
end
Defined in:
cpu.crConstructors
-
.new(number : Int32? = nil, parse_stats : Bool = true)
Creates a new CPU stat to monitor the given core.
Instance Method Summary
-
#guest
Returns the "guest" stat field.
-
#guest_nice
Returns the "guest_nice" stat field.
-
#idle
Returns the "idle" stat field.
- #idle_total
-
#iowait
Returns the "iowait" stat field.
-
#irq
Returns the "irq" stat field.
-
#nice
Returns the "nice" stat field.
-
#number : Int32?
CPU number.
-
#softirq
Returns the "softirq" stat field.
-
#steal
Returns the "steal" stat field.
-
#system
Returns the "system" stat field.
-
#total
Sum of
#used
and#idle_total
-
#usage(previous_cpu : CPU = self) : Float64
Returns each CPU usage in percentage based on the previous
CPU
. -
#usage! : Float64
Like
#usage
, but mutates the instance. - #used
-
#user
Returns the "user" stat field.
Constructor Detail
Creates a new CPU stat to monitor the given core.
Must be lower than System.cpu_count
, or nil
for the whole cores in total.
Instance Method Detail
Returns each CPU usage in percentage based on the previous CPU
.