Skip to content

Instantly share code, notes, and snippets.

@corvax19
Created November 23, 2012 12:15
Show Gist options
  • Save corvax19/4135359 to your computer and use it in GitHub Desktop.
Save corvax19/4135359 to your computer and use it in GitHub Desktop.
Simple DNS resolve monitor with email notification #singleliner
ping -q -i1 -c3 target 2>&1|awk '/unknown host/{system("mailx -s \""$4" DNS resolution failed on `uname -n` at `date`\" [email protected] >/dev/null")} /[:alpha:]/{S=S" "$0} END {print S}'
@corvax19
Copy link
Author

Things to adjust:
target - put your hostname of interest here;
-i10 - pinging interval in seconds;
-c30 - pinging counter;
[email protected] - your email here, as Bill could be unresponsive on such notifications.

Put it on cron. With -i10 and -c30 - schedule it for each 5 minutes (5min = 300 sec = 10 * 30)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment