So i coded this
Please notice that you will need other external host with http + php where you should put simple-portscan.php.
Maybe it's not the best solution, but it's working for me.
scan_host="freepc";
scan_host_test=`ping -w 1 -c 1 ${scan_host} | grep "64 bytes from ${scan_host}"`;
# set first pool to working one
if [ -n "$scan_host_test" ]
then
CHECK_POOL1=`wget "http://${scan_host}/simple-portscan.php?url=${_pool1url}" -q -O - | grep open`;
CHECK_POOL2=`wget "http://${scan_host}/simple-portscan.php?url=${_pool2url}" -q -O - | grep open`;
CHECK_POOL3=`wget "http://${scan_host}/simple-portscan.php?url=${_pool3url}" -q -O - | grep open`;
if [ -z "$CHECK_POOL1" ] && [ -n "$CHECK_POOL2" ]
then
POOL1=$POOL2;
POOL2="";
else
if [ -z "$CHECK_POOL1" ] && [ -n "$CHECK_POOL3" ]
then
POOL1=$POOL3;
POOL3="";
fi
fi
fi
echo "USING FIRST POOL: $POOL1";
simple-portscan.php
$url_arr = split(":",$url_string);
$host = $url_arr[0];
$port = $url_arr[1];
$timeout = 1;
$fp = fsockopen($host,$port,$errno,$errstr,$timeout);
if($fp)
{
echo "port " . $port . " open on " . $host . "\n";
fclose($fp);
}
else
{
echo "port " . $port . " closed on " . $host . "\n";
}
flush();
?>