Documentation ¶
Overview ¶
Package probe contains the probe implementation.
Index ¶
- func CheckEmpty(s string) string
- func CleanData(p []Prober)
- func CleanDataFile(filename string, backups int)
- func LoadDataFromFile(filename string) error
- func SaveDataToFile(filename string) error
- func SetMetaData(name string, ver string)
- func SetResultData(name string, result *Result)
- func SetResultsData(r []Result)
- type MetaData
- type NotificationStrategyData
- func (n *NotificationStrategyData) Clone() NotificationStrategyData
- func (n *NotificationStrategyData) IsExceedMaxTimes() bool
- func (n *NotificationStrategyData) NeedToSendNotification() bool
- func (n *NotificationStrategyData) NextNotification()
- func (n *NotificationStrategyData) ProcessStatus(status bool)
- func (n *NotificationStrategyData) Reset()
- type Prober
- type Result
- type Stat
- type Status
- func (s *Status) Emoji() string
- func (s Status) MarshalJSON() (b []byte, err error)
- func (s Status) MarshalYAML() (interface{}, error)
- func (s *Status) Status(status string)
- func (s Status) String() string
- func (s Status) Title() string
- func (s *Status) UnmarshalJSON(b []byte) (err error)
- func (s *Status) UnmarshalYAML(unmarshal func(interface{}) error) error
- type StatusCounter
- type StatusHistory
- type TextChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanData ¶
func CleanData(p []Prober)
CleanData removes the items in resultData not in []Prober Note: No need to consider the thread-safe, because this function is only called once during the startup
func CleanDataFile ¶
CleanDataFile keeps the max backup of data file Note: No need to consider the thread-safe, because this function is only called once during the startup
func LoadDataFromFile ¶
LoadDataFromFile load the results from file Note: No need to consider the thread-safe, because this function is only called once during the startup
func SaveDataToFile ¶
SaveDataToFile save the results to file Note: No need to consider the thread-safe, because this function and SetResultData in same goroutine
func SetMetaData ¶
SetMetaData set the meta data Note: No need to consider the thread-safe, because this function is only called during the startup
func SetResultData ¶
SetResultData set the result of probe Note: this function would be called by status update goroutine
int saveData() in cmd/easeprobe/report.go
Types ¶
type MetaData ¶
type MetaData struct { Name string `yaml:"name"` Ver string `yaml:"version"` // contains filtered or unexported fields }
MetaData the meta data of data file
type NotificationStrategyData ¶
type NotificationStrategyData struct { global.NotificationStrategySettings `yaml:",inline" json:",inline"` // the current notified times Notified int `yaml:"notified" json:"notified"` // the current continuous failed rounds Failed int `yaml:"failed" json:"failed"` // the next round will be notified Next int `yaml:"next" json:"next"` // the Interval is the interval between two notifications Interval int `yaml:"interval" json:"interval"` // the flag to indicate whether the notification is sent IsSent bool `yaml:"-" json:"-"` }
NotificationStrategyData is the notification strategy
func NewNotificationStrategyData ¶
func NewNotificationStrategyData(strategy global.IntervalStrategy, maxTimes int, factor int) *NotificationStrategyData
NewNotificationStrategyData returns a new NotificationStrategy
func (*NotificationStrategyData) Clone ¶
func (n *NotificationStrategyData) Clone() NotificationStrategyData
Clone returns a new NotificationStrategyData
func (*NotificationStrategyData) IsExceedMaxTimes ¶
func (n *NotificationStrategyData) IsExceedMaxTimes() bool
IsExceedMaxTimes returns true if the current times is equal to the max times
func (*NotificationStrategyData) NeedToSendNotification ¶
func (n *NotificationStrategyData) NeedToSendNotification() bool
NeedToSendNotification returns true if the notification should be sent
func (*NotificationStrategyData) NextNotification ¶
func (n *NotificationStrategyData) NextNotification()
NextNotification returns the next notification times
func (*NotificationStrategyData) ProcessStatus ¶
func (n *NotificationStrategyData) ProcessStatus(status bool)
ProcessStatus processes the probe status
func (*NotificationStrategyData) Reset ¶
func (n *NotificationStrategyData) Reset()
Reset resets the current times
type Prober ¶
type Prober interface { LabelMap() prometheus.Labels SetLabelMap(labels prometheus.Labels) Kind() string Name() string Channels() []string Timeout() time.Duration Interval() time.Duration Result() *Result Config(global.ProbeSettings) error Probe() Result }
Prober Interface
type Result ¶
type Result struct { Name string `json:"name" yaml:"name"` Endpoint string `json:"endpoint" yaml:"endpoint"` StartTime time.Time `json:"time" yaml:"time"` StartTimestamp int64 `json:"timestamp" yaml:"timestamp"` RoundTripTime time.Duration `json:"rtt" yaml:"rtt"` Status Status `json:"status" yaml:"status"` PreStatus Status `json:"prestatus" yaml:"prestatus"` Message string `json:"message" yaml:"message"` LatestDownTime time.Time `json:"latestdowntime" yaml:"latestdowntime"` RecoveryDuration time.Duration `json:"recoverytime" yaml:"recoverytime"` Stat Stat `json:"stat" yaml:"stat"` }
Result is the status of health check
func GetResultData ¶
GetResultData get the result of probe Note: the function would be called by Data Saving, SLA Report, Web Server
func NewResultWithName ¶
NewResultWithName return a Result object with name
func (*Result) DebugJSONIndent ¶
DebugJSONIndent convert the object to indent JSON
func (*Result) SLAPercent ¶
SLAPercent calculate the SLAPercent
type Stat ¶
type Stat struct { Since time.Time `json:"since" yaml:"since"` Total int64 `json:"total" yaml:"total"` Status map[Status]int64 `json:"status" yaml:"status"` UpTime time.Duration `json:"uptime" yaml:"uptime"` DownTime time.Duration `json:"downtime" yaml:"downtime"` StatusCounter NotificationStrategyData `json:"alert" yaml:"alert"` }
Stat is the statistics of probe result
type Status ¶
type Status int
Status is the status of Probe
The status of a probe
func (Status) MarshalJSON ¶
MarshalJSON is marshal the status
func (Status) MarshalYAML ¶
MarshalYAML is Marshal the status
func (*Status) UnmarshalJSON ¶
UnmarshalJSON is Unmarshal the status
func (*Status) UnmarshalYAML ¶
UnmarshalYAML is Unmarshal the status
type StatusCounter ¶
type StatusCounter struct { StatusHistory []StatusHistory // the status history MaxLen int // the max length of the status history CurrentStatus bool // the current status StatusCount int // the count of the same status }
StatusCounter is the object to count the status
func NewStatusCounter ¶
func NewStatusCounter(maxLen int) *StatusCounter
NewStatusCounter return a StatusCounter object
func (*StatusCounter) AppendStatus ¶
func (s *StatusCounter) AppendStatus(status bool, message string)
AppendStatus appends the status
func (*StatusCounter) Clone ¶
func (s *StatusCounter) Clone() StatusCounter
Clone returns a copy of the StatusThreshold
func (*StatusCounter) SetMaxLen ¶
func (s *StatusCounter) SetMaxLen(maxLen int)
SetMaxLen sets the max length of the status history
type StatusHistory ¶
StatusHistory is a history of status
type TextChecker ¶
type TextChecker struct { Contain string `yaml:"contain,omitempty" json:"contain,omitempty" jsonschema:"title=Contain Text,description=the string must be contained"` NotContain string `` /* 138-byte string literal not displayed */ RegExp bool `` /* 141-byte string literal not displayed */ // contains filtered or unexported fields }
TextChecker is the struct to check the output
func (*TextChecker) CheckRegExp ¶
func (tc *TextChecker) CheckRegExp(Output string) error
CheckRegExp checks the output text, - if it contains a configured pattern then return nil - if it does not contain a configured pattern then return nil
func (*TextChecker) CheckText ¶
func (tc *TextChecker) CheckText(Output string) error
CheckText checks the output text, - if it contains a configured string then return nil - if it does not contain a configured string then return nil
func (*TextChecker) Config ¶
func (tc *TextChecker) Config() (err error)
Config the text checker initialize the regexp
func (*TextChecker) String ¶
func (tc *TextChecker) String() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package base is the base package for all probes
|
Package base is the base package for all probes |
Package client is the native client probe package
|
Package client is the native client probe package |
conf
Package conf is the configuration package for native client
|
Package conf is the configuration package for native client |
kafka
Package kafka is the native client probe for kafka.
|
Package kafka is the native client probe for kafka. |
memcache
Package memcache is the native client probe for memcache
|
Package memcache is the native client probe for memcache |
mongo
Package mongo implements a probe client for the MongoDB database.
|
Package mongo implements a probe client for the MongoDB database. |
mysql
Package mysql is the client probe for MySQL.
|
Package mysql is the client probe for MySQL. |
postgres
Package postgres is the native client probe for PostgreSQL
|
Package postgres is the native client probe for PostgreSQL |
redis
Package redis is the native client probe for Redis
|
Package redis is the native client probe for Redis |
zookeeper
Package zookeeper is the zookeeper client probe
|
Package zookeeper is the zookeeper client probe |
Package host is the host probe package
|
Package host is the host probe package |
Package http is the HTTP probe package.
|
Package http is the HTTP probe package. |
Package ping is the ping probe package
|
Package ping is the ping probe package |
Package shell is the shell probe package
|
Package shell is the shell probe package |
Package ssh is the ssh probe package
|
Package ssh is the ssh probe package |
Package tcp is the tcp probe package
|
Package tcp is the tcp probe package |
Package tls is the tls probe package
|
Package tls is the tls probe package |