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.

Send an e-mail when the current IP changes
#1
Good morning, I have been searching the Openrb website for a Script through which I get the current IP changes, I am not sure which of the two Script is valid.

I don't know if this script only sends the e-mail if the IP of the LM changes or if the current IP changes:
require('json')

data = io.readproc('if-json')

data = json.decode(data)

ip = data.eth0.inetaddr





ip_old = storage.get('ip_old')

if ip_old == nil then

  storage.set('ip_old', ip)

end



if ip ~= ip_old then

  subject = 'LM IP changed'

  message = 'The new IP is: ' .. ip

  mail('user@example.com', subject, message)

  storage.set('ip_old', ip)
end
 
 - I don't know exactly what we get with this Script
 
 require('json')

 res = io.readproc('if-json')

 res = json.decode(res)

 ip = res.eth0.inetaddr
 alert('Current LM IP is: %s', ip)
 

 
Thank you

BR 

 Josema
Reply


Messages In This Thread
Send an e-mail when the current IP changes - by josemabera - 09.11.2019, 10:07

Forum Jump: