Documentation
¶
Overview ¶
Package monitors watches the addresses the owner names: each is asked every minute by the box, dashboard open or not, and the owner hears when one stops answering and when it answers again.
An address answers when its status is 2xx or 3xx: a redirect to a sign-in page is an app that lives. It is down after three failed reads in a row. The state is kept in memory: a restart of the core starts every address anew.
Index ¶
Constants ¶
const ( Pending = "pending" // not read yet, or never answered and not down yet Up = "up" Down = "down" )
The states of an address.
const ConfigFile = "/var/lib/casaos/monitors.json"
ConfigFile holds the addresses (root, 0600: a query may carry a key).
Variables ¶
var ( ErrNotFound = errors.New("no such address") // ErrInvalid is a change the box refuses; its text says what. ErrInvalid = errors.New("the address is refused") // ErrFile is a monitors.json that cannot be read: nothing is written over it. ErrFile = errors.New("the file of the addresses cannot be read: nothing was written") )
var Default = New("/")
Default is the box's own.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
Root string
Now func() time.Time
// Changed is told when an address goes down (with why) and when it answers again; since is the first failed
// read of that outage, the same in both calls. Set before Run.
Changed func(id, name, reason string, since time.Time, down bool)
// Paused says whether the reads are to be skipped now: an update of Docker stops every app. Set before Run.
Paused func() bool
// contains filtered or unexported fields
}
Hub is the watched addresses of one box.
type Monitor ¶
type Monitor struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
InsecureTLS bool `json:"insecure_tls"`
}
Monitor is one address to watch.
type View ¶
type View struct {
Monitor
Status string `json:"status"`
// Code and Millis are the status and the time to the answer of the last read; Error is why it failed.
Code int `json:"code,omitempty"`
Millis int64 `json:"ms,omitempty"`
Error string `json:"error,omitempty"`
// Since is when the address went up, or the first failed read of the outage.
Since *time.Time `json:"since,omitempty"`
Checked *time.Time `json:"checked,omitempty"`
}
View is an address and what its last read said.