Using NetHogs to find who is using your bandwidth on CentOS 7

No Comments

It’s common to run a server for multiple users, running multiple different services. Sometimes this can make it a little difficult to track down who might be causing a drain on resources.  However, using NetHogs, it’s nice and easy to trace big bandwidth users.

Picture the scene, your server or VPS is running along quite happily.  Suddenly you notice a significant blip in your usage.

bandwidth blip

Thoughts of hackers, angry customers, huge bandwidth bills or, even worse, the phone might ring!  Don’t worry though – NetHogs to the rescue.

What is NetHogs?

NetHogs is opensource software released by Arnout Engelen and is compatible with most current Linux distributions.  The author describes it as “… a small ‘net top’ tool. Instead of breaking the traffic down per protocol or per subnet, like most tools do, it groups bandwidth by process.”

In the scenario above this is exactly what we need – which process is using all my bandwidth?

How to install

First of all, you need to ensure you have the EPEL repository enabled – if not, please follow my guide here.

Now you can install via yum with:

[user@server] sudo yum install nethogs

Next simply run the command to launch the application.

[user@server] sudo nethogs

All the active processes on our server will then be monitored, giving you a rundown of sent and received data which will update every second.

If you have multiple network connections and only want to monitor one of them, simply add its name after the command.

[user@server] sudo nethogs eth0

Whilst running, you can also use a selection of interactive controls.

q : quit
s : sort by sent traffic (i.e. outbound)
r : sort by receive traffic (i.e. inbound)
m : switch between total (KB, B, MB) and KB/s mode

Once you’ve identified the source of the problem you’ll be able to take action to resolve it – or send them a big bill, depending on what time of the night it is.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.