Documentation ¶
Index ¶
- Constants
- Variables
- type Check
- type CheckResult
- type Checker
- type Config
- type Error
- type ExecPublisher
- type ExecPublisherConfig
- type MemoryPublisher
- func (p *MemoryPublisher) Configure(cfg map[string]interface{}) error
- func (p *MemoryPublisher) EventCount(checkname string) int
- func (p *MemoryPublisher) GetEvent(checkname string, index int) *CheckResult
- func (p *MemoryPublisher) Publish(result *CheckResult) error
- func (p *MemoryPublisher) Start() error
- func (p *MemoryPublisher) Stop() error
- type Publisher
- type Runner
- type SentryPublisher
- type SentryPublisherConfig
- type SpewPublisher
- type SpewPublisherConfig
Constants ¶
const ( StateOk = 0 StateWarning = 1 StateCritical = 2 StateUnknown = 3 )
const (
ErrInvalidConfig = iota
)
Variables ¶
var Log = log.New()
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check struct { Name string Command string Args []string // Command after being parsed according to shell quoting rules Interval int Retry int Timeout int }
Check describes an individual nagios check.
type CheckResult ¶
type CheckResult struct { Name string // Check name Output []byte // Output returned by the command Returncode int // Exitcode of the command }
CheckResult describes the result of a given check.
type Checker ¶
type Checker interface { Start() (chan *CheckResult, error) Stop() error RegisterChecks(checks map[string]Check) }
Checker schedules and executes checks to be run.
type Config ¶
type Config struct { Publishers map[string]map[string]interface{} Hostname string Checks map[string]Check }
Config describes the full agent configuration.
type ExecPublisher ¶
type ExecPublisher struct {
// contains filtered or unexported fields
}
ExecPublisher is a Publisher which executes an external program whenever a check result is received.
func (*ExecPublisher) Configure ¶
func (p *ExecPublisher) Configure(cfg map[string]interface{}) error
Configure sets the configuration to be used by the publisher.
func (*ExecPublisher) Publish ¶
func (p *ExecPublisher) Publish(result *CheckResult) error
Publish prints the result of a check to stdout.
type ExecPublisherConfig ¶
type ExecPublisherConfig struct { Cmd string // The command to execute on Publish Stdin string // Template to use to format stdin to Cmd }
ExecPublisherConfig describes the configuration used by the ExecPublisher.
type MemoryPublisher ¶
MemoryPublisher is a simple Publisher which stores all check results in memory. This publisher is used for testing and is not meant to be used normally.
func (*MemoryPublisher) Configure ¶
func (p *MemoryPublisher) Configure(cfg map[string]interface{}) error
Configure sets the configuration to be used by the publisher.
func (*MemoryPublisher) EventCount ¶
func (p *MemoryPublisher) EventCount(checkname string) int
func (*MemoryPublisher) GetEvent ¶
func (p *MemoryPublisher) GetEvent(checkname string, index int) *CheckResult
func (*MemoryPublisher) Publish ¶
func (p *MemoryPublisher) Publish(result *CheckResult) error
func (*MemoryPublisher) Start ¶
func (p *MemoryPublisher) Start() error
Start starts this publisher.
type Publisher ¶
type Publisher interface { // Start tells a Publisher to start so it can begin accepting check results. // It should be called after Configure. Start() error // Stop tells a Publisher to shut down. // No more check results may be published to it after calling Stop. Stop() error // Configure sets the configuration to be used by the Publisher. // It should be called before Start. Configure(cfg map[string]interface{}) error // Publish accepts a CheckResult to be published. // It should be safe for concurrent calling by multiple goroutines. Publish(*CheckResult) error }
Publisher publishes CheckResults.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is the main component of the application. It runs the Checker and Publisher subcomponents and facilitates communication between them.
func NewRunnerFromFile ¶
NewRunnerFromFile creates a new Runner using the configuration loaded from the given file.
type SentryPublisher ¶
type SentryPublisher struct {
// contains filtered or unexported fields
}
SentryPublisher is a Publisher which publishes non-OK check results to Sentry (https://getsentry.com/)
func (*SentryPublisher) Configure ¶
func (p *SentryPublisher) Configure(cfg map[string]interface{}) error
Configure sets the configuration to be used by the publisher.
func (*SentryPublisher) Publish ¶
func (p *SentryPublisher) Publish(result *CheckResult) error
Publish publishes the CheckResult to Sentry if it has a state other than StateOk.
func (*SentryPublisher) Start ¶
func (p *SentryPublisher) Start() error
Start starts this publisher.
type SentryPublisherConfig ¶
type SentryPublisherConfig struct { Dsn string // The project DSN to use Hostname string // The hostname to report to sentry }
SentryPublisherConfig describes the configuration used by the SentryPublisher.
type SpewPublisher ¶
type SpewPublisher struct {
// contains filtered or unexported fields
}
SpewPublisher is a publisher which simply spews check results to stdout. This publisher is mainly useful for debugging and to use as a simple reference implementation for a Publisher.
func (*SpewPublisher) Configure ¶
func (p *SpewPublisher) Configure(cfg map[string]interface{}) error
Configure sets the configuration to be used by the publisher.
func (*SpewPublisher) Publish ¶
func (p *SpewPublisher) Publish(result *CheckResult) error
Publish prints the result of a check to stdout.
type SpewPublisherConfig ¶
type SpewPublisherConfig struct { }
SpewPublisherConfig describes the configuration used by the SpewPublisher.