Linux Sys Admin Tools
Linux Sys Admin Tools
by VI VEK GI TE on JUNE 27, 2009 280 COMM ENTS LAST UPDATED J UNE 16, 2010
Need to monitor Linux server performance? Try these built-in command and a few add-on tools. Most Linux distributions are equipped with tons of monitoring. These tools provide metrics which can be used to get information about system activities. You can use these tools to find the possible causes of a performance problem. The commands discussed below are some of the most basic commands when it comes to system analysis and debugging server issues such as: 1. Finding out bottlenecks. 2. Disk (storage) bottlenecks. 3. CPU and memory bottlenecks. 4. Network bottlenecks.
The command vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.
# vmstat 3
Sample Outputs:
procs -----------memory---------- ---swap-- -----io---- -system-- -----cpu-----r in 0 4 b swpd free buff cs us sy id wa st cache si so bi bo
0 2 4
0 2540988 522188 5130400 1 96 0 0 0 2540988 522188 5130400 1 0 99 0 0 0 2540956 522188 5130400 4 1 95 0 0 0 2540956 522188 5130500 1 0 99 0 0 0 2540940 522188 5130512 1 0 98 0 0 0 2538444 522188 5130588 4 1 96 0 0 0 2490060 522188 5130640 5 1 94 0 0
32
1 0 1199 665 0 0 1151 1569 0 0 1117 439 0 0 1189 932 0 0 1187 1417 0 0 1253 1123
720
536
18
# vmstat -m
=> Related: How do I find out Linux Resource utilization to detect system bottlenecks?
#3: w - Find Out Who Is Logged on And What They Are Doing
w command displays information about the users currently on the machine, and their processes.
# w username # w vivek
Sample Outputs:
17:58:47 up 5 days, 20:28, 0.26, 0.24 USER TTY PCPU WHAT FROM 2 users, load average: 0.36,
LOGIN@
IDLE
JCPU
root pts/0 10.1.3.145 0.02s vim /etc/resolv.conf root 0.00s w pts/1 10.1.3.145
14:55
5.00s
0.04s
17:43
0.00s
0.03s
#4: uptime - Tell How Long The System Has Been Running
The uptime command can be used to see how long the server has been running. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
# uptime
Output:
18:02:41 up 41 days, 23:42, 0.00, 0.00 1 user, load average: 0.00,
1 can be considered as optimal load value. The load can change from system to system. For a single CPU system 1 - 3 and SMP systems 6-10 load value might be acceptable.
Sample Outputs:
PID TTY 1 ? 2 ? 3 ? 4 ? 5 ? TIME CMD 00:00:02 init 00:00:02 migration/0 00:00:01 ksoftirqd/0 00:00:00 watchdog/0 00:00:00 migration/1
6 ? .... ..... 4881 ? 4885 tty1 4886 tty2 4887 tty3 4888 tty4 4891 tty5 4892 tty6 4893 ttyS1 12853 ? 12854 ? 14231 ? 14232 ? 54981 pts/0
00:00:15 ksoftirqd/1
00:53:28 java 00:00:00 mingetty 00:00:00 mingetty 00:00:00 mingetty 00:00:00 mingetty 00:00:00 mingetty 00:00:00 mingetty 00:00:00 agetty 00:00:00 cifsoplockd 00:00:00 cifsdnotifyd 00:10:34 lighttpd 00:00:00 php-cgi 00:00:00 vim
To turn on extra full mode (it will show command line arguments passed to process):
# ps -AlF
OR
# pgrep lighttpd
OR
# pgrep -u vivek php-cgi
Sample Output:
buffers Mem: 523124 total cached 12302896 5154740 used free shared
9739664
2563232
4061800 0
8241096 1052248
=> Related: : 1. Linux Find Out Virtual Memory PAGESIZE 2. Linux Limit CPU Usage Per Process 3. How much RAM does my Ubuntu / Fedora Linux desktop PC have?
# iostat
Sample Outputs:
Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in) 06/26/2009 avg-cpu: %user 3.50 Device: Blk_read sda 16193351 sda1 2166 sda2 16189010 sda3 1615 %nice %system %iowait 0.09 0.51 Blk_read/s 0.03 %steal 0.00 %idle 95.86
Blk_wrtn/s
31.88
512.03
0.00
0.00
31.87
512.03
0.00
0.00
Sample Outputs:
Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in) 06/26/2009 06:45:12 PM CPU %user %iowait %steal %idle 06:45:16 PM 0.00 0.00 06:45:20 PM 0.03 0.00 06:45:24 PM 0.00 0.00 06:45:28 PM 0.00 0.00 06:45:32 PM 0.03 0.00 Average: 0.01 all 97.78 all 97.52 all 98.78 all 98.22 all 96.19 all 97.70 2.00 %nice %system
0.00
0.22
2.07
0.00
0.38
0.94
0.00
0.28
1.56
0.00
0.22
3.53
0.00
0.25
2.02
0.00
0.27
0.00
=> Related: : How to collect Linux system utilization data into a file
The mpstat command displays activities for each available processor, processor 0 being the first one. mpstat -P ALL to display average CPU utilization per processor:
# mpstat -P ALL
Sample Output:
Linux 2.6.18-128.1.14.el5 (www03.nixcraft.in) 06/26/2009 06:48:11 PM CPU %user %nice %soft %steal %idle intr/s 06:48:11 PM all 3.50 0.09 0.17 0.00 95.86 1218.04 06:48:11 PM 0.12 0.00 06:48:11 PM 0.11 0.00 06:48:11 PM 0.11 0.00 06:48:11 PM 0.24 0.00 06:48:11 PM 0.10 0.00 06:48:11 PM 0.10 0.00 0 3.44 0.08 96.04 1000.31 1 3.10 0.08 96.28 34.93 2 4.16 95.25 0.11 0.00 %sys %iowait %irq
0.34
0.03
0.01
0.31
0.02
0.00
0.32
0.09
0.02
0.36
0.02
0.00
3 3.77 0.11 95.46 44.80 4 2.96 0.07 96.52 25.91 5 3.26 0.08 96.23 14.98
0.38
0.03
0.01
0.29
0.04
0.02
0.28
0.03
0.01
6 4.00 95.42
0.10 3.75
0.34
0.01
0.00
0.39
0.03
0.01
=> Related: : Linux display each multiple SMP CPU processors utilization individually.
Sample Outputs:
47394: Address Mapping 0000000000400000 php-cgi 0000000000886000 php-cgi 00000000008a9000 [ anon ] /usr/bin/php-cgi Kbytes Mode Offset Device
0000000000aa8000 php-cgi 000000000f678000 [ anon ] 000000314a600000 ld-2.5.so 000000314a81b000 ld-2.5.so 000000314a81c000 ld-2.5.so 000000314aa00000 libc-2.5.so 000000314ab4c000 libc-2.5.so ..... ...... .. 00002af8d48fd000 xsl.so 00002af8d490c000 libnss_files-2.5.so
00002af8d4916000 2044 ----- 000000000000a000 008:00002 libnss_files-2.5.so 00002af8d4b15000 libnss_files-2.5.so 00002af8d4b16000 libnss_files-2.5.so 00002af8d4b17000 zero (deleted) 00007fffc95fe000 [ stack ] ffffffffff600000 [ anon ] mapped: 933712K 768000K 4 r---- 0000000000009000 008:00002
writeable/private: 4304K
shared:
The last line is very important: mapped: 933712K total amount of memory mapped to files writeable/private: 4304K the amount of private address space shared: 768000K the amount of address space this process is sharing with others => Related: : Linux find the memory used by a program / process using pmap command
ss: Display Linux TCP / UDP Network and Socket Information Get Detailed Information About Particular IP address Connections Using netstat Command
Network traffic statistics by TCP connection IP traffic statistics by network interface Network traffic statistics by protocol Network traffic statistics by TCP/UDP port and by packet size Network traffic statistics by Layer2 address
To display all IPv4 HTTP packets to and from port 80, i.e. print only packets that contain data, not, for example, SYN and FIN packets and ACK-only packets, enter:
# tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
# # # #
Displays various basic information about the computer's hardware and software. Linux Kernel version GNOME version Hardware Installed memory Processors and speeds System Status Currently available disk space Processes Memory and swap space Network usage File Systems Lists all mounted filesystems along with basic information about each.