7 个实用的命令行工具来来监控Linux性能
以下是最流行的7个命令工具,用于监控和调试Linux的系统性能。
-
Top - Linxu Process Monitoring
It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer Size, Process PID, User, Commands and much more. It also shows high memory and cpu utilization of a running processess. The top command is much userful for system administrator to monitor and take correct action when required. Let’s see top command in action.
# top -
VmStat – Virtual Memory Statistics
Linux VmStat command used to display statistics of virtual memory, kernerl threads, disks, system processes, I/O blocks, interrupts, CPU activity and much more.
# vmstat -
Tcpdump – Network Packet Analyzer
Tcpdump one of the most widely used command-line network packet analyzer or packets sniffer program that is used capture or filter TCP/IP packets that received or transferred on a specific interface over a network. It also provides a option to save captured packages in a file for later analysis. tcpdump is almost available in all major Linux distributions.
# tcpdump -i eth0 -
Iotop – Monitor Linux Disk I/O
Iotop is also much similar to top command and Htop program, but it has accounting function to monitor and display real time Disk I/O and processes. This tool is much useful for finding the exact process and high used disk read/writes of the processes.
-
Iostat – Input/Output Statistics
IoStat is simple tool that will collect and show system input and output storage device statistics. This tool is often used to trace storage device performance issues including devices, local disks, remote disks such as NFS.
# iostatLinux 2.6.18-238.9.1.el5 (tecmint.com) 09/13/2012
avg-cpu: %user %nice %system %iowait %steal %idle
2.60 3.65 1.04 4.29 0.00 88.42Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
cciss/c0d0 17.79 545.80 256.52 855159769 401914750
cciss/c0d0p1 0.00 0.00 0.00 5459 3518
cciss/c0d0p2 16.45 533.97 245.18 836631746 384153384
cciss/c0d0p3 0.63 5.58 3.97 8737650 6215544
cciss/c0d0p4 0.00 0.00 0.00 8 0
cciss/c0d0p5 0.63 3.79 5.03 5936778 7882528
cciss/c0d0p6 0.08 2.46 2.34 3847771 3659776 -
Lsof – List Open Files
Lsof used to display list of all the open files and the processes. The open files included are disk files, network sockets, pipes, devices and processes. One of the main reason for using this command is when a disk cannot be unmounted and displays the error that files are being used or opened. With this commmand you can easily identify which files are in use. The most common format for this command is.
# lsofCOMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
init 1 root cwd DIR 104,2 4096 2 /
init 1 root rtd DIR 104,2 4096 2 /
init 1 root txt REG 104,2 38652 17710339 /sbin/init
init 1 root mem REG 104,2 129900 196453 /lib/ld-2.5.so
init 1 root mem REG 104,2 1693812 196454 /lib/libc-2.5.so
init 1 root mem REG 104,2 20668 196479 /lib/libdl-2.5.so
init 1 root mem REG 104,2 245376 196419 /lib/libsepol.so.1
init 1 root mem REG 104,2 93508 196431 /lib/libselinux.so.1
init 1 root 10u FIFO 0,17 953 /dev/initctl -
Netstat – Network Statistics
Netstat is a command line tool for monitoring incoming and outgoing network packets statistics as well as interface statistics. It is very useful tool for every system administrator to monitor network performance and troubleshoot network related problems
Active Internet connections (w/o servers)
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 5 [ ] DGRAM 7326 /dev/log
unix 2 [ ] DGRAM 7964
unix 2 [ ] DGRAM 7961
unix 3 [ ] STREAM CONNECTED 7868
unix 3 [ ] STREAM CONNECTED 7867
unix 2 [ ] DGRAM 7697
unix 3 [ ] STREAM CONNECTED 7487 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 7486
unix 2 [ ] DGRAM 7432
unix 3 [ ] STREAM CONNECTED 7319 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 7318
unix 3 [ ] STREAM CONNECTED 7304
unix 3 [ ] STREAM CONNECTED 7303
unix 3 [ ] STREAM CONNECTED 6441 @/com/ubuntu/upstart
unix 3 [ ] STREAM CONNECTED 6439
unix 3 [ ] DGRAM 6145
unix 3 [ ] DGRAM 6144
unix 3 [ ] STREAM CONNECTED 6089 @/com/ubuntu/upstart
unix 3 [ ] STREAM CONNECTED 6084