Skip to content

Instantly share code, notes, and snippets.

@sdubois
Created September 2, 2022 14:08
Show Gist options
  • Save sdubois/ff41185fa8bf085fbfce719ec6c9a3ca to your computer and use it in GitHub Desktop.
Save sdubois/ff41185fa8bf085fbfce719ec6c9a3ca to your computer and use it in GitHub Desktop.
Monitors an IP address to see if it is accessible. Useful for uptime monitoring and testing.
#!/bin/bash
# Monitors an IP address to see if it is accessible. Useful for uptime monitoring and testing.
# Ex: bash ping-checker.sh 8.8.8.8
while true
do
ping -c1 $1 | grep -q '0 packets received' && echo 'down'
ping -c1 $1 | grep -q '1 packets received' && echo 'up'
sleep 120
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment