Send new IP by E-mail once it is changed
Example: Send new IP by E-mail once it is changed
Task
Make a program which will automatically send the new IP address from the Logic Machine once it’s changed
Add resident script with 60sec interval
- 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