Problem

You are having difficulty determining the cause connectivity related errors

Solution

Here is a script that can be run from most Linux systems.

  1. Save this script on a one or more systems

  2. Update the target=

  3. Update the port=

  4. Setup cron job to run this script at a frequency you prefer (eg. every 5 seconds)

  5. Wait for next connectivity event

  6. 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"
BASH