event

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeAcknowledgementCleared = "acknowledgement-cleared"
	TypeAcknowledgementSet     = "acknowledgement-set"
	TypeCustom                 = "custom"
	TypeDowntimeEnd            = "downtime-end"
	TypeDowntimeRemoved        = "downtime-removed"
	TypeDowntimeStart          = "downtime-start"
	TypeFlappingEnd            = "flapping-end"
	TypeFlappingStart          = "flapping-start"
	TypeIncidentAge            = "incident-age"
	TypeMute                   = "mute"
	TypeState                  = "state"
	TypeUnmute                 = "unmute"
)

Please keep the following types in alphabetically order and, even more important, make sure that the database type event_type reflects the same values.

Variables

View Source
var ErrSuperfluousMuteUnmuteEvent = errors.New("ignoring superfluous (un)mute event")

ErrSuperfluousMuteUnmuteEvent indicates that a superfluous mute or unmute event is being ignored and is triggered when trying to mute/unmute an already muted/unmuted incident.

View Source
var ErrSuperfluousStateChange = errors.New("ignoring superfluous state change")

ErrSuperfluousStateChange indicates a superfluous state change being ignored and stopping further processing.

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"`

	Mute       types.Bool `json:"mute"`
	MuteReason string     `json:"mute_reason"`

	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) SetMute

func (e *Event) SetMute(muted bool, reason string)

SetMute alters the event mute and mute reason.

func (*Event) String

func (e *Event) String() string

func (*Event) Sync

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

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

func (*Event) Validate

func (e *Event) Validate() error

Validate validates the current event state. Returns an error if it detects a misconfigured field.

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"`
	Mute       types.Bool      `db:"mute"`
	MuteReason types.String    `db:"mute_reason"`
}

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