notifications

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMessage

func BuildMessage(rule rules.Rule, result rules.RuleResult, mode config.RuleMode, successfulChecks, totalHosts int) string

func SendRuleNotifications

func SendRuleNotifications(
	ctx context.Context,
	rule rules.Rule,
	notification Notification,
	notifierMap map[string]Notifier,
) error

Types

type LogNotifier

type LogNotifier struct {
	// contains filtered or unexported fields
}

func NewLogNotifier

func NewLogNotifier(logger *zap.SugaredLogger) *LogNotifier

func (*LogNotifier) Close

func (n *LogNotifier) Close() error

func (*LogNotifier) Initialize

func (n *LogNotifier) Initialize(ctx context.Context) error

func (*LogNotifier) SendNotification

func (n *LogNotifier) SendNotification(_ context.Context, notification Notification) error

func (*LogNotifier) Type

func (n *LogNotifier) Type() NotificationType

type Notification

type Notification struct {
	Message  string
	Level    NotificationLevel
	Site     string
	Group    string
	Host     string
	Port     string
	Protocol string
	Tags     []string
}

type NotificationLevel

type NotificationLevel string
const (
	InfoLevel    NotificationLevel = "info"
	WarningLevel NotificationLevel = "warning"
	ErrorLevel   NotificationLevel = "error"
)

func GetLevel

func GetLevel(result rules.RuleResult) NotificationLevel

type NotificationType

type NotificationType string
const (
	LogNotification NotificationType = "log"
)

type Notifier

type Notifier interface {
	SendNotification(ctx context.Context, notification Notification) error
	Type() NotificationType
	Initialize(ctx context.Context) error
	Close() error
}

func NewNotifier

func NewNotifier(notifierType string, opts ...interface{}) (Notifier, error)

Jump to

Keyboard shortcuts

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