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 : Int32 = Process.pid, cpu : CPU? = CPU.new) #

[View source]

Instance Method Detail

def cmajflt #

Returns the "cmajflt" stat field.


def cminflt #

Returns the "cminflt" stat field.


def comm #

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

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 #

Returns the "cstime" stat field.


def cutime #

Returns the "cutime" stat field.


def data : Array(String) #

[View source]
def flags #

Returns the "flags" stat field.


def itrealvalue #

Returns the "itrealvalue" stat field.


def majflt #

Returns the "majflt" stat field.


def minflt #

Returns the "minflt" stat field.


def nice #

Returns the "nice" stat field.


def numthreads #

Returns the "numthreads" stat field.


def parse_stat_file #

[View source]
def pgrp #

Returns the "pgrp" stat field.


def pid : Int32 #

[View source]
def ppid #

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


def priority #

Returns the "priority" stat field.


def rss #

Returns the "rss" stat field.


def session #

Returns the "session" stat field.


def starttime #

Returns the "starttime" stat field.


def state #

[View source]
def stime #

Returns the "stime" stat field.


def tpgid #

Returns the "tpgid" stat field.


def tty_nr #

Returns the "tty_nr" stat field.


def utime #

Returns the "utime" stat field.


def vsize #

Returns the "vsize" stat field.