agenthealth

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package agenthealth derives the alerts the agent status page shows from what the server already knows: heartbeats, the inventory summary, the agent's jobs and their newest runs, and the server version. It never talks to the agent.

Index

Constants

View Source
const StaleAfter = 90 * time.Second

StaleAfter is how long without a heartbeat (sent every 30 s) an agent counts as stale; three missed beats so a single slow request does not flap the status

Variables

This section is empty.

Functions

func Detail

func Detail(a *db.Agent) *inventory.Detail

Detail decodes the agent's stored full inventory; nil when it has none

func EffectiveStatus

func EffectiveStatus(a *db.Agent, now time.Time) db.AgentStatus

EffectiveStatus is the status to display: the stored status unless the heartbeat has gone stale, which makes an "online" agent "offline"

func Stale

func Stale(a *db.Agent, now time.Time) bool

Stale reports whether the agent's last heartbeat is older than StaleAfter (or it never sent one)

func Summary

func Summary(a *db.Agent) *inventory.Summary

Summary decodes the agent's stored inventory summary; nil when it has none

Types

type Alert

type Alert struct {
	Level  Level  `json:"level"`
	Title  string `json:"title"`
	Detail string `json:"detail,omitempty"`
	// JobID links the alert to a job when it is about one
	JobID *uuid.UUID `json:"job_id,omitempty"`
}

Alert is one finding about an agent

func Evaluate

func Evaluate(in Input) []Alert

Evaluate computes the alerts, most severe first

type Input

type Input struct {
	Agent *db.Agent
	// Jobs are the agent's jobs (jobs for other agents are ignored)
	Jobs []*db.BackupJob
	// LastRuns maps job id → newest run (from DB.LatestRunByJob); nil = unknown
	LastRuns map[uuid.UUID]*db.JobLastRun
	// ServerVersion is compared with the agent's version ("dev" disables the check)
	ServerVersion string
	Now           time.Time
}

Input is everything Evaluate looks at

type Level

type Level string

Level orders alerts: danger first, then warning, then info

const (
	LevelDanger  Level = "danger"
	LevelWarning Level = "warning"
	LevelInfo    Level = "info"
)

Jump to

Keyboard shortcuts

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