Documentation
¶
Index ¶
- func Always(mc *MetaCheck) bool
- func Never(mc *MetaCheck) bool
- func OnStateChanged(mc *MetaCheck) bool
- func RegisterCheckDetail(name string, checkConstructor func(c *MetaCheck) ICheck)
- type Account
- type CheckDefaults
- type CheckError
- type CheckState
- type Config
- type Email
- type ICheck
- type MetaCheck
- func (mc *MetaCheck) DefaultNotifyFailedFunc(cond func(mc *MetaCheck) bool, err *CheckError) NotifyFuncSwitch
- func (mc *MetaCheck) DefaultNotifyOkFunc(cond func(mc *MetaCheck) bool) NotifyFuncSwitch
- func (mc *MetaCheck) HasStateChanged() bool
- func (mc *MetaCheck) InitTicker(runQueue chan<- func() func(*Notification))
- func (mc *MetaCheck) NewError(err error) *CheckError
- func (m *MetaCheck) RollState()
- func (mc *MetaCheck) Run() func(*Notification)
- func (mc *MetaCheck) SetDefaults(def *CheckDefaults)
- func (mc *MetaCheck) SetState(s CheckState)
- func (mc *MetaCheck) Validate() error
- type Notification
- type NotifyFuncSwitch
- type NotifyTarget
- type StartupNotification
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnStateChanged ¶ added in v0.2.2
Activates the notification if the state has changed
func RegisterCheckDetail ¶
Types ¶
type CheckDefaults ¶
type CheckDefaults struct { NotifyTargets []NotifyTarget `yaml:"notifyTargets"` Interval *int `yaml:"interval"` Timeout *int `yaml:"timeout"` }
CheckDefaults represents the global default values for checks
func (*CheckDefaults) Validate ¶
func (c *CheckDefaults) Validate() error
type CheckError ¶
type CheckError struct {
// contains filtered or unexported fields
}
func (*CheckError) Error ¶
func (c *CheckError) Error() string
type CheckState ¶ added in v0.2.2
type CheckState bool
Represents the state of a check
const ( // CheckOk represents a successful check CheckOk CheckState = true // CheckFailed represents a failed check CheckFailed CheckState = false )
type Config ¶
type Config struct { StartupNotification *StartupNotification `yaml:"startupNotification"` CheckConfigDir string `yaml:"checkConfigDir"` Notification *Notification `yaml:"notification"` CheckDefaults *CheckDefaults `yaml:"checkDefaults"` Checks []*MetaCheck }
Represents the global main configuration
type Email ¶
type Email struct { Enabled bool `yaml:"enabled"` Account *Account `yaml:"account"` Host string `yaml:"host"` Port int `yaml:"port"` From string `yaml:"from"` To []string `yaml:"to"` }
Represents an email configuration for notifications
type ICheck ¶ added in v0.2.2
type ICheck interface { Validate() error SetDefaults(*MetaCheck) Run() (CheckState, NotifyFuncSwitch) }
Represents the interface for a check
type MetaCheck ¶ added in v0.2.2
type MetaCheck struct { Name string Address string `yaml:"address"` Interval int `yaml:"interval"` Timeout int `yaml:"timeout"` Type string `yaml:"type"` Config map[string]any `yaml:"config"` NotifyTargets []NotifyTarget `yaml:"notifyTargets"` // contains filtered or unexported fields }
Represents a check configuration
func (*MetaCheck) DefaultNotifyFailedFunc ¶ added in v0.2.2
func (mc *MetaCheck) DefaultNotifyFailedFunc(cond func(mc *MetaCheck) bool, err *CheckError) NotifyFuncSwitch
Returns a default notification function for errors If cond() returns true, it returns a func that sends a notification If cond() returns false and the current check state is CheckFailed, it returns a func that prints only a log message Otherwise, it returns nil
func (*MetaCheck) DefaultNotifyOkFunc ¶ added in v0.2.2
func (mc *MetaCheck) DefaultNotifyOkFunc(cond func(mc *MetaCheck) bool) NotifyFuncSwitch
Returns a default notification function for OK messages If cond() returns true, it returns a func that sends a notification Otherwise, it returns nil
func (*MetaCheck) HasStateChanged ¶ added in v0.2.2
Checks if the state has changed
func (*MetaCheck) InitTicker ¶ added in v0.2.2
func (mc *MetaCheck) InitTicker(runQueue chan<- func() func(*Notification))
Initializes the ticker for the check
func (*MetaCheck) NewError ¶ added in v0.2.2
func (mc *MetaCheck) NewError(err error) *CheckError
Creates a new error for the check
func (*MetaCheck) RollState ¶ added in v0.2.2
func (m *MetaCheck) RollState()
Rolls the state of the check
func (*MetaCheck) Run ¶ added in v0.2.2
func (mc *MetaCheck) Run() func(*Notification)
Runs the check
func (*MetaCheck) SetDefaults ¶ added in v0.2.2
func (mc *MetaCheck) SetDefaults(def *CheckDefaults)
Sets the default values for the check
func (*MetaCheck) SetState ¶ added in v0.2.2
func (mc *MetaCheck) SetState(s CheckState)
Sets the previous state of the check
type Notification ¶
type Notification struct { DefaultTarget NotifyTarget `yaml:"defaultTarget"` Targets map[string]*Target `yaml:"targets"` }
Represents the notification configuration
func (*Notification) Notify ¶
func (n *Notification) Notify(targets []NotifyTarget, subject, text string)
Sends a notification to the specified targets
func (*Notification) Validate ¶
func (n *Notification) Validate() error
Validates the notification configuration
type NotifyFuncSwitch ¶ added in v0.2.2
type NotifyFuncSwitch func() func(*Notification)
type StartupNotification ¶
type StartupNotification struct {
Targets []NotifyTarget `yaml:"targets"`
}
Represents the startup notification configuration