event

package
v0.0.0-...-cd37cee Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeState           = "state"
	TypeAcknowledgement = "acknowledgement"
	TypeInternal        = "internal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Time     time.Time `json:"-"`
	SourceId int64     `json:"-"`

	Name      string            `json:"name"`
	URL       string            `json:"url"`
	Tags      map[string]string `json:"tags"`
	ExtraTags map[string]string `json:"extra_tags"`

	Type     string   `json:"type"`
	Severity Severity `json:"severity"`
	Username string   `json:"username"`
	Message  string   `json:"message"`

	ID int64 `json:"-"`
}

Event received of a specified Type for internal processing.

The JSON struct tags are being used to unmarshal a JSON representation received from the listener.Listener. Some fields are being omitted as they are only allowed to be populated from within icinga-notifications. Currently, there is no Event being marshalled into its JSON representation.

func (*Event) FullString

func (e *Event) FullString() string

func (*Event) String

func (e *Event) String() string

func (*Event) Sync

func (e *Event) Sync(ctx context.Context, tx *sqlx.Tx, db *icingadb.DB, objectId types.Binary) error

Sync transforms this event to *event.EventRow and synchronises with the database.

type EventRow

type EventRow struct {
	ID       int64           `db:"id"`
	Time     types.UnixMilli `db:"time"`
	ObjectID types.Binary    `db:"object_id"`
	Type     types.String    `db:"type"`
	Severity Severity        `db:"severity"`
	Username types.String    `db:"username"`
	Message  types.String    `db:"message"`
}

EventRow represents a single event database row and isn't an in-memory representation of an event.

func NewEventRow

func NewEventRow(e *Event, objectId types.Binary) *EventRow

func (*EventRow) TableName

func (er *EventRow) TableName() string

TableName implements the contracts.TableNamer interface.

type Severity

type Severity int
const (
	SeverityNone Severity = iota
	SeverityOK
	SeverityDebug
	SeverityInfo
	SeverityNotice
	SeverityWarning
	SeverityErr
	SeverityCrit
	SeverityAlert
	SeverityEmerg
)

func GetSeverityByName

func GetSeverityByName(sev string) (Severity, error)

func (*Severity) MarshalJSON

func (s *Severity) MarshalJSON() ([]byte, error)

func (*Severity) Scan

func (s *Severity) Scan(src any) error

Scan implements the sql.Scanner interface. Supports SQL NULL.

func (*Severity) String

func (s *Severity) String() string

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(data []byte) error

func (Severity) Value

func (s Severity) Value() (driver.Value, error)

Value implements the driver.Valuer interface. Supports SQL NULL.

Jump to

Keyboard shortcuts

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