monitor

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package monitor is the read-plane poller (plan §4): it discovers apps (one per Docker Compose project), builds the normalized BASIC health record for each service (plan §4.3), samples host metrics, holds the latest snapshot in memory for the UI, and persists metric samples. It only ever READS Docker (through the socket-proxy) — no write can originate here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Project     string
	DisplayName string
	Services    []ServiceStatus
	Ops         *ops.Result
	WorkingDir  string
	ConfigFiles []string
}

App is one Compose project and its services. Ops is the canonical App Ops Interface record (nil when ops is not configured for this app — plan §4.3). WorkingDir/ConfigFiles come from the compose labels and let the write plane target `docker compose` for this project.

func (App) Degraded

func (a App) Degraded() bool

Degraded reports whether any service is down or unhealthy.

func (App) Rich

func (a App) Rich() bool

Rich reports whether the app has a RICH ops record.

func (App) Total

func (a App) Total() int

Total returns the number of services.

func (App) UpCount

func (a App) UpCount() int

UpCount returns the number of running services.

type Monitor

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

Monitor runs the poll loop and publishes snapshots.

func New

func New(db *store.DB, cli *docker.Client, host *hostmon.Sampler, interval, retention time.Duration, log *slog.Logger, prober *ops.Prober) *Monitor

New builds a Monitor. prober may be nil (ops probing disabled).

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context)

Run polls immediately, then every interval, until ctx is cancelled.

func (*Monitor) Snapshot

func (m *Monitor) Snapshot() *Snapshot

Snapshot returns the latest published snapshot (nil before the first poll).

type ServiceStatus

type ServiceStatus struct {
	Service      string
	ContainerID  string
	Name         string
	Image        string
	State        string
	Health       string
	CPUPercent   float64
	MemBytes     uint64
	MemLimit     uint64
	RestartCount int
	ExitCode     int  // last exit code (137 ≈ OOM/at-limit kill — used by the supervisor)
	OOMKilled    bool // the container's last stop was an OOM kill
	HasRWVolume  bool // a shared read-write bind/named volume (auto-scaling C3 disqualifier)
	StatusText   string
}

ServiceStatus is the normalized BASIC record for one container/service.

func (ServiceStatus) Running

func (s ServiceStatus) Running() bool

Running reports whether the service container is running.

type Snapshot

type Snapshot struct {
	At        time.Time
	DockerOK  bool
	DockerErr string
	Version   string
	Apps      []App
	Host      hostmon.Sample
	HostOK    bool
	HostErr   string
}

Snapshot is the full read-plane view the UI renders.

func (*Snapshot) AppByProject

func (s *Snapshot) AppByProject(project string) *App

AppByProject returns the app with the given project, or nil.

Jump to

Keyboard shortcuts

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