# remote
for HOST in $(cat /tmp/hosts | sort); do
echo ${HOST}
PORTS=$(sudo nmap -T4 -sS ${HOST} | grep -e "80\|81\|8080" | cut -d "/" -f1)
for PROTOCOL in http https; do
printf "%-5s:" ${PROTOCOL}
for PORT in ${PORTS}; do
printf "%4s:" ${PORT}
ssh user@www.example.com wget --timeout=3 -t 1 --no-check-certificate ${PROTOCOL}://${HOST}:${PORT} -O - >/dev/null 2>&1; STATE=$?; [ ${STATE} -eq 0 ] && echo -n "OK "; [ ${STATE} -eq 4 ] && echo -n "ERR "; [ ${STATE} -eq 8 ] && echo -n "404 "
done
echo
done
echo
done
# local
for LINE in $(cat /tmp/list); do
HOST=${LINE%:*}
PORTS=${LINE#*:}
echo ${HOST}
for PORT in ${PORTS//,/ }; do
printf "%4s:" ${PORT}
wget --timeout=3 -t 1 --no-check-certificate http://${HOST}:${PORT} -O - > /dev/null 2>&1
STATE=$?
case "${STATE}" in
0)
echo -n "OK "
;;
8)
echo -n "404 "
;;
4)
echo -n "ERR "
;;
*)
echo -n "${STATE} ";
;;
esac
done
echo
echo
done