1 .\" Copyright (c) 2011 Sergey Kandaurov <pluknet@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm procstat_open_core ,
32 .Nm procstat_open_kvm ,
33 .Nm procstat_open_sysctl ,
35 .Nm procstat_getfiles ,
36 .Nm procstat_getprocs ,
37 .Nm procstat_freefiles ,
38 .Nm procstat_freeprocs ,
39 .Nm procstat_get_pipe_info ,
40 .Nm procstat_get_pts_info ,
41 .Nm procstat_get_shm_info ,
42 .Nm procstat_get_socket_info ,
43 .Nm procstat_get_vnode_info
44 .Nd library interface for file and process information retrieval
52 .Fn procstat_close "struct procstat *procstat"
54 .Fo procstat_freefiles
55 .Fa "struct procstat *procstat"
56 .Fa "struct filestat_list *head"
59 .Fn procstat_freeprocs "struct procstat *procstat" "struct kinfo_proc *p"
61 .Fo procstat_get_pipe_info
62 .Fa "struct procstat *procstat"
63 .Fa "struct filestat *fst"
64 .Fa "struct pipestat *pipe"
68 .Fo procstat_get_pts_info
69 .Fa "struct procstat *procstat"
70 .Fa "struct filestat *fst"
71 .Fa "struct ptsstat *pts"
75 .Fo procstat_get_shm_info
76 .Fa "struct procstat *procstat"
77 .Fa "struct filestat *fst"
78 .Fa "struct shmstat *shm"
82 .Fo procstat_get_socket_info
83 .Fa "struct procstat *procstat"
84 .Fa "struct filestat *fst"
85 .Fa "struct sockstat *sock"
89 .Fo procstat_get_vnode_info
90 .Fa "struct procstat *procstat"
91 .Fa "struct filestat *fst"
92 .Fa "struct vnstat *vn"
95 .Ft "struct filestat_list *"
97 .Fa "struct procstat *procstat"
98 .Fa "struct kinfo_proc *kp"
101 .Ft "struct kinfo_proc *"
102 .Fo procstat_getprocs
103 .Fa "struct procstat *procstat"
106 .Fa "unsigned int *count"
108 .Ft "struct procstat *"
109 .Fn procstat_open_core "const char *filename"
110 .Ft "struct procstat *"
111 .Fn procstat_open_kvm "const char *nlistf" "const char *memf"
112 .Ft "struct procstat *"
113 .Fn procstat_open_sysctl void
117 library contains the API for runtime file and process information
118 retrieval from the running kernel via the
120 library backend, and for post-mortem analysis via the
122 library backend, or from the process
124 file, searching for statistics in special
129 .Fn procstat_open_kvm
131 .Fn procstat_open_sysctl
136 library routines, respectively, to access kernel state information
137 used to retrieve processes and files states.
139 .Fn procstat_open_core
142 routines to access statistics stored as a set of notes in a process
144 file, written by the kernel at the moment of the process abnormal termination.
147 argument is the process core file name.
150 argument is the executable image of the kernel being examined.
153 the currently running kernel is assumed.
156 argument is the kernel memory device file.
165 The functions dynamically allocate and return a
167 structure pointer used in the rest of the
169 library routines until the corresponding
171 call that cleans up the resources allocated by the
176 .Fn procstat_getprocs
177 function gets a pointer to the
179 structure from one of the
181 functions and returns a dynamically allocated (sub-)set of active processes
182 in the kernel filled in to array of
189 arguments constitute a filtering predicate as described in the
192 The number of processes found is returned in the reference parameter
194 The caller is responsible to free the allocated memory with a subsequent
195 .Fn procstat_freeprocs
199 .Fn procstat_getfiles
200 function gets a pointer to the
202 structure initialized with one of the
204 functions, a pointer to
206 structure from the array obtained from the
208 function, and returns a dynamically allocated linked list of filled in
210 structures using the STAILQ macros defined in
212 The caller is responsible to free the allocated memory with a subsequent
213 .Fn procstat_freefiles
217 .Fn procstat_get_pipe_info ,
218 .Fn procstat_get_pts_info ,
219 .Fn procstat_get_shm_info ,
220 .Fn procstat_get_socket_info
222 .Fn procstat_get_vnode_info
223 functions are used to retrieve information about pipes, pseudo-terminals,
224 shared memory objects,
225 sockets, and vnodes, respectively.
226 Each of them have a similar interface API.
229 argument is a pointer obtained from one of
234 argument is an element of STAILQ linked list as obtained from the
235 .Fn procstat_getfiles
241 field that specifies a file type and a corresponding function to be
243 .Nm procstat_get_*_info
245 The actual object is returned in the 3rd reference parameter.
248 argument indicates an actual error message in case of failure.
250 .Bl -tag -width 20n -compact -offset indent
251 .It Li PS_FST_TYPE_FIFO
252 .Nm procstat_get_vnode_info
253 .It Li PS_FST_TYPE_VNODE
254 .Nm procstat_get_vnode_info
255 .It Li PS_FST_TYPE_SOCKET
256 .Nm procstat_get_socket_info
257 .It Li PS_FST_TYPE_PIPE
258 .Nm procstat_get_pipe_info
259 .It Li PS_FST_TYPE_PTS
260 .Nm procstat_get_pts_info
261 .It Li PS_FST_TYPE_SHM
262 .Nm procstat_get_shm_info
286 library was written by
287 .An Stanislav Sedov Aq stas@FreeBSD.org .
289 This manual page was written by
290 .An Sergey Kandaurov Aq pluknet@FreeBSD.org .