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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cschantz
2025-11-06 16:38:58 -05:00
parent 7ccbdcd4c0
commit a978893c60
+43 -26
View File
@@ -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 "<registration>" "/var/lib/Acronis/BackupAndRecovery/MMS/user.config" 2>/dev/null; then
reg_address=$(grep -oP '<address>\K[^<]+' /var/lib/Acronis/BackupAndRecovery/MMS/user.config 2>/dev/null)
reg_env=$(grep -oP '<environment>\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
if [ "$ports_found" = false ]; then
echo -e " ${DIM}No Acronis ports currently listening${NC}"
echo ""
# Check outbound connectivity to cloud (port 443)
if command -v curl >/dev/null 2>&1; then
reg_url=$(grep -oP '<address>\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
fi
echo ""