But last months i discovered a nasty habit of my Cisco EPC3928AD EuroDocsis 3.0 2-PORT Voice Gateway.
It has a bug in the static IP config and can't set any static IP's, if i do then it forgets them after a week or so.
Every week i need to reassign new IPs for 13 devices in my crontab
Beeing fed up with this a discovered my router/modem can handle ARP-scan, unfortunately not snmp as it is killed by my provider.
So i wanted to use ARP-Scan and found Ceedebee his ARP-Scan script and works like a charm.
Unfortunately every 10 minutes i get the following error in the log.
--
Error: EventSystem: Warning!, lua script ...........lua has been running for more than 10 seconds
--
Have been searching and doing trail and error.
But seems i can't find what is keeping the LUA running.
Anyone maybe Ceedebee a idea...
p.s
Doesn't make any difference if i insert 1 or several devices to check.
Or expanding the check time.
Code: Select all
function splitString(str, delim, maxNb)
-- Eliminate bad cases...
if string.find(str, delim) == nil then
return { str }
end
if maxNb == nil or maxNb < 1 then
maxNb = 0 -- No limit
end
local result = {}
local pat = "(.-)" .. delim .. "()"
local nb = 0
local lastPos
for part, pos in string.gmatch(str, pat) do
nb = nb + 1
result[nb] = part
lastPos = pos
if nb == maxNb then break end
end
-- Handle the last field
if nb ~= maxNb then
result[nb + 1] = string.sub(str, lastPos)
end
return result
end
commandArray = {}
--Get the list of phones to check on
phoneslist= uservariables['Telefoonlijst']
--Do an arp-scan on the localnet
--and search for the mac adresses
if phoneslist ~= nil then
local newphonelist =""
local currenttime = os.time()
local outdoorsdelay = 5 * 60
--do the arp scan and store the result
local command = "sudo arp-scan --interface=eth0 192.168.xxx.1-192.168.xxx.yyy --retry=5 --ignoredups"
local handle = io.popen(command)
local result = handle:read("*all")
handle:close()
--Get a list of all phones
phones=splitString(phoneslist,"|")
--Search arp-scan result for presence of MAC for each phone
for i,line in pairs(phones) do
--Get the data for this phone
phone=splitString(line,";")
--and the switch state
switchstate = otherdevices[phone[2]]
--Fill a new list with phones
if i > 1 then newphonelist = newphonelist.."|" end
newphonelist = newphonelist..phone[1]..";"..phone[2]
-- If phone detected write current time and switch on
-- else switch off after the given delay time
if string.find(result, string.lower(phone[1])) ~= nil then
phone[3]= currenttime
if string.lower(switchstate) == 'off' then commandArray[phone[2]] = 'On' end
else
if tonumber(currenttime) > (tonumber(phone[3]) + outdoorsdelay) and string.lower(switchstate) == 'on' then
commandArray[phone[2]] = 'Off'
print(phone[2].."; now:"..os.date("%Y-%m-%d %H:%M:%S", currenttime).."; last seen: "..os.date("%Y-%m-%d %H:%M:%S",tonumber(phone[3])))
end
end
newphonelist = newphonelist..";"..phone[3]
end
--print(newphonelist)
commandArray['Variable:Telefoonlijst']= newphonelist
else
print("Uservariable 'Telefoonlijst' not found!")
end