cmd

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	R  = "\033[0m" // reset
	B  = "\033[1m" // bold
	D  = "\033[2m" // dim
	UL = "\033[4m" // underline

	FRed = "\033[31m"
	FGrn = "\033[32m"
	FYel = "\033[33m"
	FBlu = "\033[34m"
	FCyn = "\033[36m"

	FBRed = "\033[91m"
	FBGrn = "\033[92m"
	FBYel = "\033[93m"
	FBCyn = "\033[96m"
	FBWht = "\033[97m"

	BRed = "\033[41m"
	BGrn = "\033[42m"
	BBlu = "\033[44m"
)
View Source
const FDim = "\033[2m"

FDim constant used by colorDelta — our other subcommands define this too; we duplicate here only if it isn't already in scope. Go catches duplicate definitions at compile time, so the build fails fast if we collide.

Variables

View Source
var MaskIPsEnabled bool

MaskIPs is a global flag accessible from UI and doctor rendering.

View Source
var Version = "0.50.0"

Version is set at build time via ldflags.

Functions

func BuildDaemonBackends

func BuildDaemonBackends(dataDir string) (persistence engine.DaemonStore, apiSrv engine.DaemonAPIServer, cleanup func())

BuildDaemonBackends opens the SQLite store and API server and returns the engine interfaces to pass into DaemonConfig. cleanup must be called on daemon shutdown (after eng.Close()).

func NewDaemonAPIServer

func NewDaemonAPIServer(sockPath string, persistence engine.DaemonStore, dbPath string) (engine.DaemonAPIServer, error)

NewDaemonAPIServer creates a Unix-socket API server at sockPath and returns an engine.DaemonAPIServer. The persistence adapter's underlying *store.Store is retrieved via type assertion so the api package can use it for incident queries. Returns (nil, nil) on failure — callers treat nil as "no API".

func NewDaemonPersistence

func NewDaemonPersistence(dbPath string) (engine.DaemonStore, func(), error)

NewDaemonPersistence opens (or creates) the SQLite incident database at dbPath, runs migrations, and returns an engine.DaemonStore adapter. The caller is responsible for calling Close() on the returned engine.DaemonStore via the returned cleanup func — or simply by casting to io.Closer.

On error (e.g. SQLite init failure) it returns nil, nil — the daemon degrades to JSONL-only without crashing.

func Run

func Run() error

Run parses flags and starts the application.

Types

type CheckResult

type CheckResult struct {
	Category string      `json:"category"`
	Name     string      `json:"name"`
	Status   CheckStatus `json:"status"`
	Detail   string      `json:"detail"`
	Advice   string      `json:"advice,omitempty"`
}

CheckResult holds the outcome of a single health check.

type CheckStatus

type CheckStatus int

CheckStatus represents the severity of a doctor check result.

const (
	CheckOK   CheckStatus = 0
	CheckWarn CheckStatus = 1
	CheckCrit CheckStatus = 2
	CheckSkip CheckStatus = 3
)

func (CheckStatus) String

func (s CheckStatus) String() string

type Config

type Config struct {
	Interval     time.Duration
	HistorySize  int
	JSONMode     bool
	MDMode       bool
	WatchMode    bool
	WatchCount   int
	Section      string
	RecordPath   string
	ReplayPath   string
	DaemonMode   bool
	DataDir      string
	PromEnabled  bool
	PromAddr     string
	AlertWebhook string
	AlertCommand string
	// Doctor mode
	DoctorMode    bool
	AppDoctorMode bool
	DiscoverMode  bool
	CronMode      bool
	AlertMode     bool
	// Forensics mode
	ForensicsMode bool
	// Diagnose mode
	DiagnoseMode   bool
	DiagnoseTarget string
	// Shell widget
	ShellInit   string
	TmuxStatus  bool
	CronInstall bool
	// Privacy
	MaskIPs bool
	// RCA tuning
	NoHysteresis bool // disable alert state machine sustained-threshold gating
}

Config holds CLI configuration.

type DoctorReport

type DoctorReport struct {
	Timestamp   time.Time           `json:"timestamp"`
	Hostname    string              `json:"hostname"`
	Checks      []CheckResult       `json:"checks"`
	WorstStatus CheckStatus         `json:"worst_status"`
	RCA         interface{}         `json:"rca,omitempty"`
	Snap        *model.Snapshot     `json:"-"` // for diagnosis rendering
	Rates       *model.RateSnapshot `json:"-"`
}

DoctorReport holds the full health check output.

type ExitCodeError

type ExitCodeError struct{ Code int }

ExitCodeError signals a non-zero exit code without calling os.Exit directly.

func (ExitCodeError) Error

func (e ExitCodeError) Error() string

type ForensicsEvent

type ForensicsEvent struct {
	Timestamp time.Time `json:"timestamp"`
	Source    string    `json:"source"`   // "dmesg", "journal", "sar", "auth"
	Category  string    `json:"category"` // "oom", "crash", "restart", "hardware", "security", "resource"
	Severity  string    `json:"severity"` // "info", "warn", "crit"
	Summary   string    `json:"summary"`
	Detail    string    `json:"detail,omitempty"`
}

ForensicsEvent represents a single forensic finding.

type ForensicsReport

type ForensicsReport struct {
	Hostname    string                `json:"hostname"`
	AnalyzedAt  time.Time             `json:"analyzed_at"`
	Sessions    []model.ActiveSession `json:"active_sessions"` // #29: reuse model type
	UniqueIPs   int                   `json:"unique_session_ips"`
	Events      []ForensicsEvent      `json:"events"`
	OOMKills    int                   `json:"oom_kills"`
	Crashes     int                   `json:"crashes"`
	Restarts    int                   `json:"restarts"`
	HWErrors    int                   `json:"hw_errors"`
	SecurityEvt int                   `json:"security_events"`
}

ForensicsReport holds the complete forensics analysis.

Directories

Path Synopsis
monitor is a headless version of xtop that prints RCA results to stdout.
monitor is a headless version of xtop that prints RCA results to stdout.
xtop-agent is the headless fleet-agent binary.
xtop-agent is the headless fleet-agent binary.

Jump to

Keyboard shortcuts

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