From 82a96cd19ac9e90c540d00a86f3f2db9e8560421 Mon Sep 17 00:00:00 2001 From: David Runge Date: Tue, 21 Mar 2017 09:58:38 +0100 Subject: bin/host_online_status: Adding script to easily checking if a host is available by pinging it. --- bin/host_online_status | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/host_online_status 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 -- cgit v1.2.3-70-g09d2