Documentation
¶
Index ¶
- Constants
- Variables
- func Dir(useLocal bool, name string) http.FileSystem
- func DiscoverEC2ByTag(tagName string, values ...string) ([]*netutil.Service, error)
- func FS(useLocal bool) http.FileSystem
- func FSByte(useLocal bool, name string) ([]byte, error)
- func FSMustByte(useLocal bool, name string) []byte
- func FSMustString(useLocal bool, name string) string
- func FSString(useLocal bool, name string) (string, error)
- type Check
- func (self *Check) Execute() (Observation, error)
- func (self *Check) ID() string
- func (self *Check) IsFallen() bool
- func (self *Check) IsFlapping() bool
- func (self *Check) IsOK() bool
- func (self *Check) IsRisen() bool
- func (self *Check) Monitor(eventStream chan CheckEvent) error
- func (self *Check) StateString() string
- type CheckEvent
- type Config
- type Consumer
- type EventRouter
- func (self *EventRouter) AddHandler(handler *Handler) error
- func (self *EventRouter) LoadConfig(path string) error
- func (self *EventRouter) RegenerateCache()
- func (self *EventRouter) ReloadConfig() error
- func (self *EventRouter) Run(input io.Reader) error
- func (self *EventRouter) RunQueryCacher(interval time.Duration) error
- type Handler
- type HandlerConfig
- type Measurement
- type MeasurementUnit
- type Observation
- type ObservationState
- type Observations
- type Reacter
- type Server
Constants ¶
const ( DEFAULT_AMQP_PORT = 5672 DEFAULT_QUEUE_NAME = `reacter` )
const ( Unknown MeasurementUnit = 0 Numeric = 1 Time = 2 Percent = 3 Bytes = 4 Counter = 5 )
const ( SuccessState ObservationState = 0 WarningState = 1 CriticalState = 2 UnknownState = 3 )
const DefaultFlapHighThresh = 0.5
const DefaultFlapLowThresh = 0.25
const DefaultMaxObservations = 21
const FlapBaseCoefficient = 0.8
const FlapWeightMultiplier = 0.02
Variables ¶
var DefaultCacheDir = executil.RootOrString(
`/dev/shm/reacter/handler-queries`,
`~/.cache/reacter`,
)
var DefaultCheckInterval = 60
var DefaultCheckTimeout = 10000
var DefaultConfigDir = executil.RootOrString(`/etc/reacter/conf.d`, `~/.config/reacter.d`)
var DefaultConfigFile = executil.RootOrString(`/etc/reacter.yml`, `~/.config/reacter.yml`)
var DefaultHandleExecTimeout = 6 * time.Second
var DefaultHandleQueryExecTimeout = 3 * time.Second
var ZeroconfInstanceName = `reacter`
Functions ¶
func Dir ¶ added in v1.0.1
func Dir(useLocal bool, name string) http.FileSystem
Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.
func DiscoverEC2ByTag ¶ added in v1.0.5
func FS ¶ added in v1.0.1
func FS(useLocal bool) http.FileSystem
FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSByte ¶ added in v1.0.1
FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSMustByte ¶ added in v1.0.1
FSMustByte is the same as FSByte, but panics if name is not present.
func FSMustString ¶ added in v1.0.1
FSMustString is the string version of FSMustByte.
Types ¶
type Check ¶
type Check struct { UID string `json:"id"` NodeName string `json:"node_name"` Name string `json:"name"` Command interface{} `json:"command"` Timeout interface{} `json:"timeout"` Enabled bool `json:"enabled"` State ObservationState `json:"state"` HardState bool `json:"hard"` StateChanged bool `json:"changed"` Parameters map[string]interface{} `json:"parameters"` Environment map[string]string `json:"environment"` Directory string `json:"directory,omitempty"` Interval interface{} `json:"interval"` FlapThresholdHigh float64 `json:"flap_threshold_high"` FlapThresholdLow float64 `json:"flap_threshold_low"` Rise int `json:"rise"` Fall int `json:"fall"` Observations *Observations `json:"observations"` EventStream chan CheckEvent `json:"-"` StopMonitorC chan bool `json:"-"` }
func (*Check) Execute ¶
func (self *Check) Execute() (Observation, error)
func (*Check) IsFlapping ¶
func (*Check) Monitor ¶
func (self *Check) Monitor(eventStream chan CheckEvent) error
func (*Check) StateString ¶
type CheckEvent ¶
type Consumer ¶
type Consumer struct { ID string Host string Port int Username string Password string Vhost string QueueName string Durable bool Autodelete bool Exclusive bool // contains filtered or unexported fields }
func NewConsumer ¶
type EventRouter ¶
type EventRouter struct { NodeName string Handlers []*Handler ConfigFile string ConfigDir string CacheDir string }
func NewEventRouter ¶
func NewEventRouter() *EventRouter
func (*EventRouter) AddHandler ¶
func (self *EventRouter) AddHandler(handler *Handler) error
func (*EventRouter) LoadConfig ¶
func (self *EventRouter) LoadConfig(path string) error
func (*EventRouter) RegenerateCache ¶
func (self *EventRouter) RegenerateCache()
func (*EventRouter) ReloadConfig ¶
func (self *EventRouter) ReloadConfig() error
Loads the ConfigFile (if present), and recursively scans and load all *.yml files in ConfigDir.
func (*EventRouter) RunQueryCacher ¶
func (self *EventRouter) RunQueryCacher(interval time.Duration) error
type Handler ¶
type Handler struct { Name string `json:"name"` QueryCommand interface{} `json:"query,omitempty"` NodeFile string `json:"nodefile,omitempty"` NodeFileAutoreload bool `json:"nodefile_autoreload,omitempty"` NodeNames []string `json:"node_names,omitempty"` SkipOK bool `json:"skip_ok"` CheckNames []string `json:"checks,omitempty"` States []int `json:"states,omitempty"` SkipFlapping bool `json:"skip_flapping"` OnlyChanges bool `json:"only_changes"` Command interface{} `json:"command,omitempty"` Environment map[string]string `json:"environment,omitempty"` Parameters map[string]string `json:"parameters,omitempty"` Directory string `json:"directory,omitempty"` Disable bool `json:"disable,omitempty"` Timeout interface{} `json:"timeout,omitempty"` Cooldown interface{} `json:"cooldown,omitempty"` QueryTimeout interface{} `json:"query_timeout,omitempty"` CacheDir string `json:"-"` // contains filtered or unexported fields }
func (*Handler) Execute ¶
func (self *Handler) Execute(event CheckEvent) error
func (*Handler) ExecuteNodeQuery ¶
func (*Handler) GetCacheFilename ¶
func (*Handler) LoadNodeFile ¶
func (self *Handler) LoadNodeFile()
func (*Handler) ShouldExec ¶
type HandlerConfig ¶
type HandlerConfig struct {
HandlerDefinitions []Handler `json:"handlers"`
}
type Measurement ¶
type MeasurementUnit ¶
type MeasurementUnit int32
type Observation ¶
type Observation struct { Timestamp time.Time `json:"-"` State ObservationState `json:"-"` Output []string `json:"-"` Errors []string `json:"-"` PerformanceData map[string]Measurement `json:"measurements,omitempty"` }
func (*Observation) SetState ¶
func (self *Observation) SetState(state int)
type ObservationState ¶
type ObservationState int32
func (ObservationState) String ¶ added in v1.0.1
func (self ObservationState) String() string
type Observations ¶
type Observations struct { Values []Observation `json:"-"` Size int `json:"size"` Flapping bool `json:"flapping"` FlapDetect bool `json:"flap_detection"` FlapThresholdLow float64 `json:"flap_threshold_low"` FlapThresholdHigh float64 `json:"flap_threshold_high"` StateChangeFactor float64 `json:"flap_factor"` }
func NewObservations ¶
func NewObservations() *Observations
func (*Observations) Push ¶
func (self *Observations) Push(observation Observation) error
type Reacter ¶
type Reacter struct { NodeName string `json:"name"` Peers []*netutil.Service `json:"peers"` Checks []*Check `json:"-"` Events chan CheckEvent `json:"-"` ConfigFile string `json:"-"` ConfigDir string `json:"-"` PrintJson bool `json:"-"` WriteJson io.Writer `json:"-"` OnlyPrintChanges bool `json:"-"` SuppressFlapping bool `json:"-"` // contains filtered or unexported fields }
func NewReacter ¶
func NewReacter() *Reacter
func (*Reacter) LoadConfig ¶
Load the configuration file the given path and append any checks to this instance.
func (*Reacter) ReloadConfig ¶
Loads the ConfigFile (if present), and recursively scans and load all *.yml files in ConfigDir.
func (*Reacter) StartEventProcessing ¶
func (self *Reacter) StartEventProcessing()