config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

health-check (489B)


      1 #!/bin/sh
      2 
      3 online() {
      4   if ! ping -c 1 -W 1 8.8.8.8 > /dev/null; then
      5     return 1
      6   fi
      7   if ! ping -c 1 -W 1 1.1.1.1 > /dev/null; then
      8     return 1
      9   fi
     10 }
     11 
     12 main() {
     13   if ! online; then
     14     echo "health check failed: not online" > /dev/stderr
     15     exit 1
     16   fi
     17 
     18   hosts="$(pass hosts)"
     19   for host in ${hosts}; do
     20     if ! curl --location --max-time 3 --show-error --silent "${host}" \
     21 	 > /dev/null; then
     22       notify-send --urgency=low "${host} is not reachable"
     23     fi
     24   done
     25 }
     26 
     27 main "$@"