#!/bin/bash if ! which nc >/dev/null; then logError "${SCRIPT_NAME}: Did not find nc in path!" return fi # Usage: doTcpPortTest [] 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}" }