SNMPTRAP(1)

πŸ’– SNMPTRAP β€” the Net-SNMP girlies' guide πŸ’–

okay so bestie, this is the snmptrap(1) page from the Net-SNMP manual, and also snmpinform β€” they're like twins, one of them just texts back. πŸ’…


✨ NAME ✨

snmptrap, snmpinform β€” sends an SNMP notification to a manager 🫢


✨ SYNOPSIS ✨

snmptrap -v 1 [COMMON OPTIONS] AGENT enterprise-oid agent generic-trap
specific-trap uptime [OID TYPE VALUE]...

snmptrap -v [2c|3] [COMMON OPTIONS] [-Ci] AGENT uptime trap-oid [OID
TYPE VALUE]...

snmpinform -v [2c|3] [COMMON OPTIONS] AGENT uptime trap-oid [OID
TYPE VALUE]...

✨ DESCRIPTION ✨

so snmptrap is an SNMP application that uses the SNMP TRAP operation to send info to a network manager. like, it's the one sliding into the manager's DMs unprompted. 😌

you can hand it one or more object identifiers (OIDs) as arguments on the command line, no cap. and every single object identifier needs a type and a value riding along with it β€” they're a package deal, bestie. each variable name gets written in the format that's spelled out in variables(5).

when you invoke it as snmpinform, or when you add -Ci to the command line flags of snmptrap, it sends an INFORM-PDU instead β€” and that one expects a response from the trap receiver, retransmitting if required. it's giving "did you get my message?? πŸ₯Ί did you??" otherwise it sends a TRAP-PDU or a TRAP2-PDU, which is more of a "no reply needed, just vibing" situation.

if any of the required version 1 parameters β€” enterprise-oid, agent, and uptime β€” are specified as empty, it defaults to:

  • 1.3.6.1.4.1.3.1.1 (that's enterprises.cmu.1.1, iconic)
  • hostname
  • host-uptime

respectively. slay. ✨


πŸŽ€ the TYPE character πŸŽ€

the TYPE is a single character, and it's gotta be one of these:

i  INTEGER
u  UNSIGNED
c  COUNTER32
s  STRING
x  HEX STRING
d  DECIMAL STRING
n  NULLOBJ
o  OBJID
t  TIMETICKS
a  IPADDRESS
b  BITS

and these are handled in the exact same way as the snmpset command. iykyk. πŸ’–


🌸 about the AGENT argument 🌸

the AGENT argument is only embedded in SNMP TRAP PDUs but not in SNMP INFORM PDUs. so if you were wondering why it ghosted your inform, that's why. πŸ™ˆ

if AGENT is not an empty string, it must be an IPv4 address. this limitation comes from RFC 1157, in which the agent address field is defined as follows:

agent-addr NetworkAddress, -- address of object generating trap

and from RFC 1155:

NetworkAddress ::=
    CHOICE {
        internet IpAddress
    }
[ ... ]
IpAddress ::=
    [APPLICATION 0]          -- in network-byte order
        IMPLICIT OCTET STRING (SIZE (4))

πŸ¦‹ an example, because examples ate πŸ¦‹

here's an example of how to use snmptrap:

snmptrap -v 1 -c public manager enterprises.spider test-hub 3 0 ''
interfaces.iftable.ifentry.ifindex.1 i 1

this will send a generic linkUp trap to manager, for interface 1. periodt. πŸ”₯


✨ OPTIONS ✨

snmptrap takes the common options described in the snmpcmd(1) manual page, plus the -Ci option we already talked about up above. πŸ‘‘

⚠️ note that snmptrap REQUIRES an argument specifying the agent to query, as described there. it's not optional, bestie. it will not let you skip that step. πŸ’€

✨ SEE ALSO ✨


and that's the whole page, angel!! go forth and send your traps πŸ’œ

this was Net-SNMP version V5.9.5.2, dated 19 Jun 2003 β€” yeah she's an elder icon but she still serves πŸŒˆπŸ‘‘πŸ’…

πŸ“¦ where this page comes from