ids.alfacom.it/deployment/setup_analytics_timer.sh
marco370 cbd03d9e64 Add network analytics and live dashboard features
Introduce new network analytics capabilities with persistent storage, hourly and daily aggregations, and enhanced frontend visualizations. This includes API endpoints for retrieving analytics data, systemd services for automated aggregation, and UI updates for live and historical dashboards. Additionally, country flag emojis are now displayed on the detections page.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: 3c14f651-7633-4128-8526-314b4942b3a0
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/oGXAoP7
2025-11-22 11:34:36 +00:00

64 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Setup systemd timer for analytics aggregation
# Deve essere eseguito come root
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${BLUE}╔═══════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ IDS Analytics Timer Setup ║${NC}"
echo -e "${BLUE}╚═══════════════════════════════════════════════╝${NC}"
echo ""
# Check root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}❌ Questo script deve essere eseguito come root${NC}"
echo -e "${YELLOW} Usa: sudo $0${NC}"
exit 1
fi
IDS_DIR="/opt/ids"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Copy systemd files
echo -e "${BLUE}📋 Copia file systemd...${NC}"
cp "${SCRIPT_DIR}/ids-analytics-aggregator.service" /etc/systemd/system/
cp "${SCRIPT_DIR}/ids-analytics-aggregator.timer" /etc/systemd/system/
# Set permissions
chmod 644 /etc/systemd/system/ids-analytics-aggregator.service
chmod 644 /etc/systemd/system/ids-analytics-aggregator.timer
# Reload systemd
echo -e "${BLUE}🔄 Reload systemd daemon...${NC}"
systemctl daemon-reload
# Enable and start timer
echo -e "${BLUE}⚙️ Enable e start timer...${NC}"
systemctl enable ids-analytics-aggregator.timer
systemctl start ids-analytics-aggregator.timer
# Check status
echo -e "\n${BLUE}📊 Stato timer:${NC}"
systemctl status ids-analytics-aggregator.timer --no-pager
echo -e "\n${BLUE}📅 Prossime esecuzioni:${NC}"
systemctl list-timers ids-analytics-aggregator.timer --no-pager
echo -e "\n${GREEN}╔═══════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ ✅ ANALYTICS TIMER CONFIGURATO ║${NC}"
echo -e "${GREEN}╚═══════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}📝 Comandi utili:${NC}"
echo -e " ${YELLOW}Stato timer:${NC} sudo systemctl status ids-analytics-aggregator.timer"
echo -e " ${YELLOW}Prossime run:${NC} sudo systemctl list-timers"
echo -e " ${YELLOW}Log aggregazione:${NC} sudo journalctl -u ids-analytics-aggregator -f"
echo -e " ${YELLOW}Test manuale:${NC} sudo systemctl start ids-analytics-aggregator"
echo ""