Documentation ¶
Index ¶
- Constants
- Variables
- func Autostyle(i int) chart.Style
- func Load(c *conf.Conf)
- func Match(pattern, name string) (matched bool, err error)
- func Run() error
- type Action
- type ActionType
- type Context
- func (c *Context) Ack() string
- func (c *Context) Eval(v interface{}) (interface{}, error)
- func (c *Context) EvalAll(v interface{}) (interface{}, error)
- func (c *Context) Expr(v string) (string, error)
- func (c *Context) GetMeta(metric, name string, v interface{}) (interface{}, error)
- func (c *Context) Graph(v interface{}) (interface{}, error)
- func (c *Context) GraphAll(v interface{}) (interface{}, error)
- func (c *Context) HostView(host string) string
- func (c *Context) IsEmail() bool
- func (c *Context) LeftJoin(q ...interface{}) (interface{}, error)
- func (c *Context) Lookup(table, key string) (string, error)
- func (c *Context) LookupAll(table, key string, group interface{}) (string, error)
- func (c *Context) Rule() (string, error)
- type Event
- type HostData
- type HostInterface
- type MetadataDescription
- type MetadataMetric
- type Metavalue
- type Metavalues
- type Result
- type RunHistory
- type Schedule
- func (s *Schedule) Action(user, message string, t ActionType, ak expr.AlertKey) error
- func (s *Schedule) AddNotification(ak expr.AlertKey, n *conf.Notification, started time.Time)
- func (s *Schedule) AddSilence(start, end time.Time, alert, tagList string, confirm bool, edit string) (map[expr.AlertKey]bool, error)
- func (s *Schedule) Check(T miniprofiler.Timer, now time.Time) (time.Duration, error)
- func (s *Schedule) CheckAlert(T miniprofiler.Timer, r *RunHistory, a *conf.Alert)
- func (s *Schedule) CheckExpr(T miniprofiler.Timer, rh *RunHistory, a *conf.Alert, e *expr.Expr, ...) (alerts expr.AlertKeys, err error)
- func (s *Schedule) CheckNotifications(rh *RunHistory) time.Duration
- func (s *Schedule) CheckUnknown()
- func (s *Schedule) ClearSilence(id string) error
- func (s *Schedule) Data(rh *RunHistory, st *State, a *conf.Alert, isEmail bool) *Context
- func (s *Schedule) ExecuteBody(w io.Writer, rh *RunHistory, a *conf.Alert, st *State, isEmail bool) ([]*conf.Attachment, error)
- func (s *Schedule) ExecuteSubject(w io.Writer, rh *RunHistory, a *conf.Alert, st *State) error
- func (s *Schedule) ExprGraph(t miniprofiler.Timer, res []*expr.Result, q string, now time.Time) (chart.Chart, error)
- func (s *Schedule) ExprPNG(t miniprofiler.Timer, w io.Writer, width, height int, res []*expr.Result, ...) error
- func (s *Schedule) ExprSVG(t miniprofiler.Timer, w io.Writer, width, height int, res []*expr.Result, ...) error
- func (s *Schedule) GetMetadata(metric string, subset opentsdb.TagSet) []metadata.Metasend
- func (s *Schedule) Host(filter string) map[string]*HostData
- func (s *Schedule) Init(c *conf.Conf)
- func (s *Schedule) Load(c *conf.Conf)
- func (s *Schedule) MarshalGroups(filter string) (*StateGroups, error)
- func (s *Schedule) MetadataMetrics() map[string]*MetadataMetric
- func (s *Schedule) NewRunHistory(start time.Time) *RunHistory
- func (s *Schedule) Notify(st *State, n *conf.Notification)
- func (s *Schedule) PingHosts()
- func (s *Schedule) Poll()
- func (s *Schedule) PutMetadata(k metadata.Metakey, v interface{})
- func (s *Schedule) RestoreState()
- func (s *Schedule) Run() error
- func (s *Schedule) RunHistory(r *RunHistory)
- func (s *Schedule) Save()
- func (s *Schedule) Silenced() map[expr.AlertKey]time.Time
- func (s *Schedule) Status(ak expr.AlertKey) *State
- func (s *Schedule) URL() *url.URL
- type Silence
- type State
- type StateGroup
- type StateGroups
- type StateTuple
- type States
- type Status
Constants ¶
const (
Separator = filepath.Separator
)
Variables ¶
var DefaultSched = &Schedule{}
var ErrBadPattern = errors.New("syntax error in pattern")
ErrBadPattern indicates a globbing pattern was malformed.
Functions ¶
func Match ¶
Match returns true if name matches any of the patterns. The pattern syntax is:
pattern: { term } [ '|' { term } '|' ... ] term: '*' matches any sequence of non-Separator characters '?' matches any single non-Separator character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '\\', '[') '\\' c matches character c character-range: c matches character c (c != '\\', '-', ']') '\\' c matches character c lo '-' hi matches character c for lo <= c <= hi
Match requires pattern to match all of name, not just a substring. The only possible returned error is ErrBadPattern, when pattern is malformed.
Types ¶
type ActionType ¶
type ActionType int
const ( ActionNone ActionType = iota ActionAcknowledge ActionClose ActionForget )
func (ActionType) MarshalJSON ¶
func (a ActionType) MarshalJSON() ([]byte, error)
func (ActionType) String ¶
func (a ActionType) String() string
type Context ¶
type Context struct { *State Alert *conf.Alert Attachments []*conf.Attachment // contains filtered or unexported fields }
func (*Context) Eval ¶
Eval executes the given expression and returns a value with corresponding tags to the context's tags. If no such result is found, the first result with nil tags is returned. If no such result is found, nil is returned.
func (*Context) Lookup ¶
Lookup returns the value for a key in the lookup table for the context's tagset.
type HostData ¶
type HostData struct { CPU struct { Logical int64 `json:",omitempty"` Physical int64 `json:",omitempty"` Processors map[string]string `json:",omitempty"` } Interfaces map[string]*HostInterface LastBoot int64 `json:",omitempty"` LastUpdate int64 `json:",omitempty"` Manufacturer string `json:",omitempty"` Memory struct { Modules map[string]string `json:",omitempty"` Total int64 `json:",omitempty"` } Metrics []string Model string `json:",omitempty"` Name string `json:",omitempty"` OS struct { Caption string `json:",omitempty"` Version string `json:",omitempty"` } SerialNumber string `json:",omitempty"` }
type HostInterface ¶
type MetadataDescription ¶
type MetadataMetric ¶
type MetadataMetric struct { Unit string `json:",omitempty"` Type string `json:",omitempty"` Description []*MetadataDescription }
type Metavalues ¶
type Metavalues []Metavalue
func (Metavalues) Last ¶
func (m Metavalues) Last() *Metavalue
type RunHistory ¶
type Schedule ¶
type Schedule struct { sync.Mutex Conf *conf.Conf Notifications map[expr.AlertKey]map[string]time.Time Silence map[string]*Silence Group map[time.Time]expr.AlertKeys Metadata map[metadata.Metakey]Metavalues Search *search.Search Lookups map[string]*expr.Lookup LastCheck time.Time // contains filtered or unexported fields }
func (*Schedule) AddNotification ¶
func (*Schedule) AddSilence ¶
func (*Schedule) Check ¶
Check evaluates all critical and warning alert rules. An error is returned if the check could not be performed.
func (*Schedule) CheckAlert ¶
func (s *Schedule) CheckAlert(T miniprofiler.Timer, r *RunHistory, a *conf.Alert)
func (*Schedule) CheckNotifications ¶
func (s *Schedule) CheckNotifications(rh *RunHistory) time.Duration
CheckNotifications processes past notification events. It returns the duration until the soonest notification triggers.
func (*Schedule) CheckUnknown ¶
func (s *Schedule) CheckUnknown()
CheckUnknown checks for unknown alerts.
func (*Schedule) ClearSilence ¶
func (*Schedule) ExecuteBody ¶
func (*Schedule) ExecuteSubject ¶
func (*Schedule) GetMetadata ¶
func (*Schedule) MarshalGroups ¶
func (s *Schedule) MarshalGroups(filter string) (*StateGroups, error)
func (*Schedule) MetadataMetrics ¶
func (s *Schedule) MetadataMetrics() map[string]*MetadataMetric
func (*Schedule) NewRunHistory ¶
func (s *Schedule) NewRunHistory(start time.Time) *RunHistory
func (*Schedule) PutMetadata ¶
func (*Schedule) RestoreState ¶
func (s *Schedule) RestoreState()
Restores notification and alert state from the file on disk.
func (*Schedule) RunHistory ¶
func (s *Schedule) RunHistory(r *RunHistory)
RunHistory processes an event history and trisggers notifications if needed.
type Silence ¶
func (*Silence) MarshalJSON ¶
type State ¶
type State struct { *Result // Most recent last. History []Event `json:",omitempty"` Actions []Action `json:",omitempty"` Touched time.Time Alert string // helper data since AlertKeys don't serialize to JSON well Tags string // string representation of Group Group opentsdb.TagSet Subject string NeedAck bool Open bool Forgotten bool }
func (*State) AbnormalStatus ¶
AbnormalStatus returns the most recent non-normal status, or StNone if none found.
type StateGroup ¶
type StateGroups ¶
type StateGroups struct { Groups struct { NeedAck []*StateGroup `json:",omitempty"` Acknowledged []*StateGroup `json:",omitempty"` } TimeAndDate []int Silenced map[expr.AlertKey]time.Time }
type StateTuple ¶
type States ¶
func (States) GroupSets ¶
GroupSets returns slices of TagSets, grouped by most common ancestor. Those with no shared ancestor are grouped by alert name.
func (States) GroupStates ¶
func (s States) GroupStates() map[StateTuple]States
GroupStates groups by NeedAck, Active, and Status.