]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/procstat/procstat.1
zfs: merge openzfs/zfs@57cfae4a2 (master)
[FreeBSD/FreeBSD.git] / usr.bin / procstat / procstat.1
1 .\"-
2 .\" Copyright (c) 2007-2009 Robert N. M. Watson
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd April 7, 2022
29 .Dt PROCSTAT 1
30 .Os
31 .Sh NAME
32 .Nm procstat
33 .Nd get detailed process information
34 .Sh SYNOPSIS
35 .Nm
36 .Op Fl -libxo
37 .Op Fl h
38 .Op Fl M Ar core
39 .Op Fl N Ar system
40 .Op Fl w Ar interval
41 .Ar command
42 .Op Ar pid ... | Ar core ...
43 .Nm
44 .Op Fl -libxo
45 .Fl a
46 .Op Fl h
47 .Op Fl M Ar core
48 .Op Fl N Ar system
49 .Op Fl w Ar interval
50 .Ar command
51 .Nm
52 .Op Fl -libxo
53 .Op Fl h
54 .Op Fl M Ar core
55 .Op Fl N Ar system
56 .Op Fl w Ar interval
57 .Oo
58 .Fl b |
59 .Fl c |
60 .Fl e |
61 .Fl f Oo Fl C Oc |
62 .Fl i Oo Fl n Oc |
63 .Fl j Oo Fl n Oc |
64 .Fl k Oo Fl k Oc |
65 .Fl l |
66 .Fl r Oo Fl H Oc |
67 .Fl s |
68 .Fl S |
69 .Fl t |
70 .Fl v |
71 .Fl x
72 .Oc
73 .Op Ar pid ... | Ar core ...
74 .Nm
75 .Op Fl -libxo
76 .Fl a
77 .Op Fl h
78 .Op Fl M Ar core
79 .Op Fl N Ar system
80 .Op Fl w Ar interval
81 .Oo
82 .Fl b |
83 .Fl c |
84 .Fl e |
85 .Fl f Oo Fl C Oc |
86 .Fl i Oo Fl n Oc |
87 .Fl j Oo Fl n Oc |
88 .Fl k Oo Fl k Oc |
89 .Fl l |
90 .Fl r Oo Fl H Oc |
91 .Fl s |
92 .Fl S |
93 .Fl t |
94 .Fl v |
95 .Fl x
96 .Oc
97 .Nm
98 .Op Fl -libxo
99 .Fl L
100 .Op Fl h
101 .Op Fl M Ar core
102 .Op Fl N Ar system
103 .Op Fl w Ar interval
104 .Ar core ...
105 .Nm pargs
106 .Op Fl -libxo
107 .Ar pid ...
108 .Nm penv
109 .Op Fl -libxo
110 .Ar pid ...
111 .Nm pwdx
112 .Op Fl -libxo
113 .Ar pid ...
114 .Sh DESCRIPTION
115 .Nm
116 utility displays detailed information about the processes identified by the
117 .Ar pid
118 arguments, or if the
119 .Fl a
120 flag is used, all processes.
121 It can also display information extracted from a process core file, if
122 the core file is specified as the argument.
123 .Pp
124 The
125 .Nm pargs ,
126 .Nm penv
127 and
128 .Nm pwdx
129 utilities display the arguments, environment, and current working directory,
130 respectively of the process specified by
131 .Ar pid
132 argument.
133 They mimic the behavior of Solaris utilities of the same names.
134 .Pp
135 If the
136 .Fl -libxo
137 flag is specified the output is generated via
138 .Xr libxo 3
139 in a selection of different human and machine readable formats.
140 See
141 .Xr xo_parse_args 3
142 for details on command line arguments.
143 .Pp
144 The following commands are available for
145 .Nm :
146 .Bl -tag -width indent
147 .It Ar advlock
148 Print information about advisory locks on files.
149 All three types of locks are listed, BSD-style
150 .Xr lockf 2 ,
151 POSIX-style
152 .Xr fcntl 2
153 .Va F_SETLK ,
154 and remote
155 .Xr lockd 8
156 locks used by NFSv3.
157 .Pp
158 Note that neither the
159 .Fl a
160 option nor
161 .Va pid
162 list can be used to limit the display of the locks, mostly because
163 some types of locks do not have local (or any) owning processes.
164 .It Ar basic
165 Print basic process statistics (this is the default).
166 .It Ar binary | Fl b
167 Display binary information for the process.
168 .Pp
169 Substring commands are accepted.
170 .It Ar argument(s) | Fl c
171 Display command line arguments for the process.
172 .Pp
173 Substring commands are accepted.
174 .It Ar environment | Fl e
175 Display environment variables for the process.
176 .Pp
177 Substring commands are accepted.
178 .It Ar file(s) | Ar fd(s) | Fl f
179 Display file descriptor information for the process.
180 .Pp
181 If the
182 .Fl C
183 subcommand flag is used then additional capability information is printed.
184 .It Ar signal(s) | Fl i
185 Display signal pending and disposition information for the process.
186 .Pp
187 If the
188 .Fl n
189 subcommand option is used, the signal numbers are shown instead of signal
190 names.
191 .Pp
192 Substring commands are accepted.
193 .It Ar tsignal(s) | Fl j
194 Display signal pending and blocked information for the process's threads.
195 .Pp
196 If the
197 .Fl n
198 subcommand option is used, the signal numbers are shown instead of signal
199 names.
200 .Pp
201 Substring commands are accepted.
202 .It Ar kstack | Fl k
203 Display the stacks of kernel threads in the process, excluding stacks of
204 threads currently running on a CPU and threads with stacks swapped to disk.
205 .Pp
206 If the
207 .Fl v
208 subcommand option is used (or the command flag is repeated), function
209 offsets as well as function names are printed.
210 .It Ar rlimit | Fl l
211 Display resource limits for the process.
212 .It Ar ptlwpinfo | Fl L
213 Display LWP info for the process pertaining to its signal driven exit.
214 .It Ar rusage | Fl r
215 Display resource usage information for the process.
216 .Pp
217 If the
218 .Fl v
219 .Pq or Fl H
220 subcommand flag
221 is used then per-thread statistics are printed, rather than per-process
222 statistics.
223 The second field in the table will list the thread ID to which the row of
224 information corresponds.
225 .It Ar credential(s) | Fl s
226 Display security credential information for the process.
227 .Pp
228 Substring commands are accepted.
229 .It Ar cpuset | Ar cs | Fl S
230 Display the cpuset information for the thread.
231 .It Ar thread(s) | Fl t
232 Display thread information for the process.
233 .It Ar vm | Fl v
234 Display virtual memory mappings for the process.
235 .It Ar auxv | Fl x
236 Display ELF auxiliary vector for the process.
237 .It Ar pargs
238 Display arguments for the process.
239 .It Ar penv
240 Display environment variables for the process.
241 .It Ar pwdx
242 Display current working directory for the process.
243 .El
244 .Pp
245 All options generate output in the format of a table, the first field of
246 which is the process ID to which the row of information corresponds.
247 The
248 .Fl h
249 flag may be used to suppress table headers.
250 .Pp
251 The
252 .Fl w
253 flag may be used to specify a wait interval at which to repeat the printing
254 of the requested process information.
255 If the
256 .Fl w
257 flag is not specified, the output will not repeat.
258 .Pp
259 Information for VM, file descriptor, and cpuset options is available
260 only to the owner of a process or the superuser.
261 A cpuset value displayed as -1 means that the information is either invalid
262 or not available.
263 .Ss Binary Information
264 Display the process ID, command, and path to the process binary:
265 .Pp
266 .Bl -tag -width indent -compact
267 .It PID
268 process ID
269 .It COMM
270 command
271 .It OSREL
272 osreldate for process binary
273 .It PATH
274 path to process binary (if available)
275 .El
276 .Ss Command Line Arguments
277 Display the process ID, command, and command line arguments:
278 .Pp
279 .Bl -tag -width indent -compact
280 .It PID
281 process ID
282 .It COMM
283 command
284 .It ARGS
285 command line arguments (if available)
286 .El
287 .Ss Environment Variables
288 Display the process ID, command, and environment variables:
289 .Pp
290 .Bl -tag -width "ENVIRONMENT" -compact
291 .It PID
292 process ID
293 .It COMM
294 command
295 .It ENVIRONMENT
296 environment variables (if available)
297 .El
298 .Ss File Descriptors
299 Display detailed information about each file descriptor referenced by a
300 process, including the process ID, command, file descriptor number, and
301 per-file descriptor object information, such as object type and file system
302 path.
303 By default, the following information will be printed:
304 .Pp
305 .Bl -tag -width indent -compact
306 .It PID
307 process ID
308 .It COMM
309 command
310 .It FD
311 file descriptor number or cwd/root/jail
312 .It T
313 file descriptor type
314 .It V
315 vnode type
316 .It FLAGS
317 file descriptor flags
318 .It REF
319 file descriptor reference count
320 .It OFFSET
321 file descriptor offset
322 .It PRO
323 network protocol
324 .It NAME
325 file path or socket addresses (if available)
326 .El
327 .Pp
328 The following file descriptor types may be displayed:
329 .Pp
330 .Bl -tag -width X -compact
331 .It e
332 POSIX semaphore
333 .It E
334 eventfd
335 .It f
336 fifo
337 .It h
338 shared memory
339 .It k
340 kqueue
341 .It m
342 message queue
343 .It P
344 process descriptor
345 .It p
346 pipe
347 .It s
348 socket
349 .It t
350 pseudo-terminal master
351 .It v
352 vnode
353 .El
354 .Pp
355 The following vnode types may be displayed:
356 .Pp
357 .Bl -tag -width X -compact
358 .It -
359 not a vnode
360 .It b
361 block device
362 .It c
363 character device
364 .It d
365 directory
366 .It f
367 fifo
368 .It l
369 symbolic link
370 .It r
371 regular file
372 .It s
373 socket
374 .It x
375 revoked device
376 .El
377 .Pp
378 The following file descriptor flags may be displayed:
379 .Pp
380 .Bl -tag -width X -compact
381 .It r
382 read
383 .It w
384 write
385 .It a
386 append
387 .It s
388 async
389 .It f
390 fsync
391 .It n
392 non-blocking
393 .It d
394 direct I/O
395 .It l
396 lock held
397 .El
398 .Pp
399 If the
400 .Fl C
401 flag is specified, the vnode type, reference count, and offset fields will be
402 omitted, and a new capabilities field will be included listing capabilities,
403 as described in
404 .Xr cap_rights_limit 2 ,
405 present for each capability descriptor.
406 .Pp
407 The following network protocols may be displayed (grouped by address family):
408 .Pp
409 .Dv AF_INET ,
410 .Dv AF_INET6
411 .Pp
412 .Bl -tag -width indent -compact
413 .It ICM
414 .Dv IPPROTO_ICMP ;
415 see
416 .Xr icmp 4 .
417 .It IP?
418 unknown protocol.
419 .It RAW
420 .Dv IPPROTO_RAW ;
421 see
422 .Xr ip 4 .
423 .It SCT
424 .Dv IPPROTO_SCTP ;
425 see
426 .Xr sctp 4 .
427 .It TCP
428 .Dv IPPROTO_TCP ;
429 see
430 .Xr tcp 4 .
431 .It UDP
432 .Dv IPPROTO_UDP ;
433 see
434 .Xr udp 4 .
435 .El
436 .Pp
437 .Dv AF_LOCAL
438 .Pp
439 .Bl -tag -width indent -compact
440 .It UDD
441 .Dv IPPROTO_UDP ;
442 see
443 .Xr udp 4 .
444 .It UDS
445 .Dv IPPROTO_TCP ;
446 see
447 .Xr tcp 4 .
448 .It UD?
449 unknown protocol.
450 .El
451 .Pp
452 .Dv AF_DIVERT
453 .Pp
454 .Bl -tag -width indent -compact
455 .It IPD
456 .Dv Divert socket; see
457 .Xr divert 4 .
458 .El
459 .Pp
460 .Bl -tag -width indent -compact
461 .It ?
462 unknown address family.
463 .El
464 .Ss Signal Disposition Information
465 Display signal pending and disposition for a process:
466 .Pp
467 .Bl -tag -width indent -compact
468 .It PID
469 process ID
470 .It COMM
471 command
472 .It SIG
473 signal name
474 .It FLAGS
475 process signal disposition details, three symbols
476 .Bl -tag -width X -compact
477 .It P
478 if signal is pending in the global process queue; - otherwise.
479 .It I
480 if signal delivery disposition is
481 .Dv SIG_IGN ;
482 - otherwise.
483 .It C
484 if the signal will be caught; - otherwise.
485 .El
486 .El
487 .Pp
488 If
489 .Fl n
490 switch is given, the signal numbers are shown instead of signal names.
491 .Ss Thread Signal Information
492 Display signal pending and blocked for a process's threads:
493 .Pp
494 .Bl -tag -width indent -compact
495 .It PID
496 process ID
497 .It TID
498 thread ID
499 .It COMM
500 command
501 .It SIG
502 signal name
503 .It FLAGS
504 thread signal delivery status, two symbols
505 .Bl -tag -width X -compact
506 .It P
507 if signal is pending for the thread, - otherwise
508 .It B
509 if signal is blocked in the thread signal mask, - if not blocked
510 .El
511 .El
512 .Pp
513 The
514 .Fl n
515 switch has the same effect as for the
516 .Fl i
517 switch: the signal numbers are shown instead of signal names.
518 .Ss Kernel Thread Stacks
519 Display kernel thread stacks for a process, allowing further interpretation
520 of thread wait channels.
521 If the
522 .Fl k
523 flag is repeated, function offsets, not just function names, are printed.
524 .Pp
525 This feature requires
526 .Cd "options STACK"
527 or
528 .Cd "options DDB"
529 to be compiled into the kernel.
530 .Pp
531 .Bl -tag -width indent -compact
532 .It PID
533 process ID
534 .It TID
535 thread ID
536 .It COMM
537 command
538 .It TDNAME
539 thread name
540 .It KSTACK
541 kernel thread call stack
542 .El
543 .Ss Resource Limits
544 Display resource limits for a process:
545 .Pp
546 .Bl -tag -width indent -compact
547 .It PID
548 process ID
549 .It COMM
550 command
551 .It RLIMIT
552 resource limit name
553 .It SOFT
554 soft limit
555 .It HARD
556 hard limit
557 .El
558 .Ss Resource Usage
559 Display resource usage for a process.
560 If the
561 .Fl H
562 flag is specified,
563 resource usage for individual threads is displayed instead.
564 .Pp
565 .Bl -tag -width "RESOURCE" -compact
566 .It PID
567 process ID
568 .It TID
569 thread ID
570 .Po
571 if
572 .Fl H
573 is specified
574 .Pc
575 .It COMM
576 command
577 .It RESOURCE
578 resource name
579 .It VALUE
580 current usage
581 .El
582 .Ss Security Credentials
583 Display process credential information:
584 .Pp
585 .Bl -tag -width indent -compact
586 .It PID
587 process ID
588 .It COMM
589 command
590 .It EUID
591 effective user ID
592 .It RUID
593 real user ID
594 .It SVUID
595 saved user ID
596 .It EGID
597 effective group ID
598 .It RGID
599 real group ID
600 .It SVGID
601 saved group ID
602 .It UMASK
603 file creation mode mask
604 .It FLAGS
605 credential flags
606 .It GROUPS
607 group set
608 .El
609 .Pp
610 The following credential flags may be displayed:
611 .Pp
612 .Bl -tag -width X -compact
613 .It C
614 capability mode
615 .El
616 .Ss Thread Information
617 Display per-thread information, including process ID, per-thread ID, name,
618 CPU, and execution state:
619 .Pp
620 .Bl -tag -width indent -compact
621 .It PID
622 process ID
623 .It TID
624 thread ID
625 .It COMM
626 command
627 .It TDNAME
628 thread name
629 .It CPU
630 current or most recent CPU run on
631 .It PRI
632 thread priority
633 .It STATE
634 thread state
635 .It WCHAN
636 thread wait channel
637 .El
638 .Ss Virtual Memory Mappings
639 Display process virtual memory mappings, including addresses, mapping
640 meta-data, and mapped object information:
641 .Pp
642 .Bl -tag -width indent -compact
643 .It PID
644 process ID
645 .It START
646 starting address of mapping
647 .It END
648 ending address of mapping
649 .It PRT
650 protection flags
651 .It RES
652 resident pages
653 .It PRES
654 private resident pages
655 .It REF
656 reference count
657 .It SHD
658 shadow page count
659 .It FLAG
660 mapping flags
661 .It TP
662 VM object type
663 .El
664 .Pp
665 The following protection flags may be displayed:
666 .Pp
667 .Bl -tag -width X -compact
668 .It r
669 read
670 .It w
671 write
672 .It x
673 execute
674 .El
675 .Pp
676 The following VM object types may be displayed:
677 .Pp
678 .Bl -tag -width XX -compact
679 .It --
680 none
681 .It dd
682 dead
683 .It df
684 default
685 .It dv
686 device
687 .It md
688 device with managed pages
689 .Pq GEM/TTM
690 .It ph
691 physical
692 .It sg
693 scatter/gather
694 .It sw
695 swap
696 .It vn
697 vnode
698 .It gd
699 guard (pseudo-type)
700 .El
701 .Pp
702 The following mapping flags may be displayed:
703 .Pp
704 .Bl -tag -width X -compact
705 .It C
706 copy-on-write
707 .It N
708 needs copy
709 .It S
710 one or more superpage mappings are used
711 .It D
712 grows down (top-down stack)
713 .It U
714 grows up (bottom-up stack)
715 .It W
716 pages in this range are locked by
717 .Xr mlock 2
718 or
719 .Xr mlockall 2
720 .El
721 .Ss ELF Auxiliary Vector
722 Display ELF auxiliary vector values:
723 .Pp
724 .Bl -tag -width indent -compact
725 .It PID
726 process ID
727 .It COMM
728 command
729 .It AUXV
730 auxiliary vector name
731 .It VALUE
732 auxiliary vector value
733 .El
734 .Ss Advisory Lock Information
735 .Bl -tag -width indent -compact
736 .It RW
737 Read/Write type,
738 .Va RO
739 for read,
740 .Va RW
741 for write lock
742 .It TYPE
743 Type of the lock, one of
744 .Va FLOCK
745 for
746 .Xr flock 2 ,
747 .Va FCNTL
748 for
749 .Xr fcntl 2 ,
750 .Va LOCKD
751 for remote
752 .It PID
753 Process id of the owner, for
754 .Va FCNTL
755 and remote types
756 .It SYSID
757 Remote system id if applicable
758 .It FSID
759 File system id where the locked file resize
760 .It RDEV
761 rdev for the file system
762 .It INO
763 Unique file identifier (inode number) of the locked file
764 on the file system
765 .It START
766 Start offset of the locked range
767 .It LEN
768 Length of the locked range.
769 Zero means till EOF
770 .It PATH
771 If available, the path of the locked file
772 .El
773 .Sh EXIT STATUS
774 .Ex -std
775 .Sh EXAMPLES
776 Show binary information about the current shell:
777 .Bd -literal -offset indent
778 $ procstat binary $$
779   PID COMM                OSREL PATH
780 46620 bash              1201000 /usr/local/bin/bash
781 .Ed
782 .Pp
783 Same as above but showing information about open file descriptors:
784 .Bd -literal -offset indent
785 $ procstat files $$
786   PID COMM                FD T V FLAGS    REF  OFFSET PRO NAME
787 46620 bash              text v r r-------   -       - -   /usr/local/bin/bash
788 46620 bash              ctty v c rw------   -       - -   /dev/pts/12
789 46620 bash               cwd v d r-------   -       - -   /tmp
790 46620 bash              root v d r-------   -       - -   /
791 46620 bash                 0 v c rw------   7  372071 -   /dev/pts/12
792 46620 bash                 1 v c rw------   7  372071 -   /dev/pts/12
793 46620 bash                 2 v c rw------   7  372071 -   /dev/pts/12
794 46620 bash               255 v c rw------   7  372071 -   /dev/pts/12
795 .Ed
796 .Pp
797 Show the arguments used to launch
798 .Xr init 8 :
799 .Bd -literal -offset indent
800 $ procstat arguments 1
801   PID COMM             ARGS
802     1 init             /sbin/init --
803 .Ed
804 .Pp
805 Extract binary information from a core dump:
806 .Bd -literal -offset indent
807 $ procstat binary core.36642
808   PID COMM                OSREL PATH
809 36642 top               1201000 /usr/bin/top
810 .Ed
811 .Pp
812 Trying to extract information from a core file generated in a different major
813 .Fx
814 version might show an error like this:
815 .Bd -literal -offset indent
816 $ procstat mplayer.core
817 procstat: kinfo_proc structure size mismatch
818 procstat: procstat_getprocs()
819 .Ed
820 .Sh SEE ALSO
821 .Xr fstat 1 ,
822 .Xr ps 1 ,
823 .Xr sockstat 1 ,
824 .Xr cap_enter 2 ,
825 .Xr cap_rights_limit 2 ,
826 .Xr mlock 2 ,
827 .Xr mlockall 2 ,
828 .Xr libprocstat 3 ,
829 .Xr libxo 3 ,
830 .Xr signal 3 ,
831 .Xr xo_parse_args 3 ,
832 .Xr ddb 4 ,
833 .Xr divert 4 ,
834 .Xr icmp 4 ,
835 .Xr ip 4 ,
836 .Xr sctp 4 ,
837 .Xr tcp 4 ,
838 .Xr udp 4 ,
839 .Xr stack 9
840 .Sh AUTHORS
841 .An Robert N M Watson Aq Mt rwatson@FreeBSD.org .
842 .br
843 .Xr libxo 3
844 support was added by
845 .An -nosplit
846 Allan Jude
847 .Aq Mt allanjude@FreeBSD.org .
848 .br
849 .An Juraj Lutter
850 .Aq Mt juraj@lutter.sk
851 added the pargs, penv and pwdx functionality.
852 .Sh BUGS
853 The display of open file or memory mapping pathnames is implemented using the
854 kernel's name cache.
855 If a file system does not use the name cache, or the path to a file is not in
856 the cache, a path will not be displayed.
857 .Pp
858 .Nm
859 currently supports extracting data only from a live kernel, and not from
860 kernel crash dumps.