seaworthy.ps

Tools for asserting on processes running in containers using ps.

build_process_tree(ps_rows)[source]

Build a tree structure from a list of PsRow objects. :param ps_rows: a list of PsRow objects :return: a PsTree object

list_container_processes(container)[source]

List the processes running inside a container. We use an exec rather than container.top() because we want to run ‘ps’ inside the container. This is because we want to get PIDs and usernames in the container’s namespaces. container.top() uses ‘ps’ from outside the container in the host’s namespaces. Note that this requires the container to have a ‘ps’ that responds to the arguments we give it– we use BusyBox’s (Alpine’s) ‘ps’ as a baseline for available functionality. :param container: the container to query :return: a list of PsRow objects

exception PsException[source]

Exception indicating problems operating on process lists and trees.

class PsRow(pid, ppid, ruser, args)[source]

Representation of a process list entry, containing the details of a single process.

classmethod columns()[source]

List the columns required to construct a suitable ps command.

class PsTree(row, children=NOTHING)[source]

Node in a process tree, linking a PsRow to its child processes.

count()[source]

Return the number of processes in this subtree.