zoukankan      html  css  js  c++  java
  • linux 利用nethogs查看某进程的网卡流量

    一、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 就可以查看当前占用带宽的进程

    3.2 我们来测试 找出eth0 上占用大量带宽的程序

      nethogs 网卡设备

      我们检测 eth0,运行一下命令

    [root@SaltMaster ~]# nethogs eth0

     图中第一行就是测试中的流量记录,表示192.168.40.250这台客户端去访问我的80 端口所占用的带宽。

    在PID 那一列,可以使用 lsof -p  pid 查看进程测试。

    或者用lsof -i :端口号,来查看是哪些进程在占用。如查看80端口  lsof -i :80

    每个人都应是守望者,守望我们的心智,我们的理想,以防它在生活中不知不觉地坠落、被操控和被自己遗忘。。。
  • 相关阅读:
    ActiveReport换页的判断(当设置了repeatstyle为OnPage)
    创建与删除SQL约束或字段约束。 http://www.cnblogs.com/hanguoji/archive/2006/11/17/563871.html
    在SQL Server 2005中实现表的行列转换
    ActiveReport,Detail隐藏的问题
    SQL Server identity列的操作方法
    「預り」の意味
    POJ 1595 Prime Cuts
    Hdu Graph’s Cycle Component
    POJ 3250 Bad Hair Day
    Hdu 1548 A strange lift(BFS)
  • 原文地址:https://www.cnblogs.com/yanqingxu/p/10880526.html
Copyright © 2011-2022 走看看