#!/bin/bash hostname=$1 port=$2 if nc -z -w1 $hostname $port > /dev/null 2>&1; then echo "Service $hostname:$port is running" exit 0 else echo "Service $hostname:$port is unreachable" exit 1 fi