probe

package
v0.0.0-...-b7c0045 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package probe stores basic probes that are used to check services health

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Target  string
	Options map[string]interface{}

	Warning time.Duration
	Fatal   time.Duration
}

Config holds probe configuration, submitted through Init methods.

type DNS

type DNS struct {
	Config
	// contains filtered or unexported fields
}

DNS Probe, used to check whether a DNS server is answering. `domain` will be resolved through a lookup for an A record. `expected` should be the first returned IPv4 address or empty to accept any IP address.

func (*DNS) Init

func (d *DNS) Init(c Config) error

Init configures the probe.

func (*DNS) Probe

func (d *DNS) Probe() (status Status, message string)

Probe checks a DNS server. If the operation succeeds, the message will be the duration of the dial in ms. Otherwise, an error message is returned.

type HTTP

type HTTP struct {
	Config
	// contains filtered or unexported fields
}

HTTP Probe, used to check HTTP(S) websites status.

func (*HTTP) Init

func (h *HTTP) Init(c Config) error

Init configures the probe.

func (*HTTP) Probe

func (h *HTTP) Probe() (status Status, message string)

Probe checks a website status. If the operation succeeds, the message will be the duration of the HTTP request in ms. Otherwise, an error message is returned.

type HTTPOptions

type HTTPOptions struct {
	Regex             string
	VerifyCertificate bool
}

HTTPOptions is a structure containing optional parameters. The `Regex` is used to check the content of the website, and can be empty. Set `VerifyCertificate` to `false` to skip the TLS certificate verification.

type Minecraft

type Minecraft struct {
	Config
}

Minecraft Probe, used to check minecraft servers status

func (*Minecraft) Init

func (m *Minecraft) Init(c Config) error

Init configures the probe.

func (*Minecraft) Probe

func (m *Minecraft) Probe() (status Status, message string)

Probe checks a minecraft server status. If the operation succeeds, the message will contain the number of connected and allowed players and the server version. If there is no slot available for a new player, a warning will be triggered. Otherwise, an error message is returned.

type Port

type Port struct {
	Config
	// contains filtered or unexported fields
}

Port Probe, used to check if a port is open or not.

func (*Port) Init

func (p *Port) Init(c Config) error

Init configures the probe.

func (*Port) Probe

func (p *Port) Probe() (status Status, message string)

Probe checks a port status If the operation succeeds, the message will be the duration of the dial in ms. Otherwise, an error message is returned.

type Prober

type Prober interface {
	Init(Config) error
	Probe() (status Status, message string)
}

Prober is the base interface that each probe must implement.

type SMTP

type SMTP struct {
	Config
}

SMTP Probe, used to check smtp servers status BEWARE! Only full TLS servers are working with this probe.

func (*SMTP) Init

func (s *SMTP) Init(c Config) error

Init configures the probe.

func (*SMTP) Probe

func (s *SMTP) Probe() (status Status, message string)

Probe checks a mailbox status. If the operation succeeds, the message will be the duration of the SMTP handshake in ms. Otherwise, an error message is returned.

type Status

type Status string

Status represents the current status of a monitored service.

const (
	StatusUnknown Status = ""
	StatusWarning Status = "WARNING"
	StatusError   Status = "ERROR"
	StatusOK      Status = "OK"
)

These constants represent the different available statuses of a service.

func EvaluateDuration

func EvaluateDuration(duration time.Duration, warning time.Duration) (status Status, message string)

EvaluateDuration is a shortcut for warning duration checks. It returns a message containing the duration, and a OK or a WARNING status depending on the provided warning duration.

Jump to

Keyboard shortcuts

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