Table of Contents

proc_stat plugin

This plugin provides an interface to the /proc/stat file.


Functions

proc_stat(key)parse absolute values from /proc/stat
proc_stat(key, delay)parse delta values from /proc/stat
proc_stat::cpu(key, delay)parse cpu info from /proc/stat
proc_stat::disk(device, key, delay)parse disk info from /proc/stat

proc_stat(key)

Valid keys are:

page.innumber of page-in events
page.outnumber of page-out events
swap.innumber of swap-in events
swap.outnumber of swap-out events
intr.<n>number of interrupts #n
intr.sumtotal number of interrupts

all other entries from /proc/stat are provided verbatim, with the first column as a key. Do a 'cat /proc/stat' to see which values are supported on your system.

The 'delay' value specifies a period of time (in milliseconds) for a delta computation. If you use a delta of 0 (zero) or omit the delta parameter, you get the absolute values (same as in /proc/stat). For delay values > 0 you get the delta value in 1/sec unit. Using a delta value of 500 msec seems to be a good choice.


proc_stat::cpu(key, delay)

Valid keys are:

userpercentage spent in user mode (0..100)
nicepercentage spent in niced tasks (0..100)
systempercentage spent in kernel mode (0..100)
iowaitpercentage spent in kernel mode (0..100)
irqpercentage spent in kernel mode (0..100)
softirqpercentage spent in kernel mode (0..100)
idlepercentage idle (0..100)
busypercentage busy (100-idle)

The 'delay' value specifies a period of time (in milliseconds) for a delta computation. If you use a delta of 0 (zero), you get the absolute values (same as in /proc/stat). For delay values > 0 you get the delta value in 1/sec unit. Using a delta value of 500 msec seems to be a good choice.

Keys iowait,irq and softirq can be used only with Kernel 2.6


proc_stat::disk(device, key, delay)

The 'device' parameter specifies the device in the form 'major:minor'. Do a 'cat /proc/stat' to see which devices are available on your system. Note that the 'device' field is interpreted as a 'regular expression' (regex), if you use a regex you get the sum of all matching devices (e.g. 'proc_stat::disk ('3:.*', 'rblk', 500)' will return the sum of read blocks for 3:0, 3:1, 3:2, …)

Valid keys are:

iototal number of disk I/O events
rionumber of disk read events
rblknumber of blocks read from disk
wionumber of disk write events
wblknumber of blocks written to disk

The 'delay' value specifies a period of time (in milliseconds) for a delta computation. If you use a delta of 0 (zero), you get the absolute values (same as in /proc/diskstats). For delay values > 0 you get the delta value in 1/sec unit. Using a delta value of 500 msec seems to be a good choice.

Kernel 2.6: With Kernel 2.6, the 'disk_io' lines disappeared from /proc/stat, and therefore you'll get no results with this plugin. Use the diskstats-plugin instead!


Example

Widget BusyBar {
    class 'Bar'
    expression  proc_stat::cpu('busy',   500)
    expression2 proc_stat::cpu('system', 500)
    length 10	
    direction 'E'
    update 100
}

Widget Disk {
    class 'Text'
    expression (proc_stat::disk('.*', 'rblk', 500) + proc_stat::disk('.*', 'wblk', 500))/2
    prefix 'I/O'
    width 10	
    precision 0
    align 'R'	
    update 100
}