notify

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const NotifyFailureTypeBothFailure = "SmartFailure" //SmartFailure always takes precedence when Scrutiny & Smart failed.
View Source
const NotifyFailureTypeEmailTest = "EmailTest"
View Source
const NotifyFailureTypeScrutinyFailure = "ScrutinyFailure"
View Source
const NotifyFailureTypeSmartFailure = "SmartFailure"

Variables

This section is empty.

Functions

func ShouldNotify added in v0.4.14

func ShouldNotify(logger logrus.FieldLogger, device models.Device, smartAttrs measurements.Smart, statusThreshold pkg.MetricsStatusThreshold, statusFilterAttributes pkg.MetricsStatusFilterAttributes, repeatNotifications bool, c *gin.Context, deviceRepo database.DeviceRepo) bool

ShouldNotify check if the error Message should be filtered (level mismatch or filtered_attributes)

Types

type Notify

type Notify struct {
	Logger  logrus.FieldLogger
	Config  config.Interface
	Payload Payload
}

func New added in v0.4.14

func New(logger logrus.FieldLogger, appconfig config.Interface, device models.Device, test bool) Notify

func (*Notify) GenShoutrrrNotificationParams

func (n *Notify) GenShoutrrrNotificationParams(shoutrrrUrl string) (string, *shoutrrrTypes.Params, error)

func (*Notify) Send

func (n *Notify) Send() error

func (*Notify) SendScriptNotification

func (n *Notify) SendScriptNotification(scriptUrl string) error

func (*Notify) SendShoutrrrNotification

func (n *Notify) SendShoutrrrNotification(shoutrrrUrl string) error

func (*Notify) SendWebhookNotification

func (n *Notify) SendWebhookNotification(webhookUrl string) error

type Payload

type Payload struct {
	HostId       string `json:"host_id,omitempty"` //host id (optional)
	DeviceType   string `json:"device_type"`       //ATA/SCSI/NVMe
	DeviceName   string `json:"device_name"`       //dev/sda
	DeviceSerial string `json:"device_serial"`     //WDDJ324KSO
	Test         bool   `json:"test"`              // false

	//private, populated during init (marked as Public for JSON serialization)
	Date        string `json:"date"`         //populated by Send function.
	FailureType string `json:"failure_type"` //EmailTest, BothFail, SmartFail, ScrutinyFail
	Subject     string `json:"subject"`
	Message     string `json:"message"`
}

TODO: include user label for device.

func NewPayload added in v0.4.14

func NewPayload(device models.Device, test bool, currentTime ...time.Time) Payload

func (*Payload) GenerateFailureType added in v0.4.14

func (p *Payload) GenerateFailureType(deviceStatus pkg.DeviceStatus) string

func (*Payload) GenerateMessage

func (p *Payload) GenerateMessage() string

func (*Payload) GenerateSubject

func (p *Payload) GenerateSubject() string

Jump to

Keyboard shortcuts

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