Viewing Linux System Resources--Learning Notes
1. vmstat command Virtual Meomory Statistics
Function: Dynamic understanding of the use of system resources, and to see which link in the current system is the most occupied system resources.
It can be used to monitor CPU usage, process status, memory usage, virtual memory usage, hard disk input/output status and other information.
[root@localhost ~]# vmstat [-a] [Refresh Delay Refresh Number] [root@localhost ~]# vmstat [option] #- The meaning of a is to replace buff/cache's memory output information with inact/active (active or not).
|procs||Process information field:
|memory||Memory information field:
|swap||Exchange partition information field:
|io||Disk Read/Write Information Field:
|system||System information field:
|cpu||CPU information field:
The difference between caching and buffering # In short, cache is used to speed up data "read" from the hard disk, while buffer is used to speed up data "write" to the hard disk. # It takes some space out of memory to speed up data reading and writing.
2. dmesg command
Whether in the process of system startup or in the process of system operation, as long as the information generated by the kernel is stored in the system buffer, if it is too late to view the relevant information when booting, you can use the dmesg command to call out the information, which is often used to view the hardware information of the system.
In addition, boot information can also be viewed through the dmesg file in the / var/log / directory.
[root@localhost ~]# dmesg //View CPU information [root@localhost ~]# dmesg | grep CPU [ 0.000000] CPU MTRRs all blank - virtualized system. [ 0.000000] ACPI: SSDT 0000000027ff02a0 001CC (v01 VBOX VBOXCPUT 00000002 INTL 20100528) [ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs [ 0.000000] setup_percpu: NR_CPUS:5120 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 [ 0.000000] PERCPU: Embedded 31 pages/cpu @ffff880027c00000 s87168 r8192 d31616 u1048576 [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 [ 0.000000] RCU restricting CPUs from NR_CPUS=5120 to nr_cpu_ids=2. [ 0.000000] Offload RCU callbacks from all CPUs [ 0.000000] Offload RCU callbacks from CPUs: 0-1. [ 0.004173] CPU: Physical Processor ID: 0 [ 0.004176] CPU: Processor Core ID: 0 [ 0.005597] mce: CPU supports 0 MCE banks [ 0.077132] smpboot: CPU0: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (fam: 06, model: 5e, stepping: 03) [ 0.190670] Performance Events: unsupported p6 CPU model 94 no PMU driver, software events only. [ 0.205585] mce: CPU supports 0 MCE banks [ 0.207719] Brought up 2 CPUs [ 1.019449] microcode: CPU0 sig=0x506e3, pf=0x2, revision=0x0 [ 1.019460] microcode: CPU1 sig=0x506e3, pf=0x2, revision=0x0 //View the first network card information [root@localhost ~]# dmesg | grep eth0 [ 2.406609] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:6c:3e:95 [ 2.406621] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
III. free Order
The free command is used to display the state of system memory, including the usage of system physical memory, virtual memory (swap swap partition), shared memory and system cache. Its output is very similar to the memory part of top command.
[root@localhost~]# free [option] [Options] - b: Display memory usage in bytes. - k: Display memory usage in KB units. This option is the default option for the free command. - m: Display memory usage in MB. - g: Display memory usage in GB. - t: The total amount of output memory and swap partitions in the final output. - o: The system buffer column is not displayed. - s: Number of interval seconds. Continuous display of memory usage based on the specified interval time. [Output] Tot: Represents the total memory of the system Used: Represents memory already used by the application free: Represents memory that is not currently in use Shared: Represents memory used by shared link libraries buff/cache: Represents the memory used by page cache and buffer of the system available: Represents memory that an application can also apply for available <= free + buff/cache This is less than, because some page s or cache s of the system are not recyclable.
IV. Viewing CPU Information
# Display the start time and average load of the system, which is the first line of the top command. The w command can also see this data
6. Viewing System and Kernel Related Information
uname [option] [Options] - a: View all relevant information about the system - r: View the kernel version - s: View the kernel name
List file information that process calls or opens
All processes in the system can be queried by ps command. So, can we know more about which files the process is calling? Of course, use the lsof command.
[root@localhost ~]# lsof [Options] [option] -c Character string List only files opened by processes that begin with strings. +d Catalog Name Lists all files called by a process in a directory. -u User name List only files opened by a user's process. -p pid List one PID The file opened by the process. //example [root@localhost ~]# lsof | more #Query all process calls in the system [root@localhost ~]# lsof /sbin/init #Query which process a file is called by [root@localhost ~]# lsof +d /usr/lib #Query which processes call all files in a directory [root@localhost ~]# lsof -c httpd #See which files are invoked by processes starting with httpd [root@localhost ~]# lsof -p 1 #Query PID is a process call file of 1 [root@localhost ~]# lsof -u root #Query a user's process call file by username