Last active
November 12, 2024 02:11
-
-
Save tsaavik/80ad446c23026d79069dc6df238b82a3 to your computer and use it in GitHub Desktop.
DNS Checker
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 "DNS Checker v1.0 David Mcanulty 2017" | |
echo -e "\t- # repeatably tests dns and records success/failures\n" | |
success=0 | |
failure=0 | |
dnshost=$1 | |
datestamp=$(date) | |
red=$(tput setaf 1) | |
green=$(tput setaf 2) | |
reset=$(tput sgr0) | |
dim=$(tput dim) | |
if [[ -z "${dnshost}" ]] ;then | |
echo "This script requires a host to lookup on the commandline to run" | |
echo "for example: $0 google.com" | |
exit 1 | |
fi | |
while sleep 1; do | |
clear | |
echo "There have been ${green}#${success} successful${reset} lookups of $dnshost since $datestamp" | |
echo -e "There have been ${red}#${failure} failures${reset}${dim}\n\n" | |
dig +short $1 | |
if [[ $? -gt 0 ]]; then | |
((failure++)) | |
else | |
((success++)) | |
fi | |
echo -e "${reset}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment