• 06 查看网卡实时流量


    #!/bin/bash
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
    
    NIC=$1
    echo -e "Time ----------------- In ------- Out"
    while true; do
        OLD_IN=$(awk '/'$NIC'/ {print $2}' /proc/net/dev)
        OLD_OUT=$(awk '/'$NIC'/ {print $10}' /proc/net/dev)
        sleep 1
        NEW_IN=$(awk '/'$NIC'/ {print $2}' /proc/net/dev)
        NEW_OUT=$(awk '/'$NIC'/ {print $10}' /proc/net/dev)
        IN=$(printf "%.1f%s" "$((($NEW_IN-$OLD_IN)/1024))" "KB/s")
        OUT=$(printf "%.1f%s" "$((($NEW_OUT-$OLD_OUT)/1024))" "KB/s")
        echo "$(date "+%Y-%m-%d %H:%M:%S")    $IN    $OUT"
    done
  • 相关阅读:
    java面试常见的类
    Day6
    DAY5
    Day4
    Day3
    Day2
    Day1
    echarts3关系图:力引导布局, 固定某些节点
    Hbuilder中配置cmd
    webpack 学习
  • 原文地址:https://www.cnblogs.com/LiuChang-blog/p/14697940.html
Copyright © 2020-2023  润新知