Documentation ¶
Overview ¶
Package gochecks provide a monitoring checks engine to create or embbed small monitoring system that can publish the periodic check result to other monitoring plataforms
Index ¶
- Variables
- func Amqp2CheckEngine(checkEngine *CheckEngine, brokerURI, exchange, topic, queue string, ...)
- func CriticalIfError(value float32, err error) (string, string)
- type CalculateStateFunction
- type ChannelPublisher
- type CheckEngine
- type CheckFunction
- func NewC4CMTSTempChecker(host, service, ip, community string, maxAllowedTemp int) CheckFunction
- func NewGenericCheck(host, service string, metricFunc ObtainMetricFunction, ...) CheckFunction
- func NewGenericHTTPChecker(host, service, url string, validationFunc ValidateHTTPResponseFunction) CheckFunction
- func NewHTTPChecker(host, service, url string, expectedStatusCode int) CheckFunction
- func NewHeartbeatCheck(host, service string) CheckFunction
- func NewJenkinsJobsChecker(host, service, jenkinsBaseURL string, jobRegExp string) CheckFunction
- func NewJuniperCPUChecker(host, service, ip, community string, maxAllowedCPUPercent uint) CheckFunction
- func NewJuniperTempChecker(host, service, ip, community string, maxAllowedTemp uint) CheckFunction
- func NewMysqlConnectionCheck(host, service, mysqluri string) CheckFunction
- func NewPingChecker(host, service, ip string) CheckFunction
- func NewPostgresConnectionCheck(host, service, postgresuri string) CheckFunction
- func NewRabbitMQQueueLenCheck(host, service, amqpuri, queue string, max int) CheckFunction
- func NewRabbitMQQueueListLenCheck(host, service, amqpuri string, queues []string, max int) CheckFunction
- func NewSentryUnresolvedIssuesChecker(host, service, sentryBaseUrl, projectName string) CheckFunction
- func NewSnmpChecker(host, service, ip, community string, conf SnmpCheckerConf) CheckFunction
- func NewTCPPortChecker(host, service, ip string, port int, timeout time.Duration) CheckFunction
- func (f CheckFunction) Attributes(attributes map[string]string) CheckFunction
- func (f CheckFunction) CriticalIfGreaterThan(threshold float32) CheckFunction
- func (f CheckFunction) CriticalIfLessThan(threshold float32) CheckFunction
- func (f CheckFunction) Retry(times int, sleep time.Duration) CheckFunction
- func (f CheckFunction) TTL(ttl float32) CheckFunction
- func (f CheckFunction) Tags(tags ...string) CheckFunction
- func (f CheckFunction) WarningIfGreaterThan(threshold float32) CheckFunction
- func (f CheckFunction) WarningIfLessThan(threshold float32) CheckFunction
- type CheckPublisher
- type Event
- type EventFilterFunction
- type JobStatus
- type JobsMessage
- type LogPublisher
- type MultiCheckFunction
- type ObtainMetricFunction
- type RabbitMqPublisher
- type SnmpCheckerConf
- type ValidateContentFunction
- type ValidateHTTPResponseFunction
Constants ¶
This section is empty.
Variables ¶
var DefaultSnmpCheckConf = SnmpCheckerConf{ // contains filtered or unexported fields }
DefaultSnmpCheckConf default values for snmp conection parameters
Functions ¶
func Amqp2CheckEngine ¶
func Amqp2CheckEngine(checkEngine *CheckEngine, brokerURI, exchange, topic, queue string, queueOptions *simpleamqp.QueueOptions)
Amqp2CheckEngine continously add check result from a queue (generated using RabbitMqPublisher) to a given CheckEngine
Types ¶
type CalculateStateFunction ¶
CalculateStateFunction function that given a metric and error generate the corresponding state value and description
type ChannelPublisher ¶
type ChannelPublisher struct {
Channel chan Event
}
ChannelPublisher object to publish to a channel each check result
func NewChannelPublisher ¶
func NewChannelPublisher(c chan Event) ChannelPublisher
NewChannelPublisher return a new ChannelPublisher
func (ChannelPublisher) PublishCheckResult ¶
func (p ChannelPublisher) PublishCheckResult(event Event)
PublishCheckResult send the event to the publisher channel
type CheckEngine ¶
type CheckEngine struct {
// contains filtered or unexported fields
}
CheckEngine monitoring check engine to schedule periodics checks and publish the results
func NewCheckEngine ¶
func NewCheckEngine(publishers []CheckPublisher) *CheckEngine
NewCheckEngine return a CheckEngine that publish the results of the periodic checks to the given publishers
func (*CheckEngine) AddCheck ¶
func (ce *CheckEngine) AddCheck(check CheckFunction, period time.Duration)
AddCheck schedule a new check to be executed with the given period
func (*CheckEngine) AddMultiCheck ¶
func (ce *CheckEngine) AddMultiCheck(check MultiCheckFunction, period time.Duration)
AddMultiCheck schedule a new multi check to be executed with the given period the muli check can return an array of events/results
func (*CheckEngine) AddResult ¶
func (ce *CheckEngine) AddResult(event Event)
AddResult publish the given check result as if it was generated by a scheduled check
func (*CheckEngine) SetFilter ¶
func (ce *CheckEngine) SetFilter(f EventFilterFunction)
type CheckFunction ¶
type CheckFunction func() Event
CheckFunction type for a function that return a event
func NewC4CMTSTempChecker ¶
func NewC4CMTSTempChecker(host, service, ip, community string, maxAllowedTemp int) CheckFunction
NewC4CMTSTempChecker returns a check function that check if any of the slot of a Arris C4 CMTS have a temperature above a given max
func NewGenericCheck ¶
func NewGenericCheck(host, service string, metricFunc ObtainMetricFunction, stateFunc CalculateStateFunction) CheckFunction
NewGenericCheck returns a check function that invoke a given function to obtain a metric (metricFunc) and invoke another function (stateFunc) to calculate the resulting state and description from this metric value
func NewGenericHTTPChecker ¶
func NewGenericHTTPChecker(host, service, url string, validationFunc ValidateHTTPResponseFunction) CheckFunction
NewGenericHTTPChecker returns a check function that can check the returned http response of a http get with a given validation function
func NewHTTPChecker ¶
func NewHTTPChecker(host, service, url string, expectedStatusCode int) CheckFunction
NewHTTPChecker returns a check function that get a given url and validate if the return code is the expected one
func NewHeartbeatCheck ¶
func NewHeartbeatCheck(host, service string) CheckFunction
NewHeartbeatCheck returns a check function which returns a Event
func NewJenkinsJobsChecker ¶
func NewJenkinsJobsChecker(host, service, jenkinsBaseURL string, jobRegExp string) CheckFunction
NewJenkinsJobsChecker returns a check function that validate that the jenkins api is accesible and all the jenkins jobs matching the given jobRegExp are ok (blue color). When one or more of these jobs are in error the event is critical and the jobs names are included at the event description
func NewJuniperCPUChecker ¶
func NewJuniperCPUChecker(host, service, ip, community string, maxAllowedCPUPercent uint) CheckFunction
NewJuniperCPUChecker returns a check function that check if a Juniper device (router, switch, etc) have a any cpu usage above a given percent
func NewJuniperTempChecker ¶
func NewJuniperTempChecker(host, service, ip, community string, maxAllowedTemp uint) CheckFunction
NewJuniperTempChecker returns a check function that check if a Juniper device (router, switch, etc) have a temperature above a given max
func NewMysqlConnectionCheck ¶
func NewMysqlConnectionCheck(host, service, mysqluri string) CheckFunction
NewMysqlConnectionCheck returns a check function to detect connection/credentials problems to connect to mysql
func NewPingChecker ¶
func NewPingChecker(host, service, ip string) CheckFunction
NewPingChecker returns a check function that can check if a host answer to a ICMP Ping
func NewPostgresConnectionCheck ¶
func NewPostgresConnectionCheck(host, service, postgresuri string) CheckFunction
NewPostgresConnectionCheck returns a check function to detect connection/credentials problems to connect to postgres
func NewRabbitMQQueueLenCheck ¶
func NewRabbitMQQueueLenCheck(host, service, amqpuri, queue string, max int) CheckFunction
NewRabbitMQQueueLenCheck returns a check function that check if queue have more pending messages than a given limit
func NewRabbitMQQueueListLenCheck ¶
func NewRabbitMQQueueListLenCheck(host, service, amqpuri string, queues []string, max int) CheckFunction
func NewSentryUnresolvedIssuesChecker ¶
func NewSentryUnresolvedIssuesChecker(host, service, sentryBaseUrl, projectName string) CheckFunction
func NewSnmpChecker ¶
func NewSnmpChecker(host, service, ip, community string, conf SnmpCheckerConf) CheckFunction
NewSnmpChecker returns a check function that check if a host respond to a snmp get query
func NewTCPPortChecker ¶
func NewTCPPortChecker(host, service, ip string, port int, timeout time.Duration) CheckFunction
NewTCPPortChecker returns a check function that can check if a host have a tcp port open
func (CheckFunction) Attributes ¶
func (f CheckFunction) Attributes(attributes map[string]string) CheckFunction
Attributes returns a new check function that adds the attributes map to the result generated by the initial check function
func (CheckFunction) CriticalIfGreaterThan ¶
func (f CheckFunction) CriticalIfGreaterThan(threshold float32) CheckFunction
CriticalIfGreaterThan returns a new check function that change the state to "critical" when the resulting metric is greater than a threadshold and is not already "critical"
func (CheckFunction) CriticalIfLessThan ¶
func (f CheckFunction) CriticalIfLessThan(threshold float32) CheckFunction
CriticalIfLessThan returns a new check function that change the state to "critical" when the resulting metric is less than a threadshold and is not already "critical"
func (CheckFunction) Retry ¶
func (f CheckFunction) Retry(times int, sleep time.Duration) CheckFunction
Retry returns a new check function that execute the given function up to a given retry times or until the first execution that returns a ok (whichever comes first). The new function will return the event of the last execution
func (CheckFunction) TTL ¶
func (f CheckFunction) TTL(ttl float32) CheckFunction
TTL returns a new check function that adds the given TTL time (in seconds) to the result generated by the initial check function
func (CheckFunction) Tags ¶
func (f CheckFunction) Tags(tags ...string) CheckFunction
Tags returns a new check function that adds the given tags to the result generated by the initial check function
func (CheckFunction) WarningIfGreaterThan ¶
func (f CheckFunction) WarningIfGreaterThan(threshold float32) CheckFunction
WarningIfGreaterThan returns a new check function that change the state to "warning" when the resulting metric is greater than a threadshold and is not already "critical"
func (CheckFunction) WarningIfLessThan ¶
func (f CheckFunction) WarningIfLessThan(threshold float32) CheckFunction
WarningIfLessThan returns a new check function that change the state to "warning" when the resulting metric is less than a threadshold and is not already "critical"
type CheckPublisher ¶
type CheckPublisher interface {
PublishCheckResult(Event)
}
CheckPublisher define the check result Publisher
type Event ¶
type Event struct { Host string Service string State string Metric interface{} Description string Tags []string Attributes map[string]string TTL float32 }
Event is the check result
func NoopEventFilter ¶
type EventFilterFunction ¶
type JobsMessage ¶
type JobsMessage struct {
Jobs []JobStatus `json:"jobs"`
}
JobsMessage jenkins jobs statuses
type LogPublisher ¶
type LogPublisher struct{}
LogPublisher object to log each check result
func NewLogPublisher ¶
func NewLogPublisher() LogPublisher
NewLogPublisher return a new LogPublisher
func (LogPublisher) PublishCheckResult ¶
func (p LogPublisher) PublishCheckResult(event Event)
PublishCheckResult log the event
type MultiCheckFunction ¶
type MultiCheckFunction func() []Event
MultiCheckFunction type for a function that return an array of events
type ObtainMetricFunction ¶
ObtainMetricFunction function that return a metric value or error
type RabbitMqPublisher ¶
type RabbitMqPublisher struct {
// contains filtered or unexported fields
}
RabbitMqPublisher object to publish the event to a rabbitmq exchange
func NewRabbitMqPublisher ¶
func NewRabbitMqPublisher(amqpuri, exchange string) RabbitMqPublisher
NewRabbitMqPublisher return a publisher to send to RabbitMq exchange
func (RabbitMqPublisher) PublishCheckResult ¶
func (p RabbitMqPublisher) PublishCheckResult(event Event)
PublishCheckResult publish the event to a configured rabbitmq exchange
type SnmpCheckerConf ¶
type SnmpCheckerConf struct {
// contains filtered or unexported fields
}
SnmpCheckerConf snmp connection parameters to use for the check
type ValidateContentFunction ¶
ValidateContentFunctio function type that should validate a content (usualy a http body) and return the state (ok, critical, warning) and error description for a check.
type ValidateHTTPResponseFunction ¶
ValidateHTTPResponseFunction function type that should validate a http response and return the state (ok, critical, warning) and error description for a check. (Used with NewGenericHTTPChecker)
func BodyGreaterThan ¶
func BodyGreaterThan(minLength int) ValidateHTTPResponseFunction
BodyGreaterThan return a function that given a http response return true if the body is greater than a given number of bytes
func BodyValidation ¶
func BodyValidation(bodyValidationFunc ValidateContentFunction) ValidateHTTPResponseFunction
BodyValidation return a ValidationHTTPResponseFunction that check the body of a http response using the given bodyValidationFunc