Common commands for tracing online problems under Linux

Source: Internet
Author: User

(1) Check the process that consumes the most CPU
Method One:
Core directive: PS
Actual command:
PS H-eo pid,pcpu | Sort-nk2 | Tail
The following results are performed:
[Email protected] ~]$ PS H-eo pid,pcpu | Sort-nk2 | Tail
31396 0.6
31396 0.6
31396 0.6
31396 0.6
31396 0.6
31396 0.6
31396 0.6
31396 0.6
30904 1.0
30914 1.0
Results:
See, the most CPU-intensive pid=30914 (actually 31396)

Method Two:
Core directive: Top
Actual command:
Top
Shift + t

(2) on the basis of (1), what is the corresponding service name?
Method One:
Core directive: PS
Actual command:
PS aux | Fgrep PID
The following results are performed:
[[Email protected] ~]$ PS aux | Fgrep 30914
Work 30914 1.0 0.8 309568 71668? Sl Feb02 124:44./router2–conf=rs.conf
Results:
See, the process is./router2

Method Two:
Core directive: ... No, check proc directly.
Actual command:
Ll/proc/pid
The following results are performed:
[Email protected] ~]$ ll/proc/30914
lrwxrwxrwx 1 Work Work 0 13:27 CWD--/home/work/im-env/router2
lrwxrwxrwx 1 Work Work 0 13:27 exe--/home/work/im-env/router2/router2
Results:
This is good, the whole path is out.

(3) View a port's connection status
Method One:
Core directive: Netstat
Actual command:
Netstat-lap | Fgrep Port
The following results are performed:
[Email protected] ~]$ Netstat-lap | Fgrep 22022
TCP 0 0 10.58.xxx.29:22022 *:* LISTEN 31396/imui
TCP 0 0 10.58.xxx.29:22022 10.58.xxx.29:46642 established 31396/imui
TCP 0 0 10.58.xxx.29:22022 10.58.xxx.29:46640 established 31396/imui

Method Two:
Core directive: lsof
Actual command:
Lsof-i:p ORT
The following results are performed:
[[email protected] ~]$/usr/sbin/lsof-i: 22022
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Router 30904 work 50u IPv4 69065770 TCP 10.58.xxx.29:46638->10.58.xxx.29:22022 (established)
Router 30904 work 51u IPv4 69065772 TCP 10.58.xxx.29:46639->10.58.xxx.29:22022 (established)
Router 30904 work 52u IPv4 69065774 TCP 10.58.xxx.29:46640->10.58.xxx.29:22022 (established)

(4) to be continued ...

Common commands for tracing online problems under Linux

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.