From 716901a78db4d4e5a856173d9251d12e8755ad62 Mon Sep 17 00:00:00 2001 From: cschantz Date: Thu, 6 Nov 2025 16:38:58 -0500 Subject: [PATCH] Improve Acronis agent registration and port detection Fixed Issues: - Registration check now uses correct config file (user.config) - Parses actual registration XML to verify cloud connection - Shows registration URL and environment Port Monitoring: - Now detects actual Acronis listening ports via netstat - Shows real local ports (9850 for MMS, dynamic ports for aakore) - Identifies which service owns each port - Tests actual cloud connectivity with timeout Changes: - Registration verified from /var/lib/Acronis/.../user.config - Port 9850 (localhost): MMS management service - Dynamic ports: aakore agent core - Added cloud connectivity test to registration URL --- modules/backup/acronis-agent-status.sh | 73 ++++++++++++++++---------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/modules/backup/acronis-agent-status.sh b/modules/backup/acronis-agent-status.sh index 3599257..4508dd7 100755 --- a/modules/backup/acronis-agent-status.sh +++ b/modules/backup/acronis-agent-status.sh @@ -132,17 +132,21 @@ echo "" # Check agent registration status echo -e "${BOLD}Agent Registration:${NC}" -if [ -f "/etc/Acronis/Global.config" ]; then - if grep -q "CloudUrl" "/etc/Acronis/Global.config" 2>/dev/null; then - echo -e " ${GREEN}✓${NC} Agent is registered with Acronis Cloud" +if [ -f "/var/lib/Acronis/BackupAndRecovery/MMS/user.config" ]; then + # Check for registration info in user.config + if grep -q "" "/var/lib/Acronis/BackupAndRecovery/MMS/user.config" 2>/dev/null; then + reg_address=$(grep -oP '
\K[^<]+' /var/lib/Acronis/BackupAndRecovery/MMS/user.config 2>/dev/null) + reg_env=$(grep -oP '\K[^<]+' /var/lib/Acronis/BackupAndRecovery/MMS/user.config 2>/dev/null) - # Extract cloud URL if possible - cloud_url=$(grep -oP 'CloudUrl[>="].*?https://[^"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^"<]+' | head -1) - if [ -n "$cloud_url" ]; then - echo -e " URL: ${cloud_url}" + if [ -n "$reg_address" ]; then + echo -e " ${GREEN}✓${NC} Agent is registered with Acronis Cloud" + echo -e " URL: ${reg_address}" + [ -n "$reg_env" ] && echo -e " Environment: ${reg_env}" + else + echo -e " ${YELLOW}⚠${NC} Registration incomplete" fi else - echo -e " ${YELLOW}⚠${NC} Agent may not be registered" + echo -e " ${YELLOW}⚠${NC} Agent not registered" fi else echo -e " ${YELLOW}⚠${NC} Configuration file not found" @@ -152,29 +156,42 @@ echo "" # Check active ports echo -e "${BOLD}Network Connectivity:${NC}" -echo -e "Active Acronis ports:" -declare -a PORTS=( - "80:HTTP" - "443:HTTPS/Cloud" - "5060:Agent Management" - "7770:Backup Traffic" - "7800:Backup Gateway" - "8443:Web Console" - "44445:Agent Communication" -) +# Check for actual Acronis listening ports +acronis_ports=$(netstat -tlnp 2>/dev/null | grep -E "(acronis|mms|aakore)" | awk '{print $4 " " $7}' | sort -u) -ports_found=false -for port_entry in "${PORTS[@]}"; do - IFS=':' read -r port port_desc <<< "$port_entry" - if netstat -tuln 2>/dev/null | grep -q ":${port}\s"; then - echo -e " ${GREEN}✓${NC} Port ${port} (${port_desc})" - ports_found=true +if [ -n "$acronis_ports" ]; then + echo "Active Acronis services:" + echo "$acronis_ports" | while read -r addr process; do + port=$(echo "$addr" | grep -oP ':\K[0-9]+$') + if echo "$addr" | grep -q "127.0.0.1\|::1"; then + # Local-only port + if [ "$port" = "9850" ]; then + echo -e " ${GREEN}✓${NC} Port $port (localhost) - MMS Service" + else + echo -e " ${GREEN}✓${NC} Port $port (localhost) - $(basename "$process" | cut -d/ -f2)" + fi + else + echo -e " ${GREEN}✓${NC} Port $port - $(basename "$process" | cut -d/ -f2)" + fi + done +else + echo -e " ${YELLOW}⚠${NC} No Acronis ports detected" +fi + +echo "" + +# Check outbound connectivity to cloud (port 443) +if command -v curl >/dev/null 2>&1; then + reg_url=$(grep -oP '
\K[^<]+' /var/lib/Acronis/BackupAndRecovery/MMS/user.config 2>/dev/null) + if [ -n "$reg_url" ]; then + echo -n "Testing cloud connectivity... " + if timeout 5 curl -s -o /dev/null -w "%{http_code}" "$reg_url" 2>/dev/null | grep -q "^[2-4]"; then + echo -e "${GREEN}✓${NC} Connected" + else + echo -e "${YELLOW}⚠${NC} Cannot reach cloud (may be firewall/network issue)" + fi fi -done - -if [ "$ports_found" = false ]; then - echo -e " ${DIM}No Acronis ports currently listening${NC}" fi echo ""