probe

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package probe contains the probe implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEmpty added in v1.3.0

func CheckEmpty(s string) string

CheckEmpty return "empty" if the string is empty

func CleanData added in v1.5.0

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 added in v1.5.0

func CleanDataFile(filename string, backups int)

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 added in v1.5.0

func LoadDataFromFile(filename string) error

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 added in v1.5.0

func SaveDataToFile(filename string) error

SaveDataToFile save the results to file Note: No need to consider the thread-safe, because this function and SetResultData in same goroutine

func SetMetaData added in v1.5.0

func SetMetaData(name string, ver string)

SetMetaData set the meta data Note: No need to consider the thread-safe, because this function is only called during the startup

func SetResultData added in v1.5.0

func SetResultData(name string, result *Result)

SetResultData set the result of probe Note: this function would be called by status update goroutine

int saveData() in cmd/easeprobe/report.go

func SetResultsData added in v1.5.0

func SetResultsData(r []Result)

SetResultsData set the results of probe

Types

type MetaData added in v1.5.0

type MetaData struct {
	Name string `yaml:"name"`
	Ver  string `yaml:"version"`
	// contains filtered or unexported fields
}

MetaData the meta data of data file

func GetMetaData added in v1.5.0

func GetMetaData() *MetaData

GetMetaData get the meta data

type Prober

type Prober interface {
	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 added in v1.5.0

func GetResultData(name string) *Result

GetResultData get the result of probe Note: the function would be called by Data Saving, SLA Report, Web Server

func NewResult

func NewResult() *Result

NewResult return a Result object

func NewResultWithName added in v1.5.0

func NewResultWithName(name string) *Result

NewResultWithName return a Result object with name

func (*Result) Clone added in v1.5.0

func (r *Result) Clone() Result

Clone return a clone of the Result

func (*Result) DebugJSON added in v1.2.0

func (r *Result) DebugJSON() string

DebugJSON convert the object to DebugJSON

func (*Result) DebugJSONIndent added in v1.2.0

func (r *Result) DebugJSONIndent() string

DebugJSONIndent convert the object to indent JSON

func (*Result) DoStat

func (r *Result) DoStat(d time.Duration)

DoStat is the function do the statistics

func (*Result) SLAPercent added in v1.6.0

func (r *Result) SLAPercent() float64

SLAPercent calculate the SLAPercent

func (*Result) Title

func (r *Result) Title() string

Title return the title for notification

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
}

Stat is the statistics of probe result

func (*Stat) Clone added in v1.5.0

func (s *Stat) Clone() Stat

Clone return a clone of the Stat

type Status

type Status int

Status is the status of Probe

const (
	StatusInit Status = iota
	StatusUp
	StatusDown
	StatusUnknown
	StatusBad
)

The status of a probe

func (*Status) Emoji

func (s *Status) Emoji() string

Emoji convert the status to emoji

func (Status) MarshalJSON

func (s Status) MarshalJSON() (b []byte, err error)

MarshalJSON is marshal the status

func (Status) MarshalYAML added in v1.5.0

func (s Status) MarshalYAML() (interface{}, error)

MarshalYAML is Marshal the status

func (*Status) Status

func (s *Status) Status(status string)

Status convert the string to Status

func (Status) String

func (s Status) String() string

String convert the Status to string

func (Status) Title added in v1.9.0

func (s Status) Title() string

Title convert the Status to title

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON is Unmarshal the status

func (*Status) UnmarshalYAML added in v1.5.0

func (s *Status) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is Unmarshal the status

type StatusCounter added in v1.9.0

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 added in v1.9.0

func NewStatusCounter(maxLen int) *StatusCounter

NewStatusCounter return a StatusCounter object

func (*StatusCounter) AppendStatus added in v1.9.0

func (s *StatusCounter) AppendStatus(status bool, message string)

AppendStatus appends the status

func (*StatusCounter) Clone added in v1.9.0

func (s *StatusCounter) Clone() StatusCounter

Clone returns a copy of the StatusThreshold

func (*StatusCounter) SetMaxLen added in v1.9.0

func (s *StatusCounter) SetMaxLen(maxLen int)

SetMaxLen sets the max length of the status history

type StatusHistory added in v1.9.0

type StatusHistory struct {
	Status  bool
	Message string
}

StatusHistory is a history of status

type TextChecker added in v1.7.0

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) Check added in v1.7.0

func (tc *TextChecker) Check(Text string) error

Check the text

func (*TextChecker) CheckRegExp added in v1.7.0

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 added in v1.7.0

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 added in v1.7.0

func (tc *TextChecker) Config() (err error)

Config the text checker initialize the regexp

func (*TextChecker) String added in v1.7.0

func (tc *TextChecker) String() string

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 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL