systemd

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 28 Imported by: 10 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// GenerateDeviceProps is a function to generate systemd device
	// properties, used by Set methods. Unless
	// [github.com/opencontainers/cgroups/devices]
	// package is imported, it is set to nil, so cgroup managers can't
	// configure devices.
	GenerateDeviceProps func(r *cgroups.Resources, sdVer int) ([]systemdDbus.Property, error)
)

Functions

func DetectUID

func DetectUID() (int, error)

DetectUID detects UID from the OwnerUID field of `busctl --user status` if running in userNS. The value corresponds to sd_bus_creds_get_owner_uid(3) . If running under RootlessKit, the value of $ROOTLESSKIT_PARENT_EUID is used instead.

Otherwise returns os.Getuid() .

func DetectUserDbusSessionBusAddress

func DetectUserDbusSessionBusAddress() (string, error)

DetectUserDbusSessionBusAddress returns $DBUS_SESSION_BUS_ADDRESS, if set. Otherwise it returns "unix:path=$XDG_RUNTIME_DIR/bus", if $XDG_RUNTIME_DIR/bus exists.

func ExpandSlice

func ExpandSlice(slice string) (string, error)

systemd represents slice hierarchy using `-`, so we need to follow suit when generating the path of slice. Essentially, test-a-b.slice becomes /test.slice/test-a.slice/test-a-b.slice.

func IsRunningSystemd

func IsRunningSystemd() bool

NOTE: This function comes from package github.com/coreos/go-systemd/util It was borrowed here to avoid a dependency on cgo.

IsRunningSystemd checks whether the host was booted with systemd as its init system. This functions similarly to systemd's `sd_booted(3)`: internally, it checks whether /run/systemd/system/ exists and is a directory. http://www.freedesktop.org/software/systemd/man/sd_booted.html

func RangeToBits

func RangeToBits(str string) ([]byte, error)

RangeToBits converts a text representation of a CPU mask (as written to or read from cgroups' cpuset.* files, e.g. "1,3-5") to a slice of bytes with the corresponding bits set (as consumed by systemd over dbus as AllowedCPUs/AllowedMemoryNodes unit property value).

Types

type LegacyManager

type LegacyManager struct {
	// contains filtered or unexported fields
}

func NewLegacyManager

func NewLegacyManager(cg *cgroups.Cgroup, paths map[string]string) (*LegacyManager, error)

func (*LegacyManager) AddPid added in v0.0.5

func (m *LegacyManager) AddPid(subcgroup string, pid int) error

AddPid adds a process with a given pid to an existing cgroup. The subcgroup argument is either empty, or a path relative to a cgroup under under the manager's cgroup.

func (*LegacyManager) Apply

func (m *LegacyManager) Apply(pid int) error

func (*LegacyManager) Destroy

func (m *LegacyManager) Destroy() error

func (*LegacyManager) Exists

func (m *LegacyManager) Exists() bool

func (*LegacyManager) Freeze

func (m *LegacyManager) Freeze(state cgroups.FreezerState) error

func (*LegacyManager) GetAllPids

func (m *LegacyManager) GetAllPids() ([]int, error)

func (*LegacyManager) GetCgroups

func (m *LegacyManager) GetCgroups() (*cgroups.Cgroup, error)

func (*LegacyManager) GetFreezerState

func (m *LegacyManager) GetFreezerState() (cgroups.FreezerState, error)

func (*LegacyManager) GetPaths

func (m *LegacyManager) GetPaths() map[string]string

func (*LegacyManager) GetPids

func (m *LegacyManager) GetPids() ([]int, error)

func (*LegacyManager) GetStats

func (m *LegacyManager) GetStats() (*cgroups.Stats, error)

func (*LegacyManager) OOMKillCount

func (m *LegacyManager) OOMKillCount() (uint64, error)

func (*LegacyManager) Path

func (m *LegacyManager) Path(subsys string) string

func (*LegacyManager) Set

func (m *LegacyManager) Set(r *cgroups.Resources) error

func (*LegacyManager) Stats added in v0.0.7

func (m *LegacyManager) Stats(opts *cgroups.StatsOptions) (*cgroups.Stats, error)

Stats returns cgroup statistics for the specified controllers.

type UnifiedManager

type UnifiedManager struct {
	// contains filtered or unexported fields
}

func NewUnifiedManager

func NewUnifiedManager(config *cgroups.Cgroup, path string) (*UnifiedManager, error)

func (*UnifiedManager) AddPid added in v0.0.5

func (m *UnifiedManager) AddPid(subcgroup string, pid int) error

AddPid adds a process with a given pid to an existing cgroup. The subcgroup argument is either empty, or a path relative to a cgroup under under the manager's cgroup.

func (*UnifiedManager) Apply

func (m *UnifiedManager) Apply(pid int) error

func (*UnifiedManager) Destroy

func (m *UnifiedManager) Destroy() error

func (*UnifiedManager) Exists

func (m *UnifiedManager) Exists() bool

func (*UnifiedManager) Freeze

func (m *UnifiedManager) Freeze(state cgroups.FreezerState) error

func (*UnifiedManager) GetAllPids

func (m *UnifiedManager) GetAllPids() ([]int, error)

func (*UnifiedManager) GetCgroups

func (m *UnifiedManager) GetCgroups() (*cgroups.Cgroup, error)

func (*UnifiedManager) GetFreezerState

func (m *UnifiedManager) GetFreezerState() (cgroups.FreezerState, error)

func (*UnifiedManager) GetPaths

func (m *UnifiedManager) GetPaths() map[string]string

func (*UnifiedManager) GetPids

func (m *UnifiedManager) GetPids() ([]int, error)

func (*UnifiedManager) GetStats

func (m *UnifiedManager) GetStats() (*cgroups.Stats, error)

func (*UnifiedManager) OOMKillCount

func (m *UnifiedManager) OOMKillCount() (uint64, error)

func (*UnifiedManager) Path

func (m *UnifiedManager) Path(_ string) string

func (*UnifiedManager) Set

func (*UnifiedManager) Stats added in v0.0.7

func (m *UnifiedManager) Stats(opts *cgroups.StatsOptions) (*cgroups.Stats, error)

Stats returns cgroup statistics for the specified controllers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL