remotemonitor

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Location is the unique location name of this monitor.
	Location string

	// PublicURL is the publicly-routable base URL for this monitor.
	// It must match what is configured for twilio SMS.
	PublicURL string

	// ListenAddr is the address and port to bind to.
	ListenAddr string

	// CheckMinutes denotes the number of minutes between checks (for all instances).
	CheckMinutes int

	Twilio struct {
		AccountSID string
		AuthToken  string
		FromNumber string
	}

	// Instances determine what remote GoAlert instances will be monitored and send potential errors.
	Instances []Instance
}

Config contains all necessary values for remote monitoring.

type Instance

type Instance struct {
	// Location must be unique.
	Location string

	// TestAPIKey is used to create test alerts.
	// The service it points to should have an escalation policy that allows at least 60 seconds
	// before escalating to a human. It should send initial notifications to the monitor via SMS.
	TestAPIKey string

	// ErrorAPIKey is the key used to create new alerts for encountered errors.
	ErrorAPIKey string

	// HeartbeatURLs are sent a POST request after a successful test cycle for this instance.
	HeartbeatURLs []string

	// PublicURL should point to the publicly-routable base of the instance.
	PublicURL string

	// Phone is the number that incomming SMS messages from this instances will be from.
	// Must be unique between all instances.
	Phone string

	// ErrorsOnly, if set, will disable creating test alerts for the instance. Any error-alerts will
	// still be generated, however.
	ErrorsOnly bool
}

An Instance represents a running remote GoAlert instance to monitor.

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor will check for functionality and communication between itself and one or more instances. Each monitor should have a unique phone number and location.

func NewMonitor

func NewMonitor(cfg Config) (*Monitor, error)

NewMonitor creates and starts a new Monitor with the given Config.

func (*Monitor) ServeHTTP

func (m *Monitor) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Monitor) Shutdown

func (m *Monitor) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the monitor, waiting for any in-flight checks to complete.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL