OS

[스크랩] 네트워크 트래픽 모니터링 vnstat

by LionHeart posted Mar 08, 2016
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

vnstat 는 콘솔 환경 트래픽 측정 툴이며 리눅스와 BSD 계열에서 사용이 가능합니다.
아래 사이트에서 다운로드 한후 설치를 진행합니다.

http://humdi.net/vnstat/
[root@ruo91 ~]# cd /usr/local/src
[root@ruo91 ~]# wget http://humdi.net/vnstat/vnstat-1.9.tar.gz
[root@ruo91 ~]# tar xzvf vnstat-1.9.tar.gz
[root@ruo91 ~]# cd vnstat-1.9
[root@ruo91 ~]# make && make install
[root@ruo91 ~]# touch /var/lib/vnstat/eth0


crontab 에 매 5분 마다 실행 하도록 아래 내용 추가 합니다.

[root@ruo91 ~]# echo '*/5 * * * * vnstat -u -i eth0' >> /etc/crontab
[root@ruo91 ~]# service crond restart
crond 를 정지 중: [  OK  ]
crond (을)를 시작 중: [  OK  ]

vnstat 기본 사용법은 vnstat -u -i eth0 이며 -i 옵션 뒤에는 트래픽을 측정할 NIC(Network Interface Card)를 입력 해주시면 됩니다.

vnstat 실행

[root@ruo91 ~]# vnstat
Database updated: Tue Oct 27 12:53:56 2009

   eth0 since 10/27/09

          rx:  350.88 MiB      tx:  2.34 MiB      total:  353.22 MiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Oct '09    350.88 MiB |    2.34 MiB |  353.22 MiB |    1.26 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated       408 MiB |       2 MiB |     410 MiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
         today    350.88 MiB |    2.34 MiB |  353.22 MiB |   62.31 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated       652 MiB |       3 MiB |     655 MiB |


옵션 사용 예
시간별

[root@ruo91 ~]# vnstat -h
eth0 21:25
^ r
| r
| r r
| r r r
| t r r r t
| rt r r r r t t
| rt r r r r t t
| rt r r t r r r t t
| rt r rt t r r r rt rt t rt rt t
| rt rt rt rt rt r rt r r r r r rt rt rt rt rt rt rt t
-+--------------------------------------------------------------------------->
| 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21

h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) h rx (KiB) tx (KiB)
22 250,801 205,825 06 100,529 49,054 14 205,356 157,877
23 705,144 885,844 07 52,806 44,130 15 258,228 226,265
00 928,792 224,789 08 52,298 45,230 16 1,028,043 343,843
01 1,271,180 292,260 09 70,396 61,719 17 755,804 293,309
02 212,296 186,481 10 155,502 72,451 18 235,691 284,886
03 165,931 91,943 11 266,673 92,497 19 275,554 658,386
04 150,997 437,071 12 392,244 122,185 20 307,819 850,813
05 180,170 56,391 13 133,829 120,555 21 117,474 292,787


하루(매일) 측정시

[root@ruo91 ~]# vnstat -d

eth0 / daily

day rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
07/03/09 10.90 GiB | 6.39 GiB | 17.29 GiB | 1.68 Mbit/s
07/04/09 21.21 GiB | 5.65 GiB | 26.87 GiB | 2.61 Mbit/s
07/05/09 10.58 GiB | 6.67 GiB | 17.25 GiB | 1.67 Mbit/s
07/06/09 49.90 GiB | 9.69 GiB | 59.59 GiB | 5.79 Mbit/s
07/07/09 28.09 GiB | 7.58 GiB | 35.68 GiB | 3.46 Mbit/s
07/08/09 17.60 GiB | 6.83 GiB | 24.43 GiB | 2.37 Mbit/s
07/09/09 20.80 GiB | 15.64 GiB | 36.44 GiB | 3.54 Mbit/s
07/10/09 16.10 GiB | 11.14 GiB | 27.24 GiB | 2.64 Mbit/s
07/11/09 9.79 GiB | 4.96 GiB | 14.76 GiB | 1.43 Mbit/s
07/12/09 9.36 GiB | 9.60 GiB | 18.97 GiB | 1.84 Mbit/s
07/13/09 11.26 GiB | 8.16 GiB | 19.42 GiB | 1.89 Mbit/s
07/14/09 32.65 GiB | 9.56 GiB | 42.21 GiB | 4.10 Mbit/s
07/15/09 35.32 GiB | 15.55 GiB | 50.88 GiB | 4.94 Mbit/s
07/16/09 20.71 GiB | 15.24 GiB | 35.95 GiB | 3.49 Mbit/s
07/17/09 15.10 GiB | 15.34 GiB | 30.44 GiB | 2.95 Mbit/s
07/18/09 14.23 GiB | 5.20 GiB | 19.44 GiB | 1.89 Mbit/s
07/19/09 23.59 GiB | 6.73 GiB | 30.32 GiB | 2.94 Mbit/s
07/20/09 36.36 GiB | 7.53 GiB | 43.90 GiB | 4.26 Mbit/s
07/21/09 28.11 GiB | 6.06 GiB | 34.16 GiB | 3.32 Mbit/s
07/22/09 20.80 GiB | 15.36 GiB | 36.16 GiB | 3.51 Mbit/s
07/23/09 18.20 GiB | 10.71 GiB | 28.91 GiB | 2.81 Mbit/s
07/24/09 13.07 GiB | 6.25 GiB | 19.33 GiB | 1.88 Mbit/s
07/25/09 9.74 GiB | 6.38 GiB | 16.11 GiB | 1.56 Mbit/s
07/26/09 11.51 GiB | 6.66 GiB | 18.17 GiB | 1.76 Mbit/s
07/27/09 16.68 GiB | 9.18 GiB | 25.86 GiB | 2.51 Mbit/s
07/28/09 17.06 GiB | 6.61 GiB | 23.67 GiB | 2.30 Mbit/s
07/29/09 23.19 GiB | 7.21 GiB | 30.41 GiB | 2.95 Mbit/s
07/30/09 9.34 GiB | 7.79 GiB | 17.13 GiB | 1.66 Mbit/s
07/31/09 19.19 GiB | 8.63 GiB | 27.82 GiB | 2.70 Mbit/s
08/01/09 17.13 GiB | 10.50 GiB | 27.63 GiB | 2.81 Mbit/s
------------------------+-------------+-------------+---------------
estimated 17.94 GiB | 11.00 GiB | 28.94 GiB |


월별(monthly)

[root@ruo91 ~]# vnstat -m

eth0 / monthly

month rx | tx | total | avg. rate
------------------------+--------------+--------------+---------------
Nov '08 74.94 GiB | 96.48 GiB | 171.42 GiB | 554.76 kbit/s
Dec '08 279.32 GiB | 276.05 GiB | 555.37 GiB | 1.74 Mbit/s
Jan '09 324.34 GiB | 413.38 GiB | 737.72 GiB | 2.31 Mbit/s
Feb '09 273.73 GiB | 362.49 GiB | 636.22 GiB | 2.21 Mbit/s
Mar '09 353.50 GiB | 270.03 GiB | 623.53 GiB | 1.95 Mbit/s
Apr '09 361.74 GiB | 365.01 GiB | 726.74 GiB | 2.35 Mbit/s
May '09 345.62 GiB | 440.43 GiB | 786.05 GiB | 2.46 Mbit/s
Jun '09 758.45 GiB | 359.30 GiB | 1.09 TiB | 3.62 Mbit/s
Jul '09 609.40 GiB | 282.21 GiB | 891.61 GiB | 2.79 Mbit/s
Aug '09 17.13 GiB | 10.50 GiB | 27.63 GiB | 2.81 Mbit/s
------------------------+--------------+--------------+---------------
estimated 556.15 GiB | 340.85 GiB | 897.00 GiB |


상위 10 순위 출력
[root@ruo91 ~]# vnstat -t

eth0 / top 10

# day rx | tx | total | avg. rate
-----------------------------+-------------+-------------+---------------
1 06/24/09 80.56 GiB | 10.47 GiB | 91.03 GiB | 8.84 Mbit/s
2 06/09/09 49.11 GiB | 21.65 GiB | 70.76 GiB | 6.87 Mbit/s
3 06/15/09 38.01 GiB | 28.77 GiB | 66.78 GiB | 6.48 Mbit/s
4 06/26/09 53.03 GiB | 10.57 GiB | 63.60 GiB | 6.17 Mbit/s
5 07/06/09 49.90 GiB | 9.69 GiB | 59.59 GiB | 5.79 Mbit/s
6 06/25/09 47.32 GiB | 10.11 GiB | 57.43 GiB | 5.58 Mbit/s
7 02/20/09 19.15 GiB | 37.55 GiB | 56.70 GiB | 5.50 Mbit/s
8 02/02/09 20.65 GiB | 34.03 GiB | 54.68 GiB | 5.31 Mbit/s
9 01/14/09 20.00 GiB | 32.99 GiB | 52.99 GiB | 5.14 Mbit/s
10 04/26/09 32.37 GiB | 19.22 GiB | 51.59 GiB | 5.01 Mbit/s
-----------------------------+-------------+-------------+---------------


매주 측정한 값 보기

[root@ruo91 ~]# vnstat -w

eth0 / weekly

rx | tx | total | avg. rate
---------------------------+-------------+-------------+---------------
last 7 days 114.11 GiB | 56.58 GiB | 170.69 GiB | 2.38 Mbit/s
last week 137.79 GiB | 58.96 GiB | 196.75 GiB | 2.73 Mbit/s
current week 102.60 GiB | 49.92 GiB | 152.52 GiB | 2.49 Mbit/s
---------------------------+-------------+-------------+---------------
estimated 121.38 GiB | 59.06 GiB | 180.44 GiB |


5초 동안 트래픽 측정

[root@ruo91 ~]# vnstat -tr
28892 packets sampled in 5 seconds  
Traffic average for eth0

      rx        55.01 Mbit/s          4684 packets/s
      tx       588.80 kbit/s          1093 packets/s


현재 트래픽 상황을 실시간으로 기록하고 사용자가 CTRL-C 를 누르면 기록 된 것을 보여줌

[root@ruo91 ~]# vnstat -l
Monitoring eth0...    (press CTRL-C to stop)

   rx:    37.58 Mbit/s  3188 p/s          tx:      484 kbit/s   912 p/s


 eth0  /  traffic statistics
                             rx       |       tx
--------------------------------------+----------------------------------------
bytes 74.74 MiB | 1.22 MiB
--------------------------------------+----------------------------------------
max 76.68 Mbit/s | 1.42 Mbit/s
average 51.02 Mbit/s | 832.67 kbit/s
min 36.86 Mbit/s | 484 kbit/s
--------------------------------------+----------------------------------------
packets 51926 | 19036
--------------------------------------+----------------------------------------
max 6753 p/s | 2706 p/s
average 4327 p/s | 1586 p/s
min 3188 p/s | 912 p/s
--------------------------------------+----------------------------------------
time 12 seconds


URL: 제주소년의 프로그래밍 세상 http://jejuchild.tistory.com/205