Safe Haskell | None |
---|---|
Language | Haskell2010 |
Internal types and functions for cgroup controllers
Synopsis
- newtype Controller a = Controller {
- unController :: Path Abs Dir
- resolveCGroupController :: Text -> IO (Controller a)
- resolveCGroupController' :: Path Abs File -> Path Abs File -> Text -> IO (Controller a)
- data CGroup = CGroup {}
- data Mount = Mount {
- mountId :: Text
- mountParentId :: Text
- mountStDev :: Text
- mountRoot :: Path Abs Dir
- mountPoint :: Path Abs Dir
- mountOptions :: Text
- mountTags :: [Text]
- mountFilesystemType :: Text
- mountSource :: Text
- mountSuperOptions :: [Text]
- findMatchingCGroup :: Text -> [CGroup] -> Maybe CGroup
- resolveControllerMountPath :: Text -> CGroup -> [Mount] -> Maybe (Path Abs Dir)
- tryResolveMount :: Text -> CGroup -> Mount -> Maybe (Path Abs Dir)
- parseMountInfo :: Parser [Mount]
- parseCGroups :: Parser [CGroup]
- type Parser = Parsec Void Text
CGroup Controllers
newtype Controller a Source #
A CGroup controller path for a specific subsystem
Instances
Eq (Controller a) Source # | |
Defined in System.CGroup.Controller.Internal (==) :: Controller a -> Controller a -> Bool # (/=) :: Controller a -> Controller a -> Bool # | |
Ord (Controller a) Source # | |
Defined in System.CGroup.Controller.Internal compare :: Controller a -> Controller a -> Ordering # (<) :: Controller a -> Controller a -> Bool # (<=) :: Controller a -> Controller a -> Bool # (>) :: Controller a -> Controller a -> Bool # (>=) :: Controller a -> Controller a -> Bool # max :: Controller a -> Controller a -> Controller a # min :: Controller a -> Controller a -> Controller a # | |
Show (Controller a) Source # | |
Defined in System.CGroup.Controller.Internal showsPrec :: Int -> Controller a -> ShowS # show :: Controller a -> String # showList :: [Controller a] -> ShowS # |
resolveCGroupController :: Text -> IO (Controller a) Source #
Resolve a CGroup controller by name, as viewed by the current process
see cgroups(7): /proc/self/cgroup is a file that contains information about control groups applied to this process
see proc(5): /proc/self/mountinfo is a file that contains information about mounts available to this process
Throws an Exception when the controller is not able to be found, or when running outside of a cgroup
resolveCGroupController' :: Path Abs File -> Path Abs File -> Text -> IO (Controller a) Source #
Resolve a CGroup controller by name, under the given cgroup and mountinfo paths
Throws an Exception when the controller is not able to be found, or when running outside of a cgroup
CGroups
A cgroup, as viewed within /proc/[pid]/cgroup
see cgroups(7): /proc/[pid]/cgroup section
Mounts
A mount, as viewed within /proc/[pid]/mountinfo
see proc(5): /proc/[pid]/mountinfo section
Mount | |
|
Internal intermediate operations
findMatchingCGroup :: Text -> [CGroup] -> Maybe CGroup Source #
Find a CGroup matching a controller name
For cgroups version 1, we use containsController
to explicitly look for the controller within a cgroup
For cgroups version 2, we use emptyControllers
to find a cgroup without any controllers
see cgroups(7): /proc/[pid]/cgroup section
resolveControllerMountPath :: Text -> CGroup -> [Mount] -> Maybe (Path Abs Dir) Source #
Find a Mount matching a controller name and cgroup, returning the absolute resolved path of a controller
tryResolveMount :: Text -> CGroup -> Mount -> Maybe (Path Abs Dir) Source #
Attempt to match a cgroup controller to a mount, returning the absolute resolved path of the controller
Returns Nothing if the mount does not match the cgroup controller
A matching mount must have a filesystem type of "cgroup" and contain the controller name within its "super options".
Per cgroups(7), the cgroup path is relative to a mount root in the process's mount hierarchy. Notably, a mount root is not the same as its mount point. A mount point is the path at which the mount is visible to the process.
As such, we need to look for a mount whose mount root either..
- ..exactly matches our cgroup's path, in which case we directly return the mount's mount path; OR
- ..is a prefix of our cgroup's path, in which case we return the relative path from the mount root appended to the mount's mount path
parseMountInfo :: Parser [Mount] Source #
Parse an entire /proc/[pid]/mountinfo file into a list of mounts
parseCGroups :: Parser [CGroup] Source #
Parse an entire /proc/[pid]/cgroup file into a list of cgroups