diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-09-17 19:35:42 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-09-17 19:35:42 +0000 |
commit | b1657454b0cafeffb783c830b0053f41cbafc55e (patch) | |
tree | 09ca0fa2f6687856d4f130385dfee8bcfbb3469c | |
parent | 3eb6963fb3427094cf09825b2c198cab3bc90617 (diff) | |
download | acf-alpine-baselayout-b1657454b0cafeffb783c830b0053f41cbafc55e.tar.bz2 acf-alpine-baselayout-b1657454b0cafeffb783c830b0053f41cbafc55e.tar.xz |
Modified netword stats to not need iproute2.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1470 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | health-model.lua | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/health-model.lua b/health-model.lua index 854e2cc..7a25c83 100644 --- a/health-model.lua +++ b/health-model.lua @@ -97,25 +97,22 @@ end get_networkstats = function () local stats = cfe({ type="structure", value={}, label="Network Stats", timestamp=os.time() }) - local result = querycmd("/bin/ip -s link show") + local result = fs.read_file("/proc/net/dev") -- parse the result local i=0 - local intf = "" - for line in string.gmatch(result, "[^\n]*\n?") do - if i==0 then - intf = string.match(line, "^%x+:%s+(%w+):") - if not intf or intf == "" then - break + for line in string.gmatch(result, "[^\n]+\n?") do + if i>1 then + local intf = string.match(line, "([^%s:]+):") + line = string.match(line, ":(.*)$") + local words = {} + for word in string.gmatch(line, "%S+") do + words[#words+1] = word end stats.value[intf] = {} - elseif i==3 then - local bytes, packets = string.match(line, "^%s+(%d+)%s+(%d+)") - stats.value[intf].RX = {bytes=bytes, packets=packets} - elseif i==5 then - local bytes, packets = string.match(line, "^%s+(%d+)%s+(%d+)") - stats.value[intf].TX = {bytes=bytes, packets=packets} + stats.value[intf].RX = {bytes=words[1], packets=words[2]} + stats.value[intf].TX = {bytes=words[9], packets=words[10]} end - i=(i+1)%6 + i=i+1 end return stats end |