Files
Linux-Server-Management-Too…/modules/backup/acronis-agent-status.sh
T
cschantz 472978bf06 Deduplicate port 9850 in network connectivity display
Port 9850 was showing twice because it listens on both IPv4 (127.0.0.1)
and IPv6 (::1). Added awk deduplication to show each port only once.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 16:54:17 -05:00

305 lines
9.8 KiB
Bash
Executable File

#!/bin/bash
################################################################################
# Acronis Agent Status Checker
################################################################################
# Purpose: Check status of all Acronis Cyber Protect services
# Services monitored:
# - aakore (Acronis Agent Core)
# - acronis_mms (Management Service)
# - acronis_schedule (Scheduler)
# - active-protection.service (Ransomware Protection)
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
# Require root
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root"
exit 1
fi
print_banner "Acronis Agent Status"
echo ""
echo -e "${BOLD}Checking Acronis Cyber Protect Services...${NC}"
echo ""
# Array of services to check
declare -a SERVICES=(
"aakore:Acronis Agent Core"
"acronis_mms:Management Service"
"acronis_schedule:Backup Scheduler"
"active-protection:Ransomware Protection"
)
# Track overall status
all_running=true
any_installed=false
# Function to check service status
check_service_status() {
local service_name="$1"
local service_desc="$2"
# Check if service exists
if systemctl list-unit-files | grep -q "^${service_name}.service"; then
any_installed=true
# Get service status
if systemctl is-active --quiet "$service_name"; then
echo -e " ${GREEN}${NC} ${BOLD}${service_desc}${NC}"
echo -e " Status: ${GREEN}RUNNING${NC}"
# Get uptime
local uptime=$(systemctl show "$service_name" -p ActiveEnterTimestamp --value)
if [ -n "$uptime" ]; then
echo -e " Uptime: ${uptime}"
fi
# Get PID
local pid=$(systemctl show "$service_name" -p MainPID --value)
if [ "$pid" != "0" ]; then
echo -e " PID: ${pid}"
fi
else
all_running=false
echo -e " ${RED}${NC} ${BOLD}${service_desc}${NC}"
echo -e " Status: ${RED}STOPPED${NC}"
# Check if failed
if systemctl is-failed --quiet "$service_name"; then
echo -e " ${RED}[FAILED]${NC} - Service has errors"
fi
fi
echo ""
elif service "$service_name" status &>/dev/null; then
# Fallback to service command for older systems
any_installed=true
if service "$service_name" status | grep -q "running"; then
echo -e " ${GREEN}${NC} ${BOLD}${service_desc}${NC}"
echo -e " Status: ${GREEN}RUNNING${NC}"
else
all_running=false
echo -e " ${RED}${NC} ${BOLD}${service_desc}${NC}"
echo -e " Status: ${RED}STOPPED${NC}"
fi
echo ""
fi
}
# Check each service
for service_entry in "${SERVICES[@]}"; do
IFS=':' read -r service_name service_desc <<< "$service_entry"
check_service_status "$service_name" "$service_desc"
done
# Check if Acronis is even installed
if [ "$any_installed" = false ]; then
echo -e "${YELLOW}${BOLD}⚠ Acronis Agent Not Installed${NC}"
echo ""
echo "Acronis Cyber Protect is not installed on this system."
echo ""
echo "To install:"
echo " 1. Return to Backup & Recovery menu"
echo " 2. Select 'Acronis Management'"
echo " 3. Choose 'Install Acronis Agent'"
echo ""
press_enter
exit 0
fi
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo ""
# Overall status summary
if [ "$all_running" = true ]; then
echo -e "${GREEN}${BOLD}✓ All Services Running${NC}"
echo ""
echo "Acronis Cyber Protect is operational and ready for backups."
else
echo -e "${YELLOW}${BOLD}⚠ Some Services Not Running${NC}"
echo ""
echo "Some Acronis services are stopped. You may want to:"
echo " • Start services: Select 'Service Management' from Acronis menu"
echo " • Check logs: Select 'View Logs' for error details"
echo " • Restart services: Try restarting all services"
fi
echo ""
# Check agent registration status
echo -e "${BOLD}Agent Registration:${NC}"
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)
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 not registered"
fi
else
echo -e " ${YELLOW}${NC} Configuration file not found"
fi
echo ""
# Check active ports
echo -e "${BOLD}Network Connectivity:${NC}"
# Check for actual Acronis listening ports (deduplicate IPv4/IPv6)
acronis_ports=$(netstat -tlnp 2>/dev/null | grep -E "(acronis|mms|aakore)" | awk '{
split($4, addr, ":");
port = addr[length(addr)];
if (!seen[port]++) {
print $4 " " $7;
}
}')
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 '<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 ""
# Check disk space for backups
echo -e "${BOLD}Local Storage Status:${NC}"
if [ -d "/var/lib/Acronis" ]; then
backup_dir_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}')
echo -e " Agent data: ${backup_dir_size} (local cache/logs/config)"
# Check free space on partition
free_space=$(df -h /var/lib/Acronis | tail -1 | awk '{print $4}')
use_percent=$(df -h /var/lib/Acronis | tail -1 | awk '{print $5}' | tr -d '%')
echo -e " Free space: ${free_space} (on root partition)"
if [ -n "$use_percent" ] && [ "$use_percent" -gt 90 ] 2>/dev/null; then
echo -e " ${RED}⚠ Warning: Disk usage at ${use_percent}%${NC}"
fi
fi
echo ""
echo -e "${DIM}Note: Backup storage usage is shown in Acronis web console${NC}"
echo ""
# Quick Actions
echo -e "${BOLD}Quick Actions:${NC}"
echo ""
echo -e " ${CYAN}1)${NC} Start All Services"
echo -e " ${CYAN}2)${NC} Stop All Services"
echo -e " ${CYAN}3)${NC} Restart All Services"
echo -e " ${CYAN}4)${NC} View Live Logs"
echo -e " ${CYAN}5)${NC} Check Agent Version"
echo ""
echo -e " ${RED}0)${NC} Return to Menu"
echo ""
echo -n "Select action (or press Enter to return): "
read -r action
case "$action" in
1)
echo ""
echo "Starting all Acronis services..."
systemctl start aakore
systemctl start acronis_mms
systemctl start acronis_schedule
systemctl start active-protection
echo ""
print_success "Services started"
sleep 2
exec "$0"
;;
2)
echo ""
echo "Stopping all Acronis services..."
systemctl stop active-protection
systemctl stop acronis_schedule
systemctl stop acronis_mms
systemctl stop aakore
echo ""
print_success "Services stopped"
sleep 2
exec "$0"
;;
3)
echo ""
echo "Restarting all Acronis services..."
systemctl restart aakore
systemctl restart acronis_mms
systemctl restart acronis_schedule
systemctl restart active-protection
echo ""
print_success "Services restarted"
sleep 2
exec "$0"
;;
4)
if [ -f "/var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" ]; then
echo ""
echo "Showing live log (Ctrl+C to exit)..."
sleep 1
tail -f /var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log
else
print_error "Log file not found"
press_enter
fi
;;
5)
echo ""
echo -e "${BOLD}Agent Version Information:${NC}"
if command -v /usr/lib/Acronis/BackupAndRecovery/aakore &>/dev/null; then
/usr/lib/Acronis/BackupAndRecovery/aakore --version 2>/dev/null || echo "Version info not available"
else
echo "Agent binary not found"
fi
echo ""
press_enter
;;
*)
# Return to menu
exit 0
;;
esac