
  Aggiornamento schema database...
   Applicando migrazioni SQL...
  Sistema Migrazioni Database (Versioned)
 Verifica sistema versioning...
psql:/opt/ids/database-schema/migrations/000_init_schema_version.sql:14: NOTICE:  relation "schema_version" already exists, skipping
✅ Sistema versioning attivo
 Versione database corrente: 2
✅ Database già aggiornato (nessuna migrazione da applicare)
   ✅ Migrazioni SQL applicate
   Sincronizzando schema Drizzle...

> rest-express@1.0.0 db:push
> drizzle-kit push

No config path provided, using default 'drizzle.config.ts'
Reading config file '/opt/ids/drizzle.config.ts'
Using 'pg' driver for database querying
[✓] Pulling schema from database...
[✓] Changes applied
✅ Schema database completamente sincronizzato

 Configurazione RSyslog (log MikroTik)...
   ✅ RSyslog già configurato

 Restart servizi...
✅ Servizi riavviati

╔═══════════════════════════════════════════════╗
║   ✅ AGGIORNAMENTO COMPLETATO                 ║
╚═══════════════════════════════════════════════╝

 VERIFICA SISTEMA:
   • Log backend:  tail -f /var/log/ids/backend.log
   • Log frontend: tail -f /var/log/ids/frontend.log
   • API backend:  curl http://localhost:8000/health
   • Frontend:     curl http://localhost:5000

 STATO SERVIZI:
ids         1547  6.0  4.0 2187384 650548 ?      Sl   Nov21  57:18 /usr/bin/python3.11 main.py
root       12542  0.0  0.0  18344  8576 pts/3    S    09:45   0:00 sudo -u ids python3 syslog_parser.py
ids        12544  0.2  0.1  52844 27132 pts/3    S    09:45   0:06 python3 syslog_parser.py
root       13114  0.0  0.0  18344  8576 pts/3    S    09:58   0:00 sudo -u ids python3 syslog_parser.py
ids        13116  8.3  0.1  52928 27136 pts/3    S    09:58   3:04 python3 syslog_parser.py
root       14333  0.0  0.2 729796 33360 pts/0    Rl+  10:35   0:00 /usr/bin/node /usr/bin/npm run dev

[root@ids ids]# sudo ./deployment/setup_systemd_services.sh
 Setup Systemd Services per IDS

 Generazione IDS_API_KEY...
✅ IDS_API_KEY generata e salvata in .env
 Installazione systemd units...
♻  Reload systemd daemon...
⏸  Fermando processi manuali esistenti...
 Attivazione servizi...
Created symlink /etc/systemd/system/multi-user.target.wants/ids-ml-backend.service → /etc/systemd/system/ids-ml-backend.service.
✅ ids-ml-backend.service attivato
Created symlink /etc/systemd/system/multi-user.target.wants/ids-syslog-parser.service → /etc/systemd/system/ids-syslog-parser.service.
✅ ids-syslog-parser.service attivato

📊 Status Servizi:
● ids-ml-backend.service - IDS ML Backend (FastAPI)
     Loaded: loaded (/etc/systemd/system/ids-ml-backend.service; enabled; preset: disabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 10:35:57 CET; 2s ago
    Process: 14445 ExecStart=/usr/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 14445 (code=exited, status=1/FAILURE)
        CPU: 21ms

● ids-syslog-parser.service - IDS Syslog Parser (Network Logs Processor)
     Loaded: loaded (/etc/systemd/system/ids-syslog-parser.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-11-22 10:35:57 CET; 2s ago
   Main PID: 14471 (python3)
      Tasks: 1 (limit: 100409)
     Memory: 10.8M (max: 1.0G available: 1013.1M)
        CPU: 236ms
     CGroup: /system.slice/ids-syslog-parser.service
             └─14471 /usr/bin/python3 syslog_parser.py


╔═══════════════════════════════════════════════╗
║   ✅ SYSTEMD SERVICES CONFIGURATI              ║
╚═══════════════════════════════════════════════╝

📚 COMANDI UTILI:
   systemctl status ids-ml-backend       - Status ML Backend
   systemctl status ids-syslog-parser    - Status Syslog Parser
   systemctl restart ids-ml-backend      - Restart ML Backend
   systemctl restart ids-syslog-parser   - Restart Syslog Parser
   journalctl -u ids-ml-backend -f       - Log ML Backend
   journalctl -u ids-syslog-parser -f    - Log Syslog Parser

[root@ids ids]# systemctl status ids-ml-backend
● ids-ml-backend.service - IDS ML Backend (FastAPI)
     Loaded: loaded (/etc/systemd/system/ids-ml-backend.service; enabled; preset: disabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 10:35:57 CET; 8s ago
    Process: 14445 ExecStart=/usr/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 14445 (code=exited, status=1/FAILURE)
        CPU: 21ms
[root@ids ids]# systemctl status ids-syslog-parser
● ids-syslog-parser.service - IDS Syslog Parser (Network Logs Processor)
     Loaded: loaded (/etc/systemd/system/ids-syslog-parser.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-11-22 10:35:57 CET; 20s ago
   Main PID: 14471 (python3)
      Tasks: 1 (limit: 100409)
     Memory: 11.0M (max: 1.0G available: 1012.9M)
        CPU: 1.699s
     CGroup: /system.slice/ids-syslog-parser.service
             └─14471 /usr/bin/python3 syslog_parser.py

Nov 22 10:35:57 ids.alfacom.it systemd[1]: Started IDS Syslog Parser (Network Logs Processor).
[root@ids ids]#                                                                                                            