Stem Docs

Proc Utilities

Proc Utilities

Helper functions for querying process and system information from the /proc contents. Fetching information this way provides huge performance benefits over lookups via system utilities (ps, netstat, etc). For instance, resolving connections this way cuts the runtime by around 90% verses the alternatives. These functions may not work on all platforms (only Linux?).

The method for reading these files (and a little code) are borrowed from psutil, which was written by Jay Loden, Dave Daeschler, Giampaolo Rodola’ and is under the BSD license.

These functions are not being vended to stem users. They may change in the future, use them at your own risk.

Changed in version 1.3.0: Dropped the get_* prefix from several function names. The old names still work, but are deprecated aliases.

Module Overview:

is_available - checks if proc utilities can be used on this system
system_start_time - unix timestamp for when the system started
physical_memory - memory available on this system
cwd - provides the current working directory for a process
uid - provides the user id a process is running under
memory_usage - provides the memory usage of a process
stats - queries statistics about a process
file_descriptors_used - number of file descriptors used by a process
connections - provides the connections made by a process
stem.util.proc.Stat(enum)

Types of data available via the stats() function.

Stat

Description

COMMAND

command name under which the process is running

CPU_UTIME

total user time spent on the process

CPU_STIME

total system time spent on the process

START_TIME

when this process began, in unix time