This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Resident script - IP watchdog
#2
(09.10.2017, 14:06)sorin Wrote: Hi, 
I need a resident script that ping an IP , and if does not receive any reply to open a actuator.
Please help  Idea
Thanks a lot!

Here you are:

Code:
function socketping(ip, port, timeout)
 port = port or 80
 local sock = require('socket').tcp()
 sock:settimeout(timeout or 2)
 local res, err = sock:connect(ip, port)
 sock:close()
 
 return res, err
end


ip = '192.168.2.1'

if not socketping(ip) then grp.write('1/2/3', true) end
Reply


Messages In This Thread
Resident script - IP watchdog - by sorin - 09.10.2017, 14:06
RE: Resident script - IP watchdog - by buuuudzik - 09.10.2017, 14:29
RE: Resident script - IP watchdog - by sorin - 09.10.2017, 14:45
RE: Resident script - IP watchdog - by sorin - 17.12.2017, 16:57
RE: Resident script - IP watchdog - by admin - 03.04.2018, 12:01
RE: Resident script - IP watchdog - by Daniel - 06.11.2019, 21:13
RE: Resident script - IP watchdog - by Daniel - 08.11.2019, 08:54
RE: Resident script - IP watchdog - by admin - 08.11.2019, 09:28
RE: Resident script - IP watchdog - by admin - 08.11.2019, 10:53

Forum Jump: