Documentation ¶
Index ¶
- Constants
- Variables
- func HandleSignal(sig os.Signal, handler func(*Inspeqtor))
- func HandleSignals()
- func ParseInq(global *ConfigFile, confDir string) (*Host, []Checkable, error)
- type Action
- type ActionBuilder
- type AlertRoute
- type Checkable
- type ConfigFile
- type EmailEvent
- type EmailNotifier
- type EmailSender
- type Entity
- type Event
- type EventType
- type GlobalConfig
- type Host
- type Inspeqtor
- type NotifierBuilder
- type Operator
- type Restartable
- type Restarter
- type Rule
- type RuleState
- type Service
- func (svc *Service) Collect(silenced bool, completeCallback func(Checkable))
- 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.5.0"
)
Variables ¶
var ( Actions = map[string]ActionBuilder{ "alert": buildAlerter, "restart": buildRestarter, } Notifier = map[string]NotifierBuilder{ "email": buildEmailNotifier, "gmail": buildGmailNotifier, } )
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" )
var (
CommandHandlers = map[string]commandFunc{
"start": startDeploy,
"finish": finishDeploy,
"status": currentStatus,
"show": sparkline,
"♡": heart,
}
)
var Defaults = GlobalConfig{15, 300}
var (
Events = []EventType{ProcessDoesNotExist, ProcessExists, RuleFailed, RuleRecovered}
)
Functions ¶
func HandleSignal ¶
func HandleSignals ¶
func HandleSignals()
Types ¶
type ActionBuilder ¶
type ActionBuilder func(Checkable, *AlertRoute) (Action, error)
An Action is something which is triggered when a rule is broken. This is typically either a Notification or to Restart 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 ConfigFile ¶
type ConfigFile struct { Top GlobalConfig AlertRoutes map[string]*AlertRoute }
func ParseGlobal ¶
func ParseGlobal(rootDir string) (*ConfigFile, error)
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 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 Valid bool }
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 Restartable ¶
type Restartable interface {
Restart() error
}
A Service is Restartable, Host is not.
type Rule ¶
type Rule struct { Entity Checkable MetricFamily string MetricName string Op Operator DisplayThreshold string Threshold float64 CurrentValue float64 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 |