conf

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: 31 Imported by: 0

Documentation

Overview

Package conf is the configuration of the application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConfigModified

func IsConfigModified(path string) bool

IsConfigModified checks if the configuration file is modified

func JSONSchema

func JSONSchema() (string, error)

JSONSchema return the json schema of the configuration

func MergeConstLabels

func MergeConstLabels(ps []probe.Prober)

MergeConstLabels merge const labels from all probers. Prometheus requires all metric of the same name have the same set of labels in a collector

func ResetPreviousYAMLFile

func ResetPreviousYAMLFile()

ResetPreviousYAMLFile resets the previousYAMLFile

Types

type Conf

type Conf struct {
	Version   string                `yaml:"version" json:"version,omitempty" jsonschema:"title=Version,description=Version of the EaseProbe configuration"`
	HTTP      []http.HTTP           `yaml:"http" json:"http,omitempty" jsonschema:"title=HTTP Probe,description=HTTP Probe Configuration"`
	TCP       []tcp.TCP             `yaml:"tcp" json:"tcp,omitempty" jsonschema:"title=TCP Probe,description=TCP Probe Configuration"`
	Shell     []shell.Shell         `yaml:"shell" json:"shell,omitempty" jsonschema:"title=Shell Probe,description=Shell Probe Configuration"`
	Client    []client.Client       `yaml:"client" json:"client,omitempty" jsonschema:"title=Native Client Probe,description=Native Client Probe Configuration"`
	SSH       ssh.SSH               `yaml:"ssh" json:"ssh,omitempty" jsonschema:"title=SSH Probe,description=SSH Probe Configuration"`
	TLS       []tls.TLS             `yaml:"tls" json:"tls,omitempty" jsonschema:"title=TLS Probe,description=TLS Probe Configuration"`
	Host      host.Host             `yaml:"host" json:"host,omitempty" jsonschema:"title=Host Probe,description=Host Probe Configuration"`
	Ping      []ping.Ping           `yaml:"ping" json:"ping,omitempty" jsonschema:"title=Ping Probe,description=Ping Probe Configuration"`
	WebSocket []websocket.WebSocket `yaml:"websocket" json:"websocket,omitempty" jsonschema:"title=WebSocket Probe,description=WebSocket Probe Configuration"`
	Notify    notify.Config         `yaml:"notify" json:"notify,omitempty" jsonschema:"title=Notification,description=Notification Configuration"`
	Settings  Settings              `yaml:"settings" json:"settings,omitempty" jsonschema:"title=Global Settings,description=EaseProbe Global configuration"`
}

Conf is Probe configuration

func Get

func Get() *Conf

Get return the global configuration

func New

func New(conf *string) (*Conf, error)

New read the configuration from yaml

func (*Conf) AllNotifiers

func (conf *Conf) AllNotifiers() []notify.Notify

AllNotifiers return all notifiers

func (*Conf) AllProbers

func (conf *Conf) AllProbers() []probe.Prober

AllProbers return all probers

func (*Conf) InitAllLogs

func (conf *Conf) InitAllLogs()

InitAllLogs initialize all logs

type HTTPServer

type HTTPServer struct {
	IP              string        `` /* 138-byte string literal not displayed */
	Port            string        `yaml:"port" json:"port" jsonschema:"type=integer,title=Web Server Port,description=port of the http server,default=8181"`
	AutoRefreshTime time.Duration `` /* 148-byte string literal not displayed */
	AccessLog       Log           `yaml:"log" json:"log,omitempty" jsonschema:"title=Access Log,description=access log of the http server"`
}

HTTPServer is the settings of http server

type Log

type Log struct {
	Level      LogLevel    `` /* 162-byte string literal not displayed */
	File       string      `yaml:"file" json:"file,omitempty" jsonschema:"title=Log File,description=the file to save the log"`
	SelfRotate bool        `` /* 129-byte string literal not displayed */
	MaxSize    int         `` /* 170-byte string literal not displayed */
	MaxAge     int         `` /* 165-byte string literal not displayed */
	MaxBackups int         `` /* 193-byte string literal not displayed */
	Compress   bool        `yaml:"compress" json:"compress,omitempty" jsonschema:"title=Compress,description=whether to compress the rotated log file"`
	Writer     io.Writer   `yaml:"-" json:"-"`
	Logger     *log.Logger `yaml:"-" json:"-"`
	IsStdout   bool        `yaml:"-" json:"-"`
}

Log is the log settings

func NewLog

func NewLog() Log

NewLog create a new Log

func (*Log) CheckDefault

func (l *Log) CheckDefault()

CheckDefault initialize the Log configuration

func (*Log) Close

func (l *Log) Close()

Close close the log file

func (*Log) ConfigureLogger

func (l *Log) ConfigureLogger()

ConfigureLogger configure the logger

func (*Log) GetWriter

func (l *Log) GetWriter() io.Writer

GetWriter return the log writer

func (*Log) InitLog

func (l *Log) InitLog(logger *log.Logger)

InitLog initialize the log

func (*Log) LogInfo

func (l *Log) LogInfo(name string)

LogInfo log info

func (*Log) Open

func (l *Log) Open()

Open open the log file

func (*Log) Rotate

func (l *Log) Rotate()

Rotate rotate the log file

type LogLevel

type LogLevel log.Level

LogLevel is the log level

func (*LogLevel) GetLevel

func (l *LogLevel) GetLevel() log.Level

GetLevel return the log level

func (LogLevel) MarshalYAML

func (l LogLevel) MarshalYAML() (interface{}, error)

MarshalYAML is marshal the format

func (*LogLevel) UnmarshalYAML

func (l *LogLevel) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is unmarshal the debug level

type Notify

type Notify struct {
	Retry global.Retry `yaml:"retry" json:"retry,omitempty" jsonschema:"title=retry,description=the retry settings"`
	Dry   bool         `` /* 155-byte string literal not displayed */
}

Notify is the settings of notification

type Probe

type Probe struct {
	Interval                             time.Duration `` /* 148-byte string literal not displayed */
	Timeout                              time.Duration `` /* 145-byte string literal not displayed */
	global.StatusChangeThresholdSettings `yaml:",inline" json:",inline"`
	global.NotificationStrategySettings  `yaml:"alert" json:"alert" jsonschema:"title=Alert,description=the alert settings"`
}

Probe is the settings of prober

type Prometheus

type Prometheus struct {
	Mode         PrometheusMode `` /* 153-byte string literal not displayed */
	Addr         string         `` /* 171-byte string literal not displayed */
	PushInterval string         `` /* 174-byte string literal not displayed */
}

Prometheus is the settings of prometheus

type PrometheusMode

type PrometheusMode string

PrometheusMode mode enum

const (
	PrometheusModePull PrometheusMode = "pull"
	PrometheusModePush PrometheusMode = "push"
)

PrometheusMode

type SLAReport

type SLAReport struct {
	Schedule Schedule `` /* 182-byte string literal not displayed */
	Time     string   `` /* 144-byte string literal not displayed */
	//Debug    bool     `yaml:"debug" json:"debug,omitempty" jsonschema:"title=Debug,description=if true the SLA report will be printed to stdout,default=false"`
	DataFile string   `` /* 153-byte string literal not displayed */
	Backups  int      `yaml:"backups" json:"backups,omitempty" jsonschema:"title=Backups,description=the number of backups of SLA report,default=5"`
	Channels []string `yaml:"channels" json:"channels,omitempty" jsonschema:"title=Channels,description=the channels of SLA report"`
}

SLAReport is the settings for SLA report

type Schedule

type Schedule int

Schedule is the schedule.

const (
	None Schedule = iota
	Minutely
	Hourly
	Daily
	Weekly
	Monthly
)

Schedule enum

func (Schedule) MarshalYAML

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

MarshalYAML marshal the configuration to yaml

func (*Schedule) UnmarshalYAML

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

UnmarshalYAML is unmarshal the debug level

type Settings

type Settings struct {
	Name       string     `` /* 132-byte string literal not displayed */
	IconURL    string     `yaml:"icon" json:"icon,omitempty" jsonschema:"title=Icon URL,description=The URL of the icon of the EaseProbe instance"`
	PIDFile    string     `` /* 140-byte string literal not displayed */
	Log        Log        `yaml:"log" json:"log,omitempty" jsonschema:"title=EaseProbe Log,description=The log settings of the EaseProbe instance"`
	TimeFormat string     `` /* 164-byte string literal not displayed */
	TimeZone   string     `` /* 178-byte string literal not displayed */
	Probe      Probe      `` /* 133-byte string literal not displayed */
	Notify     Notify     `` /* 137-byte string literal not displayed */
	SLAReport  SLAReport  `` /* 132-byte string literal not displayed */
	HTTPServer HTTPServer `` /* 136-byte string literal not displayed */
	Prometheus Prometheus `` /* 146-byte string literal not displayed */
}

Settings is the EaseProbe configuration

Jump to

Keyboard shortcuts

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