Project

General

Profile

Actions

Tareas #20

open

Prueba de acceso y conectividad

Added by Demo MiGestion365 Admin about 1 month ago. Updated about 1 month ago.

Status:
Resuelta
Priority:
Normal
Assignee:
-
Start date:
02/23/2026
Due date:
02/23/2026 (36 days late)
% Done:

0%

Estimated time:

Description

Dado los inconvenientes de conectividad que se experimentan esporádicamente implementé un script que corre cada un minuto y chequea la conectividad a:

atdb.relevando.com ... utilizando el comando nc -vz atdb.relevando.com 3306
/atc-ftth-vno-transfers/LATAM/Argentina ... (disco montado desde S3)
google.com

Si el resultado es correcto no loguea nada. Sólo loguea si alguna de las instancias enumeradas no responde.

Actions #1

Updated by Demo MiGestion365 Admin about 1 month ago

  • Description updated (diff)
Actions #2

Updated by Demo MiGestion365 Admin about 1 month ago · Edited

Se genera el siguiente script:
connectivity_monitor.sh

#!/usr/bin/env bash
set -u

# ---------- Config ----------
LOG_FILE="/var/log/connectivity_monitor.log"
INTERVAL_SEC=60
LS_TIMEOUT=8          # segundos para probar el listado del S3 montado
NC_TIMEOUT=8          # segundos para nc (si tu nc soporta -w)
S3_PATH="/atc-ftth-vno-transfers/LATAM/Argentina"

# ---------- Helpers ----------
timestamp() { date "+%Y-%m-%d %H:%M:%S%z"; }

log_error() {
  # Crea el log si no existe y asegura permisos razonables
  if [ ! -e "$LOG_FILE" ]; then
    touch "$LOG_FILE" 2>/dev/null || true
  fi
  echo "$(timestamp) [ERROR] $1" >> "$LOG_FILE"
}

check_nc() {
  local host="$1" port="$2" name="$3"
  # -z: solo escaneo; -v: verbose; -w: timeout (si está disponible en tu nc)
  if ! nc -vz -w "$NC_TIMEOUT" "$host" "$port" >/dev/null 2>&1; then
    log_error "$name inaccesible: no se pudo abrir TCP $host:$port"
    return 1
  fi
  return 0
}

check_s3_path() {
  # Usa timeout para evitar que s3fs congele el proceso
  if ! timeout "$LS_TIMEOUT" ls -1 "$S3_PATH" >/dev/null 2>&1; then
    log_error "S3FS lento/inaccesible: fallo al listar $S3_PATH (timeout ${LS_TIMEOUT}s)"
    return 1
  fi
  return 0
}

# ---------- Loop principal ----------
echo "Iniciando monitor de conectividad (intervalo ${INTERVAL_SEC}s). Log de errores: $LOG_FILE"
while true; do
  # 1) MySQL (SIRET)
  check_nc "atdb.relevando.com" "3306" "MySQL atdb.relevando.com"

  # 2) S3 montado
  check_s3_path

  # 3) Internet (salida TCP 443)
  check_nc "google.com" "443" "Internet (google.com:443)"

  sleep "$INTERVAL_SEC"
done
Actions #3

Updated by Demo MiGestion365 Admin about 1 month ago · Edited

Se procede a la instalación del script

sudo install -m 755 connectivity_monitor.sh /usr/local/bin/connectivity_monitor.sh
sudo touch /var/log/connectivity_monitor.log
sudo chown "$USER":"$USER" /var/log/connectivity_monitor.log

/usr/local/bin/connectivity_monitor.sh

y se lo deja corriendo con:

nohup /usr/local/bin/connectivity_monitor.sh >/dev/null 2>&1 &
Actions #4

Updated by Demo MiGestion365 Admin about 1 month ago · Edited

  • Due date set to 02/23/2026
  • Status changed from Nueva to Resuelta

La manera de visualizar el log es:

 tail -f /var/log/connectivity_monitor.log
 tail -50 /var/log/connectivity_monitor.log
Actions

Also available in: Atom PDF