From fef4d6ff2ad9f48e6dccde0f061453e6a3ac624e Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 19 Apr 2020 22:13:44 +0200 Subject: added new hierarchy --- src/monitor/README.md | 1 + src/monitor/lsof.md | 40 ++++++++++++++++++++++++++++++++++++++++ src/monitor/pgrep.md | 15 +++++++++++++++ src/monitor/pidstat.md | 31 +++++++++++++++++++++++++++++++ src/monitor/pmap.md | 7 +++++++ src/monitor/pstack.md | 6 ++++++ 6 files changed, 100 insertions(+) create mode 100644 src/monitor/README.md create mode 100644 src/monitor/lsof.md create mode 100644 src/monitor/pgrep.md create mode 100644 src/monitor/pidstat.md create mode 100644 src/monitor/pmap.md create mode 100644 src/monitor/pstack.md (limited to 'src/monitor') diff --git a/src/monitor/README.md b/src/monitor/README.md new file mode 100644 index 0000000..545e774 --- /dev/null +++ b/src/monitor/README.md @@ -0,0 +1 @@ +# Resource analysis & monitor diff --git a/src/monitor/lsof.md b/src/monitor/lsof.md new file mode 100644 index 0000000..8253003 --- /dev/null +++ b/src/monitor/lsof.md @@ -0,0 +1,40 @@ +# lsof(8) + +```markdown +lsof + -a ......... AND slection filters instead ORing (OR: default) + -p ... filter by + +fg ........ show file flags for file descripros + -n ......... don't convert network addr to hostnames + -P ......... don't convert network port to service names + -i <@h[:p]>. show connections to h (hostname|ip addr) with optional port p +``` + +```markdown +file flags: + R/W/RW ..... read/write/read-write + CR ......... create + AP ......... append + TR ......... truncate +``` + +# Examples + +## File flags +Show open files with file flags for process: +```markdown +lsof +fg -p +``` +## Open TCP connections +Show open tcp connections for `$USER`: +```markdown +lsof -a -u $USER -i tcp +``` +**Note**: `-a` _ands_ the results. If `-a` is not given all open files matching +`$USER` and all tcp connections are listed (_ored_). + +## Open connection to specific host +Show open connections to `localhost` for `$USER`: +```markdown +lsof -a -u $USER -i @localhost +``` diff --git a/src/monitor/pgrep.md b/src/monitor/pgrep.md new file mode 100644 index 0000000..2b52a73 --- /dev/null +++ b/src/monitor/pgrep.md @@ -0,0 +1,15 @@ +# pgrep(1) + +```markdown +pgrep [opts] + -n only list newest matching process + -u only show matching for user + -l additionally list command + -a additionally list command + arguments +``` + +## Debug newest process +For example attach gdb to newest zsh process from `$USER`. +```markdown +gdb -p $(pgrep -n -u $USER zsh) +``` diff --git a/src/monitor/pidstat.md b/src/monitor/pidstat.md new file mode 100644 index 0000000..b57f231 --- /dev/null +++ b/src/monitor/pidstat.md @@ -0,0 +1,31 @@ +# pidstat(1) + +```markdown +pidstat [opt] [interval] [cont] + -U [user] show username instead UID, optionally only show for user + -r memory statistics + -d I/O statistics + -h single line per process and no lines with average +``` + +# Page fault and memory utilization +```markdown +pidstat -r -p [interval] [count] +``` + +```markdown +minor_pagefault: Happens when the page needed is already in memory but not + allocated to the faulting process, in that case the kernel + only has to create a new page-table entry pointing to the + shared physical page (not required to load a memory page from + disk). + +major_pagefault: Happens when the page needed is NOT in memory, the kernel + has to create a new page-table entry and populate the + physical page (required to load a memory page from disk). +``` + +# I/O statistics +```markdown +pidstat -d -p [interval] [count] +``` diff --git a/src/monitor/pmap.md b/src/monitor/pmap.md new file mode 100644 index 0000000..7c905ae --- /dev/null +++ b/src/monitor/pmap.md @@ -0,0 +1,7 @@ +# pmap(1) + +```markdown +pmap + Dump virtual memory map of process. + Compared to /proc//maps it shows the size of the mappings. +``` diff --git a/src/monitor/pstack.md b/src/monitor/pstack.md new file mode 100644 index 0000000..c135844 --- /dev/null +++ b/src/monitor/pstack.md @@ -0,0 +1,6 @@ +# pstack(1) + +```markdown +pstack + Dump stack for all threads of process. +``` -- cgit v1.2.3