struct

Hardware::PID::Stat

Inherits Struct / Value / Object

Parse stat initialized at Hadware::PID#stat

pid_stat = Hardware::PID::Stat.new
loop do
  sleep 1
  p pid_stat.cpu_usage! # => 1.5
end

Constructors

new(pid : Int64 = Process.pid, cpu : CPU | Nil = CPU.new)
Source

Instance methods

cmajflt

Returns the "cmajflt" stat field.

cminflt

Returns the "cminflt" stat field.

comm
Source
cpu_time(children : Bool = false) : Int32

Returns the CPU time with or without including ones from children processes.

Source
cpu_usage!(children : Bool = false, current_cpu : CPU = CPU.new) : Float64

Returns the CPU used in percentage.

pid_stat = Hardware::PID::Stat.new
loop do
  sleep 1
  p pid_stat.cpu_usage! # => 1.5
end
Source
cstime

Returns the "cstime" stat field.

cutime

Returns the "cutime" stat field.

data
Source
flags

Returns the "flags" stat field.

itrealvalue

Returns the "itrealvalue" stat field.

majflt

Returns the "majflt" stat field.

minflt

Returns the "minflt" stat field.

nice

Returns the "nice" stat field.

numthreads

Returns the "numthreads" stat field.

parse_stat_file
Source
pgrp

Returns the "pgrp" stat field.

ppid

Generate methods based on stat Returns the "ppid" stat field.

priority

Returns the "priority" stat field.

rss

Returns the "rss" stat field.

session

Returns the "session" stat field.

starttime

Returns the "starttime" stat field.

state
Source
stime

Returns the "stime" stat field.

tpgid

Returns the "tpgid" stat field.

tty_nr

Returns the "tty_nr" stat field.

utime

Returns the "utime" stat field.

vsize

Returns the "vsize" stat field.

Nested types