Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConfigHttpHandler ¶
Create a handler function that is usable by http.Handle. This handler will be able response to GET, POST and PUT requests. * GET the list of checks as a JSON array * POST will create a new check and add it to the CheckList. * After any of POST or PUT operation, the configuration is persisted to it's store.
Types ¶
type Alerter ¶
type Alerter interface {
Alert(event *Event)
}
An Alerter raises an alert based on the event it received. An alert is a communication to a system or a user with the information about current's and past check's states. For concrete implementation, see the "github.com/marcw/poller/alert" package.
func NewPagerDutyAlerter ¶
func NewSmtpAlerter ¶
type Backend ¶
type Backend interface { Log(e *Event) Close() }
A backend log checks event. For concrete implementation, see the "github.com/marcw/poller/backend" package.
func NewLibratoBackend ¶
func NewStatsdBackend ¶
Instanciate a new Backend that will send data to a statsd instance
func NewStdoutBackend ¶
func NewStdoutBackend() Backend
func NewSyslogBackend ¶
Create a new SyslogBackend instance.
type Check ¶
type Check struct { Key string // Key (should be unique among same Scheduler Interval time.Duration // Interval between each check UpSince time.Time // Time since the service is up DownSince time.Time // Time since the service is down WasDownFor time.Duration // Time since the service was down WasUpFor time.Duration // Time since the service was up Alert bool // Raise alert if service is down Alerted bool // Is backend already alerted? NotifyFix bool // Notify if service is back up AlertDelay time.Duration // Delay before raising an alert (zero value = NOW) Config *bag.Bag // contains filtered or unexported fields }
func NewCheckFromJSON ¶
NewCheckFromJSON() instantiates a new Check from a JSON representation.
func (*Check) AlertDescription ¶
func (*Check) ShouldAlert ¶
Check if it's time to send the alert. Returns true if it is.
func (*Check) ShouldNotifyFix ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
The Config struct holds and links together a CheckList, a Scheduler and a configuration Store.
type Event ¶
type Event struct { Check *Check // check Duration time.Duration // total duration of check StatusCode int // http status code, if any Time time.Time // time of check Alert bool // true if backend should raise an alert NotifyFix bool // true if backend should notify of service being up again // contains filtered or unexported fields }
Represents the state of a Check after being polled
type Poller ¶
A Poller is the glue between a Scheduler, a Backend, a Probe and a Alerter.
func NewDirectPoller ¶
func NewDirectPoller() Poller
NewDirectPoller() returns a "no-frills" Poller instance. It waits for the next scheduled check, poll it, log it and if alerting is needed, pass it through the alerter.
type Probe ¶
A Probe is a specialized way to poll a check. ie: a HttpProbe will specialize in polling HTTP resources.
func NewUdpProbe ¶
type Scheduler ¶
type Scheduler interface { Schedule(check *Check) error Stop(key string) StopAll() Start() Next() <-chan *Check }
func NewSimpleScheduler ¶
func NewSimpleScheduler() Scheduler
Instantiates a SimpleScheduler which scheduling strategy's fairly basic. For each scheduled check, a new time.Timer is created in its own goroutine.