HTTP Health Check
Check URLs for expected status codes and response time.
$ webtoolist --script port-check
Check whether TCP ports on a host are reachable, with a timeout.
networktcpportsdiagnosticsDependencies: bash /dev/tcp
#!/usr/bin/env bash
set -euo pipefail
host="${1:-}"
shift || true
(($# > 0)) || { echo "usage: $0 HOST PORT [PORT...]" >&2; exit 1; }
timeout_s="${TIMEOUT:-2}"
for port in "$@"; do
if timeout "$timeout_s" bash -c "</dev/tcp/$host/$port" 2>/dev/null; then
echo "open $host:$port"
else
echo "closed $host:$port"
fi
done
./port-check example.com 22 80 443
TIMEOUT=5 ./port-check 192.168.1.10 5432
/dev/tcp, so no nc dependency is required.timeout turns an unanswered SYN into a bounded wait instead of a hang.Related scripts
Check URLs for expected status codes and response time.