trigger

package
v0.0.1-dev-fe9d83c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Triggers         = "triggers"
	DB               = "triggers"
	Collection       = "triggers"
	ReqCollection    = "requests"
	ResponsePolicyV2 = "/etc/policies/alert_resp/alert_resp2_0.yml"
	ISO8601Z         = "2006-01-02T15:04:05+00:00"
)

Variables

View Source
var DefaultOptions = []Options{
	{
		Name:        "Administrative Level Notification",
		Description: `Configure how you are going to be notified for system events and host alerts, including levels 'warning', 'error', and 'critical'.`,
		Attributes: []Attribute{
			{
				Name:   "severity",
				Type:   "string",
				Value:  "W",
				Enable: true,
			},
			{
				Name:   "severity",
				Type:   "string",
				Value:  "E",
				Enable: true,
			},
			{
				Name:   "severity",
				Type:   "string",
				Value:  "C",
				Enable: true,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "DEV",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "CPU",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "DSK",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "MEM",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "NET",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "SRV",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "VRT",
				Enable: false,
			},
		},
		Enable: false,
	},
	{
		Name:        "Instance Level Notification",
		Description: `Configure how you are going to be notified for instance alerts, including levels 'warning', and 'critical'.`,
		Attributes: []Attribute{
			{
				Name:   "severity",
				Type:   "string",
				Value:  "W",
				Enable: true,
			},
			{
				Name:   "severity",
				Type:   "string",
				Value:  "E",
				Enable: false,
			},
			{
				Name:   "severity",
				Type:   "string",
				Value:  "C",
				Enable: true,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "DEV",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "CPU",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "DSK",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "MEM",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "NET",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "SRV",
				Enable: false,
			},
			{
				Name:   "category",
				Type:   "string",
				Value:  "VRT",
				Enable: false,
			},
		},
		Enable: false,
	},
}

Functions

func TimeISO8601Z

func TimeISO8601Z(t time.Time) string

func WriteFakePolicyFile

func WriteFakePolicyFile(policy *Policy)

Types

type Attribute

type Attribute struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Value  any    `json:"value"`
	Enable bool   `json:"enable"`
}

type Options

type Options struct {
	Name        string      `json:"name" yaml:"name" bson:"name"`
	Description string      `json:"description" yaml:"description"`
	Match       string      `json:"-" yaml:"match"`
	Attributes  []Attribute `json:"attributes" bson:"-" yaml:"-"`
	Response    `json:"response" yaml:"response"`
	Enable      bool            `json:"enable" yaml:"enable"`
	Status      *status.Trigger `json:"status" yaml:"-" bson:"status"`
}

func Get

func Get(name string) (*Options, bool)

func (*Options) GenMatchRule

func (o *Options) GenMatchRule() string

func (*Options) GenTaskUpdate

func (o *Options) GenTaskUpdate() Options

func (*Options) HasEmailRecipients

func (o *Options) HasEmailRecipients() bool

func (*Options) HasSlackChannels

func (o *Options) HasSlackChannels() bool

func (*Options) InitOkStatus

func (o *Options) InitOkStatus()

func (*Options) InitResponse

func (o *Options) InitResponse()

func (*Options) InitStatus

func (o *Options) InitStatus(current, desired string)

func (*Options) InitUpdateStatus

func (o *Options) InitUpdateStatus()

func (*Options) IsSame

func (o *Options) IsSame(trigger Options) bool

func (*Options) SetCompleted

func (o *Options) SetCompleted()

func (*Options) SetError

func (o *Options) SetError()

type Policy

type Policy struct {
	Name     string    `json:"name" yaml:"name"`
	Version  float64   `json:"version" yaml:"version"`
	Enable   bool      `json:"enable" yaml:"enable"`
	Triggers []Options `json:"triggers" yaml:"triggers"`
}

func (*Policy) AppendTrigger

func (p *Policy) AppendTrigger(trigger Options)

func (*Policy) GetTrigger

func (p *Policy) GetTrigger(name string) Options

func (*Policy) UpdateOrAppendTrigger

func (p *Policy) UpdateOrAppendTrigger(trigger Options)

type Response

type Response struct {
	Types  []string          `json:"types" yaml:"-"`
	Slacks []slack.Channel   `json:"slacks" yaml:"slacks"`
	Emails []email.Recipient `json:"emails" yaml:"emails"`
}

type Toggle

type Toggle struct {
	Enable bool `json:"enable" yaml:"enable"`
}

Jump to

Keyboard shortcuts

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