Skip to content

Instantly share code, notes, and snippets.

@gustavonovaes
Last active August 24, 2017 17:54
Show Gist options
  • Save gustavonovaes/a69781c4efe5231075ef94200ab28856 to your computer and use it in GitHub Desktop.
Save gustavonovaes/a69781c4efe5231075ef94200ab28856 to your computer and use it in GitHub Desktop.
Guarda log do horário que o ping ao host falha
#/bin/sh
host=$1
log_path=$2
if [ ! -f $log_path ]; then
touch $log_path
fi
store_fail() {
date +"%Y-%m-%d %H:%I:%S" >> $1
}
while true; do
if ! ping -c 1 -W 1 $host &> /dev/null; then
store_fail $log_path
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment