shell获取Linux系统网卡相关信息


    interface_name=`cat /proc/net/dev | sed -n '3,$p' | awk -F ':' {'print $1'}`
    eth_arr=($interface_name)

    for eth in ${eth_arr[@]};do
        ip=`ifconfig $eth | grep -w inet`
        ether=`ifconfig $eth | grep -w ether | awk '{print $1,$2}'`
        bandwidth=`ethtool $eth| grep 'Speed'`

        eth_status=`ifconfig $eth | grep 'UP'`
        if [ -z "$eth_status" ];then
            eth_status=" DONW"
        else
            eth_status=" UP"
        fi
        multi_queue_cnt=`cat /proc/interrupts | grep -v event|grep $eth | wc -l`
        if [ $multi_queue_cnt -gt 1 ];then
            is_eth_multi_queue="true"
        else
            is_eth_multi_queue="false"
        fi
        echo " $eth: 
        $ip $ether $bandwidth status:$eth_status  is_eth_multi_quque:$is_eth_multi_queue"
    done

你可能感兴趣的:(shell脚本学习)