Need to monitor Linux server system performance? Try these tools built in or attached to the system below. Most Linux distributions are equipped with a large number of monitoring tools. These tools provide metrics that can be used to obtain relevant information and system activities. You can use these tools to discover possible causes of performance problems. The tools discussed here are just some of the most basic tools for analyzing and debugging the server under the problem.
1. Identify bottlenecks 2. Hard disk (storage) bottleneck 3.CPU and Memory bottlenecks 4. Network bottlenecks #1: top-process activity Top provides a real-time, dynamic view of the current running system, which is the running process. By default, displays the task with the highest CPU utilization in the system and refreshes every 5 seconds. Figure 01. Linux Top Command
Common hotkeys
Hotkey |
Use |
T |
Displays the summary information switch. |
M |
Displays the memory information switch. |
A |
Classification shows the large use of different resources of the system. Helps to quickly identify tasks that are resource-intensive in your system. |
F |
Add deletes the fields you want to display. |
O |
Adjusts the order in which you want to display the fields. |
R |
Adjusts the nice value of a running process. |
K |
Ends a running process. |
Z |
Color/black and white display switch |
#2: Vmstat-system activity, hardware and system Information Use the Vmstat command to get information about processes, memory, memory paging, blocking IO, traps, and CPU activity. # Vmstat 3 Sample output: procs-----------memory-------------Swap-------io------System-------CPU------ R b swpd free buff cache si so bi bo in CS us sy ID WA St 0 0 0 2540988 522188 5130400 0 0 2 32 4 2 4 1 96 0 0 1 0 0 2540988 522188 5130400 0 0 0 720 1199 665 1 0 99 0 0 0 0 0 2540956 522188 5130400 0 0 0 0 1151 1569 4 1 95 0 0 0 0 0 2540956 522188 5130500 0 0 0 6 1117 439 1 0 99 0 0 0 0 0 2540940 522188 5130512 0 0 0 536 1189 932 1 0 98 0 0 0 0 0 2538444 522188 5130588 0 0 0 0 1187 1417 4 1 96 0 0 0 0 0 2490060 522188 5130640 0 0 0 18 1253 1123 5 1 94 0 0 Show memory usage Details # vmstat-m Show memory Active/Inactive information # vmstat-a
#3: W-show who is logged in, what are they doing? The W command displays information about the current user of the system and its running process. # W Username # w Vivek Output Example: 17:58:47 up 5 days, 20:28, 2 users, load average:0.36, 0.26, 0.24 USER TTY from [email protected] IDLE jcpu PCPU Root pts/0 10.1.3.145 14:55 5.00s 0.04s 0.02s vim/etc/resolv.conf Root pts/1 10.1.3.145 17:43 0.00s 0.03s 0.00s W #4: Uptime-Tell the system how long it has been running? The uptime command used to show only how long the system was running. Now, you can show how long the system is running, how many users are currently logged in, and what the average load is in the last 1, 5, 15 minutes. # uptime Input sample: 18:02:41 up, 23:42, 1 user, Load average:0.00, 0.00, 0.00 1 can be considered as the optimal load value. The load will vary with the system. Single CPU system 1-3 and SMP system 6-10 are all possible to accept. #5: PS-Show process The PS command displays a snapshot of the currently running process. Displays all processes using-a or-E. # ps-a Output example: PID TTY time CMD 1? 00:00:02 Init 2? 00:00:02 migration/0 3? 00:00:01 ksoftirqd/0 6} 00:00:00 watchdog/0 5? 00:00:00 MIGRATION/1 4} 00:00:15 KSOFTIRQD/1 .... ..... 4881? 00:53:28 Java 4885 tty1 00:00:00 Mingetty 4886 Tty2 00:00:00 Mingetty 4887 Tty3 00:00:00 Mingetty 4888 Tty4 00:00:00 Mingetty 4891 tty5 00:00:00 Mingetty 4892 Tty6 00:00:00 Mingetty 4893 ttyS1 00:00:00 Agetty 12853? 00:00:00 CIFSOPLOCKD 12854? 00:00:00 cifsdnotifyd 14231? 00:10:34 lighttpd 14232? 00:00:00 php-cgi 54981 pts/0 00:00:00 Vim 55465? 00:00:00 php-cgi 55546? 00:00:00 Bind9-snmp-stat 55704 PTS/1 00:00:00 PS PS is very similar to top, but PS provides more information. Output Long Format # Ps-al Output append full format (shows parameters passed in when the process executes) # Ps-alf Show process Structure # PS-ALFH Show threads after a process # PS-ALLM Print all processes on the server # PS AX # PS Axu Print Process Tree # PS-EJH # PS AXJF # Pstree Print security information # Ps-eo Euser,ruser,suser,fuser,f,comm,label # PS AXZ # Ps-em View processes running with the Vivek user name # ps-u vivek-u Vivek U Setting Custom output formats # Ps-eo Pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm # PS Axo Stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm # Ps-eopid,tt,user,fname,tmout,f,wchan Show only the LIGHTTPD process ID # ps-c Lighttpd-o pid= Or # pgrep LIGHTTPD Or # pgrep-u Vivek PHP-CGI Show process name with PID 55977 # ps-p 55977-o comm= Identify the top 10 processes that consume the most memory # PS-AUXF | Sort-nr-k 4 | Head-10 Find the top 10 processes with the most CPU # PS-AUXF | Sort-nr-k 3 | Head-10 |