Documentation ¶
Overview ¶
Package namespaces provides functions to render information of Linux namespaces and cgroups.
To enable debug info, set namespaces.DEBUG to true.
For a full guide visit https://github.com/mhausenblas/cinf
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DEBUG bool NS []NSTYPE MAX_COMMAND_LEN int )
Functions ¶
func Gather ¶
func Gather()
Gather reads out process-related info from /proc and fills the global namespaces map with it. Note that only filenames that match the [0-9]* pattern are considered here since those are the ones representing processes, with the filename being the PID.
Example:
namespaces.Gather()
func LookupCG ¶
func LookupCG(cgspec string)
LookupCG displays details about a cgroup a process belongs to. Note that cgspec is expected to be in the format PID:CGROUP_HIERARCHY with allowed values for CGROUP_HIERARCHY being the cgroups v1 hierarchy values as found in /proc/groups - see http://man7.org/linux/man-pages/man7/cgroups.7.html for more infos.
Example:
namespaces.LookupCG("1000:2")
func LookupNS ¶
func LookupNS(targetns string)
LookupNS displays details about a specific namespace.
Example:
namespaces.LookupNS("4026532198")
func LookupPID ¶
func LookupPID(pid string)
LookupPID displays the namespaces a process is in.
Example:
namespaces.LookupPID("1000")
func MonitorPID ¶
func MonitorPID(monspec string)
MonitorPID monitors control files values of cgroup a process belongs to. Note that monspec is expected to be in the format PID:CF1,CF2,… with allowed values for CFx being the cgroups control files as described in http://man7.org/linux/man-pages/man7/cgroups.7.html
Example:
namespaces.MonitorPID("1000:memory.usage_in_bytes,memory.max_usage_in_bytes")
Types ¶
type NSTYPE ¶
type NSTYPE string
const ( NS_MOUNT NSTYPE = "mnt" // CLONE_NEWNS, filesystem mount points NS_UTS NSTYPE = "uts" // CLONE_NEWUTS, nodename and NIS domain name NS_IPC NSTYPE = "ipc" // CLONE_NEWIPC, interprocess communication NS_PID NSTYPE = "pid" // CLONE_NEWPID, process ID number space isolation NS_NET NSTYPE = "net" // CLONE_NEWNET, network system resources NS_USER NSTYPE = "user" // CLONE_NEWUSER, user and group ID number space isolation NS_CGROUP NSTYPE = "cgroup" // CLONE_NEWCGROUP, cgroup root directory )
The supported namespaces