Command for viewing system resource usage in Linux

Source: Internet
Author: User
Use \ 'top-I \ 'to check how many processes are running. The system may have memory or I/O bottlenecks. Use free to check whether the system memory usage is high, use iostat to check the I/O load...
Another method is PS-Ef | sort-K7, which sorts processes by running time and determines which process consumes the most CPU time.
Top: 
Main Parameters
D: Specify the update interval, in seconds.
Q: there are no delayed updates. If a Super User exists, the top command is executed in the highest priority order.
C: displays the complete process path and name.
S: The accumulation mode, which accumulates the CPU time of the completed or disappearing sub-itinerary.
S: security mode.
I: no idle (idle) or useless (zombie) itinerary is displayed.
N: displays the number of updates. After the update is completed, it will exit
Display parameters:
PID (process ID): process ID.
User: the user name of the process owner.
PR: process priority.
Ni: the priority value of the process.
Virt: Virtual Memory occupied by the process.
Res: The physical memory occupied by the process.
SHR: the shared memory value used by the process.
S: Process status. s indicates sleep, r indicates running, Z indicates frozen, and N indicates that the priority of the process is negative.
% CPU: CPU usage occupied by the process.
% Mem: Percentage of physical memory and total memory occupied by the process.
Time +: The total CPU time occupied by the process after it is started.
Command: the name of the startup command that the process starts. If this line does not appear, the process has a complete command line.
Some interactive commands can be used to complete other parameter functions during the use of the top command. These commands are started by using the shortcut key.
<Space>: refresh immediately.
P: sort by CPU usage.
T: sort by time and accumulated time.
Q: exit the top command.
M: Switch to Display memory information.
T: process and CPU status information is displayed during switchover.
C: Switch the display command name and the complete command line.
M: sort by memory size.
W: Write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

Free 
1. Role
The free command is used to display memory usage. The permission is applied to all users.

2. Format
Free [-B-k-m] [-o] [-s delay] [-t] [-V]

3. Main Parameters
-B-k-m: memory usage is displayed in bytes (KB, MB.
-S delay: the number of seconds to display the memory usage.
-T: displays the total memory column.
-O: the buffer adjustment column is not displayed.

Uptime
 
18:59:15 up 25 min, 2 users, load average: 1.23, 1.32, 1.21
Current Time
How long has the system been running?
Number of connected users
System load in the last minute, five minutes, and fifteen minutes
Parameter:-V displays version information.

Vmstat
 
Procs ----------- memory ---------- --- swap -- ----- Io ---- System -- ---- CPU ----
R B SWPD free buff cache Si so Bi Bo in CS us Sy ID wa
0 1 24980 10792 8296 47316 5 19 205 1161 698 26 3 1 70
1. Observe disk Activity
Disk activity is mainly based on the following indicators:
BI: The number of blocks read from the disk per second (blocks/s ). The larger the number, the more disk read activity.
Bo: The number of blocks written to the disk per second (blocks/s ). The larger the number, the more disk write activity.
Wa: percentage of time when the CPU waits for disk I/O (pending disk Io. The larger the number, the more serious the file system activity hinders the CPU, because the CPU is waiting for the slow disk system to provide data. It is ideal to set wa to 0. If Wa is often greater than 10, the file system may need to adjust its performance.
2. Observe CPU Activity
Vmstat better reflects CPU usage than top:
US: The CPU usage time ratio of the user program. The larger the number, the busier the user process.
Sy: CPU usage time ratio for system calls. Note that NFS runs in the kernel, so the CPU time occupied by NFS activity is reflected in SY. If this number is large, you need to consider whether a kernel process is heavy, for example, NFS tasks. If both us and SY are large, you need to consider separating some user programs from other servers to avoid mutual influence.
ID: Percentage of idle CPU time.
Wa: percentage of time when the CPU waits for pending disk Io.

Iostat
 
Used to count CPU usage and tty device, hard disk and CD-ROM I/0 count
Parameters:
-C: Only CPU rows are displayed.
-D: Display disk lines
-K Displays disk output in kilobytes
-T include the timestamp in the output
-X includes extended disk metrics in the output

Avg-cpu: % user % nice % sys % iowait % idle
20.25 0.18 2.61 76.39 0.57
% Percentage of CPU idle time when iowait waits for local I/O
% Percentage of idle CPU time when idle does not wait for local I/O

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Hda 9.86 284.34 84.48 685407 2036
Transmission per second (tps), 512 bytes of block read per second (Blk_read/s), 512 bytes of block write per second (Blk_wrtn/s), and 512 bytes of block read (Blk_read) and the total number of writes (Blk_wrtn. System 
# Uname-a # view kernel/operating system/CPU Information
# Head-n 1/etc/issue # view the operating system version
# Cat/proc/cpuinfo # view CPU Information
# Hostname # view the computer name
# Lspci-TV # list all PCI devices
# Lsusb-TV # list all USB devices
# Lsmod # list loaded Kernel Modules
# Env # view environment variables
Resources 
# Free-m # view memory usage and swap zone usage
# DF-h # view the usage of each partition
# Du-SH # view the size of a specified directory
# Grep memtotal/proc/meminfo # view total memory
# Grep memfree/proc/meminfo # view the Amount of idle memory
# Uptime # view system running time, number of users, and load
# Cat/proc/loadavg # view system load
Disks and partitions 
# Mount | column-T # view the status of the mounted Partition
# Fdisk-L # view all partitions
# Swapon-s # view all swap partitions
# Hdparm-I/dev/hda # view disk parameters (only applicable to ide devices)
# Dmesg | grep ide # view the IDE Device Detection Status at startup
Network 
# Ifconfig # view the attributes of all network interfaces
# Iptables-L # view firewall settings
# Route-N # view the route table
# Netstat-lntp # view all listening ports
# Netstat-antp # view all established connections
# Netstat-s # view network statistics
Process 
# Ps-Ef # view all processes
# Top # display Process status in real time
User 
# W # view active users
# Id # view specified user information
# Last # view User Logon logs
# Cut-d:-f1/etc/passwd # view all users in the system
# Cut-d:-f1/etc/group # view all groups in the system
# Crontab-l # view the scheduled tasks of the current user
Service 
# Chkconfig -- list # list all system services
# Chkconfig -- list | grep on # list all started system services
Program 
# Rpm-qa # view all installed software packages

Related Article

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.