alerts

package
v0.0.0-...-694375a Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package alerts contains code relating to the storage and manipulation of alerts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertRaise

type AlertRaise func(x alert.Alert, config string) error

AlertRaise is a function-signature.

When an alert becomes raised we need to notify a human, we don't have support for doing that directly, instead we execute an external process to do that - here is the callback function which is invoked to do that.

type Alerts

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

Alerts is our object for interfacing with alerts.

func New

func New() (*Alerts, error)

New is the constructor for our object.

func (*Alerts) AckEvent

func (s *Alerts) AckEvent(id string) error

AckEvent changes the state of the given alert to be "acknowledged".

func (*Alerts) AddEvent

func (s *Alerts) AddEvent(data alert.Alert) error

AddEvent adds a new event to our database.

func (*Alerts) AddUser

func (s *Alerts) AddUser(user string, pass string) error

AddUser adds a new user to the database

func (*Alerts) Alerts

func (s *Alerts) Alerts() ([]alert.Alert, error)

Alerts return all alerts, and their details.

func (*Alerts) ClearEvent

func (s *Alerts) ClearEvent(id string) error

ClearEvent changes the state of the given alert to be "cleared".

func (*Alerts) Close

func (s *Alerts) Close()

Close ensures that our database-connection is closed.

func (*Alerts) DelUser

func (s *Alerts) DelUser(user string) error

DelUser deletes a user from the system.

func (*Alerts) GetAlert

func (s *Alerts) GetAlert(id int) (alert.Alert, error)

GetAlert returns a single alert, via the identifier.

func (*Alerts) GetUsers

func (s *Alerts) GetUsers() ([]string, error)

GetUsers returns all known usernames.

func (*Alerts) Notify

func (s *Alerts) Notify(callback AlertRaise, config string) error

Notify is called to trigger the _initial_ notification for any event which has become raised.

It will not be involved in _re_notification.

func (*Alerts) RaiseEvent

func (s *Alerts) RaiseEvent(id string) error

RaiseEvent changes the state of the given alert to be "raised".

func (*Alerts) Reap

func (s *Alerts) Reap() error

Reap remove old/obsolete events from the database.

func (*Alerts) Renotify

func (s *Alerts) Renotify(callback AlertRaise, config string) error

Renotify triggers notifications for any alerts which continue to be outstanding.

func (*Alerts) ValidateLogin

func (s *Alerts) ValidateLogin(user string, pass string) (bool, error)

ValidateLogin tests a given User/Pass pair for validity

func (*Alerts) Warp

func (s *Alerts) Warp() error

Warp handles any alerts in a raised state, having a `raise_at` time in the future. (By clearing them.)

This allows heartbeat alerts to auto-clear when they return.

Jump to

Keyboard shortcuts

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