Documentation
¶
Overview ¶
Package hostwatch measures the host's disk, inode and memory usage and mails an operator when one of them crosses a threshold. It runs as its own container (cmd/hostwatch) so that it keeps reporting when the API does not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadHostname ¶
ReadHostname returns the host's name from rootFS/etc/hostname. The kernel hostname under /proc is per UTS namespace and would name the container.
Types ¶
type Config ¶
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator turns samples into due notifications. It is not safe for concurrent use; the monitor loop owns it.
func NewEvaluator ¶
func (*Evaluator) Observe ¶
Observe records samples and returns the events due now, most severe first. Nothing is marked as sent; call MarkSent once delivery succeeded, so that a failed mail is retried on the next tick. A key absent from samples keeps its state untouched, so a mount that failed statfs once does not re-alert.
type Heartbeat ¶
Heartbeat tells an external watcher that hostwatch is alive, so that its silence is noticed from outside the host.
type HostCollector ¶
type HostCollector struct {
// contains filtered or unexported fields
}
HostCollector reads the host through gopsutil. In a container, point HOST_PROC and HOST_PROC_MOUNTINFO at the host's /proc and RootFS at the host's / so that statfs lands on the host's filesystems.
func NewHostCollector ¶
func NewHostCollector(cfg Config) *HostCollector
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor runs collect, evaluate, notify and heartbeat once per tick.
func NewMonitor ¶
type PushHeartbeat ¶
type PushHeartbeat struct {
// contains filtered or unexported fields
}
PushHeartbeat calls an Uptime Kuma style push URL with status and msg.
func NewPushHeartbeat ¶
func NewPushHeartbeat(raw string) (*PushHeartbeat, error)
type Rule ¶
type Rule struct {
Warn float64
Crit float64
// For is how long a level must hold before it is raised; zero raises at once.
For time.Duration
}
Rule holds the thresholds for one kind of measurement, in percent.
type SMTPConfig ¶
type SMTPNotifier ¶
type SMTPNotifier struct {
// contains filtered or unexported fields
}
SMTPNotifier delivers over STARTTLS, or implicit TLS on port 465. There is no plaintext mode: the session carries the SMTP password.
func NewSMTPNotifier ¶
func NewSMTPNotifier(cfg SMTPConfig) *SMTPNotifier