Monday, 18 November 2024

Exploring Network Monitoring Tools in Linux: Alternatives to htop for Network Usage

 Network monitoring is essential for diagnosing performance issues or identifying processes consuming excessive bandwidth. While htop and top are excellent tools for system monitoring, they don’t directly offer the ability to sort processes by network usage. Below, we’ll discuss popular alternatives tailored for this purpose.

1. NetHogs

NetHogs is a lightweight tool designed for monitoring network bandwidth usage by processes. Unlike tools that group traffic by protocol or subnet, NetHogs tracks it by process.

Features:

  • Displays bandwidth usage per process
  • Requires no special kernel modules; relies on /proc
  • Ideal for identifying rogue processes consuming excessive bandwidth

Installation:

sudo apt install nethogs  # For Debian/Ubuntu  
sudo yum install nethogs  # For CentOS/RHEL  

Usage:
Run NetHogs with root privileges:

sudo nethogs [interface]

Example output:

PID    USER       PROGRAM           DEV     SENT     RECEIVED  
12345  user1      firefox           eth0    2.3 KB   1.8 KB  
23456  user2      wget              eth0    50 KB    1 KB  

2. iftop

iftop shows real-time bandwidth usage by host pairs on a network interface. It is ideal for determining which connections are consuming the most bandwidth.

Limitations:

  • Does not show traffic per process

Installation:

sudo apt install iftop  
sudo yum install iftop  

Usage:

sudo iftop -i [interface]

Example output:

192.168.1.100 => 192.168.1.101   3.45 MB  
192.168.1.102 <= 192.168.1.103   1.23 MB  

3. iptraf-ng

An interactive network monitoring tool with a ncurses-based interface. It supports filtering and provides statistics on traffic, including IP, TCP, and UDP.

Installation:

sudo apt install iptraf-ng  

Usage:

sudo iptraf-ng  

Example features:

  • Detailed traffic breakdown by protocol
  • No process-level traffic tracking

4. jnettop

Tracks network streams and displays real-time data transfer rates for connections.

Limitations:

  • Does not group traffic by processes

Installation:

sudo apt install jnettop  

Usage:

sudo jnettop  

5. bmon

A simple CLI-based bandwidth monitoring tool featuring graphical charts. It monitors traffic on network interfaces but does not break it down by process.

Installation:

sudo apt install bmon  

Usage:

bmon  

6. ntop/ng

ntop is a web-based network traffic analyzer. It is more robust than most CLI tools and supports long-term traffic monitoring and visualization.

Installation:

sudo apt install ntop  

Usage:
Run the tool and access the interface via a web browser (default port: 3000).
If process-level bandwidth monitoring is critical, NetHogs is the tool of choice. For monitoring connections and interfaces, iftop and iptraf-ng are excellent options. Tools like ntop offer comprehensive analysis but come with a steeper setup process and higher resource requirements.

Choose a tool based on your specific needs and the level of detail required for monitoring.

Labels:

0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home