dual-eth-network-monitor.sh

Computador industrial de placa única BPI-5202 Loongson 2K1000LAi · Archivo : dual-eth-network-monitor.sh · Lenguaje : Bash · Uso : Surveiller le trafic réseau sur les deux ports Ethernet indépendants (1000M et 100M) pour le diagnostic industriel.

Script en Bash que utiliza las herramientas iproute2 para mostrar estadísticas de tráfico en ambas interfaces Ethernet.

Ejecutable directamente bajo LoongOS o KylinOS. El BPI-5202 tiene dos puertos Ethernet físicamente separados. Verifique los nombres de interfaz con 'ip link'. Este script es útil para verificar la estabilidad del enlace en entornos industriales.

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

← Volver a la ficha