Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Alert on new public IP address with GeoIP and latency #43

Open
pirate opened this issue Dec 19, 2016 · 0 comments
Open

Alert on new public IP address with GeoIP and latency #43

pirate opened this issue Dec 19, 2016 · 0 comments

Comments

@pirate
Copy link
Owner

pirate commented Dec 19, 2016

I'm splitting this out from #24. I want to add an alert whenever your public IP changes.

I can easily get GeoIP from the public IP, and display latency by pinging 8.8.8.8. This will create a useful alert that shows the following:

screen shot 2016-12-19 at 4 30 55 pm

local IP <latency ms> public ip (geolocation)

The command to get the new public ip is:
dig +short myip.opendns.com @resolver1.opendns.com -> 123.123.123.123

The command to get the GeoIP reported city is (requires brew install geoip):
geoiplookup 123.123.123.123 | tail -1 | perl -pe 's/.*?: .*?, .., .*?, //g' | perl -pe 's/, .*$//g' -> Montréal

The command to get the latency is:
ping -c 1 -t 1 8.8.8.8 | tail -1 | perl -pe 's/^(.* = \d*\.\d*\/)(\d*)(.\d*\/.*)$/$2 ms/gm' -> 19ms

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

No branches or pull requests

1 participant