Have you ever been in a situation when working on your system with limited bandwidth and wondered what program is consuming your bandwidth ?
Nethogs is an application that can help you to find which program is responsible for it. It groups bandwidth by process on a network interface that is sending or receiving the network traffic. Nethogs is a handy application especially when there is a sudden spike in network traffic, you may use it to figure out which PID is causing this.
In this context, we shall look into how to install Nethogs on the CentOS 8 system.
Note that you will be required to run the commands as sudo or as a root user in order to install and run Nethogs.
1. Perform System Update
Run the below command to update the system:
$ sudo apt update
2. Add EPEL Repository
Nethogs is not available in the package repositories of CentOS. You can install Nethogs by first adding the EPEL repository with the below command:
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Enter sudo password. During installation, it will prompt you with y/n option for proceeding with the installation procedure. If you want to proceed, press y and then Enter.
Then you will be prompted with y/n for the GPG key. Press y and then hit Enter to accept the key.
Once the EPEL repository is added, you will see the below output in the terminal.
3. Install Nethogs
Now you can install Nethogs on your CentOS system. Use the command below to do so:
$ sudo yum install nethogs
During installation, it will prompt you with y/n option for proceeding with the installation procedure. If you want to proceed, hit y and then Enter. Now the installation of Nethogs will be initiated on your machine.
4. Verify Nethogs Installation
To verify the installation of Nethogs, use the command below:
$ sudo nethogs -v
This will display the version of Nethogs installed on our machine.
The general syntax to use Nethogs is given below:
$ sudo nethogs [option] [interface_name]
Nethogs collects information from the files located in the /proc directory. The output lists all the processes along with their PIDs that are sending and receiving the network packets on network interfaces. It then becomes easier to identify which process is consuming more bandwidth.
If you do not specify any option or interface name, Nethogs display the bandwidth information for all the interfaces:
$ sudo nethogs
To monitor a single network interface, use the below nethogs command:
$ sudo nethogs ens37
If your system has multiple network interfaces and you only want to monitor specific interfaces, you can specify it as follows:
$ sudo nethogs ens33 ens37
By default, Nethogs refreshes the output every second. You can change this interval using the -d option. To set the refresh interval to 2 seconds, the command would be:
$ sudo nethogs -d2
When Nethogs is running, you can use some options which are as follows:
For more information about Nethogs, use the -h option:
$ sudo nethogs -h
You can uninstall Nethogs as follows:
$ sudo yum remove nethogs
Enter sudo password. Now it might prompt you with y/n option for proceeding with the removal procedure. If you want to proceed, press y and then Enter. Nethogs will then be removed from your CentOS system.
This article covers how to install and use Nethogs on the CentOS system. In fact, Nethogs lets you view the bandwidth usage by your programs in order to help you figure out which processes are hogging your network bandwidth.