36 lines
941 B
Plaintext
Executable File
36 lines
941 B
Plaintext
Executable File
require "scripts/lua/functions"
|
|
|
|
commandArray = {}
|
|
|
|
|
|
--recupere les minutes
|
|
time=os.time()
|
|
minutes=tonumber(os.date('%M',time))
|
|
|
|
if (minutes % 10 == 0 ) then
|
|
local f = io.popen("ping -c 5 192.168.0.1 2>/dev/null |grep rtt |awk -F = '{print $2}'|awk -F / '{print $2}'") -- runs command
|
|
local l = f:read("*a") -- read output of command
|
|
debug("##### Perf ping : temps de ping "..l)
|
|
f:close()
|
|
-- Perf Reseau
|
|
commandArray['UpdateDevice']="145|0|"..l
|
|
end
|
|
|
|
if (minutes % 30 == 0 ) then
|
|
local f = io.popen("ping -c 4 -n www.free.fr|grep packet|awk -F ' ' '{print $1}'") -- runs command
|
|
local l = f:read("*a") -- read output of command
|
|
debug("##### Nombre de ping: "..l)
|
|
f:close()
|
|
if (l == "4") then
|
|
debug("##### Internet fonctionne correctement")
|
|
switchIfNeeded('Internet','On')
|
|
else
|
|
debug("##### Internet ne répond pas")
|
|
switchIfNeeded('Internet','Off')
|
|
end
|
|
|
|
end
|
|
|
|
|
|
return commandArray
|
|
|