Linux System Resource View

Source: Internet
Author: User
Tags cpu usage pkill aliyun


Linux Process View command:
First, the process on the Linux system and the viewing tools:
Pstree,ps,pidof,pgrep,htop,glances,pmap,vmstat,dstat,
Kill,pkill,job,bg,fg,nohup,nice,renice,killall

CENTOS5:SYSV init//based on shell script implementation, start service serial mode run
Centos6:upstart//Create a process by command, parallel execution boot//encapsulation still uses service
centos7:systemd//Reference Mac OS, only need to enable a process, you can start each service process.
Systemctl can control other services
1.pstree//view process Tree
2.ps Status display for current process
/proc: status information in the kernel
Kernel parameters: You can set its values to adjust the parameters of the kernel operating characteristics:/proc/sys
State variable: It is used to output statistics or state information in the kernel and is used only for viewing:
Parameters: Simulation into FS type;
PS Extract the information from the/proc to show
Process:
/proc/#
#:P ID//
PS [options]//three styles
1.UNIX style//ps-a
2.BSD//ps A//without horizontal line
3.GNU
How to start a process:
Auto Start/terminal Independent at System boot
User-initiated via terminal//terminal-related
-A//terminal-related
-x//Terminal Independent
U//user-related
AUX//all processes [] kernel thread
USER PID ... VSZ RSS STAT
VSZ: Virtual memory combined with size//linear address space and physical address space
3G only I use, the process sees is the virtual memory set,
RSS: Resident Memory Set resident Size, when memory is not enough, some of the in-memory data needs to be put on swap, but some cannot be put on swap: resident memory set
STAT: Status,
R:running
S:interruptable sleeping
D:uninterruptable sleeping
t:stopped
Z:zombie

+: Foreground process
L: Multithreaded Process
N: Low-priority process
Less than: high-priority process
S:session leader//Master Process
-e: Show all processes, equivalent to AX, but UNIX style
-f:full-format full format
Ps-ef
PPID: Parent Process Pid,stime: Start time, percentage of c:pcpu CPU utilization, Time: Cumulative runtime
-F: Displays information in full format
The information displayed is more complete
Ps-ef
PSR: on which CPU to run, precessor
Man PS//back with help information
-H: Displays information about the process in a hierarchical structure
Ps-efh
Other common combinations:
O: Customizable fields to display, comma delimited
Ps-axo Pid,command,pri,psr,pcpu,stat,tty,ppid,user,ni,rtprio
Ni:nice value
Rtprio:real-time priority, real-time prioritization
-eo://o must write to the back, because O is required with parameters
-axo:

3.pgrep,pkill Command
pgrep [Options] Pattern
-U UID: Displays the process of the specified user
-U uid:read User
-T TERMINAL: Processes associated with the specified terminal
-L: Show process name
-A: Displays the full process name
-P PID: Shows the child process of its process
Pgrep-p 25463//view its child processes
Child process of subprocess, is his grandson process, not his child process
Pgrep ssh//with SSH string
Pgrep S//have S-word a
Pkill and pgrep usage are similar
4.pidof Process Number of the specified process
Pidof sshd//Get its PID based on the process name
-S: Returns only one process number;
-C: Show only processes with the same "root" directory;
-X: Shows the process opened by the script;
-O: Specifies the process ID that is not displayed.

5.top Task Viewer similar to Windows
Dynamically View process state information
H Help Information

    top - 12:14:58 up 2 days,   2:47,  3 users,  load average: 0.00, 0.01, 0.05     Tasks: 307 total,   2 running, 305 sleeping,    0 STOPPED,   0 ZOMBIE    %CPU (s):   0.0  us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0  hi,  0.0 si,  0.0 st    KiB Mem :   1009272 total,   155080 free,   201980 used,    652212 buff/cache    KiB Swap:  2097148 total,   2093712 free,     3436 used.   537560 avail mem 

Load average:1,5,15min//Average queue Length, queue length on CPU waiting to run
The number of queue waits usually does not have a large number of CPUs//load thresholds generally in CPU cores *2.5 (experience)
%cpus//Sy:kernel Time,ni: CPU time used for nice adjustment, Id:idel idle percentage, wa:wait wait io percentage, hi:hwaddr interrupt hardware interrupt, Si:soft Interrupt soft interrupt, si: Stolen percentage (stolen by virtualization)
Sort:
P: Sorted by percentage of CPU occupied
M: Memory
T: Cumulative CPU consumption percent
Header information:
l command//switch CPU
Tasks and CPU information: T command
Memory Information: M command
Refresh Time
S 1//refresh once per 1s
K//kill
Options
-D #//Specify Refresh time interval
-b//Display in batch mode, bat
-N//show how many batches
Top-b-N 1
1//Decentralized display CPU
6.uptime//Display system time, run time and average load
Average load of past 1,5,15min, waiting for average queue length
UPTIME-S//System boot time
-P//How long has the switch been on?


7.htop//Need Epel source, can customize display options, support mouse
baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
https://mirrors.aliyun.com/epel/7/x86_64/
Yum Install Htop-y
Note: Yum is a transactional concept and can only run one yum command
H//memory:used/buffers/cache
Status
R:running,s:sleeping,t:traced/stopped,z:zombie,d:disk sleep//non-disruptive sleep
U//Specify user process
H//show/hide User Thread
K Kernel Thread
F cursor Tracking
P M T//sorting method
F6//Sorting of selected fields
C//mark the process and its child processes
A CPU binding
I set IO priority
Cursor selected process//L show All files opened by the process
S//Track a process-initiated system call
F4 Auto Roll Screen
-d#//delay Time
-U USERNAME//process for the specified user
-S Colume//Sort by specified fields
Sub-command:
L: Displays a list of files opened by the process
S: Track system calls for selected processes
T:tree-like display, or F5
A: Binds the selected process to the core of the task

8.vmstat//virtual memory, Reporting statistics on virtual memory
Vmstat [Options] [delay [count]]
Vmstat 2//update once per 2s
Vmstat 2 2//Total display 2 times, updated every 2s
-S//Display memory usage information
Procs: Process,
R:running: Number of processes waiting to run; Queue Length waiting to run on CPU
B:block the length of the queue of blocked, blocked tasks
Memory
SWPD: Swap memory usage, 0: Indicates if it is enabled
Free: Total amount of idle physical memory
Cache: Caching
Buffer: Buffering
swap//relative to swap
Si:swap in//rate value KB/S
So:swap out//data out of swap rate kb/s
IO//relative to disk
BI: Read data from hard disk to os,kb/s
Bo: The rate at which data is saved to a block device, kb/s
System
In:interrupts Interrupt Rate
Cs{context Switch} switching rate
Cpu
us
Sy
Id
Wa
St
Interrupt: How the CPU knows if a signal arrives when IO needs to interact with the CPU
1. Rotation, see if there is an interaction at a time
2. In-line disconnection//need to apply for use, there is a number, a break can be reused
9.pmap//Memory map
Pmap PID

PMAP [options] pid [...]
-X: Display detailed format information
Cat/proc/1/maps//function same

10.glances Command//More beautiful than the top interface
Can be viewed remotely,

-b//display NIC Data rate in bytes-d//Shutdown disk IO module-m//Close Mount module-N//Shutdown Network module-t #//Refresh Interval-1//per CPU separate display
· A – automatic sequencing of processes · C – Process sequencing by CPU percentage · M – process sort by percent of memory · P – The process by process name Master sequence · I – Process sequencing by read/write frequency (I/O) · D – Show/Hide disk I/O statistics · F – Show/Hide file system statistics · n – Show/Hide network interface statistics · S-Show/Hide sensor statistics · Y – Show/hide hard drive temperature statistics · L – Show/Hide logs (log) · b – Switching network I/O units (bytes/bits) · W – Delete warning Log · X – Delete warnings and critical logs · --Switch global CPU usage and usage per CPU • H – Show/hide this help screen · T-Browse the network I/O in a combined form U browse the network in a cumulative form I/O Q – Exit (' ESC ' and ' ctrl&c ' also available)

Glances-f/root-o HTML//Save as Html/csv format, just need to know a path, you can not specify the file name
ssh-x [email protected]//enable graphical display,
The file can be dynamically refreshed
Run the glances command in C/s mode
Service mode:
Glances-s-B ipaddr
IPADDR//This level of an address for monitoring
-b//Listening address
Client mode:
Glances-c ipaddr
ipaddr//IP for remote server

Glance Color definition:
· Green: OK (everything works)
· Blue: Careful (attention required)
· Purple: WARNING (Warning)
· Red: CRITICAL (severe)
Thresholds can be set in the configuration file, and general thresholds are set by default (Careful=50, warning=70, critical=90).
Custom (default in/etc/glances/glances.conf).

11.dstat//Tools for resource usage statistics, most fully functional
Default: Cdngy//cpu,disk,net,paging,sys
-c{d,n,g,y}
-C 0,3,total//Includes No. 0 and 3rd CPUs or total, specifying CPU
-d,disk
-D sda,sdb,... Total
-G: Display page-related statistics

-I interrupt-M mem-n net-n eth1,eth0-p proc-r io-s swap-s swap1,total--aio//Activate asynchronous IO--ip C//Activate IPC--TCP//TCP statistics--UDP//--socket--unix//unix-socket--top-bio//Most consumed disk IO--top-cpu Busiest CPU--top-int//MAX interrupt number of--top-mem--top-lantency//Latency Max Process

Dstat 1 2//display once every 1s, 2 times in total
12.kill Command
Used to send signals to a process for management of the process
Kill-l 1//View the contents of sign 1th
Kill-l//View all signal contents
There are three ways to identify each signal
1) digital representation of the signal
2) Full name of the signal
3) abbreviated name of the signal
Send a signal to a process
Kill [-S signal] [-Q sigval] [-a] [...] pid ...
Kill-s PID
Common signals:
1): Sigup: No need to close the process and let it reread the configuration file
Kill-sighup 111000
Kill-s SIGNUP 111000
2): SIGINT: Abort the running process, equivalent to CTRL + C//Pause
9): SIGKILL; Kill a running process; brutal killing.
No matter what you're doing, kill directly.
15): Default signal sigterm: terminates the running process; humanitarian destruction.
Tell you, you're going to die, finish the running job, and kill.
: SIGSTOP: Stop, send to backstage//ctrl+z
PS aux |grep vim
FG returns directly to the front desk
): Sigcont: Continue
13.killall
Based on name
Killall [-signal] Program
Killall httpd//ps aux |grep httpd there will be nothing


This article is from the "Dark Horse vacated" blog, please be sure to keep this source http://hmtk520.blog.51cto.com/12595610/1977891

Linux System Resource View

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.