From 3be11784600d82f633f9b50472ac00e8b38dcf8b Mon Sep 17 00:00:00 2001 From: Marc Hoppe Date: Thu, 23 Feb 2023 09:17:42 +0000 Subject: [PATCH] pbxpcitest --- pbxpcitest.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/pbxpcitest.sh b/pbxpcitest.sh index 332b1c2..32a1261 100644 --- a/pbxpcitest.sh +++ b/pbxpcitest.sh @@ -1,17 +1,70 @@ -#!/bin/sh +#!/bin/bash -url=root@192.168.178.116 +ip=192.168.178.116 +url=root@$ip #url=root@es-system broker=192.168.178.25 - +sleeptime=75 #topic_power="cmnd/powplug2/power" topic_power="cmnd/plug-b/power" -log=$HOME/tmp/pbxpcitest.log +log=$HOME/tmp/pbxpcitest_$(date +%y%m%d%H%M%S).log +function stopp +{ + echo -e "\n stopped !" + echo "{} ]" >> $log + exit +} +echo "Start (Stopp mit 'x')" +echo "[" >> $log +n=1 while [ true ]; do mosquitto_pub -h $broker -m "on" -t "$topic_power" - sleep 60 + echo -n "$n:on" + #sleep 5 + read -t 5 -n 1 key + if [ "$key" = "x" ]; then + stopp + fi + i=0 + test="ok" + echo -n " ping" + while [ true ]; do + read -t 0.1 -n 1 key + if [ "$key" = "x" ]; then + stopp + fi + echo -n "." + ping -w 1 -q $ip > /dev/null + r=$? + if [ $r -eq 0 ]; then + break + fi + i=$((i+1)) + if [ $i -gt 200 ]; then + echo "Fehler $i !" + test="fail" + break; + fi + done + echo "{ \"time\" : \"$(date +%T)\", \"n\" : $n, \"test\" : \"$test\", \"result\" : $r, \"count\" : $i }," >> $log + echo " $i off" + mosquitto_pub -h $broker -m "off" -t "$topic_power" + read -t 5 -n 1 key + if [ "$key" = "x" ]; then + stopp + fi + n=$((n+1)) +done +stopp + + +exit + + while [ no_connect != 0 ] + + sleep $sleeptime echo "$(date) ----------------------------------" | tee -a $log ssh $url -o ConnectTimeout=3 'cat /etc/release | grep PRODUCT' if [ $? -eq 0 ]; then @@ -36,7 +89,6 @@ while [ true ]; do echo ok4 >> $log else echo fail4 - #exit fi fi fi