Last active
December 16, 2015 00:18
-
-
Save simonpioli/5346228 to your computer and use it in GitHub Desktop.
Retrieves the IP of the supplied hostname hourly and pops up a Growl Notification if/when the IP changes. I use it when switching a website to a new server.
Note: This does require Growl and the GrowlNotify plug-in. I may rewrite it in the future support the Notification Centre in Mountain Lion and provide more options.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Enter the hostname you want to monitor (eg citypress.co.uk) and hit [ENTER]: " | |
read hostname | |
while true; do | |
newip=$(dig +short $hostname) | |
if [ "$newip" != "$previp" ]; then | |
if [ -z "$previp" ]; then | |
growlnotify --title "NOW MONITORING:" --message "$hostname - current IP $newip" | |
else | |
growlnotify --sticky --title "IP HAS CHANGED" --message "$hostname is now at $newip" | |
fi | |
else | |
echo "No change" | |
fi | |
previp=$newip | |
sleep 600 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment