1. 程式人生 > 實用技巧 >linux 檢視某程序或程式的網絡卡流量

linux 檢視某程序或程式的網絡卡流量

一、nethogs介紹

  分享一個linux 下檢測系統程序佔用頻寬情況的檢查。來自github上的開源工具。

  它不依賴核心中的模組。當我們的伺服器網路異常時,可以通過執行nethogs程式來檢測是那個程式佔用了大量頻寬。節省了查詢時間。

二、安裝方法

1.在epel 源中可以直接yum 安裝

yum install libpcap nethogs -y

2.原始碼方式安裝

  2.1 安裝c++ 環境  

[root@SaltMaster ~]# yum install gcc-c++ libpcap-devel.x86_64 libpcap.x86_64 ncurses*

  2.2 下載編譯好的二進位制檔案

[root@SaltMaster ~]# git clone https://github.com/raboof/nethogs
Initialized empty Git repository in /root/nethogs/.git/
remote: Counting objects: 1193, done.
remote: Total 1193 (delta 0), reused 0 (delta 0), pack-reused 1193
Receiving objects: 100% (1193/1193), 1.22 MiB | 29 KiB/s, done.
Resolving deltas: 100% (789/789), done.

  2.3 編譯並安裝

[root@SaltMaster ~]# cd nethogs/

[root@SaltMaster nethogs]# make
[root@SaltMaster nethogs]# make install

  完成上面步驟就算安裝完成了。如果編譯失敗的話,大部分是缺少編譯環境。

3.使用方法

3.1 直接執行nethogs 就可以檢視當前佔用頻寬的程序