From 31274f3825fb7706e9c352f108e0e25e8b8f57ac Mon Sep 17 00:00:00 2001 From: Udo Waechter Date: Wed, 14 Sep 2022 19:41:27 +0200 Subject: [PATCH] adding nummer5 tools --- nummer5/hosts.conf | 1 + nummer5/nummer5-host-powercycle.sh | 10 ++++++++++ nummer5/nummer5-hosts-alive.sh | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 nummer5/hosts.conf create mode 100755 nummer5/nummer5-host-powercycle.sh create mode 100755 nummer5/nummer5-hosts-alive.sh diff --git a/nummer5/hosts.conf b/nummer5/hosts.conf new file mode 100644 index 0000000..9ac316e --- /dev/null +++ b/nummer5/hosts.conf @@ -0,0 +1 @@ +hosts="pine01.wks pine02.wks pine03.wks pine04.wks pine05.wks adm01.wks ebin01.wks ebin02.wks" diff --git a/nummer5/nummer5-host-powercycle.sh b/nummer5/nummer5-host-powercycle.sh new file mode 100755 index 0000000..d20507b --- /dev/null +++ b/nummer5/nummer5-host-powercycle.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +host=$1 +echo "${host} turning it off" +mosquitto_pub -h mqtt.wks -t switch_cloud/switch/${host}/command -m OFF +sleep 2 +echo "${host} turning it on" +mosquitto_pub -h mqtt.wks -t switch_cloud/switch/${host}/command -m ON + +ping -W 1 ${host} diff --git a/nummer5/nummer5-hosts-alive.sh b/nummer5/nummer5-hosts-alive.sh new file mode 100755 index 0000000..743e8f1 --- /dev/null +++ b/nummer5/nummer5-hosts-alive.sh @@ -0,0 +1,9 @@ +#!/bin/bash +. hosts.conf +for host in $hosts; do + if ping -c 1 -W 1 "$host" >/dev/null; then + echo "$host is alive" + else + echo "$host is pining for the fjords" + fi +done