snmp

package
v0.0.0-...-a0c03a0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SourceType constants
	HostType    SourceType = "host"
	ClusterType SourceType = "cluster"

	// ModType constants
	Copy ModType = "copy"
	Set  ModType = "set"

	// SelectType constants
	Equals SelectType = "equals"

	// As constants
	Value         As = "value"
	ValueStr      As = "value-str"
	ValueStrShort As = "value-str-short"

	OidValue         As = "oid.value"
	OidValueStr      As = "oid.value-str"
	OidValueStrShort As = "oid.value-str-short"

	// OnError constants
	Send OnError = "send"
	Drop OnError = "drop"

	// Alert related constants
	Firing          EventType = "error"
	Clearing        EventType = "clear"
	EventTypeText   string    = "event_type"
	FingerprintText string    = "alert_fingerprint"
	SNMPTrapOID     string    = ".1.3.6.1.6.3.1.1.4.1.0"
	SysUpTime       string    = ".1.3.6.1.2.1.1.3.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Name               string              `yaml:"name,omitempty"`
	Enabled            Enabled             `yaml:"enabled,omitempty"`
	GeneratorUrlPrefix URLPrefix           `yaml:"generator_url_prefix,omitempty"`
	LabelMods          []Mod               `yaml:"label_mods,omitempty"`
	AnnotationMods     []Mod               `yaml:"annotation_mods,omitempty"`
	Firing             map[string][]Select `yaml:"firing,omitempty"`
	Clearing           map[string][]Select `yaml:"clearing,omitempty"`
	EndsAt             int                 `yaml:"ends_at,omitempty"`
}

Represents an alert group under v2 config

type AlertGenerator

type AlertGenerator interface {
	Alert([]string) []of.Alert // Generate an array of of.Alert for given array of Config names.
}

Parse given configs and generate alerts.

type As

type As string

type Cluster

type Cluster struct {
	SourceAddresses []string `yaml:"source_addresses,omitempty"`
}

Maps IPaddresses to there cluster name.

type Config

type Config struct {
	Defaults Default `yaml:"defaults,omitempty"`
	Alerts   []Alert `yaml:"alerts,omitempty"`
}

Represents version v2 of SNMP config

type Default

type Default struct {
	Enabled            Enabled            `yaml:"enabled,omitempty"`
	SourceType         SourceType         `yaml:"source_type,omitempty"`
	DeviceIdentifiers  []string           `yaml:"device_identifiers,omitempty"`
	Clusters           map[string]Cluster `yaml:"clusters,omitempty"`
	GeneratorUrlPrefix URLPrefix          `yaml:"generator_url_prefix,omitempty"`
	LabelMods          []Mod              `yaml:"label_mods,omitempty"`
	AnnotationMods     []Mod              `yaml:"annotation_mods,omitempty"`
	EndsAt             int                `yaml:"ends_at,omitempty"`
}

Represents Default attributes to be addded to Labels and Annotations.

type Enabled

type Enabled *bool // Need *bool to differentiate between Enabled being set to false and not being defined in config.

type EventType

type EventType string

type Lookup

type Lookup interface {
	Build() error                         // Build lookup map
	Find(*[]of.TrapVar) ([]string, error) // For given OID, return array of configs applicable.
}

Helps in identifing configs applicable for a OID.

type Mod

type Mod struct {
	Type ModType `yaml:"type,omitempty"`

	// Set specific keys
	Key   string `yaml:"key,omitempty"`
	Value string `yaml:"value,omitempty"`

	// Copy specific keys
	Oid     string            `yaml:"oid,omitempty"` // OID can be replaced with Key while removing SNMP specific details from v2 config.
	As      As                `yaml:"as,omitempty"`
	ToKey   string            `yaml:"to_key,omitempty"`
	OnError OnError           `yaml:"on_error,omitempty"`
	Map     map[string]string `yaml:"map,omitempty"`
}

Represents a mod operation to be performed on labels and annotations.

type ModType

type ModType string

type Modifier

type Modifier interface {
	Apply([]Mod) error
	Copy(Mod) error
	Set(Mod) error
}

Represents actions to be performed on snmp.Mod{}

type OnError

type OnError string

type Select

type Select struct {
	Type           SelectType `yaml:"type,omitempty"`
	Oid            string     `yaml:"oid,omitempty"` // OID can be replaced with Key while removing SNMP specific details from v2 config.
	As             As         `yaml:"as,omitempty"`
	Values         []string   `yaml:"values,omitempty"`
	AnnotationMods []Mod      `yaml:"annotation_mods,omitempty"`
}

Represents the alert selection criteria.

type SelectType

type SelectType string

type SourceType

type SourceType string

type URLPrefix

type URLPrefix string

type V2Config

type V2Config map[string]Config

Represents map of configs from different files in conf.d key in the map is the top-level name of the respective configs.

type ValueGenerator

type ValueGenerator interface {
	ValueAs(string, As) (string, error)      // Compute value as `As` for given OID.
	Value(string) (string, error)            // Literal value for given OID.
	ValueStr(string) (string, error)         // String representation of the value, for given OID.
	ValueStrShort(string) (string, error)    // Short Name of the value, for given OID.
	OIDValue(string) (string, error)         // Literal value for OID pointed by given OID,
	OIDValueStr(string) (string, error)      // String representation of the value, for OID pointed by given OID.
	OIDValueStrShort(string) (string, error) // Short Name of the value, for OID pointed by given OID.
}

Interface to handle different types of MIB resolutions.

Jump to

Keyboard shortcuts

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