Index | Files | Directories

package sched

import ""


Package Files

alertRunner.go chart.go check.go esquery2.go esquery5.go esquery6.go esquery7.go host.go notify.go sched.go silence.go template.go views.go


var DefaultClient *http.Client

DefaultClient is the default http client for requests made from templates. It is configured in cmd/bosun/main.go

var DefaultSched = &Schedule{}

func Autostyle Uses

func Autostyle(i int) chart.Style

Autostyle styles a chart series.

func Close Uses

func Close(reload bool)

func Load Uses

func Load(systemConf conf.SystemConfProvider, ruleConf conf.RuleConfProvider, dataAccess database.DataAccess, annotate backend.Backend, skipLast, quiet bool) error

Load loads a configuration into the default schedule.

func NewIncident Uses

func NewIncident(ak models.AlertKey) *models.IncidentState

func Reset Uses

func Reset()

func Run Uses

func Run() error

Run runs the default schedule.

type Battery Uses

type Battery struct {
    Status            string
    StatusLastUpdated int64

type BoardPowerReading Uses

type BoardPowerReading struct {
    Watts            int64
    WattsLastUpdated int64

type CDPCacheEntries Uses

type CDPCacheEntries []CDPCacheEntry

type CDPCacheEntry Uses

type CDPCacheEntry struct {
    DeviceID   string
    DevicePort string

Cisco Discovery Protocol

type ChassisComponent Uses

type ChassisComponent struct {
    Status            string
    StatusLastUpdated int64

type Context Uses

type Context struct {
    Alert   *conf.Alert
    IsEmail bool
    Errors  []string

    Attachments []*models.Attachment
    ElasticHost string
    // contains filtered or unexported fields

func (*Context) Ack Uses

func (c *Context) Ack() string

Ack returns the URL to acknowledge an alert.

func (c *Context) AzureResourceLink(prefix, rType, rsg, name string) (link string)

AzureResourceLink create a link to Azure's Portal for the resource ( given the subscription identifer (bosun expression prefix), as well as the resource type, group, and name. It uses the azrt expression function under the hood

func (*Context) AzureResourceTags Uses

func (c *Context) AzureResourceTags(prefix, rType, rsg, name string) map[string]string

AzureResourceTags returns the Azure tags associated with the resource as a map

func (*Context) ESQuery Uses

func (c *Context) ESQuery(indexRoot expr.ESIndexer, filter expr.ESQuery, sduration, eduration string, size int) interface{}

func (*Context) ESQueryAll Uses

func (c *Context) ESQueryAll(indexRoot expr.ESIndexer, filter expr.ESQuery, sduration, eduration string, size int) interface{}

func (*Context) Eval Uses

func (c *Context) Eval(v interface{}) interface{}

Eval takes a result or an expression which it evaluates to a result. It returns a value with tags corresponding 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) EvalAll Uses

func (c *Context) EvalAll(v interface{}) interface{}

EvalAll returns the executed expression (or the given result as is).

func (*Context) Expr Uses

func (c *Context) Expr(v string) string

Expr takes an expression in the form of a string, changes the tags to match the context of the alert, and returns a link to the expression page.

func (*Context) Get Uses

func (c *Context) Get(name string) interface{}

func (*Context) GetIncidentState Uses

func (c *Context) GetIncidentState(id int64) *models.IncidentState

GetIncidentState returns an IncidentState so users can include information about previous or other Incidents in alert notifications

func (*Context) GetMeta Uses

func (c *Context) GetMeta(metric, name string, v interface{}) interface{}

GetMeta fetches either metric metadata (if a metric name is provided) or metadata about a tagset key by name

func (*Context) Graph Uses

func (c *Context) Graph(v interface{}, args ...string) interface{}

Graph returns an SVG for the given result (or expression, for which it gets the result) with same tags as the context's tags.

func (*Context) GraphAll Uses

func (c *Context) GraphAll(v interface{}, args ...string) interface{}

GraphAll returns an SVG for the given result (or expression, for which it gets the result).

func (c *Context) GraphLink(v string) string

GraphLink takes an expression in the form of a string, and returns a link to the expression page's graph tab with the time set.

func (*Context) HTTPGet Uses

func (c *Context) HTTPGet(url string) string

func (*Context) HTTPGetJSON Uses

func (c *Context) HTTPGetJSON(url string) *jsonq.JsonQuery

func (*Context) HTTPPost Uses

func (c *Context) HTTPPost(url, bodyType, data string) string

func (*Context) HostView Uses

func (c *Context) HostView(host string) string

HostView returns the URL to the host view page.

func (*Context) Incident Uses

func (c *Context) Incident() string

func (*Context) Last Uses

func (c *Context) Last() interface{}

Hack so template can read IncidentId off of event.

func (*Context) LastError Uses

func (c *Context) LastError() string

LastError gets the most recent error string for the context's Error slice or returns an empty string if the error slice is empty

func (*Context) LeftJoin Uses

func (c *Context) LeftJoin(v ...interface{}) (interface{}, error)

LeftJoin takes slices of results and expressions for which it gets the slices of results. Then it joins the 2nd and higher slice of results onto the first slice of results. Joining is performed by group: a group that includes all tags (with same values) of the first group is a match.

func (*Context) Lookup Uses

func (c *Context) Lookup(table, key string) string

Lookup returns the value for a key in the lookup table for the context's tagset. the returned string may be the representation of an error

func (*Context) LookupAll Uses

func (c *Context) LookupAll(table, key string, group interface{}) string

func (*Context) Rule Uses

func (c *Context) Rule() string

func (*Context) Set Uses

func (c *Context) Set(name string, value interface{}) string

func (*Context) Shorten Uses

func (c *Context) Shorten(link string) string

Shorten uses Bosun's url shortner service to create a shortlink for the given url

func (*Context) SlackAttachment Uses

func (c *Context) SlackAttachment() *slack.Attachment

SlackAttachment creates a new SlackAttachment with fields initalized from the IncidentState.

func (*Context) UseElastic Uses

func (c *Context) UseElastic(host string) interface{}

type Controller Uses

type Controller struct {
    Status            string
    StatusLastUpdated int64

type Disk Uses

type Disk struct {
    UsedBytes        int64
    TotalBytes       int64
    Label            string `json:",omitempty"`
    StatsLastUpdated int64

type EpochAction Uses

type EpochAction struct {
    User    string
    Message string
    Time    int64
    Type    models.ActionType

func MakeEpochAction Uses

func MakeEpochAction(a models.Action) EpochAction

type EventSummary Uses

type EventSummary struct {
    Status models.Status
    Time   int64

func MakeEventSummary Uses

func MakeEventSummary(e models.Event) (EventSummary, bool)

EventSummary is like a models.Event but strips the Results and Unevaluated

type Hardware Uses

type Hardware struct {
    Memory            map[string]*MemoryModule     `json:",omitempty"`
    ChassisComponents map[string]*ChassisComponent `json:",omitempty"`
    Storage           struct {
        Controllers   map[string]*Controller   `json:",omitempty"`
        PhysicalDisks map[string]*PhysicalDisk `json:",omitempty"`
        VirtualDisks  map[string]*VirtualDisk  `json:",omitempty"`
        Batteries     map[string]*Battery
    Temps             map[string]*Temp
    PowerSupplies     map[string]*PowerSupply `json:",omitempty"`
    BoardPowerReading *BoardPowerReading

type HostData Uses

type HostData struct {
    CPU struct {
        Logical          int64 `json:",omitempty"`
        Physical         int64 `json:",omitempty"`
        PercentUsed      float64
        StatsLastUpdated int64
        Processors       map[string]string `json:",omitempty"`
    ICMPData      map[string]*ICMPData
    Disks         map[string]*Disk
    OpenIncidents []IncidentStatus
    Interfaces    map[string]*HostInterface
    UptimeSeconds int64     `json:",omitempty"`
    Manufacturer  string    `json:",omitempty"`
    Hardware      *Hardware `json:",omitempty"`
    Memory        struct {
        TotalBytes       float64
        UsedBytes        float64
        StatsLastUpdated int64
    Processes map[string]*Process       `json:",omitempty"`
    Services  map[string]*ServiceStatus `json:",omitempty"`
    Model     string                    `json:",omitempty"`
    Name      string                    `json:",omitempty"`
    OS        struct {
        Caption string `json:",omitempty"`
        Version string `json:",omitempty"`
    SerialNumber string   `json:",omitempty"`
    VM           *VM      `json:",omitempty"`
    Guests       []string `json:",omitempty"`

func (*HostData) Clean Uses

func (hd *HostData) Clean()

Clean sets certain maps to nil so they don't get marshalled in JSON The logic is to remove ones that monitored devices might lack, such as hardware information

type HostInterface Uses

type HostInterface struct {
    Description      string          `json:",omitempty"`
    IPAddresses      []string        `json:",omitempty"`
    RemoteMacs       []string        `json:",omitempty"`
    CDPCacheEntries  CDPCacheEntries `json:",omitempty"`
    Inbps            int64
    LinkSpeed        int64  `json:",omitempty"`
    MAC              string `json:",omitempty"`
    Master           string `json:",omitempty"`
    Name             string `json:",omitempty"`
    Outbps           int64
    StatsLastUpdated int64
    Type             string

type ICMPData Uses

type ICMPData struct {
    TimedOut               bool
    TimedOutLastUpdated    int64
    DNSResolved            bool
    DNSResolvedLastUpdated int64
    RTTMS                  float64
    RTTLastUpdated         int64

type IncidentStatus Uses

type IncidentStatus struct {
    IncidentID         int64
    Active             bool
    AlertKey           models.AlertKey
    Status             models.Status
    StatusTime         int64
    Subject            string
    Silenced           bool
    LastAbnormalStatus models.Status
    LastAbnormalTime   models.Epoch
    NeedsAck           bool

type IncidentSummaryView Uses

type IncidentSummaryView struct {
    Id                     int64
    Subject                string
    Start                  int64
    AlertName              string
    Tags                   opentsdb.TagSet
    TagsString             string
    CurrentStatus          models.Status
    WorstStatus            models.Status
    LastAbnormalStatus     models.Status
    LastAbnormalTime       models.Epoch
    Unevaluated            bool
    NeedAck                bool
    Silenced               bool
    Actions                []EpochAction
    Events                 []EventSummary
    WarnNotificationChains [][]string
    CritNotificationChains [][]string
    LastStatusTime         int64

func MakeIncidentSummary Uses

func MakeIncidentSummary(c conf.RuleConfProvider, s SilenceTester, is *models.IncidentState) (*IncidentSummaryView, error)

func (IncidentSummaryView) Ask Uses

func (is IncidentSummaryView) Ask(filter string) (bool, error)

type IncidentWithTemplates Uses

type IncidentWithTemplates struct {

type MemoryModule Uses

type MemoryModule struct {
    // Maybe this should be a bool but that might be limiting
    Status            string
    StatusLastUpdated int64
    Size              string

type PhysicalDisk Uses

type PhysicalDisk struct {
    Status            string
    StatusLastUpdated int64

type PowerSupply Uses

type PowerSupply struct {
    Status                     string
    StatusLastUpdated          int64
    Amps                       float64
    AmpsLastUpdated            int64
    Volts                      float64
    VoltsLastUpdated           int64
    metadata.HWPowerSupplyMeta //Should be renamed to Meta

type Process Uses

type Process struct {
    CPUPercentUsed              float64
    CPUPercentLastUpdated       int64
    UsedRealBytes               int64
    UsedRealBytesLastUpdated    int64
    UsedVirtualBytes            int64
    UsedVirtualBytesLastUpdated int64
    Count                       int64
    CountLastUpdated            int64

type RunHistory Uses

type RunHistory struct {
    Cache    *cache.Cache
    Start    time.Time
    Backends *expr.Backends
    Events   map[models.AlertKey]*models.Event
    // contains filtered or unexported fields

func (*RunHistory) AtTime Uses

func (rh *RunHistory) AtTime(t time.Time) *RunHistory

AtTime creates a new RunHistory starting at t with the same context and events as rh.

type Schedule Uses

type Schedule struct {
    RuleConf   conf.RuleConfProvider
    SystemConf conf.SystemConfProvider

    Search *search.Search

    LastCheck time.Time

    DataAccess database.DataAccess
    // contains filtered or unexported fields

func (*Schedule) ActionByAlertKey Uses

func (s *Schedule) ActionByAlertKey(user, message string, t models.ActionType, at *time.Time, ak models.AlertKey) error

func (*Schedule) ActionByIncidentId Uses

func (s *Schedule) ActionByIncidentId(user, message string, t models.ActionType, at *time.Time, id int64) (models.AlertKey, error)

func (*Schedule) ActionNotify Uses

func (s *Schedule) ActionNotify(at models.ActionType, user, message string, aks []models.AlertKey) error

func (*Schedule) AddSilence Uses

func (s *Schedule) AddSilence(start, end time.Time, alert, tagList string, forget, confirm bool, edit, user, message string) (map[models.AlertKey]bool, error)

func (*Schedule) AlertSuccessful Uses

func (s *Schedule) AlertSuccessful(name string) bool

func (*Schedule) CheckAlert Uses

func (s *Schedule) CheckAlert(T miniprofiler.Timer, r *RunHistory, a *conf.Alert) (cancelled bool)

func (*Schedule) CheckExpr Uses

func (s *Schedule) CheckExpr(T miniprofiler.Timer, rh *RunHistory, a *conf.Alert, e *expr.Expr, checkStatus models.Status, ignore models.AlertKeys) (alerts models.AlertKeys, err error, cancelled bool)

func (*Schedule) CheckNotifications Uses

func (s *Schedule) CheckNotifications() time.Time

CheckNotifications processes past notification events. It returns the next time a notification is needed.

func (*Schedule) ClearErrors Uses

func (s *Schedule) ClearErrors(alert string) error

func (*Schedule) ClearSilence Uses

func (s *Schedule) ClearSilence(id string) error

func (*Schedule) Close Uses

func (s *Schedule) Close(reload bool)

func (*Schedule) CollectStates Uses

func (s *Schedule) CollectStates()

CollectStates sends various state information to bosun with collect.

func (*Schedule) Data Uses

func (s *Schedule) Data(rh *RunHistory, st *models.IncidentState, a *conf.Alert, isEmail bool) *Context

func (*Schedule) DeleteMetadata Uses

func (s *Schedule) DeleteMetadata(tags opentsdb.TagSet, name string) error

func (*Schedule) ExecuteAll Uses

func (s *Schedule) ExecuteAll(rh *RunHistory, a *conf.Alert, st *models.IncidentState, recordTimes bool) (*models.RenderedTemplates, []error)

func (*Schedule) ExecuteBadTemplate Uses

func (s *Schedule) ExecuteBadTemplate(errs []error, rh *RunHistory, a *conf.Alert, st *models.IncidentState) (subject, body string, err error)

func (*Schedule) ExecuteBody Uses

func (s *Schedule) ExecuteBody(rh *RunHistory, a *conf.Alert, st *models.IncidentState, isEmail bool) (string, []*models.Attachment, error)

func (*Schedule) ExecuteSubject Uses

func (s *Schedule) ExecuteSubject(rh *RunHistory, a *conf.Alert, st *models.IncidentState, isEmail bool) (string, error)

func (*Schedule) ExprGraph Uses

func (s *Schedule) ExprGraph(t miniprofiler.Timer, unit string, res []*expr.Result) (chart.Chart, error)

func (*Schedule) ExprPNG Uses

func (s *Schedule) ExprPNG(t miniprofiler.Timer, w io.Writer, width, height int, unit string, res []*expr.Result) error

func (*Schedule) ExprSVG Uses

func (s *Schedule) ExprSVG(t miniprofiler.Timer, w io.Writer, width, height int, unit string, res []*expr.Result) error

func (*Schedule) GetCheckFrequency Uses

func (s *Schedule) GetCheckFrequency(alertName string) (time.Duration, error)

GetCheckFrequency returns the duration between checks for the named alert. If the alert does not exist an error is returned.

func (*Schedule) GetLockStatus Uses

func (s *Schedule) GetLockStatus() (holder string, since time.Time)

func (*Schedule) GetMetadata Uses

func (s *Schedule) GetMetadata(metric string, subset opentsdb.TagSet) ([]metadata.Metasend, error)

func (*Schedule) GetOpenStates Uses

func (s *Schedule) GetOpenStates() (States, error)

func (*Schedule) GetQuiet Uses

func (s *Schedule) GetQuiet() bool

func (*Schedule) GetSilence Uses

func (s *Schedule) GetSilence(T miniprofiler.Timer, ak models.AlertKey) *models.Silence

func (*Schedule) GetUnknownAndUnevaluatedAlertKeys Uses

func (s *Schedule) GetUnknownAndUnevaluatedAlertKeys(alert string) (unknown, uneval []models.AlertKey)

func (*Schedule) Host Uses

func (s *Schedule) Host(filter string) (map[string]*HostData, error)

func (*Schedule) Init Uses

func (s *Schedule) Init(name string, systemConf conf.SystemConfProvider, ruleConf conf.RuleConfProvider, dataAccess database.DataAccess, annotate backend.Backend, skipLast, quiet bool) error

func (*Schedule) Lock Uses

func (s *Schedule) Lock(method string)

func (*Schedule) MarshalGroups Uses

func (s *Schedule) MarshalGroups(T miniprofiler.Timer, filter string) (*StateGroups, error)

func (*Schedule) MetadataMetrics Uses

func (s *Schedule) MetadataMetrics(metric string) (*database.MetricMetadata, error)

func (*Schedule) NewRunHistory Uses

func (s *Schedule) NewRunHistory(start time.Time, cache *cache.Cache) *RunHistory

func (*Schedule) Notify Uses

func (s *Schedule) Notify(st *models.IncidentState, rt *models.RenderedTemplates, n *conf.Notification) bool

Notify puts a rendered notification in the schedule's pendingNotifications queue

func (*Schedule) PutMetadata Uses

func (s *Schedule) PutMetadata(k metadata.Metakey, v interface{}) error

func (*Schedule) QueueNotification Uses

func (s *Schedule) QueueNotification(ak models.AlertKey, n *conf.Notification, time time.Time) error

QueueNotification persists a notification to the datastore to be sent in the future. This happens when there are notification chains or an alert is unevaluated due to a dependency.

func (*Schedule) Reset Uses

func (s *Schedule) Reset()

func (*Schedule) Run Uses

func (s *Schedule) Run() error

Run should be called once (and only once) to start all schedule activity.

func (*Schedule) RunHistory Uses

func (s *Schedule) RunHistory(r *RunHistory)

RunHistory processes an event history and triggers notifications if needed.

func (*Schedule) Silenced Uses

func (s *Schedule) Silenced() SilenceTester

Silenced returns a function that will determine if the given alert key is silenced at the current time. A function is returned to avoid needing to enumerate all alert keys unneccesarily.

func (*Schedule) Unlock Uses

func (s *Schedule) Unlock()

type ServiceStatus Uses

type ServiceStatus struct {
    Running            bool
    RunningLastUpdated int64

type SilenceTester Uses

type SilenceTester func(models.AlertKey) *models.Silence

type StateGroup Uses

type StateGroup struct {
    Active        bool `json:",omitempty"`
    Status        models.Status
    CurrentStatus models.Status
    Silenced      bool
    IsError       bool                  `json:",omitempty"`
    Subject       string                `json:",omitempty"`
    Alert         string                `json:",omitempty"`
    AlertKey      models.AlertKey       `json:",omitempty"`
    Ago           string                `json:",omitempty"`
    State         *models.IncidentState `json:",omitempty"`
    Children      []*StateGroup         `json:",omitempty"`

type StateGroups Uses

type StateGroups struct {
    Groups struct {
        NeedAck      []*StateGroup `json:",omitempty"`
        Acknowledged []*StateGroup `json:",omitempty"`
    TimeAndDate                   []int
    FailingAlerts, UnclosedErrors int

type StateTuple Uses

type StateTuple struct {
    NeedAck       bool
    Active        bool
    Status        models.Status
    CurrentStatus models.Status
    Silenced      bool

type States Uses

type States map[models.AlertKey]*models.IncidentState

func (States) GroupSets Uses

func (states States) GroupSets(minGroup int) map[string]models.AlertKeys

GroupSets returns slices of TagSets, grouped by most common ancestor. Those with no shared ancestor are grouped by alert name.

func (States) GroupStates Uses

func (states States) GroupStates(silenced SilenceTester) map[StateTuple]States

GroupStates groups by NeedAck, Active, Status, and Silenced.

type Temp Uses

type Temp struct {
    Celsius            float64
    Status             string
    StatusLastUpdated  int64
    CelsiusLastUpdated int64

type VM Uses

type VM struct {
    Host                  string `json:",omitempty"`
    PowerState            string `json:",omitempty"`
    PowerStateLastUpdated int64  `json:",omitempty"`

type VirtualDisk Uses

type VirtualDisk struct {
    Status            string
    StatusLastUpdated int64


slackPackage slack is for creating slack notifications inside of Bosun templates

Package sched imports 45 packages (graph) and is imported by 5 packages. Updated 2020-07-02. Refresh now. Tools for package owners.