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