diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-07-19 02:12:00 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-07-19 02:14:50 +0200 |
commit | d91266357a0d36f17fb48d367d4ab1c6429b505d (patch) | |
tree | bde2a7a39d4fbbaa1c06d7efe7deefacdd8d912a | |
parent | 8674c919d64291827eec05e1e3fbc21c29a7396e (diff) | |
download | vicious-legacy-d91266357a0d36f17fb48d367d4ab1c6429b505d.tar.xz |
net: add operational state support
-rw-r--r-- | README | 14 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | widgets/net.lua | 6 |
3 files changed, 12 insertions, 9 deletions
@@ -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 @@ -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... diff --git a/widgets/net.lua b/widgets/net.lua index 9eda942..5991b40 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -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] = {} |