Isolating Connectivity Issues
Problem
You are having difficulty determining the cause connectivity related errors
Solution
Here is a script that can be run from most Linux systems.
Save this script on a one or more systems
Update the
target=
Update the
port=
Setup cron job to run this script at a frequency you prefer (eg. every 5 seconds)
Wait for next connectivity event
Check the
nc.log
that will be created in the same directory as this script
Requirements: nc
command to be available
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
TIMESTAMP=`date "+%Y-%m-%d %H:%M:%S"`
logpath="$SCRIPT_DIR/nc.log"
target="127.0.0.1"
port="1521"
if nc -z "$target" "$port"; then
result="PASS Connected to '$port'"
else
result="FAIL Could not connect to '$port'"
fi
echo "$TIMESTAMP $result" >> "$logpath"