database

package
v0.0.0-...-29fb1c0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const AlertMsg = "alert service from logmania, device did not send new message for a while"

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// depraced Format -> transformation to new format by db.update()
	Hostname       map[string]string                    `json:"hostname,omitempty"`
	HostTo         map[string]map[string]bool           `json:"host_to,omitempty"`
	MaxPrioIn      map[string]logstd.Level              `json:"maxLevel,omitempty"`
	RegexIn        map[string]map[string]*regexp.Regexp `json:"regexIn,omitempty"`
	Lastseen       map[string]time.Time                 `json:"lastseen,omitempty"`
	LastseenNotify map[string]time.Time                 `json:"-"`
	// new format
	Hosts             []*Host            `json:"hosts"`
	HostsByAddress    map[string]*Host   `json:"-"`
	HostsByName       map[string]*Host   `json:"-"`
	Notifies          []*Notify          `json:"notifies"`
	NotifiesByAddress map[string]*Notify `json:"-"`
	DefaultNotify     []*Notify          `json:"-"`
}

func ReadDBFile

func ReadDBFile(path string) *DB

func (*DB) AddHost

func (db *DB) AddHost(h *Host)

func (*DB) AddNotify

func (db *DB) AddNotify(n *Notify)

func (*DB) Alert

func (db *DB) Alert(expired time.Duration, send func(e *log.Entry, n *Notify) bool)

func (*DB) ChangeHostname

func (db *DB) ChangeHostname(h *Host, name string)

func (*DB) DeleteHost

func (db *DB) DeleteHost(h *Host)

func (*DB) GetHost

func (db *DB) GetHost(str string) *Host

func (*DB) InitHost

func (db *DB) InitHost()

func (*DB) InitNotify

func (db *DB) InitNotify()

func (*DB) NewHost

func (db *DB) NewHost(addr string) *Host

func (*DB) NewNotify

func (db *DB) NewNotify(to string) *Notify

func (*DB) SendTo

func (db *DB) SendTo(e *log.Entry) (*log.Entry, *Host, []*Notify)

type Host

type Host struct {
	Name              string             `json:"name"`
	Address           string             `json:"address"`
	Lastseen          time.Time          `json:"lastseen,omitempty"`
	LastseenNotify    time.Time          `json:"lastseen_notify,omitempty"`
	Notifies          []string           `json:"notifies"`
	NotifiesByAddress map[string]*Notify `json:"-"`
}

func (*Host) AddNotify

func (h *Host) AddNotify(n *Notify)

func (*Host) DeleteNotify

func (h *Host) DeleteNotify(to string)

type Notify

type Notify struct {
	Protocol     string                    `json:"proto"`
	To           string                    `json:"to"`
	RegexIn      map[string]*regexp.Regexp `json:"regexIn"`
	RegexReplace map[string]string         `json:"regexReplace"`
	MaxPrioIn    logstd.Level              `json:"maxLevel"`
	// contains filtered or unexported fields
}

func (*Notify) AddRegex

func (n *Notify) AddRegex(expression string) error

func (*Notify) AddRegexReplace

func (n *Notify) AddRegexReplace(expression, value string) error

func (*Notify) Address

func (n *Notify) Address() string

func (*Notify) Init

func (n *Notify) Init()

func (*Notify) RunReplace

func (n *Notify) RunReplace(msg string) string

func (*Notify) Send

func (n *Notify) Send(e *log.Entry) bool

Jump to

Keyboard shortcuts

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