systems

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeStableHashId added in v0.20.0

func MakeStableHashId(strings ...string) string

Types

type System

type System struct {
	Id     string `db:"id"`
	Host   string `db:"host"`
	Port   string `db:"port"`
	Status string `db:"status"` // Use GetStatus/swapStatus after publishing the system.

	WsConn *ws.WsConn // Handler for agent WebSocket connection
	// contains filtered or unexported fields
}

func (*System) DeleteNetworkMonitor added in v0.20.0

func (sys *System) DeleteNetworkMonitor(id string) error

DeleteNetworkMonitor removes a single monitor task from the agent.

func (*System) FetchAndSaveSmartDevices added in v0.17.0

func (sys *System) FetchAndSaveSmartDevices() error

FetchAndSaveSmartDevices fetches SMART data from the agent and saves it to the database

func (*System) FetchAndSaveZfsPools added in v0.19.0

func (sys *System) FetchAndSaveZfsPools(force bool) error

FetchAndSaveZfsPools fetches ZFS detail data from the agent and saves it to the database. force bypasses the agent's detail cache for manual refreshes.

func (*System) FetchContainerInfoFromAgent added in v0.14.0

func (sys *System) FetchContainerInfoFromAgent(containerID string) (string, error)

FetchContainerInfoFromAgent fetches container info from the agent

func (*System) FetchContainerLogsFromAgent added in v0.14.0

func (sys *System) FetchContainerLogsFromAgent(containerID string) (string, error)

FetchContainerLogsFromAgent fetches container logs from the agent

func (*System) FetchPackageUpdatesFromAgent added in v0.21.0

func (sys *System) FetchPackageUpdatesFromAgent() (system.PackageUpdates, error)

FetchPackageUpdatesFromAgent fetches the list of pending package updates from the agent.

func (*System) FetchSmartDataFromAgent added in v0.15.0

func (sys *System) FetchSmartDataFromAgent() (smart.SmartDataResponse, error)

FetchSmartDataFromAgent fetches SMART data from the agent.

func (*System) FetchSystemdInfoFromAgent added in v0.16.0

func (sys *System) FetchSystemdInfoFromAgent(serviceName string) (systemd.ServiceDetails, error)

FetchSystemdInfoFromAgent fetches detailed systemd service information from the agent

func (*System) FetchSystemdLogsFromAgent added in v0.21.0

func (sys *System) FetchSystemdLogsFromAgent(serviceName string) (string, error)

FetchSystemdLogsFromAgent fetches recent journal entries for a systemd service from the agent.

func (*System) FetchZfsDataFromAgent added in v0.19.0

func (sys *System) FetchZfsDataFromAgent(force bool) (*zfs.ZfsData, error)

FetchZfsDataFromAgent fetches ZFS detail data from the agent.

func (*System) GetStatus added in v0.21.0

func (sys *System) GetStatus() string

GetStatus returns the current monitoring status.

func (*System) HasUser added in v0.18.7

func (sys *System) HasUser(app core.App, user *core.Record) bool

HasUser checks if the given user is in the system's users list. Returns true if SHARE_ALL_SYSTEMS is enabled (any authenticated user can access any system).

func (*System) StartUpdater

func (sys *System) StartUpdater()

StartUpdater starts the system updater. It first fetches the data from the agent then updates the records. If the data is not found or the system is down, it sets the system down.

func (*System) SyncNetworkMonitors added in v0.20.0

func (sys *System) SyncNetworkMonitors(configs []monitor.Config) error

SyncNetworkMonitors sends monitor configurations to the agent.

func (*System) UpsertNetworkMonitor added in v0.20.0

func (sys *System) UpsertNetworkMonitor(config monitor.Config, runNow bool) (*monitor.Result, error)

UpsertNetworkMonitor sends a single monitor configuration change to the agent.

type SystemManager

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

SystemManager manages a collection of monitored systems and their connections. It handles system lifecycle, status updates, and maintains both SSH and WebSocket connections.

func NewSystemManager

func NewSystemManager(hub hubLike) *SystemManager

NewSystemManager creates a new SystemManager instance with the provided hub. The hub must implement the hubLike interface to provide database and alert functionality.

func (*SystemManager) AddRecord

func (sm *SystemManager) AddRecord(record *core.Record, system *System) (err error)

AddRecord creates a System instance from a database record and adds it to the manager. If a system with the same ID already exists, it's removed first to ensure clean state. If no system instance is provided, a new one is created. This method is typically called when systems are created or their status changes to pending.

func (*SystemManager) AddSystem

func (sm *SystemManager) AddSystem(sys *System) error

AddSystem adds a system to the manager and starts monitoring it. It validates required fields, initializes the system context, and starts the update goroutine. Returns error if a system with the same ID already exists.

func (*SystemManager) AddWebSocketSystem

func (sm *SystemManager) AddWebSocketSystem(systemId string, agentVersion semver.Version, wsConn *ws.WsConn) error

AddWebSocketSystem creates and adds a system with an established WebSocket connection. This method is called when an agent connects via WebSocket with valid authentication. The system is immediately added to monitoring with the provided connection and version info.

func (*SystemManager) GetMonitorConfigsForSystem added in v0.20.0

func (sm *SystemManager) GetMonitorConfigsForSystem(systemID string) ([]monitor.Config, error)

GetMonitorConfigsForSystem returns all enabled monitor configs for a system.

func (*SystemManager) GetSystem added in v0.14.0

func (sm *SystemManager) GetSystem(systemID string) (*System, error)

GetSystem returns a system by ID from the store

func (*SystemManager) Initialize

func (sm *SystemManager) Initialize() error

Initialize sets up the system manager by binding event hooks and starting existing systems. It configures SSH client settings and begins monitoring all non-paused systems from the database. Systems are started with staggered delays to prevent overwhelming the hub during startup.

func (*SystemManager) NewSystem

func (sm *SystemManager) NewSystem(systemId string) *System

func (*SystemManager) RemoveSystem

func (sm *SystemManager) RemoveSystem(systemID string) error

RemoveSystem removes a system from the manager and cleans up all associated resources. It cancels the system's context, closes all connections, and removes it from the store. Returns an error if the system is not found.

Jump to

Keyboard shortcuts

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