aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/host_online_status19
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