Documentation
¶
Overview ¶
Package monitor is the alerting engine. It watches container state (Docker events), resource usage (polled stats), restart frequency, and log output, evaluates user-defined rules, and dispatches matches to the in-app feed and configured webhooks. It also maintains a stats snapshot for the Prometheus exporter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendMail ¶
func SendMail(cfg store.SMTPConfig, subject, body string) error
SendMail delivers one message via the configured SMTP server. It supports implicit TLS (cfg.TLS, e.g. port 465) and otherwise lets net/smtp negotiate STARTTLS when the server offers it. Exported so the API can send a test mail.
Types ¶
type ContainerStat ¶
type ContainerStat struct {
HostID int64
HostName string
ID string
Name string
State string
CPUPercent float64
MemBytes uint64
MemPercent float64
}
ContainerStat is the cached per-container snapshot used by the exporter.
type HostHealth ¶ added in v1.4.0
type HostHealth struct {
Reachable bool
Since time.Time
LastCheck time.Time
Err string // last ping error when unreachable
}
HostHealth is the engine's cached view of one host's reachability. Since is when the current reachable/unreachable state began, so the UI can show how long a host has been down (or up).
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is the long-running alert engine.
func (*Monitor) HostHealth ¶ added in v1.4.0
func (m *Monitor) HostHealth() map[int64]HostHealth
HostHealth returns a snapshot of every tracked host's reachability, keyed by host id, for the API to surface in the hosts list. Hosts that have not been probed yet are absent (callers treat them as reachable/unknown).
func (*Monitor) SetStatsInterval ¶ added in v1.4.0
SetStatsInterval overrides how often the stats sweep runs. Values ≤ 0 are ignored (the default stands). Call before Run; it is not safe to change once the loop is running.
func (*Monitor) Snapshot ¶
func (m *Monitor) Snapshot() []ContainerStat
Snapshot returns a copy of the latest per-container stats for the exporter.