{"id":138,"date":"2022-07-14T09:32:15","date_gmt":"2022-07-14T09:32:15","guid":{"rendered":"https:\/\/xitoring.com\/kb\/?p=138"},"modified":"2024-02-26T19:45:36","modified_gmt":"2024-02-26T19:45:36","slug":"9-built-in-monitoring-tools-on-linux","status":"publish","type":"post","link":"https:\/\/xitoring.com\/kb\/9-built-in-monitoring-tools-on-linux\/","title":{"rendered":"Top 9 Monitoring tools on Linux"},"content":{"rendered":"

Introduction<\/span><\/strong><\/h2>\n

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.<\/span><\/p>\n

For this reason, numerous command-line utilities have been developed. This article will expose you to the most useful applications in your toolkit.<\/span><\/p>\n

Prerequisites<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

<\/p>\n

1. top \u2013 Process monitoring activity command<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

Options Description<\/span>\r\n\r\n-h This command displays help information.<\/span>\r\n\r\n-v Information about the version displayed.<\/span>\r\n\r\n-b This command runs in batch mode.<\/span>\r\n\r\n-c The last state that was remembered is displayed.<\/span>\r\n\r\n-d Updates the delay between screen refreshes.<\/span>\r\n\r\n-e The task area memory scaling has been updated.<\/span>\r\n\r\n-E Scaling of summary area memory is updated.<\/span>\r\n\r\n-H Shows individual threads.\u00a0<\/span>\r\n\r\n-I Displays the number of active and idle processes.<\/span>\r\n\r\n-n Sets a limit on the number of results.<\/span>\r\n\r\n-s It works in a secure mode.<\/span>\r\n\r\n-S List processes with CPU times.<\/span>\r\n\r\n-u Shows processes for the specified user.<\/span>\r\n\r\n-1 List information for multiple CPUs.<\/span>\r\n<\/code><\/pre>\n

2. vmstat \u2013 Virtual memory statistics<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

When using “vmstat”, keep in mind that the initial report is an average of the requested information since the last reboot.\u00a0<\/span><\/p>\n

vmstat [options][delay [count]]<\/span>\r\n<\/code><\/pre>\n

Options – below will describe<\/span><\/p>\n

count -Specifies the number of updates that will be printed following the specified delay interval.<\/span><\/p>\n

Delay- This indicates the period between updates. The report will calculate the average since the last reboot if no delay is chosen.<\/span><\/p>\n

Options:<\/span><\/p>\n

The -a option will display the system’s active and inactive memory<\/span><\/p>\n

The -f option returns the total number of forks since the boot<\/span><\/p>\n

The -s option shows a selection of memory statistics and CPU and IO event counters<\/span><\/p>\n

The -d option provides read\/write statistics for various drives.<\/span><\/p>\n

The -t option provides timestamp information for each update<\/span><\/p>\n

3. uptime<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

Usage:<\/span><\/p>\n

# uptime<\/span><\/p>\n

4. ps – Displays Linux process information<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

ps provides a variety of choices for modifying the output following our requirements.<\/span><\/p>\n

Usage:<\/span><\/p>\n

ps [options]<\/span><\/strong><\/h4>\n

A snapshot of the running processes can be obtained using the ps command. To choose every process, use the -A or -e option:<\/span><\/p>\n

# ps -A<\/span><\/p>\n

Show Long Format Output<\/span><\/p>\n

# ps -Al<\/span><\/p>\n

To activate extra full mode (which displays command line parameters provided to the process), type:<\/span><\/p>\n

# ps -AlF<\/span><\/p>\n

Display Threads ( LWP and NLWP)<\/span><\/p>\n

# ps -AlFH<\/span><\/p>\n

Watch Threads After Processes<\/span><\/p>\n

# ps -AlLm<\/span><\/p>\n

Print All Process On The Server<\/span><\/p>\n

# ps ax<\/span><\/p>\n

# ps axu<\/span><\/p>\n

Want To Print A Process Tree?<\/span><\/p>\n

# ps -ejH<\/span><\/p>\n

# ps axjf<\/span><\/p>\n

# pstree<\/span><\/p>\n

5. free \u2013 Show Linux server memory usage<\/span><\/strong><\/h3>\n

Free displays the amount of physical memory, swap memory, and kernel buffers that are free and used.<\/span><\/p>\n

# free<\/span><\/p>\n

6. htop\u00a0<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

Usage:<\/span><\/p>\n

htop [-dChusv]<\/span><\/p>\n

Options:<\/span><\/strong><\/p>\n

\u00a0 \u00a0\u00a0-d \u2013delay: The delay between updates is displayed in tenths of a second.<\/span><\/strong><\/p>\n

\u00a0 \u00a0\u00a0-C \u2013no-color \u2013no-colour : Start htop in monochrome mode.<\/span><\/strong><\/p>\n

\u00a0 \u00a0\u00a0-h \u2013help : Displays the help message and exits.<\/span><\/strong><\/p>\n

\u00a0 \u00a0\u00a0-u \u2013user=USERNAME : Displays only a user’s processes.<\/span><\/strong><\/p>\n

7. iostat \u2013 Monitor Linux CPU and disk load averages<\/span><\/strong><\/h3>\n

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.<\/span><\/p>\n

To install on different distributions, use the following command:\u00a0<\/span><\/p>\n