Ok, I think we have to postpone server checks until I find a more reliable way to perform it...
Currently, using PING is not a solution. When servers fail to respond the application takes quite a bit of time to load... even when checking just 2 pings
Code:
#! /bin/bash
echo "Starting check..."
HOSTS="mirror.unlockforus.com repo.linuxliteos.com mirror.uta.edu.ec"
COUNT=2
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ "$count" -eq "0" ]; then
# 100% failed
echo "Host : $myHost is down (ping failed) at $(date)"
fi
done
echo "How fast did this message show up? That's how long it will take for the application to open"
Try the above and you will see what I mean... only 2 pings checks and it takes a while to open because mirror.uta.edu.ec is not responding. This mirror is GONE; you should remove it from the list of mirrors in the main site.
Back on topic. It takes way to long for the application to open and check the hosts. We need a better solution.
I also tried netcat without much success:
Code:
while IFS= read -r server _; do
servers=( "$server" )
nc -vzw 2 $servers 80
if [ $? == 0 ];
then
echo "$server is pinging"
else
echo "$server is not pinging"
fi
done < servers.txt
In this test you need to create a servers.txt file and add the hostnames one per line.
You will see that all hosts do respond on port 80 and that should tell us that the mirrors are fine... but they are not.
mirror.uta.edu.ec is down and doesn't respond but nc is able to connect on port 80 without expecting a response as it does... which gives us the complete wrong result for our test.
So, I don't really know how to address this. I amy have to go with wget to grab a file off of each mirror or something because ping and nc do not seem to help us much at all.
https://unlockforus.com
Sorry for seeming stupid and preferring Linux - I just don't know any better.