1. Using the top utility

To monitor CPU and memory usage on the server, you can use the top utility, which provides information about current processes and their resource usage. To run the utility, simply enter the command

top

in the terminal.

2. Using the htop command

The htop command is an improved version of top and provides more detailed information about processes and resource usage. To install htop, you can use your operating system’s package manager, for example, via the command

sudo apt install htop

for Ubuntu.

3. Monitoring with Grafana and Prometheus

For more visual monitoring of CPU and memory usage on the server, you can use Grafana and Prometheus tools. Grafana allows you to visualize data collected by Prometheus, which in turn collects information about server performance. The data can be presented in the form of graphs, charts, etc.

4. Using the sar utility

The sar (System Activity Reporter) utility allows you to collect and analyze statistics on the usage of system resources, such as CPU, memory, disk space, and network. To run sar and collect data, you can use the command

sar -u 1

, where «-u» means CPU usage, and «1» is the interval in seconds for data collection.

5. Using the vmstat utility

The vmstat (virtual memory statistics) utility allows you to track memory usage on the server, and also provides information about processes, system load, and other indicators. To run vmstat, enter the command

vmstat 1

, where «1» is the time interval in seconds to display statistics.

6. Conclusion

The choice of utility for monitoring depends on your needs and the level of complexity of data analysis. It is recommended to use a combination of different tools to get the most complete picture of resource usage on the server. Explore the capabilities of each utility and choose the most suitable option for your system.