-----LUA----- -- variable definition: PING_ADDRESS1 = "10.10.0.1" -- replace this with your first IP address PING_ADDRESS2 = "10.11.0.1" -- replace this with your second IP address TRY = 3 -- this defines that an unsuccessful check will be repeated 3 times -- aux flag SUCCESS = 0 -- this flag is used to differentiate success (1) and no success (0) -- ping check for LOOP = 1 , TRY do a, b, c = pcall(cli, "help.debug.tool=ping -c 1 " .. PING_ADDRESS1) -- lua script that pings to address 1 and returns information to the variables a, b and c if c == 0 then -- means that the ping to address 1 was successful SUCCESS = 1 -- sets the success flag to 1 cli_log("LUA ping - " .. LOOP .. ". check to target " .. PING_ADDRESS1 .. " successful") -- outputs the success message in the log -- device is online, exit lua and the script return -- exits the loop else -- continues the script in case of no success a, b, c = pcall(cli, "help.debug.tool=ping -c 1 " .. PING_ADDRESS2) -- lua script that pings to address 2 and returns information to the variables a, b and c print ("LOOP: " .. LOOP .. " - b:" .. b .. " c:" ..c) -- outputs the parameter in the cli if c == 0 then -- means that the ping to address 2 was successful SUCCESS = 1 -- sets the success flag to 1 cli_log("LUA ping - " .. LOOP .. ". check to target " .. PING_ADDRESS2 .. " successful") -- outputs the success message in the log -- device is online, exit lua and the script return -- exits the loop else -- continues the script in case of no success at the end of the final number of loops cli_log("LUA ping - " .. LOOP .. ". check, both failed") -- outputs the no success message in the log end end end if SUCCESS == 0 then -- means that no ping was successful, the following commands will be executed cli_log("LUA ping - restarting modem") -- outputs this information in the log cli("help.debug.modem_state.name=lte2") -- defines the modem to be restarted cli("help.debug.modem_state.state_change=turn_off") -- defines that the modem is to be turned off cli("help.debug.modem_state.submit") -- submits above command to the router end -----LUA----- exit