notify

package
v0.0.0-...-7f8e41e Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ICINGA_LINK = "%s/monitoring/service/show?host=%s&service=%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailConfig

type EmailConfig struct {
	Default string `yaml:"default"`

	Tenants map[string]*SMTPConfig `yaml:"tenants"`
}

type EmailNotifier

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

func NewEmailNotifier

func NewEmailNotifier(tenant string) (*EmailNotifier, error)

func (*EmailNotifier) SendHostAlert

func (n *EmailNotifier) SendHostAlert(alert *HostAlertConfig, targets ...string) error

func (*EmailNotifier) SendMessage

func (n *EmailNotifier) SendMessage(message *MessageConfig, targets ...string) error

func (*EmailNotifier) SendServiceAlert

func (n *EmailNotifier) SendServiceAlert(alert *ServiceAlertConfig, targets ...string) error

type HostAlertConfig

type HostAlertConfig struct {
	HostAddress            string `env:"HOSTADDRESS"`
	HostDisplayName        string `env:"HOSTDISPLAYNAME"`
	HostName               string `env:"HOSTNAME"`
	HostOutput             string `env:"HOSTOUTPUT"`
	HostState              string `env:"HOSTSTATE"`
	HostDurationSec        string `env:"HOSTDURATIONSEC"`
	LongDateTime           string `env:"LONGDATETIME"`
	NotificationAuthorName string `env:"NOTIFICATIONAUTHORNAME"`
	NotificationComment    string `env:"NOTIFICATIONCOMMENT"`
	NotificationType       string `env:"NOTIFICATIONTYPE"`
	ContactName            string `env:"CONTACTNAME"`

	// custom
	AckLinkURL string `env:"ACKLINKURL"`
	// contains filtered or unexported fields
}

func HostAlertFromEnv

func HostAlertFromEnv() (*HostAlertConfig, error)

func (*HostAlertConfig) Duration

func (c *HostAlertConfig) Duration() string

func (*HostAlertConfig) Subject

func (c *HostAlertConfig) Subject() string

type LarkConfig

type LarkConfig struct {
	AppID             string `yaml:"app_id"`
	AppSecret         string `yaml:"app_secret"`
	EncryptKey        string `yaml:"encrypt_key"`
	VerificationToken string `yaml:"verification_token"`
}

type LarkNotifier

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

func NewLarkNotifier

func NewLarkNotifier(tenant string) (*LarkNotifier, error)

func (*LarkNotifier) SendHostAlert

func (n *LarkNotifier) SendHostAlert(alert *HostAlertConfig, targets ...string) error

func (*LarkNotifier) SendMessage

func (n *LarkNotifier) SendMessage(message *MessageConfig, targets ...string) error

func (*LarkNotifier) SendServiceAlert

func (n *LarkNotifier) SendServiceAlert(alert *ServiceAlertConfig, targets ...string) error

type LarkTenantConfig

type LarkTenantConfig struct {
	Default string `yaml:"default"`

	Tenants map[string]*LarkConfig `yaml:"tenants"`
}

type MessageConfig

type MessageConfig struct {
	Subject  string
	Content  string
	From     string
	Markdown bool
}

type Notifier

type Notifier interface {
	SendMessage(message *MessageConfig, targets ...string) error
	SendHostAlert(alert *HostAlertConfig, targets ...string) error
	SendServiceAlert(alert *ServiceAlertConfig, targets ...string) error
}

func GetNotifier

func GetNotifier(name, tenant string) (Notifier, error)

type SMTPConfig

type SMTPConfig struct {
	From      string `yaml:"from"`
	AlertFrom string `yaml:"alert_from"`
	SMTP      struct {
		Host     string `yaml:"host"`
		Port     int    `yaml:"port"`
		Username string `yaml:"username"`
		Password string `yaml:"password"`
	} `yaml:"smtp"`
}

type ServiceAlertConfig

type ServiceAlertConfig struct {
	HostAddress            string `env:"HOSTADDRESS"`
	HostDisplayName        string `env:"HOSTDISPLAYNAME"`
	HostName               string `env:"HOSTNAME"`
	LongDateTime           string `env:"LONGDATETIME"`
	NotificationAuthorName string `env:"NOTIFICATIONAUTHORNAME"`
	NotificationComment    string `env:"NOTIFICATIONCOMMENT"`
	NotificationType       string `env:"NOTIFICATIONTYPE"`
	ServiceDisplayName     string `env:"SERVICEDISPLAYNAME"`
	ServiceName            string `env:"SERVICENAME"`
	ServiceOutput          string `env:"SERVICEOUTPUT"`
	ServiceState           string `env:"SERVICESTATE"`
	ServiceDurationSec     string `env:"SERVICEDURATIONSEC"`
	ContactName            string `env:"CONTACTNAME"`

	// custom
	IcingaWebBaseURL string `env:"ICINGAWEBBASEURL"`
	ServiceWiki      string `env:"SERVICEWIKI"`
	AckLinkURL       string `env:"ACKLINKURL"`
	// contains filtered or unexported fields
}

func ServiceAlertFromEnv

func ServiceAlertFromEnv() (*ServiceAlertConfig, error)

func (*ServiceAlertConfig) Duration

func (c *ServiceAlertConfig) Duration() string

func (*ServiceAlertConfig) Subject

func (c *ServiceAlertConfig) Subject() string

type Targets

type Targets struct {
	Tenant string

	Email []string
	Lark  []string

	// TODO: to be supported
	Wework     []string
	Sms        []string
	Pushbullet []string
	Pushover   []string
	Telegram   []string
}

Jump to

Keyboard shortcuts

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