×
×
×
×

How to collect the Connector log files?

Description

If you've worked through Connector Reachability Issues and the issue is still not resolved, our experts will need to refer to logs to investigate further. You can follow this document to extract the required logs.

Extracting the logs

Follow the steps below to generate the log archive on the connector machine and transfer it to your local machine.

Step 1: Generate the log archive

Copy the shell script given below and save it as sse-gateway-logs-zip.sh in your /home/user directory.

    
   #!/bin/bash
   # Zips the sse-gateway logs folder into the directory the script was run from.
   # Usage: ./sse-gateway-logs-zip.sh
   APPLICATION_NAME="sse-gateway"
   HOME_PATH="/usr/local/manageengine"
   LOGS_DIR="${HOME_PATH}/${APPLICATION_NAME}/logs"
   DEST_DIR="$(pwd)"
   ZIP_PATH="${DEST_DIR}/sse-gateway-logs-$(date +%Y%m%d_%H%M%S).zip"
   LOG_TRACE_NAME="SSE-LOG-ZIP"
   RED="\e[0;31m"
   GREEN="\e[0;32m"
   YELLOW="\e[0;33m"
   NC="\e[0m"
   BOLD_START="\e[1m"
   BOLD_END="\e[0m"
   log_info() {
   printf "[%s] [%s] %b\n" "$(date +"%Y-%m-%d %H:%M:%S.%3N")" "$LOG_TRACE_NAME" "$1"
   }
   log_success() {
   printf "[%s] %b%b[%s] %b %b%b\n" "$(date +"%Y-%m-%d %H:%M:%S.%3N")" "$GREEN" "$BOLD_START" "$LOG_TRACE_NAME" "$1" "$BOLD_END" "$NC"
   }
   log_warning() {
   printf "[%s] %b[%s] %b %b\n" "$(date +"%Y-%m-%d %H:%M:%S.%3N")" "$YELLOW" "$LOG_TRACE_NAME" "$1" "$NC"
   }
   log_error() {
   printf "[%s] %b%b[%s] %b %b%b\n" "$(date +"%Y-%m-%d %H:%M:%S.%3N")" "$RED" "$BOLD_START" "$LOG_TRACE_NAME" "$1" "$BOLD_END" "$NC"
   }
   # Use sudo automatically when not running as root; sudo will prompt for the password as needed
   SUDO=""
   if [ "$(id -u)" -ne 0 ]; then
   log_warning "Not running as root. Using sudo (you may be prompted for your password)..."
   SUDO="sudo"
   fi
   log_info "Checking for logs directory: ${LOGS_DIR}"
   if ! $SUDO test -d "${LOGS_DIR}"; then
   log_error "Logs directory ${LOGS_DIR} not found. Exiting."
   exit 1
   fi
   log_info "Creating archive ${ZIP_PATH} ..."
   if ! $SUDO bash -c "cd '${HOME_PATH}/${APPLICATION_NAME}' && zip -r '${ZIP_PATH}' logs"; then
   log_error "Failed to create zip archive."
   exit 2
   fi
   if [ -n "$SUDO" ]; then
   log_info "Fixing ownership of ${ZIP_PATH} ..."
   if ! $SUDO chown "$(id -u)":"$(id -g)" "${ZIP_PATH}"; then
   log_error "Failed to change ownership of ${ZIP_PATH}."
   exit 3
   fi
   fi
   log_success "Logs archived successfully at ${ZIP_PATH}"
   exit 0
       
  

Once the shell script is saved, run the following command:

sudo sh sse-gateway-logs-zip.sh
  

The script automatically checks if it's running as root. If not, it will prompt you for your sudo password, enter it to proceed. It looks for logs at /usr/local/manageengine/sse-gateway/logs and creates the archive in the current directory as sse-gateway-logs-<timestamp>.zip. On success, the script prints the full path of the generated archive.

Copy the path of the generated archive (for example: /home/<user>/sse-gateway-logs-20260707_101530.zip)

Step 2: Pull the archive to your local machine

Use scp to pull the archive.

scp user@machine-name-or-ip:/log-archive-path/sse-gateway-logs-timestamp.zip .
  

Replace the placeholders in the command with actual values:

  • user: The SSH username on the affected machine
  • machine-name-or-ip: The connector's hostname or IP address
  • /log-archive-path/sse-gateway-logs-timestamp.zip: The full path printed by the script in the previous step