Documentation ¶
Index ¶
- Constants
- Variables
- func HandleSignal(sig os.Signal, handler func(*Inspeqtor))
- func HandleSignals()
- type Action
- type ActionBuilder
- type AlertRoute
- type Checkable
- type ConfigFile
- type Controllable
- type EmailEvent
- type EmailNotifier
- type EmailSender
- type Entity
- type Event
- type EventType
- type Eventable
- type GlobalConfig
- type Host
- type Inspeqtor
- type NotifierBuilder
- type NullNotifier
- type Operator
- type Reloader
- type Restarter
- type Rule
- func (rule *Rule) Check(cycleTime uint) *Event
- func (r *Rule) Consequence() string
- func (r *Rule) DisplayState() string
- func (r *Rule) EntityName() string
- func (r *Rule) FetchDisplayCurrentValue() string
- func (r *Rule) FetchLatestMetricValue() float64
- func (r *Rule) Metric() string
- func (r *Rule) Reset()
- type RuleState
- type Service
- func (svc *Service) Collect(silenced bool, completeCallback func(Checkable))
- func (s *Service) Reload() error
- func (svc *Service) Resolve(mgrs []services.InitSystem) error
- func (s *Service) Restart() error
- func (s *Service) SetMetrics(newStore metrics.Store)
- func (s *Service) String() string
- func (s *Service) Transition(ps *services.ProcessStatus, emitter func(EventType))
- func (s *Service) Verify() []*Event
Constants ¶
const (
VERSION = "0.7.0"
)
Variables ¶
var ( Actions = map[string]ActionBuilder{ "alert": buildAlerter, "restart": buildRestarter, "reload": buildReloader, } Notifiers = map[string]NotifierBuilder{ "email": buildEmailNotifier, "gmail": buildGmailNotifier, "null": buildNullNotifier, } )
var ( BuildHost = convertHost BuildService = convertService BuildRule = convertRule BuildAction = convertAction )
var ( Term os.Signal = syscall.SIGTERM Hup os.Signal = syscall.SIGHUP SignalHandlers = map[os.Signal]func(*Inspeqtor){ Term: exit, os.Interrupt: exit, Hup: reload, } Name string = "Inspeqtor" Licensing string = "Licensed under the GNU Public License 3.0" Singleton *Inspeqtor = nil Reloaders []func(*Inspeqtor, *Inspeqtor) error = []func(*Inspeqtor, *Inspeqtor) error{basicReloader} )
var (
CommandHandlers = map[string]commandFunc{
"start": startDeploy,
"finish": finishDeploy,
"status": currentStatus,
"export": export,
"show": sparkline,
"♡": heart,
}
)
var Defaults = GlobalConfig{15, 300, map[string]string{}}
var (
Events = []EventType{ProcessDoesNotExist, ProcessExists, RuleFailed, RuleRecovered}
)
Functions ¶
func HandleSignal ¶
func HandleSignals ¶
func HandleSignals()
Types ¶
type ActionBuilder ¶
type ActionBuilder func(Eventable, *AlertRoute) (Action, error)
An Action is something which is triggered when a rule is broken. This is typically either a Notification, Restart or a Reload to the the service.
type AlertRoute ¶
An alert route is a way to send an alert to a recipient.
Channel is the notification mechanism: email, campfire, etc. Config is an undefined set of kv pairs for configuring the channel.
The configuration looks like this:
send alerts via CHANNEL with K V, K V, K V
You'd then write a rule like:
if foo > 10 then alert
func ValidateChannel ¶
type Checkable ¶
type Checkable interface { Name() string Parameter(string) string Metrics() metrics.Store Resolve([]services.InitSystem) error Rules() []*Rule Verify() []*Event Collect(bool, func(Checkable)) }
func ParseServices ¶
func ParseServices(global *ConfigFile, confDir string) ([]Checkable, error)
Parses the service-specific rules in /etc/inspeqtor/services.d/*.inq
type ConfigFile ¶
type ConfigFile struct { GlobalConfig AlertRoutes map[string]*AlertRoute }
func ParseGlobal ¶
func ParseGlobal(rootDir string) (*ConfigFile, error)
type Controllable ¶
A Service is Controllable, a Host is not.
type EmailEvent ¶
type EmailEvent struct { *Event Config *EmailNotifier }
type EmailNotifier ¶
func (EmailNotifier) Trigger ¶
func (e EmailNotifier) Trigger(event *Event) error
func (*EmailNotifier) TriggerEmail ¶
func (e *EmailNotifier) TriggerEmail(event *Event, sender EmailSender) error
type EmailSender ¶
type EmailSender func(e *EmailNotifier, doc bytes.Buffer) error
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
A named thing which can checked by Inspeqtor
func (*Entity) Parameters ¶
type EventType ¶
type EventType string
There are several different types of Events:
* Process disappeared (or did not exist when we started up) * Process appeared * Rule failed check * Rule has recovered
type GlobalConfig ¶
Parses the global inspeqtor configuration in /etc/inspeqtor/inspeqtor.conf.
type Host ¶
type Host struct {
*Entity
}
Host is the local machine.
type Inspeqtor ¶
type Inspeqtor struct { RootDir string SocketPath string StartedAt time.Time ServiceManagers []services.InitSystem Host *Host Services []Checkable GlobalConfig *ConfigFile Socket net.Listener SilenceUntil time.Time Stopping chan struct{} Handlers map[string][]func(*Inspeqtor) }
func (*Inspeqtor) TestAlertRoutes ¶
type NotifierBuilder ¶
A Notifier is a route to send an alert somewhere else. The global conf sets up the necessary params for the notification to work.
type NullNotifier ¶
type NullNotifier struct {
LastEvent *Event
}
Useful for testing
func (*NullNotifier) Trigger ¶
func (e *NullNotifier) Trigger(event *Event) error
type Rule ¶
type Rule struct { Entity Checkable MetricFamily string MetricName string Op Operator DisplayThreshold string Threshold float64 CurrentValue float64 PerSec bool CycleCount int TrippedCount int State RuleState Actions []Action }
func (*Rule) Check ¶
Run through all Rules and check if we need to trigger actions.
"tripped" means the Rule threshold was breached **this cycle**. "triggered" means the Rule threshold was breached enough cycles in a row to fire the alerts associated with the Rule.
There are three possible states for Rules: Ok - rule was fine last time and passed this time too. Triggered - threshold breached enough times, action should be taken Recovered - rule is currently Triggered but threshold was not breached this time
func (*Rule) Consequence ¶
func (*Rule) DisplayState ¶
func (*Rule) EntityName ¶
func (*Rule) FetchDisplayCurrentValue ¶
func (*Rule) FetchLatestMetricValue ¶
type Service ¶
type Service struct { *Entity // Handles process events: exists, doesn't exist EventHandler Action Process *services.ProcessStatus Manager services.InitSystem }
A service is an Entity which resolves to a Process we can monitor.
func NewService ¶
func (*Service) Collect ¶
Called for each service each cycle, in parallel. This method must be thread-safe. Since this method executes in a goroutine, errors must be handled/logged here and not just returned.
Each cycle we need to: 1. verify service is Up and running. 2. capture process metrics 3. run rules 4. trigger any necessary actions
func (*Service) Resolve ¶
func (svc *Service) Resolve(mgrs []services.InitSystem) error
Resolve each defined service to its managing init system. Called only at startup, this is what maps services to init and fires ProcessDoesNotExist events.
func (*Service) SetMetrics ¶
func (*Service) Transition ¶
func (s *Service) Transition(ps *services.ProcessStatus, emitter func(EventType))
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
conf
|
|
runit manages services usually found in /etc/service or /service, which are soft links to the actual service directories in /etc/sv: <service_name>/ run log/ run supervise/ pid # => 4994 stat # => run / down
|
runit manages services usually found in /etc/service or /service, which are soft links to the actual service directories in /etc/sv: <service_name>/ run log/ run supervise/ pid # => 4994 stat # => run / down |