netdev plugin
This plugin provides an interface to the /proc/net/dev file.
Functions
netdev(device, key, delay) | parse /proc/net/dev |
netdev::fast(device, key, delay) | parse /proc/net/dev without regex support |
'device' is a valid network device name, e.g. 'eth0' (do a 'cat /proc/net/dev' for valid names on your system)
The 'key' parameter does not have any fixed values, but is taken as a column search key into the /proc/net/dev file. Common keys are 'Rx_bytes' or 'Tx_packets'. Do a 'cat /proc/net/dev' to see which keys are available on your system. Note that every column header is prefixed with either 'Rx_' (Receive) or 'Tx_' (Transmit).
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/net/dev). 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.
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. 'netdev ('eth.', 'Tx_bytes', 500)' will return the sum of transmitted bytes for eth0, eth1, eth2, …)
The only difference between netdev() and netdev::fast() is that netdev::fast() does not support regular expressions and therefore takes less cpu time.
Example
Widget Eth0Bar { class 'Bar' expression netdev('eth0', 'Rx_bytes', 500) expression2 netdev('eth0', 'Tx_bytes', 500) length 14 direction 'E' update 100 }