Documentation
¶
Index ¶
- Constants
- func GetMonitorType(t string) string
- type AbstractMonitor
- func (mon *AbstractMonitor) AnalyseData()
- func (mon *AbstractMonitor) ClockStart(cfg *CachetMonitor, iface MonitorInterface, wg *sync.WaitGroup)
- func (mon *AbstractMonitor) ClockStop()
- func (mon *AbstractMonitor) Describe() []string
- func (mon *AbstractMonitor) GetMonitor() *AbstractMonitor
- func (mon *AbstractMonitor) Validate() []string
- type CachetAPI
- type CachetMonitor
- type CachetResponse
- type DNSAnswer
- type DNSMonitor
- type HTTPMonitor
- type Incident
- type MessageTemplate
- type MonitorInterface
Constants ¶
View Source
const DefaultInterval = time.Second * 60
View Source
const DefaultTimeFormat = "15:04:05 Jan 2 MST"
View Source
const DefaultTimeout = time.Second
View Source
const HistorySize = 10
Variables ¶
This section is empty.
Functions ¶
func GetMonitorType ¶
Types ¶
type AbstractMonitor ¶
type AbstractMonitor struct {
Name string
Target string
// (default)http / dns
Type string
Strict bool
Interval time.Duration
Timeout time.Duration
MetricID int `mapstructure:"metric_id"`
ComponentID int `mapstructure:"component_id"`
// Templating stuff
Template struct {
Investigating MessageTemplate
Fixed MessageTemplate
}
// Threshold = percentage / number of down incidents
Threshold float32
ThresholdCount bool `mapstructure:"threshold_count"`
// contains filtered or unexported fields
}
AbstractMonitor data model
func (*AbstractMonitor) AnalyseData ¶
func (mon *AbstractMonitor) AnalyseData()
TODO: test AnalyseData decides if the monitor is statistically up or down and creates / resolves an incident
func (*AbstractMonitor) ClockStart ¶
func (mon *AbstractMonitor) ClockStart(cfg *CachetMonitor, iface MonitorInterface, wg *sync.WaitGroup)
func (*AbstractMonitor) ClockStop ¶
func (mon *AbstractMonitor) ClockStop()
func (*AbstractMonitor) Describe ¶
func (mon *AbstractMonitor) Describe() []string
func (*AbstractMonitor) GetMonitor ¶
func (mon *AbstractMonitor) GetMonitor() *AbstractMonitor
func (*AbstractMonitor) Validate ¶
func (mon *AbstractMonitor) Validate() []string
type CachetAPI ¶
type CachetAPI struct {
URL string `json:"url"`
Token string `json:"token"`
Insecure bool `json:"insecure"`
}
func (CachetAPI) NewRequest ¶
func (api CachetAPI) NewRequest(requestType, url string, reqBody []byte) (*http.Response, CachetResponse, error)
TODO: test NewRequest wraps http.NewRequest
func (CachetAPI) SendMetric ¶
SendMetric adds a data point to a cachet monitor
type CachetMonitor ¶
type CachetMonitor struct {
SystemName string `json:"system_name" yaml:"system_name"`
DateFormat string `json:"date_format" yaml:"date_format"`
API CachetAPI `json:"api"`
RawMonitors []map[string]interface{} `json:"monitors" yaml:"monitors"`
Monitors []MonitorInterface `json:"-" yaml:"-"`
Immediate bool `json:"-" yaml:"-"`
}
type CachetResponse ¶
type CachetResponse struct {
Data json.RawMessage `json:"data"`
}
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() []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
type Incident ¶
type Incident struct {
ID int `json:"id"`
Name string `json:"name"`
Message string `json:"message"`
Status int `json:"status"`
Visible int `json:"visible"`
Notify bool `json:"notify"`
ComponentID int `json:"component_id"`
ComponentStatus int `json:"component_status"`
}
Incident Cachet data model
func (*Incident) GetComponentStatus ¶
func (incident *Incident) GetComponentStatus(cfg *CachetMonitor) (int, error)
func (*Incident) Send ¶
func (incident *Incident) Send(cfg *CachetMonitor) error
Send - Create or Update incident
func (*Incident) SetIdentified ¶
func (incident *Incident) SetIdentified()
SetIdentified sets status to Identified
func (*Incident) SetInvestigating ¶
func (incident *Incident) SetInvestigating()
SetInvestigating sets status to Investigating
func (*Incident) SetWatching ¶
func (incident *Incident) SetWatching()
SetWatching sets status to Watching
type MessageTemplate ¶
type MessageTemplate struct {
Subject string `json:"subject"`
Message string `json:"message"`
// contains filtered or unexported fields
}
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 {
ClockStart(*CachetMonitor, MonitorInterface, *sync.WaitGroup)
ClockStop()
Validate() []string
GetMonitor() *AbstractMonitor
Describe() []string
// contains filtered or unexported methods
}
Click to show internal directories.
Click to hide internal directories.
