Documentation ¶
Index ¶
- Variables
- func Configure(t *testing.T, trapConfig Config)
- func FormatPacketToJSON(packet *SnmpPacket) (map[string]interface{}, error)
- func GetPort(t *testing.T) uint16
- func GetStatus() map[string]interface{}
- func GetTags(packet *SnmpPacket) []string
- func IsEnabled() bool
- func IsRunning() bool
- func StartServer() error
- func StopServer()
- type Config
- type PacketsChannel
- type SnmpPacket
- type TrapServer
Constants ¶
This section is empty.
Variables ¶
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 FormatPacketToJSON ¶
func FormatPacketToJSON(packet *SnmpPacket) (map[string]interface{}, error)
FormatPacketToJSON converts an SNMP trap packet to a JSON-serializable object.
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.
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 ¶
ReadConfig builds and returns configuration from Agent configuration.
func (*Config) BuildV2Params ¶
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.