05.11.2019, 15:18
You can check some network futures yourself with the script below and do with it whatever you like. Run it as an init scrit and send an email with this information for example.
Have fun with it
require('json')
require('socket.http')
ip = io.readproc('if-json')
ip = json.decode(ip)
log("IP address: " ..ip.eth0.inetaddr)
socket.http.timeout = 5
data = socket.http.request('http://ip-api.com/json')
if data then
data = json.decode(data)
log("WAN IP: "..data.query)
log("City: "..data.city)
log("Region: "..data.region)
log("Country: "..data.countryCode)
log("Latitude: "..data.lat)
log("Longitude: "..data.lon)
else
log("There is possible no internet connection")
end
log("DNS name: " ..socket.dns.gethostname())
io.input("/sys/class/net/eth0/carrier")
carrier = io.read("*line")
if carrier == "1" then
log("Connected to the network")
else
log("No connection to the network")
end
io.input("/sys/class/net/eth0/operstate")
state = io.read("*line")
if state == "up" then
log("The network connection is active")
else
log("The network connection is inactive")
end
Have fun with it
require('json')
require('socket.http')
ip = io.readproc('if-json')
ip = json.decode(ip)
log("IP address: " ..ip.eth0.inetaddr)
socket.http.timeout = 5
data = socket.http.request('http://ip-api.com/json')
if data then
data = json.decode(data)
log("WAN IP: "..data.query)
log("City: "..data.city)
log("Region: "..data.region)
log("Country: "..data.countryCode)
log("Latitude: "..data.lat)
log("Longitude: "..data.lon)
else
log("There is possible no internet connection")
end
log("DNS name: " ..socket.dns.gethostname())
io.input("/sys/class/net/eth0/carrier")
carrier = io.read("*line")
if carrier == "1" then
log("Connected to the network")
else
log("No connection to the network")
end
io.input("/sys/class/net/eth0/operstate")
state = io.read("*line")
if state == "up" then
log("The network connection is active")
else
log("The network connection is inactive")
end