]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/procstat/procstat.1
contrib/bc: merge from vendor release 5.3.3
[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 IPD
418 .Dv IPPROTO_DIVERT ;
419 see
420 .Xr divert 4 .
421 .It IP?
422 unknown protocol.
423 .It RAW
424 .Dv IPPROTO_RAW ;
425 see
426 .Xr ip 4 .
427 .It SCT
428 .Dv IPPROTO_SCTP ;
429 see
430 .Xr sctp 4 .
431 .It TCP
432 .Dv IPPROTO_TCP ;
433 see
434 .Xr tcp 4 .
435 .It UDP
436 .Dv IPPROTO_UDP ;
437 see
438 .Xr udp 4 .
439 .El
440 .Pp
441 .Dv AF_LOCAL
442 .Pp
443 .Bl -tag -width indent -compact
444 .It UDD
445 .Dv IPPROTO_UDP ;
446 see
447 .Xr udp 4 .
448 .It UDS
449 .Dv IPPROTO_TCP ;
450 see
451 .Xr tcp 4 .
452 .It UD?
453 unknown protocol.
454 .El
455 .Pp
456 .Bl -tag -width indent -compact
457 .It ?
458 unknown address family.
459 .El
460 .Ss Signal Disposition Information
461 Display signal pending and disposition for a process:
462 .Pp
463 .Bl -tag -width indent -compact
464 .It PID
465 process ID
466 .It COMM
467 command
468 .It SIG
469 signal name
470 .It FLAGS
471 process signal disposition details, three symbols
472 .Bl -tag -width X -compact
473 .It P
474 if signal is pending in the global process queue; - otherwise.
475 .It I
476 if signal delivery disposition is
477 .Dv SIG_IGN ;
478 - otherwise.
479 .It C
480 if the signal will be caught; - otherwise.
481 .El
482 .El
483 .Pp
484 If
485 .Fl n
486 switch is given, the signal numbers are shown instead of signal names.
487 .Ss Thread Signal Information
488 Display signal pending and blocked for a process's threads:
489 .Pp
490 .Bl -tag -width indent -compact
491 .It PID
492 process ID
493 .It TID
494 thread ID
495 .It COMM
496 command
497 .It SIG
498 signal name
499 .It FLAGS
500 thread signal delivery status, two symbols
501 .Bl -tag -width X -compact
502 .It P
503 if signal is pending for the thread, - otherwise
504 .It B
505 if signal is blocked in the thread signal mask, - if not blocked
506 .El
507 .El
508 .Pp
509 The
510 .Fl n
511 switch has the same effect as for the
512 .Fl i
513 switch: the signal numbers are shown instead of signal names.
514 .Ss Kernel Thread Stacks
515 Display kernel thread stacks for a process, allowing further interpretation
516 of thread wait channels.
517 If the
518 .Fl k
519 flag is repeated, function offsets, not just function names, are printed.
520 .Pp
521 This feature requires
522 .Cd "options STACK"
523 or
524 .Cd "options DDB"
525 to be compiled into the kernel.
526 .Pp
527 .Bl -tag -width indent -compact
528 .It PID
529 process ID
530 .It TID
531 thread ID
532 .It COMM
533 command
534 .It TDNAME
535 thread name
536 .It KSTACK
537 kernel thread call stack
538 .El
539 .Ss Resource Limits
540 Display resource limits for a process:
541 .Pp
542 .Bl -tag -width indent -compact
543 .It PID
544 process ID
545 .It COMM
546 command
547 .It RLIMIT
548 resource limit name
549 .It SOFT
550 soft limit
551 .It HARD
552 hard limit
553 .El
554 .Ss Resource Usage
555 Display resource usage for a process.
556 If the
557 .Fl H
558 flag is specified,
559 resource usage for individual threads is displayed instead.
560 .Pp
561 .Bl -tag -width "RESOURCE" -compact
562 .It PID
563 process ID
564 .It TID
565 thread ID
566 .Po
567 if
568 .Fl H
569 is specified
570 .Pc
571 .It COMM
572 command
573 .It RESOURCE
574 resource name
575 .It VALUE
576 current usage
577 .El
578 .Ss Security Credentials
579 Display process credential information:
580 .Pp
581 .Bl -tag -width indent -compact
582 .It PID
583 process ID
584 .It COMM
585 command
586 .It EUID
587 effective user ID
588 .It RUID
589 real user ID
590 .It SVUID
591 saved user ID
592 .It EGID
593 effective group ID
594 .It RGID
595 real group ID
596 .It SVGID
597 saved group ID
598 .It UMASK
599 file creation mode mask
600 .It FLAGS
601 credential flags
602 .It GROUPS
603 group set
604 .El
605 .Pp
606 The following credential flags may be displayed:
607 .Pp
608 .Bl -tag -width X -compact
609 .It C
610 capability mode
611 .El
612 .Ss Thread Information
613 Display per-thread information, including process ID, per-thread ID, name,
614 CPU, and execution state:
615 .Pp
616 .Bl -tag -width indent -compact
617 .It PID
618 process ID
619 .It TID
620 thread ID
621 .It COMM
622 command
623 .It TDNAME
624 thread name
625 .It CPU
626 current or most recent CPU run on
627 .It PRI
628 thread priority
629 .It STATE
630 thread state
631 .It WCHAN
632 thread wait channel
633 .El
634 .Ss Virtual Memory Mappings
635 Display process virtual memory mappings, including addresses, mapping
636 meta-data, and mapped object information:
637 .Pp
638 .Bl -tag -width indent -compact
639 .It PID
640 process ID
641 .It START
642 starting address of mapping
643 .It END
644 ending address of mapping
645 .It PRT
646 protection flags
647 .It RES
648 resident pages
649 .It PRES
650 private resident pages
651 .It REF
652 reference count
653 .It SHD
654 shadow page count
655 .It FLAG
656 mapping flags
657 .It TP
658 VM object type
659 .El
660 .Pp
661 The following protection flags may be displayed:
662 .Pp
663 .Bl -tag -width X -compact
664 .It r
665 read
666 .It w
667 write
668 .It x
669 execute
670 .El
671 .Pp
672 The following VM object types may be displayed:
673 .Pp
674 .Bl -tag -width XX -compact
675 .It --
676 none
677 .It dd
678 dead
679 .It df
680 default
681 .It dv
682 device
683 .It md
684 device with managed pages
685 .Pq GEM/TTM
686 .It ph
687 physical
688 .It sg
689 scatter/gather
690 .It sw
691 swap
692 .It vn
693 vnode
694 .It gd
695 guard (pseudo-type)
696 .El
697 .Pp
698 The following mapping flags may be displayed:
699 .Pp
700 .Bl -tag -width X -compact
701 .It C
702 copy-on-write
703 .It N
704 needs copy
705 .It S
706 one or more superpage mappings are used
707 .It D
708 grows down (top-down stack)
709 .It U
710 grows up (bottom-up stack)
711 .It W
712 pages in this range are locked by
713 .Xr mlock 2
714 or
715 .Xr mlockall 2
716 .El
717 .Ss ELF Auxiliary Vector
718 Display ELF auxiliary vector values:
719 .Pp
720 .Bl -tag -width indent -compact
721 .It PID
722 process ID
723 .It COMM
724 command
725 .It AUXV
726 auxiliary vector name
727 .It VALUE
728 auxiliary vector value
729 .El
730 .Ss Advisory Lock Information
731 .Bl -tag -width indent -compact
732 .It RW
733 Read/Write type,
734 .Va RO
735 for read,
736 .Va RW
737 for write lock
738 .It TYPE
739 Type of the lock, one of
740 .Va FLOCK
741 for
742 .Xr flock 2 ,
743 .Va FCNTL
744 for
745 .Xr fcntl 2 ,
746 .Va LOCKD
747 for remote
748 .It PID
749 Process id of the owner, for
750 .Va FCNTL
751 and remote types
752 .It SYSID
753 Remote system id if applicable
754 .It FSID
755 File system id where the locked file resize
756 .It RDEV
757 rdev for the file system
758 .It INO
759 Unique file identifier (inode number) of the locked file
760 on the file system
761 .It START
762 Start offset of the locked range
763 .It LEN
764 Length of the locked range.
765 Zero means till EOF
766 .It PATH
767 If available, the path of the locked file
768 .El
769 .Sh EXIT STATUS
770 .Ex -std
771 .Sh EXAMPLES
772 Show binary information about the current shell:
773 .Bd -literal -offset indent
774 $ procstat binary $$
775   PID COMM                OSREL PATH
776 46620 bash              1201000 /usr/local/bin/bash
777 .Ed
778 .Pp
779 Same as above but showing information about open file descriptors:
780 .Bd -literal -offset indent
781 $ procstat files $$
782   PID COMM                FD T V FLAGS    REF  OFFSET PRO NAME
783 46620 bash              text v r r-------   -       - -   /usr/local/bin/bash
784 46620 bash              ctty v c rw------   -       - -   /dev/pts/12
785 46620 bash               cwd v d r-------   -       - -   /tmp
786 46620 bash              root v d r-------   -       - -   /
787 46620 bash                 0 v c rw------   7  372071 -   /dev/pts/12
788 46620 bash                 1 v c rw------   7  372071 -   /dev/pts/12
789 46620 bash                 2 v c rw------   7  372071 -   /dev/pts/12
790 46620 bash               255 v c rw------   7  372071 -   /dev/pts/12
791 .Ed
792 .Pp
793 Show the arguments used to launch
794 .Xr init 8 :
795 .Bd -literal -offset indent
796 $ procstat arguments 1
797   PID COMM             ARGS
798     1 init             /sbin/init --
799 .Ed
800 .Pp
801 Extract binary information from a core dump:
802 .Bd -literal -offset indent
803 $ procstat binary core.36642
804   PID COMM                OSREL PATH
805 36642 top               1201000 /usr/bin/top
806 .Ed
807 .Pp
808 Trying to extract information from a core file generated in a different major
809 .Fx
810 version might show an error like this:
811 .Bd -literal -offset indent
812 $ procstat mplayer.core
813 procstat: kinfo_proc structure size mismatch
814 procstat: procstat_getprocs()
815 .Ed
816 .Sh SEE ALSO
817 .Xr fstat 1 ,
818 .Xr ps 1 ,
819 .Xr sockstat 1 ,
820 .Xr cap_enter 2 ,
821 .Xr cap_rights_limit 2 ,
822 .Xr mlock 2 ,
823 .Xr mlockall 2 ,
824 .Xr libprocstat 3 ,
825 .Xr libxo 3 ,
826 .Xr signal 3 ,
827 .Xr xo_parse_args 3 ,
828 .Xr ddb 4 ,
829 .Xr divert 4 ,
830 .Xr icmp 4 ,
831 .Xr ip 4 ,
832 .Xr sctp 4 ,
833 .Xr tcp 4 ,
834 .Xr udp 4 ,
835 .Xr stack 9
836 .Sh AUTHORS
837 .An Robert N M Watson Aq Mt rwatson@FreeBSD.org .
838 .br
839 .Xr libxo 3
840 support was added by
841 .An -nosplit
842 Allan Jude
843 .Aq Mt allanjude@FreeBSD.org .
844 .br
845 .An Juraj Lutter
846 .Aq Mt juraj@lutter.sk
847 added the pargs, penv and pwdx functionality.
848 .Sh BUGS
849 The display of open file or memory mapping pathnames is implemented using the
850 kernel's name cache.
851 If a file system does not use the name cache, or the path to a file is not in
852 the cache, a path will not be displayed.
853 .Pp
854 .Nm
855 currently supports extracting data only from a live kernel, and not from
856 kernel crash dumps.