nicstatネットワークトラフィック統計利器


オリジナル文章、転載は明記してください:転載自システム技術非アマチュア研究
このリンクアドレス:nicstatネットワークトラフィック統計利器
この間、brendangreggのLinux Performance Analysis and Tools PPTに言及されているnicstatを見て、次はいいものだと研究して、みんなに分かち合いました.
nicstat is to network interfaces as “iostat” is to disks, or “prstat” is to processes.
nicstatはもともとSolarisプラットフォームの下でネットカードの流量を表示するツールで、Tim Cookはそれをlinuxプラットフォームに移植して、公式のウェブサイトはここを見ます.netstatに比べて、彼は以下の重要な特性を持っています.
  • Reports bytes in & out as well as packets.
  • Normalizes these values to per-second rates.
  • Reports on all interfaces (while iterating)
  • Reports Utilization (rough calculation as of now)
  • Reports Saturation (also rough)
  • Prefixes statistics with the current time

  • まずインストールします.ソースコードはここで、現在の最新バージョンは1.92です.リリース後、このバージョンはデフォルトで32ビットlinuxでコンパイルされるため、Makefileを変更する必要があります.Linux: $ diff Makefile.Linux64 Makefile.Linux 17c17 < CFLAGS = $(COPT) -m32 --- > CFLAGS = $(COPT)
    $ sudo make -f Makefile.Linux installがインストールされます.
    ドキュメントを使用するには、linuxでNICのspeedなどの情報を取得する必要があるため、特権ユーザーで実行する必要があります.
    
    $ sudo enicstat -l
    Int      Loopback   Mbit/s Duplex State
    lo            Yes        -   unkn    up
    eth0           No     1000   full    up
    bond0          No        0   unkn    up
    
    $ sudo enicstat 
        Time      Int   rKB/s   wKB/s   rPk/s   wPk/s    rAvs    wAvs %Util    Sat
    13:04:10       lo   161.1   161.1   489.2   489.2   337.3   337.3  0.00   0.00
    13:04:10     eth0   601.9   589.1  1868.1  1894.1   330.0   318.5  0.98   0.00
    13:04:10    bond0   601.9   589.1  1868.1  1894.1   330.0   318.5  0.00   0.00
    

    上記の特徴の1つは、NICのUtil(利用率)とSaturation(This the number of errors/second seen for the interface)が実践的に大きな用途に使われていることです.
    straceとソースコードによる簡単な分析:
    open(“/proc/net/dev”, O_RDONLY) = 3 open(“/proc/net/snmp”, O_RDONLY) = 5 open(“/proc/net/netstat”, O_RDONLY) = 6 open(“/proc/uptime”, O_RDONLY) = 9
    ほとんどの統計情報は上の3つのファイルから取得され、snmpはtcpとudpの統計情報を提供します.
    デフォルトの統計はKB単位で、-MオプションはM単位に変更できます.
    
    $ sudo enicstat -M
        Time      Int   rMbps   wMbps   rPk/s   wPk/s    rAvs    wAvs %Util    Sat
    13:14:51       lo    1.26    1.26   489.1   489.1   337.3   337.3  0.00   0.00
    13:14:51     eth0    4.70    4.60  1868.0  1894.0   330.0   318.5  0.98   0.00
    13:14:51    bond0    4.70    4.60  1868.0  1894.0   330.0   318.5  0.00   0.00
    

    nicstatは、tcpリンクの外部接続と内部接続の個数、リセット、Drops情報、パケット再送率などの情報を提供し、これらの情報はtcp問題の診断に役立ちます.
    
    $ sudo enicstat -t
    13:09:40    InKB   OutKB   InSeg  OutSeg Reset  AttF %ReTX InConn OutCon Drops
    TCP         0.00    0.00  2123.7  2251.7  1.84  0.79 0.000   7.16   2.95  0.00
    

    最後に注意しなければならないのは、出力情報を解読するとき:
    NOTES On Linux, the NoCP, Defer, TCP InKB, and TCP OutKB statistics are always reported as zero.
    The way that saturation is reported is a best effort, as there is no standardized naming to capture all errors related to an interface’s inability to receive or transmit a packet. Monitoring %Util and packet rates, along with an understanding of the specific NICs may be more useful in judging whether you are nearing saturation.
    楽しんでね!
    Post Footer automatically generated by wp-posturl plugin for wordpress.