본문 바로가기
카테고리 없음

[Linux] 'nethogs' 명령어 설치 및 사용법 - 네트워크 트래픽 모니터링

by 왕 달팽이 2020. 3. 12.
반응형

서버의 네트워크 상태를 모니터링하기 위한 도구로 iftop 명령과 함께 알게된 것이 nethogs 명령입니다. iftop 명령이 서버의 NIC 레벨에서 트래픽을 모니터링하는 도구인 반면 nethogs 명령은 서버에서 구동중인 데몬이나 프로세스 레벨로 트래픽을 모니터링 할 수 있는 도구입니다. 실제 서버에서 어떤 녀석이 얼마나 사용하는지 모니터링 할 수 있는 도구입니다.

nethogs 설치

iftop과 마찬가지로 리눅스 배포판에 기본 포함되지 않은 경우가 많이 있습니다. 수동으로 설치해주면 됩니다. 역시나 패키지 관리 도구를 통해 쉽게 설치할 수 있습니다.

CentOS

sudo yum install nethogs

Ubuntu

sudo apt-get install nethogs

nethogs 사용법

nethogs 명령의 사용법은 매우 간단합니다.

$ sudo nethogs {인터페이스 이름}

nethogs 명령의 인자로 인터페이스 이름을 명시하기만 하면 됩니다. 예를 들어 etho0 인터페이스를 모니터링하고 싶으면

$ sudo nethogs etho0

이렇게 입력하면 됩니다. nethogs에 인자를 주지 않으면 첫 번째 인터페이스를 모니터링하게 됩니다.

nethogs 명령을 실행하면 PID 별로 사용하고 있는 네트워크 트래픽 정보를 확인할 수 있습니다.

nethogs 옵션

nethogs -h 명령을 실행하면 nethogs에서 사용할 수 있는 옵션을 확인할 수 있습니다.

$ sudo nethogs -h
usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [device [device [device ...]]]
                -V : prints version.
                -h : prints this help.
                -b : bughunt mode - implies tracemode.
                -d : delay for update refresh rate in seconds. default is 1.
                -v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
                -c : number of updates. default is 0 (unlimited).
                -t : tracemode.
                -p : sniff in promiscious mode (not recommended).
                -s : sort output by sent column.
   -a : monitor all devices, even loopback/stopped ones.
                device : device(s) to monitor. default is all interfaces up and running excluding loopback

When nethogs is running, press:
 q: quit
 s: sort by SENT traffic
 r: sort by RECEIVE traffic
 m: switch between total (KB, B, MB) and KB/s mode

자세한 설명은 매뉴얼 페이지를 참고하시기바랍니다. (링크 : nethogs(8) - Linux man page)

반응형

댓글