Observe and troubleshoot system performance on an Ubuntu server


To observe and troubleshoot system performance on an Ubuntu server, there are several commands we can run:
htop or topThese are real-time system monitors that show a detailed list of running processes, along with information on CPU, memory usage, and more. htop is an enhanced version of top with a better user interface and more features.
vmstatvmstat command reports virtual memory statistics and can give an overview of system processes, memory, paging, block IO, traps, and CPU activity.
vmstat -s
iostatiostat is useful for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates.
iostat
mpstatmpstat command is used to display CPU usage statistics.
mpstat -P ALL
freefree shows the amount of free and used memory in the system.
free -h
sarsar System Activity Reporter can collect, report, or save system activity information.
sar -u 1 3
dstatdstat is versatile tool for generating system resource statistics.
dstat
netstatnetstat shows network statistics. This can help us figure out network bottlenecks.
netstat -tulnp
nmonnmon is high-performance system monitor tool for Linux that shows CPU, memory, network, disk, and other information.
nmon
lsoflsof lists open files and the corresponding processes. Useful for finding out what files are being used by which processes.
lsof
mysqldumpslowmysqldumpslow parse MySQL slow query log files and summarize their contents to identify slow-running SQL queries.
mysqldumpslow /path/to/slowquery.log
mysqltunerA script that evaluates your MySQL installation and provides suggestions for performance improvements.
mysqltuner
perfA performance analyzing tool in Linux, useful for detailed performance analysis.
perf stat -B command_to_run
sudo apt install sysstat iotop htop dstat
These commands can help you pinpoint the cause of the high CPU usage by MySQL.
However, interpreting the output of these commands can be complex and might require a good understanding of Linux system internals.

Follow this easy tutorial to set up Ubuntu on Windows with WSL. Install, configure, and explore the Linux file system.

Learn the importance of apt update in Linux package management. Discover how to refresh package indexes, upgrade software, and maintain your Ubuntu system efficiently. Meta Tags: apt update, Linux commands, Ubuntu tips, package management, Linux beginners, update commands, Linux tutorials