Documentation ¶
Overview ¶
Package psgo is a ps (1) AIX-format compatible golang library extended with various descriptors useful for displaying container-related data.
The idea behind the library is to provide an easy to use way of extracting process-related data, just as ps (1) does. The problem when using ps (1) is that the ps format strings split columns with whitespaces, making the output nearly impossible to parse. It also adds some jitter as we have to fork and execute ps either in the container or filter the output afterwards, further limiting applicability.
Please visit https://github.com/containers/psgo for further details about supported format descriptors and to see some usage examples.
Index ¶
- Variables
- func JoinNamespaceAndProcessInfo(pid string, descriptors []string) ([][]string, error)
- func JoinNamespaceAndProcessInfoByPids(pids []string, descriptors []string) ([][]string, error)
- func JoinNamespaceAndProcessInfoByPidsWithOptions(pids []string, descriptors []string, options *JoinNamespaceOpts) ([][]string, error)
- func JoinNamespaceAndProcessInfoWithOptions(pid string, descriptors []string, options *JoinNamespaceOpts) ([][]string, error)
- func ListDescriptors() (list []string)
- func ProcessInfo(descriptors []string) ([][]string, error)
- func ProcessInfoByPids(pids []string, descriptors []string) ([][]string, error)
- type JoinNamespaceOpts
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultDescriptors is the `ps -ef` compatible default format. DefaultDescriptors = []string{"user", "pid", "ppid", "pcpu", "etime", "tty", "time", "args"} // ErrUnknownDescriptor is returned when an unknown descriptor is parsed. ErrUnknownDescriptor = errors.New("unknown descriptor") )
Functions ¶
func JoinNamespaceAndProcessInfo ¶
JoinNamespaceAndProcessInfo has the same semantics as ProcessInfo but joins the mount namespace of the specified pid before extracting data from `/proc`.
func JoinNamespaceAndProcessInfoByPids ¶
JoinNamespaceAndProcessInfoByPids has similar semantics to JoinNamespaceAndProcessInfo and avoids duplicate entries by joining a giving PID namespace only once.
func JoinNamespaceAndProcessInfoByPidsWithOptions ¶ added in v1.3.0
func JoinNamespaceAndProcessInfoByPidsWithOptions(pids []string, descriptors []string, options *JoinNamespaceOpts) ([][]string, error)
JoinNamespaceAndProcessInfoByPidsWithOptions has similar semantics to JoinNamespaceAndProcessInfo and avoids duplicate entries by joining a giving PID namespace only once.
func JoinNamespaceAndProcessInfoWithOptions ¶ added in v1.3.0
func JoinNamespaceAndProcessInfoWithOptions(pid string, descriptors []string, options *JoinNamespaceOpts) ([][]string, error)
JoinNamespaceAndProcessInfoWithOptions has the same semantics as ProcessInfo but joins the mount namespace of the specified pid before extracting data from `/proc`.
func ListDescriptors ¶
func ListDescriptors() (list []string)
ListDescriptors returns a string slice of all supported AIX format descriptors in the normal form.
func ProcessInfo ¶
ProcessInfo returns the process information of all processes in the current mount namespace. The input format must be a comma-separated list of supported AIX format descriptors. If the input string is empty, the `DefaultDescriptors` is used. The return value is an array of tab-separated strings, to easily use the output for column-based formatting (e.g., with the `text/tabwriter` package).
Types ¶
type JoinNamespaceOpts ¶ added in v1.3.0
type JoinNamespaceOpts struct { // UIDMap specifies a mapping for UIDs in the container. If specified // huser will perform the reverse mapping. UIDMap []idtools.IDMap // GIDMap specifies a mapping for GIDs in the container. If specified // hgroup will perform the reverse mapping. GIDMap []idtools.IDMap // FillMappings specified whether UIDMap and GIDMap must be initialized // with the current user namespace. FillMappings bool }
JoinNamespaceOpts specifies different options for joining the specified namespaces.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
capabilities
Package capabilities provides a mapping from common kernel bit masks to the alphanumerical representation of kernel capabilities.
|
Package capabilities provides a mapping from common kernel bit masks to the alphanumerical representation of kernel capabilities. |
host
Package host extracts data from the host, such as the system's boot time or the tick rate of the system clock.
|
Package host extracts data from the host, such as the system's boot time or the tick rate of the system clock. |