procps-bindings-0.1.0.0: Haskell bindings to the procps library
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Proc.Bindings.Tab.Config

Synopsis

Documentation

data TableConfig Source #

This type represents our preference of what processes we want information about, and what information we want about them. It'll be translated into a list of arguments to be passed to openproc (openProcTab) or readproctab (openAllProcs).

Constructors

TableConfig 

Table filters

data Filter Source #

Which processes do we want to read information about?

This will determine which extra arguments we pass to openproc or readproctab.

Constructors

NoFilter

Read all processes

ByUids [CUid]

Filter process by user IDs

ByPids [CPid]

Filter process by process IDs

Instances

Instances details
Show Filter Source # 
Instance details

Defined in System.Proc.Bindings.Tab.Config

Eq Filter Source # 
Instance details

Defined in System.Proc.Bindings.Tab.Config

Binary flags

data Flags Source #

What information do we want about the processes?

This type will be translated into a C int to be passed to the underlying library (see flagsAsInt).

It's easiest to construct these using the Semigroup instance:

myFlags :: Flags
myFlags =
  fillMem
    <> fillCom
    <> fillEnv
    <> fillUser
    <> fillGroup

Instances

Instances details
Monoid Flags Source # 
Instance details

Defined in System.Proc.Bindings.Flags.C

Semigroup Flags Source # 
Instance details

Defined in System.Proc.Bindings.Flags.C

Show Flags Source # 
Instance details

Defined in System.Proc.Bindings.Flags.C

Eq Flags Source # 
Instance details

Defined in System.Proc.Bindings.Flags.C

Methods

(==) :: Flags -> Flags -> Bool Source #

(/=) :: Flags -> Flags -> Bool Source #

flagsAsInt :: Flags -> CInt Source #

Translate our nice haskell Flags type into a C int. Basically a bitwise OR of the fields (see all the lines at the end of readproc.h starting with #define PROC_).

Constructing flags

noFlags :: Flags Source #

Only read taskIds.

fillMem :: Flags Source #

Read /proc/#/statm.

fillCom :: Flags Source #

Read /proc/#/cmdline.

fillEnv :: Flags Source #

Read /proc/#/environ.

fillUser :: Flags Source #

Resolve user id number -> user name

fillGroup :: Flags Source #

Resolve group id number -> group name

fillStatus :: Flags Source #

Read /proc/#/status.

fillStat :: Flags Source #

Read /proc/#/stat.

fillArg :: Flags Source #

Read /proc/#/cmdline. Seems to be treated identically to fillCom.

fillCGroup :: Flags Source #

Read /proc/#/cgroup.

fillSupGroup :: Flags Source #

Resolve supplementary group id -> group name

fillOOM :: Flags Source #

Read /proc/#/oom_{score,adj}.

fillNS :: Flags Source #

Read /proc/#/ns/.

fillSystemd :: Flags Source #

Read systemd information.

fillLxc :: Flags Source #

Read LXC name, if possible.

fillLooseTasks :: Flags Source #

Treat threads as if they were processes.

editCGroupAsSingleVector :: Flags Source #

Edit cgroup as a single vector.

editCmdlineAsSingleVector :: Flags Source #

Edit cmdline as a single vector.

editEnvironAsSingleVector :: Flags Source #

Edit environ as a single vector.

Accessors

flagMem :: Flags -> Bool Source #

Read /proc/#/statm?

flagCom :: Flags -> Bool Source #

Read /proc/#/cmdline?

flagEnv :: Flags -> Bool Source #

Read /proc/#/environ?

flagUser :: Flags -> Bool Source #

Resolve user id number -> user name?

flagGroup :: Flags -> Bool Source #

Resolve group id number -> group name?

flagStatus :: Flags -> Bool Source #

Read /proc/#/status?

flagStat :: Flags -> Bool Source #

Read /proc/#/stat?

flagArg :: Flags -> Bool Source #

Read /proc/#/cmdline?

flagCGroup :: Flags -> Bool Source #

Read /proc/#/cgroup?

flagSupGroup :: Flags -> Bool Source #

Resolve supplementary group id -> group name?

flagOOM :: Flags -> Bool Source #

Read /proc/#/oom_{score,adj}?

flagNS :: Flags -> Bool Source #

Read /proc/#/ns/?

flagSystemd :: Flags -> Bool Source #

Read systemd information?

flagLxc :: Flags -> Bool Source #

Read LXC name, if possible?

flagLooseTasks :: Flags -> Bool Source #

Treat threads as if they were processes?

flagEditCGroupSingleVector :: Flags -> Bool Source #

Edit cgroup as a single vector?

flagEditCmdlineSingleVector :: Flags -> Bool Source #

Edit cmdline as a single vector?

flagEditEnvironSingleVector :: Flags -> Bool Source #

Edit environ as a single vector?

Util

branchTableConfig :: HasCallStack => (CInt -> IO a) -> (CInt -> Ptr CPid -> IO a) -> (CInt -> Ptr CUid -> CInt -> IO a) -> TableConfig -> IO a Source #

Case analysis on TableConfig. The three continuation arguments correspond to the three constructors of Filter.

Handles memory management and makes sure we pass the correct argument to openproc or readproctab.

openTableConfig :: (CInt -> IO a) -> (CInt -> Ptr CPid -> IO a) -> (CInt -> Ptr CUid -> CInt -> IO a) -> TableConfig -> IO (a, IO ()) Source #

Same as branchTableConfig, but without the bracketing.

The IO () return value is a cleanup function to free any memory that was allocated for openproc, e.g an array of uid_ts or pid_ts.