v0.1.0

Config File

Last updated


This page explains where .webMonitor.json lives, when it is created, and what every field means.

Location and Lifecycle


go-web-monitor reads no environment variables. All state and settings live in .webMonitor.json in the current working directory (the project .gitignore already excludes it).
WhenBehavior
File missing at startupCreates an empty list with SMTP defaults port: 587 and enabled: false
At startupLoads list[].url as the watch list and config as the SMTP settings; exits with an error when the JSON fails to parse
While runningOverwrites the whole file after each check round, add / del, and smtp commands

Starting the program in a different directory uses a different, independent config file.

Example


  1. {
  2. "list": [
  3. {
  4. "url": "https://example.com",
  5. "code": 200,
  6. "duration": 62554917,
  7. "online": true,
  8. "last_check": "2025-01-15T23:12:29.200334+08:00",
  9. "expire": 87,
  10. "count": 0
  11. }
  12. ],
  13. "config": {
  14. "host": "smtp.gmail.com",
  15. "port": 587,
  16. "username": "your@email.com",
  17. "password": "your_app_password",
  18. "from": "your@email.com",
  19. "to": ["recipient@email.com"],
  20. "cc": "",
  21. "enabled": true
  22. }
  23. }

list[] Fields (model.Website)


FieldTypeDescription
urlstringNormalized URL (https:// is prepended when the input does not start with http)
codeintLast HTTP status code; 0 on connection failure
durationintResponse time in nanoseconds (time.Duration)
onlinebooltrue when the status code is 200–399
last_checkstringLast check time (RFC 3339)
expireintDays until the SSL certificate expires; 0 when unavailable
countintConsecutive offline checks, from 0 to 4

Startup uses only url; the other fields are a snapshot of the previous run and are overwritten after the first round.

config Fields (model.Config)


FieldTypeDefaultDescription
hoststring""SMTP host
portint587465 uses implicit TLS, 587 uses STARTTLS
usernamestring""Auth runs only when this and password are both set
passwordstring""Stored in plaintext in the file
fromstring""Sender address
to[]string[]Recipient list
ccstring""CC address; no TUI command sets it, so edit it by hand
enabledboolfalseWhether alerts and test emails are sent

password is written in plaintext and the file gets 0644 permissions; adjust the permissions yourself on a shared host.

Manual Edits


The program overwrites the whole config file while running, so make manual changes (such as cc or bulk-importing URLs) after it exits; they take effect on the next start.
中文