monitor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package monitor owns the probe loop and flusher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PingIntervalSec   float64
	FlushIntervalSec  int
	PingTimeoutMs     int
	WifiSampleEnabled bool
}

Config bundles the runtime knobs read from app_config.

type CycleEvent

type CycleEvent struct {
	TSUnixMs int64           `json:"ts_unix_ms"`
	Total    int             `json:"total"`
	OK       int             `json:"ok"`
	Fail     int             `json:"fail"`
	Results  []probes.Result `json:"results"`
}

CycleEvent is emitted after every probe cycle.

type Monitor

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

Monitor runs the probe loop and flusher. Config is hot-reloadable via UpdateConfig; subscribers wake on change and re-read at the top of each iteration.

func New

func New(client *ent.Client, cfg Config) *Monitor

New constructs a Monitor.

func (*Monitor) AddDynamicGatewayProbe

func (*Monitor) AddDynamicGatewayProbe(existing []probes.Probe) []probes.Probe

AddDynamicGatewayProbe prepends a `router_icmp` probe pointed at the auto-detected default gateway. The gateway is resolved fresh on each startup — never persisted, since it changes with networks / DHCP.

func (*Monitor) Config

func (m *Monitor) Config() Config

Config returns a copy of the current config.

func (*Monitor) Run

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

Run blocks until ctx is canceled.

func (*Monitor) SetOnCycle

func (m *Monitor) SetOnCycle(fn func(CycleEvent))

SetOnCycle registers a per-cycle callback. Not thread-safe; call once before Run.

func (*Monitor) SetProbes

func (m *Monitor) SetProbes(probeList []probes.Probe)

SetProbes replaces the active probe list.

func (*Monitor) UpdateConfig

func (m *Monitor) UpdateConfig(cfg Config)

UpdateConfig replaces the running config and wakes all subscribers.

Jump to

Keyboard shortcuts

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