You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
572 B
Bash
26 lines
572 B
Bash
#!/bin/bash
|
|
|
|
if ! which nc >/dev/null; then
|
|
logError "${SCRIPT_NAME}: Did not find nc in path!"
|
|
return
|
|
fi
|
|
|
|
# Usage: doTcpPortTest <target-host> <target-port> [<timeout>]
|
|
function doTcpPortTest {
|
|
HOST=${1}
|
|
PORT=${2}
|
|
TIMEOUT=5
|
|
[ "${3}" = "" ] || TIMEOUT=${3}
|
|
|
|
logScript "Doing TCP port test to ${HOST}:${PORT}"
|
|
|
|
SUCCESS=false
|
|
if nc -z -w ${TIMEOUT} ${HOST} ${PORT}; then
|
|
SUCCESS=true
|
|
fi
|
|
|
|
writeData \
|
|
tcp-port \
|
|
"sourceHost=$(hostname -f),targetHost=${HOST},targetPort=${PORT}" \
|
|
"open=${SUCCESS}"
|
|
} |