2014-06-09 18:48:15 +02:00
|
|
|
local ethtool = util.exec('ethtool -S bat0')
|
|
|
|
|
|
|
|
local fields = {}
|
|
|
|
for k, v in ethtool:gmatch('([%a_]+): ([0-9]+)') do
|
|
|
|
fields[k] = tonumber(v)
|
|
|
|
end
|
|
|
|
|
|
|
|
local traffic = {}
|
|
|
|
for _, class in ipairs({'rx', 'tx', 'forward', 'mgmt_rx', 'mgmt_tx'}) do
|
2014-06-10 15:44:35 +02:00
|
|
|
traffic[class] = {
|
|
|
|
bytes = fields[class .. '_bytes'],
|
|
|
|
packets = fields[class],
|
|
|
|
}
|
2014-06-09 18:48:15 +02:00
|
|
|
end
|
|
|
|
traffic['tx']['dropped'] = fields['tx_dropped']
|
|
|
|
|
|
|
|
return traffic
|