Common commands for Linux system monitoring

Source: Internet
Author: User

1. Process monitoring (TOP)

The top command under Linux is a performance Monitor that monitors Linux performance and has this command in many Linux or Unix-like operating systems.

The top command is used to display all live processes that are running and active in a certain order, and the display results are updated periodically. This command shows CPU usage, memory usage, swap memory usage size, cache usage size, buffer usage size, process PID, commands used, and more. It can also show the memory and CPU usage of the running process.

Process PID, process user, CPU usage, memory utilization, swap memory usage size, and more. The top command provides real-time status monitoring of the system's processor. It displays a list of the most "sensitive" tasks for the CPU in the system.

Root@kallen:/home/kallen/shscript# Toptop- the: -: -Up2: the,4Users, load average:0.00,0.01,0.05Tasks: theTotal1Running MaxSleeping,0Stopped1ZOMBIECPU (s):0.0%us,0.2%sy,0.0%ni,99.8%id,0.0%wa,0.0%hi,0.0%siMem:507316K Total,473492K Used,33824K Free,17976K Bufferswap:2095100K Total,4848K Used,2090252K Free,153480K Cached PID USER PR NI VIRT RES SHR S%cpu %MEMTime+ COMMAND3082Root -   0  2852 1172  880R1  0.2   0:00.04Top2773Root -   0 10120 3500 2788S1  0.7   0:01.39Sshd1574Ntp -   0  5744 1996 1544S0  0.4   0:01.82Ntpd1Root -   0  3664 1856 1320S0  0.4   0:03.13Init2Root -   0     0    0    0S0  0.0   0:00.00Kthreadd

2. Virtual memory Statistics (VMSTAT)

The Linux VmStat command is used to display statistics for virtual memory, kernel threads, disks, system processes, I/O blocks, interrupts, CPU activity, and so on.

The use of the general Vmstat tool is accomplished by two numeric parameters, the first parameter is the number of time intervals sampled, the unit is seconds, and the second parameter is the number of samples.

[[email protected] ~]$ Vmstatprocs ----------Memory--------- ---Swap-- -----io---- -system-- ----CPU---- R  b   SWPD    Free   Buff  Cache      si    So    Bi    Bo   inch   CS US Sy  ID WA1  0  4848  23452  19024 157328   0   0    Ten    3   8   One  0  0   About  1

Test parameters explained:

r       表示运行队列,如果运行队列过大,表示你的CPU很繁忙,一般会造成CPU使用率很高b       表示阻塞的进程数swpd    虚拟内存已使用的大小,如果大于0,表示你的机器物理内存不足了, 如果不是程序内存泄露的原因,那么你该升级内存了或者把耗内存的任务迁移到其他机器free    空闲的物理内存的大小buff    系统占用的缓存大小cache   直接用来记忆我们打开的文件,给文件做缓冲si      每秒从磁盘读入虚拟内存的大小,如果这个值大于0,表示物理内存不够用或者内存泄露了us      用户CPU时间sy      系统CPU时间so      每秒虚拟内存写入磁盘的大小,如果这个值大于0,同上。sy      系统CPU时间,如果太高,表示系统调用时间长,例如是IO操作频繁。id      空闲 CPU时间,一般来说,id + us + sy =100wt      等待IO CPU时间。

3. List open files (lsof)

It is often used to display all open files and processes as a list. Open files include disk files, network sockets, pipelines, devices, and processes.

One of the main scenarios for using this command is when you cannot mount a disk and display an error message that you are using or opening a file. With this command, you can easily see which file is in use.

4. Network packet Analyzer (tcpdump)

Tcpdump is one of the most widely used network packet analyzers or packet monitoring programs that capture or filter TCP/IP packets that are received or transmitted on a specified interface on a network. It also has an option to save the captured package to a file for later analysis.

-h:查看命令帮助-i:网络接口-c:需要输出包数量
[Email protected] ~]$ tcpdump-i eth0-c2Tcpdump:verbose output suppressed, use-vor-vv forFull Protocol DecodelisteningOn   eth0, link-type en10mb (Ethernet), capture size  65535 bytes  -: the:43.797433IP Kallen.Local. SSH >172.16. 1. 208. 35949: Flags [P.], seq1248794718:1248794914Ack202785226, win3107,length 196 -: the:43.802854IP Kallen.Local. 13489> google-public-dns-a. Google.com.domain:28919+ PTR?208.1. the. 172.inch-addr.arpa. ( +)2Packets Captured inPackets Received by Filter0Packets Dropped byKernel

tcpdump command parameters and options:

[[email protected] conf]#tcpdump - Htcpdump version4. 1-pre-cvs_2012_02_01Libpcap version1. 4. 0Usage:tcpdump [-AADDEFIKLLNNOPQRSTUUVXX] [-B size] [-C Count][-c File_size] [-e Algo:secret] [-F file] [-G seconds][-I. Interface] [-M secret] [-R File] [-S Snaplen] [-t type] [-W file] [-W FileCount][-y Datalinktype] [-z command] [-Z User] [Expression]

5. Network status statistics (netstat)

Netstat is used to monitor incoming and outgoing network packets and network interface statistics, which can be used to monitor network performance, locate and solve network related problems.

[Root@kallenKallen]# Netstat-rKernel IP Routing tabledestination Gateway genmask Flags MSS Window Irtt Iface172.16.1.0 *255.255.255.0U0 0       0Eth0172.16.1.0 *255.255.255.0U0 0       0Eth1Link-Local *255.255.0.0U0 0       0Eth0Link-Local *255.255.0.0U0 0       0Eth1default172.16.1.1    0.0.0.0Ug0    0   0Eth0

6. Real-time LAN IP monitoring (IPTRAF)

Iptraf is an open source real-time network (LAN) monitoring application running on the Linux console. It collects a lot of information, such as IP traffic monitoring over the network, including TCP tokens, ICMP details, TCP/UDP traffic separation, TCP connection packets, and bytes.

It also collects common information and details about the state of the interface: TCP, UDP, IP, ICMP, non-IP,IP checksum error, interface activity, and so on.

Linux system monitoring common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.