v0.1.0

Monitoring Cycle

Last updated


This page explains when go-web-monitor checks sites, how it runs checks concurrently, and how each round's results reach the config file and the screen.

Triggers


TriggerSourceBehavior
StartupUI.start() (internal/service/ui.go:96)Runs one Monitor.Update() round as soon as the interface starts
Every minutetime.NewTicker(1 * time.Minute)Runs Update() at a fixed interval; the interval is not configurable
refresh commandhandleCommandRuns one Update() round in a background goroutine right away
add <url> commandMonitor.Add()Checks only the newly added site

Exiting (quit or <kbd>Ctrl+C</kbd>) closes the quit channel, which stops the schedule loop.

Flow of One Round


sequenceDiagram
    participant U as UI
    participant M as Monitor
    participant W as Target site
    participant F as .webMonitor.json
    U->>M: Update()
    par One goroutine per site
        M->>W: Check(url)
        W-->>M: model.Website
        M->>M: Update failure count, alert if needed
    end
    M->>F: Save()
    U->>U: QueueUpdateDraw(updateUI)
  1. sequenceDiagram
  2. participant U as UI
  3. participant M as Monitor
  4. participant W as Target site
  5. participant F as .webMonitor.json
  6. U->>M: Update()
  7. par One goroutine per site
  8. M->>W: Check(url)
  9. W-->>M: model.Website
  10. M->>M: Update failure count, alert if needed
  11. end
  12. M->>F: Save()
  13. U->>U: QueueUpdateDraw(updateUI)

  1. Update() (internal/service/monitor.go:159) starts one goroutine per URL in the watch list and waits for all of them with a sync.WaitGroup.
  2. Each goroutine calls Check() to get the status code, duration, and SSL days remaining (see HTTP Probing and SSL Expiry).
  3. The result updates the site's failure count, and the 5th consecutive offline check sends an alert (see Alert Rules).
  4. When every goroutine finishes, Save() overwrites .webMonitor.json with the full status and SMTP config.
  5. The interface redraws the table and System panel through QueueUpdateDraw.

Duration Bound


A round takes as long as its slowest site. The worst case for one site is HEAD and GET each hitting the 10-second timeout, plus the SSL certificate connection; sites run in parallel, so these times do not add up across sites.

When the Config File Is Written


WhenContent written
End of each Update() roundEvery site's status plus the SMTP config
After a successful add / delSame
After an smtp <key> <value> command (except an unknown key or a non-integer port)Same

Writes overwrite the whole file (util.Save), so manual edits made while the program runs are lost.
中文