psql $DATABASE_URL << 'EOF'
-- Conta record in ogni tabella
SELECT 'network_logs' as table_name, COUNT(*) as count FROM network_logs
UNION ALL
SELECT 'detections', COUNT(*) FROM detections
UNION ALL
SELECT 'training_history', COUNT(*) FROM training_history
UNION ALL
SELECT 'routers', COUNT(*) FROM routers
UNION ALL
SELECT 'whitelist', COUNT(*) FROM whitelist;

-- Mostra ultimi 5 log di rete
SELECT timestamp, source_ip, destination_ip, protocol, router_name
FROM network_logs
ORDER BY timestamp DESC
LIMIT 5;

-- Mostra training history
SELECT * FROM training_history ORDER BY trained_at DESC LIMIT 5;

-- Mostra detections
SELECT * FROM detections ORDER BY detected_at DESC LIMIT 5;
EOF
    table_name    | count
------------------+-------
 network_logs     |     0
 detections       |     0
 training_history |     0
 routers          |     1
 whitelist        |     0
(5 rows)

 timestamp | source_ip | destination_ip | protocol | router_name
-----------+-----------+----------------+----------+-------------
(0 rows)

 id | model_version | records_processed | features_count | accuracy | training_duration | status | notes | trained_at
----+---------------+-------------------+----------------+----------+-------------------+--------+-------+------------
(0 rows)

 id | source_ip | risk_score | confidence | anomaly_type | reason | log_count | first_seen | last_seen | blocked | blocked_at | detected_at
----+-----------+------------+------------+--------------+--------+-----------+------------+-----------+---------+------------+-------------
(0 rows)

[root@ids ids]# curl -s http://localhost:8000/stats | jq .
{
  "logs": {
    "total": 0,
    "last_hour": 0
  },
  "detections": {
    "total": 0,
    "blocked": 0
  },
  "routers": {
    "active": 1
  },
  "latest_training": null
}
[root@ids ids]# tail -50 /var/log/ids/syslog_parser.log
[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[INFO] Processate 417737400 righe, salvate 417728626 log
[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend file "base/16384/16940.223": No space left on device
HINT:  Check free disk space.

[ERROR] Errore salvataggio log: could not extend fil[root@ids ids]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
devtmpfs                        4.0M     0  4.0M   0% /dev
tmpfs                           7.7G   16K  7.7G   1% /dev/shm
tmpfs                           3.1G  8.8M  3.1G   1% /run
efivarfs                        256K   32K  220K  13% /sys/firmware/efi/efivars
/dev/mapper/almalinux_ids-root  491G   40G  451G   9% /
/dev/sda2                       960M  327M  634M  34% /boot
/dev/sda1                       599M  7.1M  592M   2% /boot/efi
tmpfs                           1.6G     0  1.6G   0% /run/user/0
tmpfs                           1.6G     0  1.6G   0% /run/user/1000