GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  LIBPROCSTAT (3)

NAME

procstat_open_core, procstat_open_kvm, procstat_open_sysctl, procstat_close, procstat_getargv, procstat_getauxv, procstat_getenvv, procstat_getfiles, procstat_getgroups, procstat_getkstack, procstat_getosrel, procstat_getpathname, procstat_getprocs, procstat_getumask, procstat_getvmmap, procstat_freeargv, procstat_freeauxv, procstat_freeenvv, procstat_freefiles, procstat_freegroups, procstat_freekstack, procstat_freeprocs, procstat_freevmmap, procstat_get_pipe_info, procstat_get_pts_info, procstat_get_sem_info, procstat_get_shm_info, procstat_get_socket_info, procstat_get_vnode_info - library interface for file and process information retrieval

CONTENTS

Library
Synopsis
Description
See Also
History
Authors

LIBRARY


.Lb libprocstat

SYNOPSIS


.In sys/param.h
.In sys/queue.h
.In libprocstat.h void procstat_close struct procstat *procstat void
.Fo procstat_freeargv struct procstat *procstat
.Fc void
.Fo procstat_freeauxv struct procstat *procstat Elf_Auxinfo *auxv
.Fc void
.Fo procstat_freeenvv struct procstat *procstat
.Fc void
.Fo procstat_freefiles struct procstat *procstat struct filestat_list *head
.Fc void
.Fo procstat_freegroups struct procstat *procstat gid_t *groups
.Fc void
.Fo procstat_freekstack struct procstat *procstat struct kinfo_kstack *kkstp
.Fc void procstat_freeprocs struct procstat *procstat struct kinfo_proc *p void
.Fo procstat_freevmmap struct procstat *procstat struct kinfo_vmentry *vmmap
.Fc int
.Fo procstat_get_pipe_info struct procstat *procstat struct filestat *fst struct pipestat *pipe char *errbuf
.Fc int
.Fo procstat_get_pts_info struct procstat *procstat struct filestat *fst struct ptsstat *pts char *errbuf
.Fc int
.Fo procstat_get_sem_info struct procstat *procstat struct filestat *fst struct semstat *sem char *errbuf
.Fc int
.Fo procstat_get_shm_info struct procstat *procstat struct filestat *fst struct shmstat *shm char *errbuf
.Fc int
.Fo procstat_get_socket_info struct procstat *procstat struct filestat *fst struct sockstat *sock char *errbuf
.Fc int
.Fo procstat_get_vnode_info struct procstat *procstat struct filestat *fst struct vnstat *vn char *errbuf
.Fc char **
.Fo procstat_getargv struct procstat *procstat const struct kinfo_proc *kp size_t nchr char *errbuf
.Fc Elf_Auxinfo *
.Fo procstat_getauxv struct procstat *procstat struct kinfo_proc *kp unsigned int *count
.Fc char **
.Fo procstat_getenvv struct procstat *procstat const struct kinfo_proc *kp size_t nchr char *errbuf
.Fc struct filestat_list *
.Fo procstat_getfiles struct procstat *procstat struct kinfo_proc *kp int mmapped
.Fc gid_t *
.Fo procstat_getgroups struct procstat *procstat struct kinfo_proc *kp unsigned int *count
.Fc int
.Fo procstat_getosrel struct procstat *procstat struct kinfo_proc *kp int *osrelp
.Fc struct kinfo_kstack *
.Fo procstat_getkstack struct procstat *procstat struct kinfo_proc *kp unsigned int *count
.Fc struct kinfo_proc *
.Fo procstat_getprocs struct procstat *procstat int what int arg unsigned int *count
.Fc int
.Fo procstat_getpathname struct procstat *procstat struct kinfo_proc *kp char *pathname size_t maxlen
.Fc int
.Fo procstat_getrlimit struct procstat *procstat struct kinfo_proc *kp int which struct rlimit* rlimit
.Fc int
.Fo procstat_getumask struct procstat *procstat struct kinfo_proc *kp unsigned short *maskp
.Fc struct kinfo_vmentry *
.Fo procstat_getvmmap struct procstat *procstat struct kinfo_proc *kp unsigned int *count
.Fc struct procstat * procstat_open_core const char *filename struct procstat * procstat_open_kvm const char *nlistf const char *memf struct procstat * procstat_open_sysctl void

DESCRIPTION

The libprocstat library contains the API for runtime file and process information retrieval from the running kernel via the sysctl(3) library backend, and for post-mortem analysis via the kvm(3) library backend, or from the process core(5) file, searching for statistics in special elf(3) note sections.

The procstat_open_kvm and procstat_open_sysctl functions use the kvm(3) or sysctl(3) library routines, respectively, to access kernel state information used to retrieve processes and files states. The procstat_open_core uses elf(3) routines to access statistics stored as a set of notes in a process core(5) file, written by the kernel at the moment of the process abnormal termination. The filename argument is the process core file name. The nlistf argument is the executable image of the kernel being examined. If this argument is NULL, the currently running kernel is assumed. The memf argument is the kernel memory device file. If this argument is NULL, then /dev/mem is assumed. See kvm_open(3) for more details. The functions dynamically allocate and return a
.Vt procstat structure pointer used in the rest of the libprocstat library routines until the corresponding procstat_close call that cleans up the resources allocated by the procstat_open_* functions.

The procstat_getprocs function gets a pointer to the
.Vt procstat structure from one of the procstat_open_* functions and returns a dynamically allocated (sub-)set of active processes in the kernel filled in to array of
.Vt kinfo_proc structures. The what and arg arguments constitute a filtering predicate as described in the kvm_getprocs(3) function. The number of processes found is returned in the reference parameter cnt. The caller is responsible to free the allocated memory with a subsequent procstat_freeprocs function call.

The procstat_getargv function gets a pointer to the
.Vt procstat structure from one of the procstat_open_* functions, a pointer to
.Vt kinfo_proc structure from the array obtained from the kvm_getprocs function, and returns a null-terminated argument vector that corresponds to the command line arguments passed to the process. The nchr argument indicates the maximum number of characters, including null bytes, to use in building the strings. If this amount is exceeded, the string causing the overflow is truncated and the partial result is returned. This is handy for programs that print only a one line summary of a command and should not copy out large amounts of text only to ignore it. If nchr is zero, no limit is imposed and all argument strings are returned. The values of the returned argument vector refer the strings stored in the
.Vt procstat internal buffer. A subsequent call of the function with the same
.Vt procstat argument will reuse the buffer. To free the allocated memory procstat_freeargv function call can be used, or it will be released on procstat_close.

The procstat_getenvv function is similar to procstat_getargv but returns the vector of environment strings. The caller may free the allocated memory with a subsequent procstat_freeenv function call.

The procstat_getauxv function gets a pointer to the
.Vt procstat structure, a pointer to
.Vt kinfo_proc structure, and returns the auxiliary vector as a dynamically allocated array of
.Vt Elf_Auxinfo elements. The caller is responsible to free the allocated memory with a subsequent procstat_freeauxv function call.

The procstat_getfiles function gets a pointer to the
.Vt procstat structure initialized with one of the procstat_open_* functions, a pointer to
.Vt kinfo_proc structure from the array obtained from the kvm_getprocs function, and returns a dynamically allocated linked list of filled in
.Vt filestat_list structures using the STAILQ macros defined in queue(3). The caller is responsible to free the allocated memory with a subsequent procstat_freefiles function call.

The procstat_getgroups function gets a pointer to the
.Vt procstat structure, a pointer to
.Vt kinfo_proc structure, and returns the process groups as a dynamically allocated array of
.Vt gid_t elements. The caller is responsible to free the allocated memory with a subsequent procstat_freegroups function call.

The procstat_getkstack function gets a pointer to the
.Vt procstat structure initialized with one of the procstat_open_* functions, a pointer to
.Vt kinfo_proc structure, and returns kernel stacks of the process as a dynamically allocated array of
.Vt kinfo_kstack structures. The caller is responsible to free the allocated memory with a subsequent procstat_freekstack function call.

The procstat_getosrel function gets a pointer to the
.Vt procstat structure, a pointer to
.Vt kinfo_proc structure, and returns osrel date in the 3rd reference parameter.

The procstat_getpathname function gets a pointer to the
.Vt procstat structure, a pointer to
.Vt kinfo_proc structure, and copies the path of the process executable to pathname buffer, limiting to maxlen characters.

The procstat_getrlimit function gets a pointer to the
.Vt procstat structure, a pointer to
.Vt kinfo_proc structure, resource index which, and returns the actual resource limit in the 4th reference parameter.

The procstat_getumask function gets a pointer to the
.Vt procstat structure, a pointer to
.Vt kinfo_proc structure, and returns the process umask in the 3rd reference parameter.

The procstat_getvmmap function gets a pointer to the
.Vt procstat structure initialized with one of the procstat_open_* functions, a pointer to
.Vt kinfo_proc structure, and returns VM layout of the process as a dynamically allocated array of
.Vt kinfo_vmentry structures. The caller is responsible to free the allocated memory with a subsequent procstat_freevmmap function call.

The procstat_get_pipe_info, procstat_get_pts_info, procstat_get_sem_info, procstat_get_shm_info, procstat_get_socket_info and procstat_get_vnode_info functions are used to retrieve information about pipes, pseudo-terminals, semaphores, shared memory objects, sockets, and vnodes, respectively. Each of them have a similar interface API. The procstat argument is a pointer obtained from one of procstat_open_* functions. The filestat fst argument is an element of STAILQ linked list as obtained from the procstat_getfiles function. The filestat structure contains a fs_type field that specifies a file type and a corresponding function to be called among the procstat_get_*_info function family. The actual object is returned in the 3rd reference parameter. The errbuf argument indicates an actual error message in case of failure.

PS_FST_TYPE_FIFO
  procstat_get_vnode_info
PS_FST_TYPE_VNODE
  procstat_get_vnode_info
PS_FST_TYPE_SOCKET
  procstat_get_socket_info
PS_FST_TYPE_PIPE
  procstat_get_pipe_info
PS_FST_TYPE_PTS
  procstat_get_pts_info
PS_FST_TYPE_SEM
  procstat_get_sem_info
PS_FST_TYPE_SHM
  procstat_get_shm_info

SEE ALSO

fstat(1), fuser(1), pipe(2), shm_open(2), socket(2), elf(3), kvm(3), queue(3), sem_open(3), sysctl(3), pts(4), core(5), vnode(9)

HISTORY

The libprocstat library appeared in
.Fx 9.0 .

AUTHORS


.An -nosplit The libprocstat library was written by
.An Stanislav Sedov Aq stas@FreeBSD.org .

This manual page was written by
.An Sergey Kandaurov Aq pluknet@FreeBSD.org .

Search for    or go to Top of page |  Section 3 |  Main Index


Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.