Documentation ¶
Index ¶
- Variables
- 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 IsRunning() bool
- func StartServer(cf *Config) 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.
Types ¶
type Config ¶
type Config struct { Enabled bool `yaml:"enabled"` // snmp_traps_enabled Port uint16 `yaml:"port"` // snmp_traps_config.port CommunityStrings []string `yaml:"communityStrings"` // snmp_traps_config.community_strings BindHost string `yaml:"bindHost"` // snmp_traps_config.bind_host StopTimeout time.Duration `yaml:"stopTimeout"` // snmp_traps_config.stop_timeout }
Config contains configuration for SNMP trap listeners. YAML field tags provided for test marshalling purposes.
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(cf *Config) (*TrapServer, error)
NewTrapServer configures and returns a running SNMP traps server.