SNMPTRAPD(8)
π NAME π
okay bestie, gather round β snmptrapd is the girl who just receives and logs SNMP trap messages. that's her whole job. she catches them, she writes them down. iconic behavior honestly. β¨
π SYNOPSIS π
snmptrapd [OPTIONS] [LISTENING ADDRESSES]
πΈ DESCRIPTION πΈ
so like, snmptrapd is an SNMP application that receives and logs SNMP TRAP and INFORM messages. she's the listener. the one who picks up the phone. π«Ά
β οΈ heads up bestie: the default is to listen on UDP port 162 on all IPv4 interfaces. and since 162 is a privileged port, snmptrapd must typically be run as root. it's giving main character with a security clearance, no cap.
β¨ OPTIONS β¨
-aβ ignoreauthenticationFailuretraps. not today, ma'am. π-Aβ append to the log file instead of truncating it. keeping the receipts, as she should.
fr fr note this: it needs to come before any -Lf options that it should apply to. order matters bestie, it's a whole thing.
-cFILE β read FILE as a configuration file (or a comma-separated list of configuration files). plural queens only. π-Cβ do not read any configuration files except the one optionally specified by the-coption. she's on a strict diet, no outside influence.-dβ dump (in hexadecimal) the sent and received SNMP packets. raw data reveal, we love to see it. π₯-D[TOKEN[,...]] β turn on debugging output for the given TOKEN(s). tryALLfor extremely verbose output. like, extremely. she will not stop talking and honestly? respect.-fβ do notfork()from the calling shell. staying attached, clingy in a cute way. π¦-FFORMAT β when logging to standard output, use the format in the string FORMAT. scroll down to FORMAT SPECIFICATIONS for the tea. β-h,--helpβ display a brief usage message and then exit. the "hi bestie here's the deal" button.-Hβ display a list of configuration file directives understood by the trap daemon and then exit. the full menu, no secrets. β¨-I[-]INITLIST β specifies which modules should (or should not) be initialized whensnmptrapdstarts up. if the comma-separated INITLIST is preceded with a-, it is the list of modules that should not be started. otherwise this is the list of the only modules that should be started.- to get a list of compiled modules, run
snmptrapdwith the arguments-Dmib_init -H(assuming debugging support has been compiled in). iykyk. π
- to get a list of compiled modules, run
-L[efos] β specify where logging output should be directed (standard error or output, to a file or via syslog). see LOGGING OPTIONS insnmpcmd(1)for details. she's got range. π-mMIBLIST β specifies a colon separated list of MIB modules to load for this application. this overrides the environment variableMIBS. seesnmpcmd(1)for details.-MDIRLIST β specifies a colon separated list of directories to search for MIBs. this overrides the environment variableMIBDIRS. seesnmpcmd(1)for details. π-nβ do not attempt to translate source addresses of incoming packets into hostnames. no name-dropping, just IPs. lowkey mysterious of her.-pFILE β save the process ID of the trap daemon in FILE. writing down her own number in case you need her. π«Ά-O[abeEfnqQsStTuUvxX] β specifies how MIB objects and other output should be displayed. see the section OUTPUT OPTIONS in thesnmpcmd(1)manual page for details.-tβ do not log traps to syslog. this disables logging to syslog. this is useful if you want thesnmptrapdapplication to only runtraphandlehooks and not to log any traps to any location. she's just vibing, observing, not journaling. π-v,--versionβ print version information for the trap daemon and then exit. the "who even am i" moment. π-xADDRESS β connect to the AgentX master agent on the specified address, rather than the default"/var/agentx/master". seesnmpd(8)for details of the format of such addresses.-Xβ do not connect to a AgentX master agent. solo era. π--name="value"β allows one to specify any token ("name") supported in thesnmptrapd.conffile and sets its value to"value". overrides the corresponding token in thesnmptrapd.conffile. seesnmptrapd.conf(5)for the full list of tokens. so powerful. so specific.
π FORMAT SPECIFICATIONS π
snmptrapd interprets format strings similarly to printf(3). she understands the following formatting sequences β and bestie, she understands all of them:
%%β a literal%%aβ the contents of theagent-addrfield of the PDU (v1 TRAPs only)%Aβ the hostname corresponding to the contents of theagent-addrfield of the PDU, if available, otherwise the contents of theagent-addrfield of the PDU (v1 TRAPs only).%bβ PDU transport address (Note: this is not necessarily an IPv4 address). Something like"[UDP: [172.16.10.12]:23456->[10.150.0.8]]"%Bβ PDU source hostname if available, otherwise PDU source address (see note above)%Eβ SNMPv3 context engine id%hβ current hour on the local system%Hβ the hour field from thesysUpTime.0varbind%jβ current minute on the local system%Jβ the minute field from thesysUpTime.0varbind%kβ current second on the local system%Kβ the seconds field from thesysUpTime.0varbind%lβ current day of month on the local system%Lβ the day of month field from thesysUpTime.0varbind%mβ current (numeric) month on the local system%Mβ the numeric month field from thesysUpTime.0varbind%Nβ enterprise string%Pβ security information from the PDU (community name for v1/v2c, user and context for v3)%qβ trap sub-type (numeric, in decimal)%sβ SNMP version number (0: v1, 1: v2c, 2: v3)%Sβ SNMPv3 security model version number%tβ decimal number of seconds since the operating system epoch (as returned bytime(2))%Tβ the value of thesysUpTime.0varbind in seconds%uβ SNMPv3 security name, or v1/v2c community name%vβ list of variable-bindings from the notification payload. These will be separated by a tab, or by a comma and a blank if the alternate form is requested See also%V%Vβ specifies the variable-bindings separator. This takes a sequence of characters, up to the next%(to embed a%in the string, use\%)%wβ trap type (numeric, in decimal)%Wβ trap description%yβ current year on the local system%Yβ the year field from thesysUpTime.0varbind
in addition to these values, an optional field width and precision may also be specified , just as in printf(3), and a flag value. The following flags are supported:
-β left justify0β use leading zeros#β use alternate form
The "use alternate form" flag changes the behavior of various format string sequences:
- Time information will be displayed based on GMT (rather than the local timezone)
- The variable-bindings will be a comma-separated list (rather than a tab-separated one)
- The system uptime will be broken down into a human-meaningful format (rather than being a simple integer)
π« Examples: π«
To get a message like "14:03 TRAP3.1 from humpty.ucd.edu" you could use something like this:
snmptrapd -P -F "%02.2h:%02.2j TRAP%w.%q from %A\n"
If you want the same thing but in GMT rather than local time, use:
snmptrapd -P -F "%#02.2h:%#02.2j TRAP%w.%q from %A\n"
π¦ LISTENING ADDRESSES π¦
By default, snmptrapd listens for incoming SNMP TRAP and INFORM packets on UDP port 162 on all IPv4 interfaces. However, it is possible to modify this behaviour by specifying one or more listening addresses as arguments to snmptrapd. See the snmpd(8) manual page for more information about the format of listening addresses. she can multitask, she can hold multiple conversations. π
π NOTIFICATION-LOG-MIB SUPPORT π
As of net-snmp 5.0, the snmptrapd application supports the NOTIFICATION-LOG-MIB. It does this by opening an AgentX subagent connection to the master snmpd agent and registering the notification log tables. As long as the snmpd application is started first, it will attach itself to it and thus you should be able to view the last recorded notifications via the nlmLogTable and nlmLogVariableTable. See the snmptrapd.conf file and the "doNotRetainNotificationLogs" token for turning off this support. See the NOTIFICATION-LOG-MIB for more details about the MIB itself.
π«Ά reminder: start snmpd first. she's not going to chase you.
π EXTENSIBILITY AND CONFIGURATION π
See the snmptrapd.conf(5) manual page. that's where all the customization lore lives, bestie.
β SEE ALSO β
snmpcmd(1), snmpd(8), printf(3), snmptrapd.conf(5), syslog(8), traptoemail(1), variables(5)
β¨ and that's the whole page, bestie! β¨ this little masterpiece is snmptrapd from Net-SNMP, version V5.9.5.2, dated 27 Apr 2014 β and yes, that date is giving vintage, but she still slays. periodt. πππ¦πΈπ
π¦ where this page comes from
- alpine 3.23: net-snmp-doc 5.9.5.2-r0 Β· Net-SNMP
- alpine 3.24: net-snmp-doc 5.9.5.2-r0 Β· Net-SNMP
- arch rolling: net-snmp 5.9.5.2-2 Β· BSD
- fedora 44: net-snmp 1:5.9.5.2-4.fc44 Β· MIT-CMU AND BSD-3-Clause AND MIT
- nixos 26.05: net-snmp 5.9.5.2
- nixpkgs unstable: net-snmp 5.9.5.2
- Copyright 1989 by Carnegie Mellon University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms