리눅스에서 장착된 랜카드에 실시간 대역폭을 확인하는 방법이 궁금합니다!

duofinal의 이미지

네트워크의 대역폭 사용률을 실시간으로 확인하려고 합니다.

/proc에서 실시간 receive / transmit 패킷 정보는 볼 수 있는데,

현재 사용하고 있는 랜카드의 실시간 대역폭은 어디서 확인하는지 알수가 없네요

김정균의 이미지

대역폭은 일정 기간동안의 전송량의 평균 * 8 로 구합니다. iptraf 라 제가 만든 check-utils 에 포함된 chkbandwidth 로 볼 수 있습니다.

drinkme의 이미지

/sys/class/net/eth0/statistics/*
를 보세요.

바라미의 이미지

http://www.linux.com/archive/articles/50649

iptables를 통해서 보는 것도 있군요..

aero의 이미지

네트웍 트레픽을 볼 수 있는 프로그램
ifstat - http://gael.roualland.free.fr/ifstat/
dstat - http://dag.wieers.com/home-made/dstat/

리눅스에서 /proc/net/dev 를 파싱해서 노가다로 계산하는 방법
http://www.linux.co.kr/home/lecture/index.php?cateNo=1&secNo=10959&theNo=&leccode=11062

제가 즐겨 쓰는방법
http://search.cpan.org/dist/Sys-Statistics-Linux/ 모듈내의
http://search.cpan.org/perldoc?Sys::Statistics::Linux::NetStats
모듈을 사용하여

#!/usr/bin/perl
use strict;
use warnings;
use Sys::Statistics::Linux::NetStats;
use Data::Dumper;
 
my $lxs = Sys::Statistics::Linux::NetStats->new;
$lxs->init;
sleep 1;
my $stat = $lxs->get;
 
#원하는 것만 찍을 때
#print $stat->{eth1}{rxbyt};
 
# 모든 내용 덤프
print Dumper $stat;

결과

$VAR1 = {
          'lo' => {
                    'txbyt' => '0.00',
                    'rxfifo' => '0.00',
                    'rxframe' => '0.00',
                    'txcompr' => '0.00',
                    'rxerrs' => '0.00',
                    'ttbyt' => '0.00',
                    'txerrs' => '0.00',
                    'rxpcks' => '0.00',
                    'txcarr' => '0.00',
                    'txdrop' => '0.00',
                    'txcolls' => '0.00',
                    'txfifo' => '0.00',
                    'rxbyt' => '0.00',
                    'txpcks' => '0.00',
                    'rxdrop' => '0.00',
                    'rxmulti' => '0.00',
                    'ttpcks' => '0.00',
                    'rxcompr' => '0.00'
                  },
          'eth1' => {
                      'txbyt' => '0.00',
                      'rxfifo' => '0.00',
                      'rxframe' => '0.00',
                      'txcompr' => '0.00',
                      'rxerrs' => '0.00',
                      'ttbyt' => '60.00',
                      'txerrs' => '0.00',
                      'rxpcks' => '1.00',
                      'txcarr' => '0.00',
                      'txdrop' => '0.00',
                      'txcolls' => '0.00',
                      'txfifo' => '0.00',
                      'rxbyt' => '60.00',
                      'txpcks' => '0.00',
                      'rxdrop' => '0.00',
                      'rxmulti' => '0.00',
                      'ttpcks' => '1.00',
                      'rxcompr' => '0.00'
                    }
        };

리눅스에서 각종 성능치는 /proc 이하 파일들을 특정시간 간격을 두고 파싱하여 계산하는 것이 대부분입니다.
이런 계산을 수동으로 한다는 건 위에서 쉘로 awk등을 사용해서 삽질해서 값을 구하는 것 처럼 귀찮고
손이 많이 가는 노가다성 작업이기도 하고요...

그럴때는 앞에서 말씀드린 Perl CPAN
http://search.cpan.org/dist/Sys-Statistics-Linux/
모듈을 쓰면 필요한 거의 모든 시스템정보 및 성능치를 손쉽게 뽑아낼 수 있습니다.
/proc 파일을 직접 노가다 파싱해서 작업하셨던 분들이면 그동안의 삽질이 억울해서 눈물흘리실 듯 :)

ahsan의 이미지

제가 Perl을 몰라서 그러는데 모듈은 어떻게 설치하나요?

aero의 이미지

duofinal의 이미지

지금까지 /proc에 장치 파일들을 가지고 직접 파싱해서 계산했는데, 관련 유틸이 많군요 ㅋ

그런데 제가 알고 싶은 것은 "네트워크에 바인드된 가용 대역폭의 크기" 입니다.

(예를 들어 윈도우의 경우 wmi를 이용하면 현재 랜카드의 대역폭을 얻어 올 수 있습니다.)

이값을 이용해서 네트워크 대역폭 사용률 ( 네트워크 트래픽 (in or out) / 네트워크에 바인드된 가용 대역폭의 크기 * 100)

계산하려고 하는게 목적인데 제가 요점을 정확히 전달하지 못한 것 같군요 ㅡㅡ;

aero의 이미지

Windows의 경우 WMI로
Win32_PerfRawData_Tcpip_NetworkInterface 나
2003 이상일 경우 Win32_PerfFormattedData_Tcpip_NetworkInterface의
CurrentBandwidth를 항목을 가져오면 되지만

Linux의 경우 ethtool 같은 유틸리티나 dmesg에 남은 로그를 보고
NIC의 최대대역폭을 가져올 수 있는 방법 등등 이 있으나
참고: http://linuxhelp.blogspot.com/2005/10/find-speed-of-your-ethernet-card-in.html
제가 같은 문제로 다양한 방법을 테스트 해본 결과 어떤 방법을 사용해도 그 최대 대역폭
값을 알아낼 수 없는 경우가 발생하더군요.(가상머신상에서 리눅스가 돌때 등)

그래서 저의 결론은 아직 리눅스에서는 완벽한 방법은 없다. 입니다.

duofinal의 이미지

다시 한번 많은 담변 감사드립니다~

dmesg로도 초기 부팅시에 랜카드 대역폭이 출력되질 않는군요~

열심히 찾아봐야 겠습니다~

사랑천사의 이미지

대역폭 사용량을 편하게 보실려면 bwm-ng를 써 보시면 될 듯 하고요.
그러니깐.. 10Mbps나 100Mbps냐 이걸 보실려고 하시는 거 같은데.. 이건 보통 dmesg로 관련 이더넷 장치를 바인딩하는 시점에 대한 정보를 보면 나타납니다. (가끔 안 나오는 것들도...) dmesg와 grep를 이용하면 쉽게 찾을 수 있습니다.
dmesg | grep eth0
뭐 대충 이렇게..
-- 이여송 --
HomePage: http://lys.lecl.net/
Blog: http://lys.lecl.net/blog
LECL: http://www.lecl.net/
E-Mail: yeosong@gmail.com ysnglee2000@lecl.net
MSN: ysnglee2000@hotmail.com

사람천사

ymir의 이미지

ethtool 이 있다면, 그냥 그걸로 열어보면 될 것 같은데요...

$ ethtool eth4
Settings for eth4:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: d
        Wake-on: d
        Current message level: 0x00000001 (1)
        Link detected: yes

linux/ethtool.h 를 열어 보시면, ioctl 에서 쓸 수 있는 정보들이 있습니다.

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.