network-monitor-eth.py

AAEON PICO-PTH4: Pico-ITX Board with Intel Panther Lake SoC · File : network-monitor-eth.py · Language : Python · Use case : Surveiller le trafic réseau sur les ports Ethernet 2.5GbE Intel I226.

Network monitoring script using psutil to display traffic statistics on the 2.5GbE Ethernet interfaces.

The board has two Intel I226 2.5GbE ports. Install psutil (pip install psutil). Check interface names with 'ip link'. Native Linux drivers support I226. Execution: python3 net_monitor.py. Useful for validating bandwidth.

network-monitor-eth.py

import socket
import time
import psutil

def monitor_network():
    # Nom de l'interface (à vérifier avec 'ip a')
    interface = 'eth0'
    print(f"Surveillance de l'interface {interface}...")
    
    try:
        while True:
            counters = psutil.net_io_counters(pernic=True)
            if interface in counters:
                stats = counters[interface]
                # Calcul du débit en Mbps (approximatif)
                bytes_sent = stats.bytes_sent
                bytes_recv = stats.bytes_recv
                
                print(f"[{time.strftime('%H:%M:%S')}] TX: {bytes_sent/1024/1024:.2f} MB | RX: {bytes_recv/1024/1024:.2f} MB")
            else:
                print(f"Interface {interface} non trouvée. Vérifiez le nom.")
                break
            time.sleep(5)
    except KeyboardInterrupt:
        print("Arrêt de la surveillance.")

if __name__ == "__main__":
    monitor_network()

← Back to the board