Documentation ¶
Overview ¶
Package monitor implements dead man's switches.
Index ¶
- Constants
- func DescribeAll(callback func(service, params string), ms []Monitor)
- func ExitStatusAll(ctx context.Context, ppfmt pp.PP, code int, message string, ms []Monitor) bool
- func FailureAll(ctx context.Context, ppfmt pp.PP, message string, ms []Monitor) bool
- func LogAll(ctx context.Context, ppfmt pp.PP, message string, ms []Monitor) bool
- func StartAll(ctx context.Context, ppfmt pp.PP, message string, ms []Monitor) bool
- func SuccessAll(ctx context.Context, ppfmt pp.PP, message string, ms []Monitor) bool
- type Healthchecks
- func (h *Healthchecks) Describe(callback func(service, params string))
- func (h *Healthchecks) ExitStatus(ctx context.Context, ppfmt pp.PP, code int, message string) bool
- func (h *Healthchecks) Failure(ctx context.Context, ppfmt pp.PP, message string) bool
- func (h *Healthchecks) Log(ctx context.Context, ppfmt pp.PP, message string) bool
- func (h *Healthchecks) Start(ctx context.Context, ppfmt pp.PP, message string) bool
- func (h *Healthchecks) Success(ctx context.Context, ppfmt pp.PP, message string) bool
- type Monitor
- type UptimeKuma
- func (h *UptimeKuma) Describe(callback func(service, params string))
- func (h *UptimeKuma) ExitStatus(ctx context.Context, ppfmt pp.PP, code int, message string) bool
- func (h *UptimeKuma) Failure(ctx context.Context, ppfmt pp.PP, message string) bool
- func (h *UptimeKuma) Log(ctx context.Context, ppfmt pp.PP, message string) bool
- func (h *UptimeKuma) Start(ctx context.Context, ppfmt pp.PP, message string) bool
- func (h *UptimeKuma) Success(ctx context.Context, ppfmt pp.PP, _message string) bool
- type UptimeKumaRequest
- type UptimeKumaResponse
Constants ¶
const ( // HealthchecksDefaultTimeout is the default timeout for a Healthchecks ping. HealthchecksDefaultTimeout = 10 * time.Second )
const ( // UptimeKumaDefaultTimeout is the default timeout for a UptimeKuma ping. UptimeKumaDefaultTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DescribeAll ¶ added in v1.9.3
DescribeAll calls [Monitor.Describe] for each monitor in the group with the callback.
func ExitStatusAll ¶
ExitStatusAll calls [Monitor.ExitStatus] for each monitor in ms.
func FailureAll ¶
FailureAll calls [Monitor.Failure] for each monitor in ms.
Types ¶
type Healthchecks ¶ added in v1.8.0
type Healthchecks struct { // The success endpoint that can be used to derive all other endpoints. BaseURL *url.URL // Timeout for each ping. Timeout time.Duration }
Healthchecks represents a Healthchecks access point. See https://healthchecks.io/docs/http_api/ for more information.
func (*Healthchecks) Describe ¶ added in v1.8.0
func (h *Healthchecks) Describe(callback func(service, params string))
Describe calls the callback with the service name "Healthchecks".
func (*Healthchecks) ExitStatus ¶ added in v1.8.0
ExitStatus pings the /number endpoint where number is the exit status.
type Monitor ¶
type Monitor interface { // Describe a monitor in a human-readable format by calling callback with service names and params. Describe(callback func(service, params string)) // Success pings the monitor to prevent notifications. Success(ctx context.Context, ppfmt pp.PP, message string) bool // Start pings the monitor with the start signal. Start(ctx context.Context, ppfmt pp.PP, message string) bool // Failure immediately signals the monitor to notify the user. Failure(ctx context.Context, ppfmt pp.PP, message string) bool // Log provides additional inforamion without changing the state. Log(ctx context.Context, ppfmt pp.PP, message string) bool // ExitStatus records the exit status (as an integer in the POSIX style). ExitStatus(ctx context.Context, ppfmt pp.PP, code int, message string) bool }
Monitor is a dead man's switch, meaning that the user will be notified when the updater fails to detect and update the public IP address. No notifications for IP changes.
func NewHealthchecks ¶ added in v1.8.0
NewHealthchecks creates a new Healthchecks monitor. See https://healthchecks.io/docs/http_api/ for more information.
type UptimeKuma ¶ added in v1.11.0
type UptimeKuma struct { // The endpoint BaseURL *url.URL // Timeout for each ping Timeout time.Duration }
UptimeKuma provides basic support of Uptime Kuma.
- ExitStatus, Start, and Log will be no-op.
- Success/Fail will be translated to status=up/down
- Messages will be sent along with Success/Fail, but it seems Uptime Kuma will only display the first one.
- ping will always be empty
func (*UptimeKuma) Describe ¶ added in v1.11.0
func (h *UptimeKuma) Describe(callback func(service, params string))
Describe calls the callback with the service name "Uptime Kuma".
func (*UptimeKuma) ExitStatus ¶ added in v1.11.0
ExitStatus with non-zero triggers [Failure]. Otherwise, it does nothing.
type UptimeKumaRequest ¶ added in v1.11.0
type UptimeKumaRequest struct { Status string `url:"status"` Msg string `url:"msg"` Ping string `url:"ping"` }
UptimeKumaRequest is for assembling the request to Uptime Kuma.
type UptimeKumaResponse ¶ added in v1.11.0
UptimeKumaResponse is for parsing the response from Uptime Kuma.