Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultSettings = CheckSettings{ Alerts: []string{"*"}, Interval: Duration(time.Second * 30), GoodThreshold: 2, FailingThreshold: 2, }
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert interface { // Send dispatches an alert in relation to the given check event. Send(details AlertDetails) error }
Alert defines the method to inform the user of a change to a service - e.g. when it comes up or goes down.
type AlertDetails ¶
type AlertDetails struct { // Text is a short, pre-generated message describing the alert. Text string `json:"text"` // Name is the name of the check that transitioned. Name string `json:"name"` // Type is the type of check involved. Type string `json:"type"` // Config is the user-supplied parameters to the check. Config interface{} `json:"config"` // LastResult is the most recent result that caused the transition. LastResult *Result `json:"last_result"` // PreviousState is the state this check was previously in. PreviousState CheckState `json:"previous_state"` // NewState is the state this check is now in. NewState CheckState `json:"new_state"` }
AlertDetails contains information about a triggered alert
type AlertType ¶
type AlertType interface { // Name returns a name for this type of alert, which must be unique within the plugin. Name() string // Create instantiates a new alert of this type, with the provided configuration. Create(config json.RawMessage) (Alert, error) }
AlertType is one way of notifying people when a service goes down or returns, e.g. posting a webhook, sending a message with Twilio
type Check ¶
type Check interface { // Execute performs the actual check to see if the service is up or not. // It should block until a result is available. Execute() Result }
Check defines the method to see if a service is up or not. The check is persistent - its Execute method will be called repeatedly over the lifetime of the application.
type CheckSettings ¶
type CheckState ¶
type CheckState int
CheckState describes the state of a check.
const ( // StateIndeterminate indicates that it's not clear if the check passed or failed, e.g. it hasn't run yet. StateIndeterminate CheckState = iota // StateGood indicates the service is operating correctly. StateGood // StateFailing indicates a problem with the service. StateFailing )
func (CheckState) MarshalJSON ¶
func (c CheckState) MarshalJSON() ([]byte, error)
func (CheckState) String ¶
func (c CheckState) String() string
String returns an english, lowercase name for the state.
type CheckType ¶
type CheckType interface { // Name returns a name for this type of check, which must be unique within the plugin. Name() string // Create instantiates a new check of this type, with the provided configuration. Create(config json.RawMessage) (Check, error) }
CheckType is one type of check that may be performed to determine the status of a service e.g. making a HTTP request, or opening a TCP socket.
type Config ¶
type Config struct { Defaults CheckSettings `json:"defaults"` Alerts []ConfiguredAlert `json:"alerts"` Checks []ConfiguredCheck `json:"checks"` }
func LoadConfig ¶
type ConfiguredAlert ¶
type ConfiguredAlert struct { Name string `json:"name"` Type string `json:"type"` Params json.RawMessage `json:"params"` }
type ConfiguredCheck ¶
type ConfiguredCheck struct { CheckSettings Name string `json:"name"` Type string `json:"type"` Params json.RawMessage `json:"params"` }
type Plugin ¶
Plugin is the API between plugins and the core. Plugins must provide an exported "Plum()" method in the main package which returns an instance of Plugin. The Plugin in turn then provides its name and the check and alerts it makes available.
type Plum ¶
type Plum struct {
// contains filtered or unexported fields
}
func (*Plum) AddPlugins ¶
func (*Plum) AlertsMatching ¶
func (*Plum) LoadConfig ¶
func (*Plum) RaiseAlerts ¶
func (p *Plum) RaiseAlerts(c *ScheduledCheck, previousState CheckState)
func (*Plum) RunCheck ¶
func (p *Plum) RunCheck(c *ScheduledCheck)
type Result ¶
type Result struct { // State gives the current state of the service. State CheckState `json:"state"` // Time is the time the check was performed. Time time.Time `json:"time"` // Detail is an short, optional explanation of the current state. Detail string `json:"detail,omitempty"` }
Result contains information about a check that was performed.
func FailingResult ¶
FailingResult creates a new result indicating the service is in a bad state.
func GoodResult ¶
func GoodResult() Result
GoodResult creates a new result indicating the service is in a good state.
type ResultHistory ¶
type ResultHistory [10]*Result
func (ResultHistory) State ¶
func (h ResultHistory) State(thresholds map[CheckState]int) CheckState
type ScheduledCheck ¶
type ScheduledCheck struct { Config ConfiguredCheck Check Check LastRun time.Time Settled bool State CheckState // contains filtered or unexported fields }
func (*ScheduledCheck) AddResult ¶
func (c *ScheduledCheck) AddResult(result *Result) ResultHistory
func (*ScheduledCheck) History ¶
func (c *ScheduledCheck) History() ResultHistory
func (*ScheduledCheck) LastResult ¶
func (c *ScheduledCheck) LastResult() *Result
func (*ScheduledCheck) Remaining ¶
func (c *ScheduledCheck) Remaining() time.Duration