systemd

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	Name         string          `json:"n" cbor:"0,keyasint"`
	State        ServiceState    `json:"s" cbor:"1,keyasint"`
	Cpu          float64         `json:"c" cbor:"2,keyasint"`
	Mem          uint64          `json:"m" cbor:"3,keyasint"`
	MemPeak      uint64          `json:"mp" cbor:"4,keyasint"`
	Sub          ServiceSubState `json:"ss" cbor:"5,keyasint"`
	CpuPeak      float64         `json:"cp" cbor:"6,keyasint"`
	PrevCpuUsage uint64          `json:"-"`
	PrevReadTime time.Time       `json:"-"`
}

Service represents a single systemd service with its stats.

func (*Service) UpdateCPUPercent

func (s *Service) UpdateCPUPercent(cpuUsage uint64)

UpdateCPUPercent calculates the CPU usage percentage for the service.

type ServiceDependency

type ServiceDependency struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	ActiveState string `json:"activeState,omitempty"`
	SubState    string `json:"subState,omitempty"`
}

ServiceDependency represents a unit that the service depends on.

type ServiceDetails

type ServiceDetails map[string]any

ServiceDetails contains extended information about a systemd service.

type ServiceState

type ServiceState uint8

ServiceState represents the status of a systemd service

const (
	StatusActive ServiceState = iota
	StatusInactive
	StatusFailed
	StatusActivating
	StatusDeactivating
	StatusReloading
)

func ParseServiceStatus

func ParseServiceStatus(status string) ServiceState

ParseServiceStatus converts a string status to a ServiceStatus enum value

type ServiceSubState

type ServiceSubState uint8

ServiceSubState represents the sub status of a systemd service

const (
	SubStateDead ServiceSubState = iota
	SubStateRunning
	SubStateExited
	SubStateFailed
	SubStateUnknown
)

func ParseServiceSubState

func ParseServiceSubState(subState string) ServiceSubState

ParseServiceSubState converts a string sub status to a ServiceSubState enum value

Jump to

Keyboard shortcuts

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