net: add operational state support

This commit is contained in:
Adrian C. (anrxc) 2010-07-19 02:12:00 +02:00
parent 8674c919d6
commit d91266357a
3 changed files with 12 additions and 9 deletions

14
README
View File

@ -167,8 +167,8 @@ vicious.widgets.fs
vicious.widgets.dio
- provides I/O statistics for requested storage devices
- takes the disk as an argument, i.e. "sda" (or specific partition,
i.e. "sda/sda5")
- takes the disk as an argument, i.e. "sda" (or a specific
partition, i.e. "sda/sda2")
- returns a table with string keys: {total_s}, {total_kb}, {total_mb},
{read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb}
and {sched}
@ -187,12 +187,12 @@ vicious.widgets.hddtemp
{/dev/sda} and {/dev/sdc} for example
vicious.widgets.net
- provides usage statistics for all network interfaces
- provides state and usage statistics of all network interfaces
- returns a table with string keys, using net interfaces as a base:
{eth0 rx_b}, {eth0 tx_b}, {eth0 rx_kb}, {eth0 tx_kb}, {eth0 rx_mb},
{eth0 tx_mb}, {eth0 rx_gb}, {eth0 tx_gb}, {eth0 down_b}, {eth0 up_b},
{eth0 down_kb}, {eth0 up_kb}, {eth0 down_mb}, {eth0 up_mb},
{eth0 down_gb}, {eth0 up_gb}, {eth1 rx_b} etc.
{eth0 carrier}, {eth0 rx_b}, {eth0 tx_b}, {eth0 rx_kb}, {eth0 tx_kb},
{eth0 rx_mb}, {eth0 tx_mb}, {eth0 rx_gb}, {eth0 tx_gb}, {eth0 down_b},
{eth0 up_b}, {eth0 down_kb}, {eth0 up_kb}, {eth0 down_mb},
{eth0 up_mb}, {eth0 down_gb}, {eth0 up_gb}, {eth1 rx_b} etc.
vicious.widgets.wifi
- provides wireless information for a requested interface

1
TODO
View File

@ -5,7 +5,6 @@
* Vicious
** TODO Import NET carrier detection from contrib
** TODO Consider including this code in format helper
- return format and format:gsub("${[^}]+}", "")
- Note: We should then also replace just $1/$2...

View File

@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
-- }}}
-- Net: provides usage statistics for all network interfaces
-- Net: provides state and usage statistics of all network interfaces
module("vicious.widgets.net")
@ -43,6 +43,10 @@ local function worker(format)
helpers.uformat(args, name .. " rx", recv, unit)
helpers.uformat(args, name .. " tx", send, unit)
-- Operational state and carrier detection
local sysnet = helpers.pathtotable("/sys/class/net/" .. name)
args["{"..name.." carrier}"] = tonumber(sysnet.carrier) or 0
if nets[name] == nil then
-- Default values on the first run
nets[name] = {}