Know how much an individual process or system-wide consume CPU or memory.
As a sysadmin, you often have to deal with an incident where the application is slow or unresponsive due to high CPU/memory/network utilization. If the server host just one process, then it’s easy to find out when the process consumes all the resources. However, imagine a shared server where multiple services are running, and you need to find which one is eating all the resources.
There are many monitoring software which does this out of the box. But if you don’t have one or looking for a command-based solution, then here you go. They are all FREE!
You may want to start by looking into top or htop result to see the processes overview.
As you can see below, it gives an excellent idea about what all processes are utilizing. If you look at the first one, which is MySQL is taking 11.9% of CPU and 2.5% of CPU.
A similar to the above listed but with a brilliant feature to record the output in a file so you can view them later. Imagine there is a pattern of having an issue at a specific time window. You can schedule to write the output in a file through crontab or other, and later you can playback.
To record the output in a file:
atop -w filename
and, to playback:
atop -r filename
It supports multiple arguments like interval, samples, etc. and I would strongly recommend taking a look at the man page.
If you are just interested in real-time troubleshooting, then just execute atop and you should see like below.
You can install atop as below.
dnf install atop
Let’s check ps command now.
You can use the ps command with PID to print their CPU and memory utilization.
Interactive command-line monitoring tool for CPU, memory, disks, network, NFS, and virtual memory utilization. To view the top process (by utilization), you can execute nmon and press t button.
You can install nmon as below.
dnf install nmon
Monit is a web-based and command-line open-source solution to monitor server resources, daemons, files, directory, file systems, etc.
Monit also got a cool widget.
Its light-weight monitoring software. But, there is more to explore here.
A lightweight open-source utility to monitor the Linux server. Monitorix got in-built HTTP so you can check the utilization and other stuff on the web. Some of the other usage reports include:
Filesystem and I/O
Monitorix also offers alert configuration so you can get notified when things are not right. It will be a good choice when you are managing cloud-based servers and looking for a proactive monitoring solution.
Netdata is a real-time performance monitoring for system resources, applications, web servers, databases, DNS, mail, hardware sensors, and a lot more. It is open-source and getting started is easy. All the data is collected, stored, and streamed for you to visualize interactively. Data is collected every second, so you never miss anything.
Loved by many industry leaders.
So what you are waiting for, try and take control of your Linux servers.
btop is a handy resource monitor fully interactive with a beautiful UI helping you manage the Linux servers.
You can easily visualize the processes in a tree view, filter from the process list, and manage the resource hogs. btop also comes powered with an auto-scaling graph showing network usage.
Besides, you can also check disk speed and complete I/O activity.
There is more to this that you can experience on Linux, FreeBSD, and macOS.
I hope the above tools help you to visualize the server utilization in real-time so you can take necessary action. If you just started as a system administrator and looking to get hands-on training, then check out this Udemy course.