monitors

package
v1.1.1-0...-162d55b Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MonitorStatusUp           = "up"
	MonitorStatusDown         = "down"
	MonitorStatusNotSaturated = "unsaturated"
)
View Source
const DefaultInterval = time.Second * 60
View Source
const DefaultTimeout = time.Second
View Source
const HistorySize = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractMonitor

type AbstractMonitor struct {
	Name   string
	Target string

	// (default)http / dns
	Type   string
	Strict bool

	Interval time.Duration
	Timeout  time.Duration
	Params   map[string]interface{}

	// Templating stuff
	Template MonitorTemplates

	// Threshold = percentage / number of down incidents
	Threshold      float32
	ThresholdCount bool `mapstructure:"threshold_count"`
	// contains filtered or unexported fields
}

AbstractMonitor data model

func (*AbstractMonitor) Describe

func (mon *AbstractMonitor) Describe() []string

func (*AbstractMonitor) GetLastStatus

func (mon *AbstractMonitor) GetLastStatus() MonitorStatus

func (*AbstractMonitor) GetMonitor

func (mon *AbstractMonitor) GetMonitor() *AbstractMonitor

func (*AbstractMonitor) GetStatus

func (mon *AbstractMonitor) GetStatus() MonitorStatus

TODO: test AnalyseData decides if the monitor is statistically up or down and creates / resolves an incident

func (*AbstractMonitor) GetTestFunc

func (mon *AbstractMonitor) GetTestFunc() MonitorTestFunc

func (*AbstractMonitor) Start

func (mon *AbstractMonitor) Start(testFunc MonitorTestFunc, wg *sync.WaitGroup, tickFunc MonitorTickFunc, immediate bool)

func (*AbstractMonitor) Stop

func (mon *AbstractMonitor) Stop()

func (*AbstractMonitor) UpdateLastStatus

func (mon *AbstractMonitor) UpdateLastStatus(status MonitorStatus) (old MonitorStatus)

func (*AbstractMonitor) Validate

func (mon *AbstractMonitor) Validate(validate backendValidateFunc) []string

type DNSAnswer

type DNSAnswer struct {
	Regex string

	Exact string
	// contains filtered or unexported fields
}

type DNSMonitor

type DNSMonitor struct {
	AbstractMonitor `mapstructure:",squash"`

	// IP:port format or blank to use system defined DNS
	DNS string

	// A(default), AAAA, MX, ...
	Question string

	Answers []DNSAnswer
	// contains filtered or unexported fields
}

func (*DNSMonitor) Validate

func (monitor *DNSMonitor) Validate(validate backendValidateFunc) []string

type HTTPMonitor

type HTTPMonitor struct {
	AbstractMonitor `mapstructure:",squash"`

	Method             string
	ExpectedStatusCode int `mapstructure:"expected_status_code"`
	Headers            map[string]string

	// compiled to Regexp
	ExpectedBody string `mapstructure:"expected_body"`
	// contains filtered or unexported fields
}

func (*HTTPMonitor) Describe

func (mon *HTTPMonitor) Describe() []string

func (*HTTPMonitor) Validate

func (mon *HTTPMonitor) Validate(validate backendValidateFunc) []string

TODO: test

type MessageTemplate

type MessageTemplate struct {
	Subject string `json:"subject"`
	Message string `json:"message"`
	// contains filtered or unexported fields
}

func (*MessageTemplate) Compile

func (t *MessageTemplate) Compile() error

TODO: test

func (*MessageTemplate) Exec

func (t *MessageTemplate) Exec(data interface{}) (string, string)

func (*MessageTemplate) SetDefault

func (t *MessageTemplate) SetDefault(d MessageTemplate)

type MonitorInterface

type MonitorInterface interface {
	Start(MonitorTestFunc, *sync.WaitGroup, MonitorTickFunc, bool)
	Stop()

	Validate(validate backendValidateFunc) []string
	Describe() []string

	GetMonitor() *AbstractMonitor
	GetTestFunc() MonitorTestFunc
	GetLastStatus() MonitorStatus
	UpdateLastStatus(status MonitorStatus) (old MonitorStatus)
	// contains filtered or unexported methods
}

type MonitorStatus

type MonitorStatus string

type MonitorTemplates

type MonitorTemplates struct {
	Investigating MessageTemplate
	Fixed         MessageTemplate
}

type MonitorTestFunc

type MonitorTestFunc func() (up bool, errs []error)

type MonitorTickFunc

type MonitorTickFunc func(monitor MonitorInterface, status MonitorStatus, errs []error, lag int64)

Jump to

Keyboard shortcuts

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