struct Hardware::PID::Stat

Overview

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

Defined in:

pid/stat.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(pid : Int64 = Process.pid, cpu : CPU | Nil = CPU.new) #

[View source]

Instance Method Detail

def cmajflt : Int64 #

Returns the "cmajflt" stat field.


def cminflt : Int64 #

Returns the "cminflt" stat field.


def comm : String #

[View source]
def cpu_time(children : Bool = false) : Int64 #

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


[View source]
def 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

[View source]
def cstime : Int64 #

Returns the "cstime" stat field.


def cutime : Int64 #

Returns the "cutime" stat field.


def data : Array(String) #

[View source]
def flags : Int64 #

Returns the "flags" stat field.


def itrealvalue : Int64 #

Returns the "itrealvalue" stat field.


def majflt : Int64 #

Returns the "majflt" stat field.


def minflt : Int64 #

Returns the "minflt" stat field.


def nice : Int64 #

Returns the "nice" stat field.


def numthreads : Int64 #

Returns the "numthreads" stat field.


def parse_stat_file #

[View source]
def pgrp : Int64 #

Returns the "pgrp" stat field.


def pid : Int64 #

[View source]
def ppid : Int64 #

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


def priority : Int64 #

Returns the "priority" stat field.


def rss : Int64 #

Returns the "rss" stat field.


def session : Int64 #

Returns the "session" stat field.


def starttime : Int64 #

Returns the "starttime" stat field.


def state : State #

[View source]
def stime : Int64 #

Returns the "stime" stat field.


def tpgid : Int64 #

Returns the "tpgid" stat field.


def tty_nr : Int64 #

Returns the "tty_nr" stat field.


def utime : Int64 #

Returns the "utime" stat field.


def vsize : Int64 #

Returns the "vsize" stat field.