snmp_trap

package
v0.0.0-...-16a0e24 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 13 Imported by: 0

README

SNMP Trap Input Plugin

The SNMP Trap plugin is a service input plugin that receives SNMP notifications (traps and inform requests).

Notifications are received on plain UDP. The port to listen is configurable.

Prerequisites

This plugin uses the snmptranslate programs from the net-snmp project. These tools will need to be installed into the PATH in order to be located. Other utilities from the net-snmp project may be useful for troubleshooting, but are not directly used by the plugin.

These programs will load available MIBs on the system. Typically the default directory for MIBs is /usr/share/snmp/mibs, but if your MIBs are in a different location you may need to make the paths known to net-snmp. The location of these files can be configured in the snmp.conf or via the MIBDIRS environment variable. See man 1 snmpcmd for more information.

Configuration
[[inputs.snmp_trap]]
  ## Transport, local address, and port to listen on.  Transport must
  ## be "udp://".  Omit local address to listen on all interfaces.
  ##   example: "udp://127.0.0.1:1234"
  ##
  ## Special permissions may be required to listen on a port less than
  ## 1024.  See README.md for details
  ##
  # service_address = "udp://:162"
  ## Timeout running snmptranslate command
  # timeout = "5s"
Using a Privileged Port

On many operating systems, listening on a privileged port (a port number less than 1024) requires extra permission. Since the default SNMP trap port 162 is in this category, using telegraf to receive SNMP traps may need extra permission.

Instructions for listening on a privileged port vary by operating system. It is not recommended to run telegraf as superuser in order to use a privileged port. Instead follow the principle of least privilege and use a more specific operating system mechanism to allow telegraf to use the port. You may also be able to have telegraf use an unprivileged port and then configure a firewall port forward rule from the privileged port.

To use a privileged port on Linux, you can use setcap to enable the CAP_NET_BIND_SERVICE capability on the telegraf binary:

setcap cap_net_bind_service=+ep /usr/bin/telegraf

On Mac OS, listening on privileged ports is unrestricted on versions 10.14 and later.

Metrics
  • snmp_trap
    • tags:
      • source (string, IP address of trap source)
      • name (string, value from SNMPv2-MIB::snmpTrapOID.0 PDU)
      • mib (string, MIB from SNMPv2-MIB::snmpTrapOID.0 PDU)
      • oid (string, OID string from SNMPv2-MIB::snmpTrapOID.0 PDU)
      • version (string, "1" or "2c" or "3")
    • fields:
      • Fields are mapped from variables in the trap. Field names are the trap variable names after MIB lookup. Field values are trap variable values.
Example Output
snmp_trap,mib=SNMPv2-MIB,name=coldStart,oid=.1.3.6.1.6.3.1.1.5.1,source=192.168.122.102,version=2c snmpTrapEnterprise.0="linux",sysUpTimeInstance=1i 1574109187723429814
snmp_trap,mib=NET-SNMP-AGENT-MIB,name=nsNotifyShutdown,oid=.1.3.6.1.4.1.8072.4.0.2,source=192.168.122.102,version=2c sysUpTimeInstance=5803i,snmpTrapEnterprise.0="netSnmpNotificationPrefix" 1574109186555115459

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SnmpTrap

type SnmpTrap struct {
	ServiceAddress string            `toml:"service_address"`
	Timeout        internal.Duration `toml:"timeout"`

	Log telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

func (*SnmpTrap) Description

func (s *SnmpTrap) Description() string

func (*SnmpTrap) Gather

func (s *SnmpTrap) Gather(_ telegraf.Accumulator) error

func (*SnmpTrap) Init

func (s *SnmpTrap) Init() error

func (*SnmpTrap) SampleConfig

func (s *SnmpTrap) SampleConfig() string

func (*SnmpTrap) Start

func (s *SnmpTrap) Start(acc telegraf.Accumulator) error

func (*SnmpTrap) Stop

func (s *SnmpTrap) Stop()

Jump to

Keyboard shortcuts

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