#!/bin/bash # variables timeout=2000 pingcount=2 interval=50 pathtoscript=/home/scripts delaytime=15 #first check out of 3 #empty empty old list cat /dev/null > nodes_NOK.txt # do the check while IFS= read -r ip; do #get node names node_name=$(awk "/^$ip/ "'{print $NF}' $pathtoscript/ffluxbot/FFnodes.txt) #Is node IP pingable if fping6 -c $pingcount -t $timeout -i $interval "$ip" &>/dev/null; then #do this echo "$node_name is Pingable" else #Els do this echo "$node_name Not Pingable" echo "$ip" >> nodes_NOK.txt fi done <$pathtoscript/ffluxbot/iplist.txt echo Â"Check 1 done" sleep $delaytime echo Â"Start Check 2" cat /dev/null > nodes_NOK2.txt #second check out of 3 while IFS= read -r ip2; do node_name=$(awk "/^$ip2/ "'{print $NF}' $pathtoscript/ffluxbot/FFnodes.txt) if fping6 -c $pingcount -t $timeout -i $interval "$ip2" &>/dev/null; then echo "$node_name is Pingable" else echo "$node_name Not Pingable" echo "$ip2" >> nodes_NOK2.txt fi done <$pathtoscript/ffluxbot/nodes_NOK.txt echo "Check 2 done" sleep $delaytime echo "Start Check 3" cat /dev/null > nodes_NOK3.txt #last check out of 3 while IFS= read -r ip3; do node_name=$(awk "/^$ip3/ "'{print $NF}' $pathtoscript/ffluxbot/FFnodes.txt) if fping6 -c $pingcount -t $timeout -i $interval "$ip3" &>/dev/null; then echo "$node_name is Pingable" else echo "$node_name Not Pingable" echo "$node_name with IPV6 $ip3 is not reachable" >> nodes_NOK3.txt fi done <$pathtoscript/ffluxbot/nodes_NOK2.txt echo "Check 3 done" # prepare Text message textmessage=$(cat nodes_NOK3.txt) echo "$textmessage" python3 $pathtoscript/ffluxbot/send_client.py -d -j BotJID -p Botpassword -t fantawams@c3l.lu -m "$textmessage" python3 $pathtoscript/ffluxbot/send_client.py -d -j BotJID -p Botpassword -t orimpe@c3l.lu -m "$textmessage"