diff options
author | David Runge <dave@sleepmap.de> | 2017-03-21 09:58:38 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2017-03-21 09:58:38 +0100 |
commit | 82a96cd19ac9e90c540d00a86f3f2db9e8560421 (patch) | |
tree | ec8b8e08e6638d8c0d06919356f862e7694f0f04 /bin/host_online_status | |
parent | 0bd054ffeeb74b37972b8a6b79bdc4f03eb94722 (diff) | |
download | dotfiles-82a96cd19ac9e90c540d00a86f3f2db9e8560421.tar.gz dotfiles-82a96cd19ac9e90c540d00a86f3f2db9e8560421.tar.bz2 dotfiles-82a96cd19ac9e90c540d00a86f3f2db9e8560421.tar.xz dotfiles-82a96cd19ac9e90c540d00a86f3f2db9e8560421.zip |
bin/host_online_status: Adding script to easily checking if a host is available by pinging it.
Diffstat (limited to 'bin/host_online_status')
-rwxr-xr-x | bin/host_online_status | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bin/host_online_status b/bin/host_online_status new file mode 100755 index 0000000..7bd026e --- /dev/null +++ b/bin/host_online_status @@ -0,0 +1,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 |