Top 9 Monitoring tools on Linux

Introduction

Every computer system can benefit from effective management and monitoring. Keeping an eye on the performance of your system will allow you to identify and handle any issues that may arise immediately.

For this reason, numerous command-line utilities have been developed. This article will expose you to the most useful applications in your toolkit.

Prerequisites

You’ll need access to a Linux-based operating system PC to follow along with this article. This might be either a virtual private server to which you have connected through SSH or your local computer. Note that this article was confirmed on a Linux server running Ubuntu 20.04, but the examples should work on any machine running any version of the Linux operating system.

1. top – Process monitoring activity command

In real-time, the top (table of processes) command in Linux displays tasks managed by the kernel. Additionally, the command offers a system information summary that displays resource usage, such as CPU and memory usage.

Options Description

-h This command displays help information.

-v Information about the version displayed.

-b This command runs in batch mode.

-c The last state that was remembered is displayed.

-d Updates the delay between screen refreshes.

-e The task area memory scaling has been updated.

-E Scaling of summary area memory is updated.

-H Shows individual threads. 

-I Displays the number of active and idle processes.

-n Sets a limit on the number of results.

-s It works in a secure mode.

-S List processes with CPU times.

-u Shows processes for the specified user.

-1 List information for multiple CPUs.

2. vmstat – Virtual memory statistics

Virtual memory statistics reporter, usually known as “vmstat,” is a command-line program for Linux that reports different system information. Memory, paging, processes, IO, CPU, and disk scheduling are topics covered by the offered data.

When using “vmstat”, keep in mind that the initial report is an average of the requested information since the last reboot. 

vmstat [options][delay [count]]

Options – below will describe

count -Specifies the number of updates that will be printed following the specified delay interval.

Delay- This indicates the period between updates. The report will calculate the average since the last reboot if no delay is chosen.

Options:

The -a option will display the system’s active and inactive memory

The -f option returns the total number of forks since the boot

The -s option shows a selection of memory statistics and CPU and IO event counters

The -d option provides read/write statistics for various drives.

The -t option provides timestamp information for each update

3. uptime

The uptime command can be used to determine the server’s uptime. The current time, the time the system has been running, the number of people presently logged in, and the average system load for the previous 1, 5, and 15 minutes.

Usage:

# uptime

4. ps – Displays Linux process information

Linux has a utility called ps, which stands for “Process Status” and is used to view information regarding a system’s processes. The ps command lists the currently running processes and their PIDs, as well as other information based on the options specified. It reads the process information from the /proc file system’s virtual files. Because /proc contains virtual files, it is referred to as a virtual file system.

ps provides a variety of choices for modifying the output following our requirements.

Usage:

ps [options]

A snapshot of the running processes can be obtained using the ps command. To choose every process, use the -A or -e option:

# ps -A

Show Long Format Output

# ps -Al

To activate extra full mode (which displays command line parameters provided to the process), type:

# ps -AlF

Display Threads ( LWP and NLWP)

# ps -AlFH

Watch Threads After Processes

# ps -AlLm

Print All Process On The Server

# ps ax

# ps axu

Want To Print A Process Tree?

# ps -ejH

# ps axjf

# pstree

5. free – Show Linux server memory usage

Free displays the amount of physical memory, swap memory, and kernel buffers that are free and used.

# free

6. htop 

The “htop” command in the Linux system is a command-line program that enables the user to monitor the system’s critical resources or server’s operations in real-time. “htop” is a more recent application than the top command. It provides numerous enhancements. “htop” is compatible with the mouse, produces output in color, and provides visual indications of CPU, memory, and swap consumption. “htop” also publishes whole command lines for processes and supports scrolling in both the vertical and horizontal directions for processes and command lines, respectively.

Usage:

htop [-dChusv]

Options:

    -d –delay: The delay between updates is displayed in tenths of a second.

    -C –no-color –no-colour : Start htop in monochrome mode.

    -h –help : Displays the help message and exits.

    -u –user=USERNAME : Displays only a user’s processes.

7. iostat – Monitor Linux CPU and disk load averages

In Linux, the iostat command monitors input/output statistics for devices and partitions. System input/output is monitored by observing how long devices are active concerning their average transfer rates. Iostat reports can raise the input/output balance between the physical disks by changing the system configuration. The iostat package will be included in the sysstat package. You need to install it if you don’t already have it.

To install on different distributions, use the following command: 

  • On RedHat / CentOS / Fedora 

yum install sysstat

  • On Debian / Ubuntu / Linux Mint 

apt-get install sysstat

usage:

# iostat

Swishes: 

  • iostat: Get report and statistics.
  • iostat -x: shows information about statistics in more detail.
  • iostat -c: Display only CPU statistics.
  • iostat -d: Only display the device report.
  • iostat -xd: Only show extended I/O statistics for devices.
  • iostat -k: Count the number of kilobytes or megabytes in the statistics.
  • iostat -k 2 3: The CPU and device statistics are displayed with a delay.
  • iostat -j ID mmcbkl0 sda6 -x -m 2 2: Statistics about persistent device names are displayed.
  • iostat -p: Display statistics for block devices.
  • iostat -N: Display lvm2 statistic information.

8. meminfo

Availability and usage of memory (both physical and swap) on the system and the shared memory and buffers used by the kernel are reported by the file ‘/proc/meminfo’.

Usage: 

# cat /proc/meminfo 

Depending on the server’s OS and architecture, “cat /proc/meminfo” would produce different results. The fields described here can differ somewhat from those in your system or not exist at all.

9. netstat

Netstat is a command-line program system administrators use to assess network traffic and configuration. The host device displays the routing table, masquerades connections, and open ports, along with their corresponding addresses.

This post aims to demonstrate how to install and set up various Netstat commands on Linux.

Netstat is a component of the net-tools package. With the following command, you can install the net-tools package on Ubuntu:

$ sudo apt install net-tools

Show Routing table:

The routing table detail is displayed on the terminal via the netstat command. Use Netstat with the -nr flag to view the routing table; it displays the kernel routing table similarly to how the route does. Use the command below:

$ netstat -nr

The -nr option allows Netstat to print addresses separated by dots instead of symbolic address names.

Show interface statistics:

Netstat will display statistics for the presently configured network interfaces when the ‘-i’ flag or option is used.

$ netstat -i

Show Network connection:

There are several options in Netstat to display active or passive sockets. The -t, -u, -w, and -x options specify active TCP, UDP, RAW, and Unix socket connections. on the terminal:

$ netstat -ta

Show Network Services:

To view a list of networks, their present states, and the related ports, enter the following command:

$ netstat -pnltu

Show all the listening ports of TCP and UDP connections:

By running the following command, you may view every TCP and UDP port:

$ netstat –a | more

Show TCP Port Connection:

Use the following command to obtain a list of all TCP (Transmission Control Protocols) port connections:

$ netstat -at

Display UDP Port Connection:

Use the command: to view the UDP (User Diagrams Protocols) port connection.

$ netstat -au

List all Listening Connections:

Use Netstat’s “-l” flag to display a list of all connections that are currently active:

$ netstat -l

Show every TCP Listening port:

Using the -‘lt’ flag, we can do as follows in acquiring a list of all TCP ports that are now active listeners:

$ netstat -lt

Show every UDP listening port:

Using the ‘-lu’ option, we can obtain a list of all UDP ports that are currently open and listening:

$ netstat -lu

Conclusion

Finally, I hope that this extensive list of the finest Linux monitoring tools will assist you in keeping an eye on various Linux components, including servers, networks, desktops, infrastructure, etc. Comment below and let me know what you think of these Linux monitoring tools. Will it aid in ensuring or improving Linux performance? Let us know if I missed any crucial monitoring tools in the comments section.

 

Leave a Reply

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