base

package
v0.0.0-...-c3423aa Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package base is the base package for all probes

Index

Constants

View Source
const (
	ServiceUp   int = 1
	ServiceDown int = 0
)

Probe Simple Status

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultProbe

type DefaultProbe struct {
	ProbeKind                            string            `yaml:"-" json:"-"`
	ProbeTag                             string            `yaml:"-" json:"-"`
	ProbeName                            string            `yaml:"name" json:"name" jsonschema:"required,title=Probe Name,description=the name of probe must be unique"`
	ProbeChannels                        []string          `` /* 133-byte string literal not displayed */
	ProbeTimeout                         time.Duration     `` /* 143-byte string literal not displayed */
	ProbeTimeInterval                    time.Duration     `` /* 147-byte string literal not displayed */
	Labels                               prometheus.Labels `yaml:"labels,omitempty" json:"labels,omitempty" jsonschema:"title=Probe LabelMap,description=the labels of probe"`
	global.StatusChangeThresholdSettings `yaml:",inline" json:",inline"`
	global.NotificationStrategySettings  `yaml:"alert" json:"alert" jsonschema:"title=Probe Alert,description=the alert strategy of probe"`
	ProbeFunc                            ProbeFuncType `yaml:"-" json:"-"`
	ProbeResult                          *probe.Result `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

DefaultProbe is the default options for all probe

func (*DefaultProbe) Channels

func (d *DefaultProbe) Channels() []string

Channels return the probe channels

func (*DefaultProbe) CheckStatusThreshold

func (d *DefaultProbe) CheckStatusThreshold() probe.Status

CheckStatusThreshold check the status threshold

func (*DefaultProbe) Config

func (d *DefaultProbe) Config(gConf global.ProbeSettings,
	kind, tag, name, endpoint string, fn ProbeFuncType) error

Config default config

func (*DefaultProbe) DownTimeCalculation

func (d *DefaultProbe) DownTimeCalculation(status probe.Status)

DownTimeCalculation calculate the down time

func (*DefaultProbe) ExportMetrics

func (d *DefaultProbe) ExportMetrics()

ExportMetrics export the metrics

func (*DefaultProbe) GetProxyConnection

func (d *DefaultProbe) GetProxyConnection(socks5 string, host string) (net.Conn, error)

GetProxyConnection return the proxy connection

func (*DefaultProbe) Interval

func (d *DefaultProbe) Interval() time.Duration

Interval get the probe interval

func (*DefaultProbe) Kind

func (d *DefaultProbe) Kind() string

Kind return the probe kind

func (*DefaultProbe) LabelMap

func (d *DefaultProbe) LabelMap() prometheus.Labels

LabelMap return the const metric labels for a probe in the configuration.

func (*DefaultProbe) LogTitle

func (d *DefaultProbe) LogTitle() string

LogTitle return the log title

func (*DefaultProbe) Name

func (d *DefaultProbe) Name() string

Name return the probe name

func (*DefaultProbe) Probe

func (d *DefaultProbe) Probe() probe.Result

Probe return the checking result

func (*DefaultProbe) Result

func (d *DefaultProbe) Result() *probe.Result

Result get the probe result

func (*DefaultProbe) SetLabelMap

func (d *DefaultProbe) SetLabelMap(labels prometheus.Labels)

SetLabelMap set a set of new labels for a probe.

Note: This method takes effect before Probe.Config() only

func (*DefaultProbe) Timeout

func (d *DefaultProbe) Timeout() time.Duration

Timeout get the probe timeout

type ProbeFuncType

type ProbeFuncType func() (bool, string)

ProbeFuncType is the probe function type

Jump to

Keyboard shortcuts

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