From 724366c038777122e292091b729e7d1e9d52c5cc Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 4 Oct 2009 00:21:15 +0200 Subject: Reworked some variables in entropy, load, mpd, net, init --- net.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'net.lua') diff --git a/net.lua b/net.lua index f38a3dd..7d72708 100644 --- a/net.lua +++ b/net.lua @@ -29,11 +29,11 @@ local function worker(format) for line in f:lines() do -- Match wmaster0 as well as rt0 (multiple leading spaces) if line:match("^[%s]?[%s]?[%s]?[%s]?[%w]+:") then - name = line:match("^[%s]?[%s]?[%s]?[%s]?([%w]+):") + local name = line:match("^[%s]?[%s]?[%s]?[%s]?([%w]+):") -- Received bytes, first value after the name - recv = tonumber(line:match(":[%s]*([%d]+)")) + local recv = tonumber(line:match(":[%s]*([%d]+)")) -- Transmited bytes, 7 fields from end of the line - send = tonumber(line:match("([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$")) + local send = tonumber(line:match("([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$")) args["{"..name.." rx_b}"] = math.floor(recv*10)/10 args["{"..name.." tx_b}"] = math.floor(send*10)/10 @@ -68,11 +68,11 @@ local function worker(format) nets[name].time = os.time() else -- Net stats are absolute, substract our last reading - interval = os.time() - nets[name].time + local interval = os.time() - nets[name].time nets[name].time = os.time() - down = (recv - nets[name][1])/interval - up = (send - nets[name][2])/interval + local down = (recv - nets[name][1])/interval + local up = (send - nets[name][2])/interval args["{"..name.." down_b}"] = math.floor(down*10)/10 args["{"..name.." up_b}"] = math.floor(up*10)/10 -- cgit v1.2.3