systemd

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTimeOut uint = 60

Variables

This section is empty.

Functions

func CreateChangeInputSchema added in v0.2.0

func CreateChangeInputSchema() *jsonschema.Schema

func CreateListLoadedUnitsSchema added in v0.3.2

func CreateListLoadedUnitsSchema() *jsonschema.Schema

func CreateListUnitFilesSchema added in v0.3.2

func CreateListUnitFilesSchema() *jsonschema.Schema

func GetRestsartReloadParamsSchema

func GetRestsartReloadParamsSchema() (*jsonschema.Schema, error)

func ValidChanges added in v0.2.0

func ValidChanges() []string

func ValidModes added in v0.2.0

func ValidModes() []string

func ValidRestartModes

func ValidRestartModes() []string

return which are define in the upstream documentation as:

func ValidStates

func ValidStates() []string

func ValidUnitFileStates added in v0.2.0

func ValidUnitFileStates() []string

Types

type ChangeUnitStateParams added in v0.2.0

type ChangeUnitStateParams struct {
	Name    string `json:"name" jsonschema:"Exact name of unit to change state"`
	Action  string `json:"action" jsonschema:"Action to perform."`
	Mode    string `json:"mode,omitempty" jsonschema:"Mode when restarting a unit. Defaults to 'replace'."`
	TimeOut uint   `json:"timeout,omitempty" jsonschema:"Time to wait for the operation to finish. Max 60s."`
	Runtime bool   `json:"runtime,omitempty" jsonschema:"Enable/Disable only temporarily (runtime)."`
}

type CheckReloadRestartParams

type CheckReloadRestartParams struct {
	TimeOut uint `` /* 238-byte string literal not displayed */
}

type Connection

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

func NewSystem

func NewSystem(ctx context.Context, auth auth.AuthKeeper) (conn *Connection, err error)

func NewUser

func NewUser(ctx context.Context) (conn *Connection, err error)

opens a new user connection to the dbus

func (*Connection) ChangeUnitState added in v0.2.0

func (conn *Connection) ChangeUnitState(ctx context.Context, req *mcp.CallToolRequest, params *ChangeUnitStateParams) (res *mcp.CallToolResult, _ any, err error)

func (*Connection) CheckForRestartReloadRunning

func (conn *Connection) CheckForRestartReloadRunning(ctx context.Context, req *mcp.CallToolRequest, params *RestartReloadParams) (res *mcp.CallToolResult, _ any, err error)

check status of reload or restart

func (*Connection) Close

func (conn *Connection) Close()

close the connection

func (*Connection) ListLoadedUnits added in v0.3.2

func (conn *Connection) ListLoadedUnits(ctx context.Context, req *mcp.CallToolRequest, params *ListLoadedUnitsParams) (*mcp.CallToolResult, any, error)

func (*Connection) ListStatesHandler

func (conn *Connection) ListStatesHandler(ctx context.Context) (lst []string, err error)

helper function to get the valid states

func (*Connection) ListUnitFiles

func (conn *Connection) ListUnitFiles(ctx context.Context, req *mcp.CallToolRequest, params *ListUnitFilesParams) (*mcp.CallToolResult, any, error)

type DbusConnection

type DbusConnection interface {
	ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitStatus, error)
	GetAllPropertiesContext(ctx context.Context, unitName string) (map[string]interface{}, error)
	ReloadOrRestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	RestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	StartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	StopUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
	KillUnitContext(ctx context.Context, name string, signal int32)
	EnableUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) (bool, []dbus.EnableUnitFileChange, error)
	DisableUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]dbus.DisableUnitFileChange, error)
	ListUnitFilesContext(ctx context.Context) ([]dbus.UnitFile, error)

	Close()
}

DbusConnection is an interface that abstracts the dbus connection. This is primarily for testing purposes.

type ListLoadedUnitsParams added in v0.3.2

type ListLoadedUnitsParams struct {
	State              string   `` /* 344-byte string literal not displayed */
	Patterns           []string `json:"patterns,omitempty" jsonschema:"List units by their names or patterns (e.g. '*.service')."`
	Properties         bool     `json:"properties,omitempty" jsonschema:"If true, return detailed properties for each unit."`
	IncludeDescription bool     `json:"include_description,omitempty" jsonschema:"If true, include the description for each unit."`
	Verbose            bool     `json:"verbose,omitempty" jsonschema:"Return more details in the response."`
}

type ListUnitFilesParams

type ListUnitFilesParams struct {
	State              string   `` /* 159-byte string literal not displayed */
	Patterns           []string `` /* 136-byte string literal not displayed */
	IncludeDescription bool     `json:"include_description,omitempty" jsonschema:"If true, include the description for each unit."`
}

type RestartReloadParams

type RestartReloadParams struct {
	Name         string `json:"name" jsonschema:"Exact name of unit to restart"`
	TimeOut      uint   `` /* 238-byte string literal not displayed */
	Mode         string `json:"mode,omitempty" jsonschema:"Mode used for the restart or reload. 'replace' should be used."`
	Forcerestart bool   `` /* 209-byte string literal not displayed */
}

type UnitProperties added in v0.2.0

type UnitProperties struct {
	Id          string `json:"Id"`
	Description string `json:"Description"`

	// Load state info
	LoadState      string `json:"LoadState"`
	FragmentPath   string `json:"FragmentPath"`
	UnitFileState  string `json:"UnitFileState"`
	UnitFilePreset string `json:"UnitFilePreset"`

	// Active state info
	ActiveState          string `json:"ActiveState"`
	SubState             string `json:"SubState"`
	ActiveEnterTimestamp uint64 `json:"ActiveEnterTimestamp"`

	// Process info
	InvocationID   string `json:"InvocationID"`
	MainPID        int    `json:"MainPID"`
	ExecMainPID    int    `json:"ExecMainPID"`
	ExecMainStatus int    `json:"ExecMainStatus"`

	// Resource usage
	TasksCurrent uint64 `json:"TasksCurrent"`
	TasksMax     uint64 `json:"TasksMax"`
	CPUUsageNSec uint64 `json:"CPUUsageNSec"`

	// Control group
	ControlGroup string `json:"ControlGroup"`

	// Exec commands (simplified - would need additional processing)
	ExecStartPre [][]interface{} `json:"ExecStartPre"`
	ExecStart    [][]interface{} `json:"ExecStart"`

	// Additional fields that might be useful
	Restart       string `json:"Restart"`
	MemoryCurrent uint64 `json:"MemoryCurrent"`
}

Jump to

Keyboard shortcuts

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