traps

package
v0.0.0-...-551a65d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NetSNMPExampleHeartbeatNotificationVariables = []gosnmp.SnmpPDU{

		{Name: "1.3.6.1.2.1.1.3.0", Type: gosnmp.TimeTicks, Value: uint32(1000)},

		{Name: "1.3.6.1.6.3.1.1.4.1.0", Type: gosnmp.OctetString, Value: "1.3.6.1.4.1.8072.2.3.0.1"},

		{Name: "1.3.6.1.4.1.8072.2.3.2.1", Type: gosnmp.Integer, Value: 1024},

		{Name: "1.3.6.1.4.1.8072.2.3.2.2", Type: gosnmp.OctetString, Value: "test"},
	}
)

List of variables for a NetSNMP::ExampleHeartBeatNotification trap message. See: http://www.circitor.fr/Mibs/Html/N/NET-SNMP-EXAMPLES-MIB.php#netSnmpExampleHeartbeatNotification

Functions

func Configure

func Configure(t *testing.T, trapConfig Config)

Configure sets Datadog Agent configuration from a config object.

func FormatPacketToJSON

func FormatPacketToJSON(packet *SnmpPacket) (map[string]interface{}, error)

FormatPacketToJSON converts an SNMP trap packet to a JSON-serializable object.

func GetPort

func GetPort(t *testing.T) uint16

GetPort requests a random UDP port number and makes sure it is available

func GetStatus

func GetStatus() map[string]interface{}

GetStatus returns key-value data for use in status reporting of the traps server.

func GetTags

func GetTags(packet *SnmpPacket) []string

GetTags returns a list of tags associated to an SNMP trap packet.

func IsEnabled

func IsEnabled() bool

IsEnabled returns whether SNMP trap collection is enabled in the Agent configuration.

func IsRunning

func IsRunning() bool

IsRunning returns whether the trap server is currently running.

func StartServer

func StartServer() error

StartServer starts the global trap server.

func StopServer

func StopServer()

StopServer stops the global trap server, if it is running.

Types

type Config

type Config struct {
	Port             uint16   `mapstructure:"port" yaml:"port"`
	CommunityStrings []string `mapstructure:"community_strings" yaml:"community_strings"`
	BindHost         string   `mapstructure:"bind_host" yaml:"bind_host"`
	StopTimeout      int      `mapstructure:"stop_timeout" yaml:"stop_timeout"`
}

Config contains configuration for SNMP trap listeners. YAML field tags provided for test marshalling purposes.

func ReadConfig

func ReadConfig() (*Config, error)

ReadConfig builds and returns configuration from Agent configuration.

func (*Config) Addr

func (c *Config) Addr() string

Addr returns the host:port address to listen on.

func (*Config) BuildV2Params

func (c *Config) BuildV2Params() *gosnmp.GoSNMP

BuildV2Params returns a valid GoSNMP SNMPv2 params structure from configuration.

type PacketsChannel

type PacketsChannel = chan *SnmpPacket

PacketsChannel is the type of channels of trap packets.

func GetPacketsChannel

func GetPacketsChannel() PacketsChannel

GetPacketsChannel returns a channel containing all received trap packets.

type SnmpPacket

type SnmpPacket struct {
	Content *gosnmp.SnmpPacket
	Addr    *net.UDPAddr
}

SnmpPacket is the type of packets yielded by server listeners.

type TrapServer

type TrapServer struct {
	Addr string
	// contains filtered or unexported fields
}

TrapServer manages an SNMPv2 trap listener.

func NewTrapServer

func NewTrapServer() (*TrapServer, error)

NewTrapServer configures and returns a running SNMP traps server.

func (*TrapServer) Stop

func (s *TrapServer) Stop()

Stop stops the TrapServer.

Jump to

Keyboard shortcuts

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