Logic Machine Forum
LM loses network! - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: LM loses network! (/showthread.php?tid=5121)



LM loses network! - phongvucba - 29.11.2023

Hi everybody ! I have a problem that needs solving! I want to write a script to know when LM loses network and send information to LM's LOG. Or if the network returns, information will also be sent to LM's LOG. I thank everyone who helped me! thank you Smile)


RE: LM loses network! - CristianAgata - 29.11.2023

(29.11.2023, 04:47)phongvucba Wrote: Hi everybody ! I have a problem that needs solving! I want to write a script to know when LM loses network and send information to LM's LOG. Or if the network returns, information will also be sent to LM's LOG. I thank everyone who helped me! thank you Smile)

Hi,
Look at this if can help you.
https://forum.logicmachine.net/showthread.php?tid=5040&highlight=Network+lost
Best regards Cristian


RE: LM loses network! - phongvucba - 30.11.2023

Thank you very much !
But what I want is for LM itself to lose internet, and it will report LM's LOG. When the network comes back, it will also report to LM's Log.
I want to check when my LM lost its internet connection. So I need to LOG it. Because when I lose my internet connection, my Gmail or telegram functions don't work anymore Sad
Thank all! Sad


RE: LM loses network! - admin - 30.11.2023

Create a scheduled script that runs every minute:
Code:
sock = require('socket').tcp()
sock:settimeout(5)
conn = sock:connect('1.1.1.1', 80)
sock:close()

conn = toboolean(conn)
prev = storage.get('connected')

if prev ~= conn then
  storage.set('connected', conn)
  log(conn and 'connected' or 'disconnected')
end



RE: LM loses network! - phongvucba - 30.11.2023

oh ! Good luck ! Thank so much Admin Smile