Documentation
¶
Index ¶
- Constants
- Variables
- type Aggregation
- type BasicAuth
- type BotComm
- type Cfg
- type Chart
- type Connectivity
- type DNSCheck
- type Details
- type Discord
- type Host
- type HostType
- type HttpResponse
- type Incident
- type IncidentDetails
- type LastOutageDetails
- type Mattermost
- type Notifications
- type Ntfy
- type Point
- type Pushover
- type SMTP
- type SSLDetails
- type Slack
- type Stat
- type Stats
- type Status
- type StatusType
- type Success
- type Tag
- type Teams
- type Telegram
- type Twilio
- type UI
- type Webhook
Constants ¶
const ( DefaultInterval = 30 * time.Second DefaultTimeout = 60 * time.Second DefaultMaxConn = 128 DefaultSuccessThreshold = 1 DefaultFailureThreshold = 2 DefaultCooldown = 5 * time.Minute )
const ( Unknown StatusType = "unknown" UP StatusType = "up" DEGRADED StatusType = "degraded" DOWN StatusType = "down" HttpType HostType = "http" MongoType HostType = "mongo" ICMPType HostType = "icmp" TCPType HostType = "tcp" DNSType HostType = "dns" RedisType HostType = "redis" PostgresType HostType = "postgres" MySQLType HostType = "mysql" )
Variables ¶
var ErrHostNotFound = errors.New("host not found")
Functions ¶
This section is empty.
Types ¶
type Aggregation ¶
type Aggregation struct {
ResponseTime time.Duration `json:"responseTime"`
Count int `json:"count"`
Uptime float64 `json:"uptime"`
TS time.Time `json:"timestamp"`
}
Aggregation - aggregation structure for the history per day
type BotComm ¶
type BotComm struct {
ClientID string `json:"clientID" yaml:"clientID"`
ClientSecret string `json:"clientSecret" yaml:"clientSecret"`
SessionIDs []string `json:"sessionIDs" yaml:"sessionIDs"` // omit to broadcast to everyone connected to the bot
}
BotComm - messages via botcomm.app.
type Cfg ¶
type Cfg struct {
Interval time.Duration `json:"interval,omitempty" yaml:"interval,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
InitialDelay *time.Duration `json:"initialDelay,omitempty" yaml:"initialDelay,omitempty"`
MaxConn int `json:"maxConn,omitempty" yaml:"maxConn,omitempty"` // maximum concurrent dial connections
SuccessThreshold int `json:"successThreshold" yaml:"successThreshold,omitempty"`
FailureThreshold int `json:"failureThreshold" yaml:"failureThreshold,omitempty"`
Conditions *Success `json:"success" yaml:"success,omitempty"`
Headers map[string]string `json:"headers" yaml:"headers,omitempty"`
UI UI `json:"ui" yaml:"ui"`
Connectivity *Connectivity `json:"connectivity" yaml:"connectivity,omitempty"`
Notifications Notifications `json:"notifications" yaml:"notifications,omitempty"`
FileHosts []*Host `json:"hosts" yaml:"hosts"`
Hosts []*Host `json:"-" yaml:"-"`
// DefaultSMTP - SMTP settings provided via CLI flags/env. Used when the
// configuration file does not define notifications.smtp.
DefaultSMTP *SMTP `json:"-" yaml:"-"`
FW chan bool `yaml:"-"`
// DEPRECATED: use Notifications instead of Alerts
Alerts *Notifications `json:"alerts,omitempty" yaml:"alerts,omitempty"`
// contains filtered or unexported fields
}
func (*Cfg) GetUI ¶
GetUI - returns a copy of the UI settings. Safe to call concurrently with a reload.
func (*Cfg) Parse ¶
Parse - reads the configuration file (json or yaml) into a fresh structure and, only if it was decoded successfully, replaces the current configuration with it. Parsing into a fresh structure guarantees that sections removed from the file are removed from the running configuration too (decoding into the existing structure would only merge new values on top of the old ones).
type Connectivity ¶
type Connectivity struct {
Disabled bool `json:"disabled" yaml:"disabled"` // disables the connectivity check (enabled by default)
Targets []string `json:"targets" yaml:"targets"` // host:port endpoints to probe over TCP
Interval time.Duration `json:"interval" yaml:"interval"` // how long a connectivity result is cached
Timeout time.Duration `json:"timeout" yaml:"timeout"` // timeout for a single connectivity probe
}
Connectivity - configures the self connectivity check. When the monitor loses its own internet connection, failed host checks are skipped instead of being reported as DOWN, avoiding false positives (e.g. home internet outage).
type DNSCheck ¶
type DNSCheck struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"` // A, AAAA, CNAME, MX, NS, TXT (default: A)
Expect []string `json:"expect,omitempty" yaml:"expect,omitempty"` // values that must be present in the answer (optional)
Resolver string `json:"resolver,omitempty" yaml:"resolver,omitempty"` // host:port of the dns server (default: system resolver)
}
DNSCheck - options of a dns host (url: dns://name)
type Details ¶
type Details struct {
Uptime string
ResponseTime string
SSL *SSLDetails
LastOutage *LastOutageDetails
}
Details is a struct that contains the uptime and response time of a host.
type Discord ¶
type Discord struct {
WebhookURL string `json:"webhookURL" yaml:"webhookURL"`
Username string `json:"username" yaml:"username"` // overrides the webhook name (optional)
}
Discord - incoming webhook.
type Host ¶
type Host struct {
ID string `json:"id" yaml:"-"`
Type HostType `json:"type" yaml:"type"`
Name *string `json:"name,omitempty" yaml:"name,omitempty"`
Description *string `json:"description,omitempty" yaml:"description,omitempty"`
Group *string `json:"group,omitempty" yaml:"group,omitempty"`
Method string `json:"method,omitempty" yaml:"method,omitempty"`
URL string `json:"url" yaml:"url"`
Interval *time.Duration `json:"interval" yaml:"interval,omitempty"` // minimum 1s
TimeoutInterval *time.Duration `json:"timeout" yaml:"timeout,omitempty"`
InitialDelay *time.Duration `json:"initialDelay" yaml:"initialDelay,omitempty"`
SuccessThreshold int `json:"successThreshold,omitempty" yaml:"successThreshold,omitempty"`
FailureThreshold int `json:"failureThreshold,omitempty" yaml:"failureThreshold,omitempty"`
Conditions *Success `json:"conditions,omitempty" yaml:"conditions,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
Alerts []string `json:"alerts,omitempty" yaml:"alerts,omitempty"`
DNS *DNSCheck `json:"dns,omitempty" yaml:"dns,omitempty"` // dns check options
Hidden bool `json:"hidden" yaml:"hidden"` // acceptable only if group is defined
Index int `json:"-" yaml:"-"`
}
Host - host structure
func (*Host) Changed ¶
Changed - reports whether the monitoring-relevant configuration of the host differs from the other one. The position in the list (Index) is ignored.
func (*Host) GenerateID ¶
GenerateID - returns a host id based on the url hash
func (*Host) SecureURL ¶
SecureURL - returns a secure url that can be used in logs or alerts. It will hide the password if present.
type HttpResponse ¶
type HttpResponse struct {
Timestamp time.Time `json:"timestamp"`
Time time.Duration `json:"time"`
Code int `json:"code,omitempty"`
Body string `json:"body,omitempty"`
OK bool `json:"-"`
Bytes []byte `json:"-"`
Status bool `json:"status,omitempty"`
StatusType StatusType `json:"statusType,omitempty"`
DNS time.Duration `json:"DNS,omitempty"`
TLSHandshake time.Duration `json:"TLSHandshake,omitempty"`
Connect time.Duration `json:"connect,omitempty"`
TTFB time.Duration `json:"TTFB,omitempty"`
SSLCertExpiry *time.Time `json:"SSLExpiry,omitempty"`
SSLIssuer string `json:"SSLIssuer,omitempty"`
TLSVersion string `json:"TLSVersion,omitempty"`
IsAggregated bool `json:"isAggregated"`
Uptime float64 `json:"uptime,omitempty"` // aggregation uptime
Count int `json:"count,omitempty"` // aggregation count
}
HttpResponse - response from the http dial
type Incident ¶
type Incident struct {
ID int `json:"id"`
Text string `json:"-"`
Details IncidentDetails `json:"details"`
Start string `json:"-"`
End string `json:"-"`
Duration string `json:"-"`
StartTS time.Time `json:"startTS"`
EndTS *time.Time `json:"endTS,omitempty"`
}
Incident - host incident structure
type IncidentDetails ¶
type LastOutageDetails ¶
type Mattermost ¶
type Mattermost struct {
WebhookURL string `json:"webhookURL" yaml:"webhookURL"`
Channel string `json:"channel" yaml:"channel"` // overrides the webhook channel (optional)
Username string `json:"username" yaml:"username"` // overrides the webhook username (optional)
}
Mattermost - Slack-compatible incoming webhook (Mattermost, Rocket.Chat, ...).
type Notifications ¶
type Notifications struct {
Slack *Slack `json:"slack" yaml:"slack"`
Telegram *Telegram `json:"telegram" yaml:"telegram"`
SMTP *SMTP `json:"smtp" yaml:"smtp"`
Webhook *Webhook `json:"webhook" yaml:"webhook"`
Discord *Discord `json:"discord" yaml:"discord"`
Teams *Teams `json:"teams" yaml:"teams"`
Mattermost *Mattermost `json:"mattermost" yaml:"mattermost"`
Pushover *Pushover `json:"pushover" yaml:"pushover"`
Ntfy *Ntfy `json:"ntfy" yaml:"ntfy"`
Twilio *Twilio `json:"twilio" yaml:"twilio"`
BotComm *BotComm `json:"botcomm" yaml:"botcomm"`
InitializationMessage *bool `json:"initializationMessage" yaml:"initializationMessage"`
ShutdownMessage bool `json:"shutdownMessage" yaml:"shutdownMessage"`
// Cooldown - minimal time between two identical notifications (same host, same status, same channel).
// Prevents spamming when a host flaps. Default: 5m. Set to 0 to disable.
Cooldown *time.Duration `json:"cooldown,omitempty" yaml:"cooldown,omitempty"`
}
type Ntfy ¶
type Ntfy struct {
URL string `json:"url" yaml:"url"` // server url, default: https://ntfy.sh
Topic string `json:"topic" yaml:"topic"` // topic name
Token string `json:"token" yaml:"token"` // access token (optional)
Priority int `json:"priority" yaml:"priority"` // 1..5, default: 3
}
Ntfy - push notifications via ntfy.sh or a self-hosted ntfy server.
type Point ¶
type Point struct {
Status StatusType
Tooltip *string
Timestamp string
TS time.Time
}
Point is a struct that contains the timestamp, status, and tooltip of a host. Used for the chart.
type Pushover ¶
type Pushover struct {
Token string `json:"token" yaml:"token"` // application token
User string `json:"user" yaml:"user"` // user or group key
Priority int `json:"priority" yaml:"priority"` // -2..2, 2 = emergency (repeats until acknowledged)
}
Pushover - push notifications via pushover.net.
type SMTP ¶
type SMTP struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
From string `json:"from" yaml:"from"`
To []string `json:"to" yaml:"to"`
// InsecureSkipVerify disables TLS certificate verification for the SMTP connection.
InsecureSkipVerify bool `json:"insecureSkipVerify" yaml:"insecureSkipVerify"`
}
type SSLDetails ¶
SSLDetails is a struct that contains the expiration date of the SSL certificate. LastOutageDetails is a struct that contains the duration of the last outage.
type Stat ¶
type Stat struct {
ID string
Name *string
Description *string
Host string
Status StatusType
Uptime int
ResponseTime string
Chart Chart
Hosts []Stat
Details *Details
Index int
}
Stat is a struct that contains the stats of a host.
type Stats ¶
type Stats struct {
IsHost bool
Status StatusType
Hosts []Stat
Incidents []*Incident
}
Stats is a struct that contains the stats of all hosts.
type Status ¶
type Status struct {
Value StatusType `json:"value"`
Timestamp time.Time `json:"timestamp"`
}
Status - status structure for Service
type Teams ¶
type Teams struct {
WebhookURL string `json:"webhookURL" yaml:"webhookURL"`
}
Teams - Microsoft Teams incoming webhook (Workflows or legacy connector).
type Twilio ¶
type Twilio struct {
AccountSID string `json:"accountSID" yaml:"accountSID"`
AuthToken string `json:"authToken" yaml:"authToken"`
From string `json:"from" yaml:"from"` // sender number or messaging service sid
To []string `json:"to" yaml:"to"` // recipient numbers
}
Twilio - SMS via Twilio.
type Webhook ¶
type Webhook struct {
URL string `json:"url" yaml:"url"`
Method string `json:"method" yaml:"method"` // default: POST
Headers map[string]string `json:"headers" yaml:"headers"` // extra headers (e.g. Authorization)
}
Webhook - generic HTTP webhook, receives a JSON payload with the event details.