dual-eth-network-monitor.sh

BPI-5202 Loongson 2K1000LAi Embedded Single Board Industrial Computer · File : dual-eth-network-monitor.sh · Language : Bash · Use case : Surveiller le trafic réseau sur les deux ports Ethernet indépendants (1000M et 100M) pour le diagnostic industriel.

Bash script using iproute2 tools to display traffic statistics on both Ethernet interfaces.

Directly executable under LoongOS or KylinOS. The BPI-5202 has two physically separate Ethernet ports. Check interface names with 'ip link'. This script is useful for checking link stability in industrial environments.

dual-eth-network-monitor.sh

#!/bin/bash
# Script de surveillance réseau pour BPI-5202
# Nécessite l'installation de 'iftop' ou 'nload'

# Identifier les interfaces. Souvent eth0 (1000M) et eth1 (100M) ou en1/en2 selon le OS.
# Utilisez 'ip link' pour vérifier les noms exacts sous Loongnix/KylinOS.

IFACE1="eth0" # 1000M
IFACE2="eth1" # 100M

if ! command -v iftop &> /dev/null; then
    echo "iftop n'est pas installé. Installation..."
    # Commande générique pour Loongnix/Debian-like
    sudo apt-get update && sudo apt-get install -y iftop
fi

echo "Surveillance du trafic sur $IFACE1 (1000M) et $IFACE2 (100M)..."
echo "Appuyez sur Ctrl+C pour arrêter."

# Lancer iftop sur la première interface en arrière-plan si possible, 
# ou afficher les statistiques de base avec ip
while true; do
    clear
    echo "=== Statistiques Réseau BPI-5202 ==="
    echo "Interface: $IFACE1"
    ip -s link show $IFACE1
    echo ""
    echo "Interface: $IFACE2"
    ip -s link show $IFACE2
    echo ""
    echo "Utilisation CPU (Loongson 2K1000LA):"
    top -bn1 | head -n 5
    sleep 2
done

← Back to the board