aboutsummaryrefslogtreecommitdiffstats
path: root/bin/host_online_status
blob: 7bd026e583439b5fc0b0e746c4ca21129c42bff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
# This script uses each argument to check if a host under that name is
# reachable using ping

set -euo pipefail

function check_online_status() {
  if ping -c 1 -w 1 $1 >> /dev/null; then
    echo "+ $1"
  else
    echo "- $1"
  fi
}

for host in $@; do
  check_online_status $host
done

exit 0