Verified Commit 72432200 authored by Fabio Bonfiglio's avatar Fabio Bonfiglio 💾
Browse files

Add custom remote host option

parent f169f8c0
......@@ -24,26 +24,35 @@
RUNME=1
DISP=1
REMOTEHOST="google.com"
DESTINATION="checknet.csv"
trap "RUNME=0" INT
echo -e "\nchecknet v0.1.0 - by Fabio Bonfiglio"
while getopts hqf: option; do
while getopts hqr:f: option; do
case "${option}" in
h)
echo -e "\nUsage: $0 [-h][-d][-f <file name>]"
echo -e "\nOptions:\n\n\t-h\tDisplay this help message."
echo -e "\t-q\tQuiet. Don't show live log feed."
echo -e "\nUsage: $0 [-h][-d][-r][-f <file name>]"
echo -e "\nOptions:\n\n\t-h\t\tDisplay this help message."
echo -e "\t-q\t\tQuiet. Don't show live log feed."
echo -e "\t-r remoteHost\tThe remote host name to reach for."
echo -e "\t-f fileName.csv\tIndicate a file path and name where to save csv entries.\n"
exit 0
;;
q) DISP="0";;
r) REMOTEHOST=${OPTARG};;
f) DESTINATION=${OPTARG};;
esac
done
nslookup $REMOTEHOST
if [[ "$?" -ne "0" ]]; then
echo "Invalid remote host name."
exit 1
fi
touch $DESTINATION && echo "Writing logs in $DESTINATION"
if [[ "$DISP" -eq "1" ]]; then
......@@ -51,7 +60,7 @@ if [[ "$DISP" -eq "1" ]]; then
fi
while [[ "$RUNME" -eq "1" ]]; do
RES=$(nslookup google.com)
RES=$(nslookup $REMOTEHOST)
if [[ "$?" -ne "0" ]]; then
echo "$(date --iso-8601=seconds), 0, DOWN" >> $DESTINATION
else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment