The Pstree,htop,glances,dstat command for Linux learning notes is used

Source: Internet
Author: User
Tags cpu usage

This article will briefly describe the use of Pstree,top,htop,dstat:

Pstree

Pstree-display a tree of processes

Pstree: Displays the process state tree, and the pstree command lists the current processes and their tree structure. The main options are as follows.

-A: Displays the command and full parameters of the executing program.

-C: Cancel the program with the same name and merge display.

-N: Sort by pid size.

-P: Displays PID.

-U: Displays UID information.


Common commands

Pstree-a Show All information

Pstree-p Show Process PID number


Difference: CENTOS6, the first process is init, CENTOS7 is SYTEMD

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/F5/wKioL1YKrfCAdeu_AAHoUon_1aA536.jpg "title=" 001. PNG "width=" 456 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:456px;height:300px; "alt=" Wkiol1ykrfcadeu _aahouon_1aa536.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/F8/wKiom1YKrg_g1ieMAAH2MtrULfo776.jpg "title=" 002. PNG "width=" 423 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:423px;height:300px; "alt=" Wkiom1ykrg_ G1iemaah2mtrulfo776.jpg "/>

Ps

Ps-report a snapshot of the current processes

Displays a snapshot of the current process information, displaying static information

The information about the processes on the Linux system is actually stored in the/proc/directory, and the directory of the digital commands stores information about the process that is the PID, and most of the process management tools will read the information here.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/F8/wKiom1YKrl2hGEWDAASw1_r2isA385.jpg "title=" 003. PNG "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:800px;height:78px; "alt=" Wkiom1ykrl2hgewdaasw1_r2isa385.jpg "/>

Common combination: aux

U: Display of process status information in user-centric organization

A: terminal-related processes;

X: Processes unrelated to the terminal;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/F5/wKioL1YKrt7Sf_oIAAHlxSFjf0Q520.jpg "title=" 004. PNG "width=" "height=" 171 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:171px; "alt=" wkiol1ykrt7sf_ Oiaahlxsfjf0q520.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/F8/wKiom1YKrwOiuo_8AALGnmtloEI198.jpg "title=" 005. PNG "width=" "height=" 196 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:196px; "alt=" Wkiom1ykrwoiuo_ 8aalgnmtloei198.jpg "/>

Common combination:-ef

-e: Show All Processes

-F: Display full format program information


Common combination:-EFH

-F: Show process information in full format

-H: Show process-related information in process-level format

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/F8/wKiom1YKr2PAhNw0AAJFVu2KeRs626.jpg "title=" 006. PNG "width=" "height=" 188 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:188px; "alt=" Wkiom1ykr2pahnw0aajfvu2kers626.jpg "/>

Common combinations:-eo, Axo (custom process output format)

-eo Pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,comm

Axo Stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm

Ni:nice value

Pri:priority, priority

Rtprio: Real-time priority


Top

Interactive, dynamic view system run Status Tool

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/F5/wKioL1YKsACiatf1AAbELo4_Dl4390.jpg "title=" 007. PNG "width=" "height=" 467 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:700PX;HEIGHT:467PX; "alt=" Wkiol1yksaciatf1aabelo4_dl4390.jpg "/>

There are many built-in commands:

The sorting methods are:

P: Percentage of CPU occupied; (percentage of CPU in the past refresh cycle);

M: Percentage of memory occupied;

T: Cumulative occupy CPU duration;


The first message shows:

Uptime information: l command

Tasks and CPU information: T command

CPU Display: 1 (digital)

Memory Information: M command


Exit Command: Q

Modify Refresh time interval: s

Terminates the specified process: K


Options:

-D #: Specifies the refresh interval, which defaults to 3 seconds;

-B: in batch mode;

-N #: Shows how many batches;


Htop

Htop is an enhanced version of the top tool that provides a more aesthetically pleasing interface to the administrator, supports interactive commands and supports mouse selection, and is included by Red Hat in the high-quality software source Epel provided by the Fedora community, so yum installation is required before use. After the installation is complete, type htop at the command line, which displays the following interface:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/F8/wKiom1YKsDvQdxY_AAky96IwAn0651.jpg "title=" 008. PNG "width=" "height=" 496 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:496px; "alt=" WKIOM1YKSDVQDXY _aaky96iwan0651.jpg "/>

Htop command:

Interactive Process viewing tools

#htop Start Htop

The interface is as follows:

F1 Get Help

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/F5/wKioL1YKsLCCzD_BAARhlOKgzng872.jpg "title=" 009. PNG "width=" "height=" 446 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:446px; "alt=" Wkiol1ykslcczd_ Baarhlokgzng872.jpg "/>


U: Display the process of the specified user, htop main interface Press U key, see the following interface, select the relevant user, enter only to show the process of the specified user

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/F8/wKiom1YKsOqxht9wAAlcawQJ9B4689.jpg "title=" 10.png "Width=" "height=" 479 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:700PX;HEIGHT:479PX; "alt=" Wkiom1yksoqxht9waalcawqj9b4689.jpg "/>


Just show root all the processes

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/F5/wKioL1YKsQagsB4vAAgxsZGX7pU842.jpg "title=" 11.png "Width=" "height=" 583 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:583px; "alt=" Wkiol1yksqagsb4vaagxszgx7pu842.jpg "/>

Options:

-D #: Specify the delay time;

-U UserName: Displays only the process of the specified user;

-S Colomn: Sort by the specified field;

Command:

S: Tracks system calls for the selected process;

L: Displays the list of files opened by the selected process;

A: Binds the selected process to a specified CPU core;

T: Show Process Tree

To use the name above, simply press the corresponding key in the Htop main interface.


Glance:

Glances is a more powerful system resource monitoring tool developed by the Python language to monitor CPU, load, memory, disk I/O, network traffic, file system, system temperature and more. Interactive commands are supported and have C/s characteristics.

The glances package is also available as a Epel source and can be installed with Yum

[Email protected] ~]# rpm-q glances #glances包已经安装

Glances-1.7.7-1.el7.noarch


#glances #运行glances You can start the Glances tool with the following interface:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/F8/wKiom1YKsUaT9SbSAAe2QjCS9fs389.jpg "title=" 12.png "Width=" "height=" 385 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:385px; "alt=" Wkiom1yksuat9sbsaae2qjcs9fs389.jpg "/>

Command format: Glances [-BDEHMNRSVYZ1] [-B bind] [-C Server] [-C conffile] [-P port] [-p password] [--password] [-t refresh] [-f fil E] [-O output]


Built-in commands:

A Sort processes automatically l Show/hide logs

C Sort processes by CPU% b Bytes or bits for network I/O

M Sort processes by mem% W Delete warning logs

P Sort processes by name X Delete Warning and critical logs

I Sort processes by I/O rate 1 Global CPU or PER-CPU stats

d show/hide disk I/o stats h show/hide

F show/hide File system stats T View network I/O as combination

n show/hide Network stats u View Cumulative network I/O

s show/hide Sensors stats Q Quit (ESC and ctrl-c also work)

Y show/hide hddtemp Stats


Note: Use H to view Help and exit help

Common options:

-B: Displays the network card data rate in bytes;

-D: Turn off the disk I/O module;

-f/path/to/somefile: Set the file location;

-O {html| CSV}: Output format;

-M: Disable Mount Module

-N: Disable network module

-T #: Refresh Interval

-1: The relevant data for each CPU is displayed separately;


Run the glances command in C/s mode:

Service mode:

Glances-s-B ipaddr & #服务器端启动glances service, and placed backstage; IPADDR: Indicates which address is listening on this machine

# glances-s-B 172.17.0.22 &


Client mode:

Glances-c ipaddr

# glances-c 172.17.0.22 #连接服务器端IP即可



Dstat


is an all-in-one system analysis statistics tool, DSTAT supports real-time refresh. However, the relevant packages need to be installed. The Centos7 CD contains RPM packages.


Dstat [-AFV] [options:] [Delay [Count]]

Common options:

-C: Display CPU-related information;

-C #,#,..., total;

-D: Display disk related information;

-D Total,sda,sdb,...

-G: Display page related statistics;

-M: Display memory related statistics;

-N: Display network related statistics;

-P: Show process-related statistics;

-R: Displays statistics related to IO requests;


--TOP-CPU: Displays the most CPU-intensive processes;

--top-io: Shows the process that most consumes IO;

--top-mem: Shows the most memory-intensive processes;

--top-lantency: Show the process with the most delay


#dstat Run the Dstat tool with an interface such as

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/F5/wKioL1YKsdbCtirQAAGbnBCRITs655.jpg "title=" 13.png "Width=" "height=" 169 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:700PX;HEIGHT:169PX; "alt=" Wkiol1yksdbctirqaagbnbcrits655.jpg "/>

Where: Total-cpu-usage represents CPU usage statistics,-dsk/total indicates disk read-write rate, net/total represents network transfer rate, paging indicates memory page swap out, System represents interrupt and Context switch (process switch)



Command DSTAT [-AFV] [options:] The dely field in [Delay [count]] indicates the refresh interval, and the Count field indicates the number of refreshes

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/F8/wKiom1YKsffCGX48AALOXDmI7jE121.jpg "title=" 14.png "Width=" "height=" 192 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:192px; "alt=" Wkiom1yksffcgx48aaloxdmi7je121.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/F5/wKioL1YKsgvAiPxoAAGu9dJ38kg934.jpg "title=" 15.png "Width=" "height=" 333 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:333px; "alt=" Wkiol1yksgvaipxoaagu9dj38kg934.jpg "/>


The Pstree,htop,glances,dstat command for Linux learning notes is used

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.