Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Format Specifications

&pagelevel(5)&pagelevel

snmptrapd interprets format strings similarly to printf(). It understands the following formatting sequences:

String

Description

%%

a literal %

%a

the contents of the agent-addr field of the PDU (v1 TRAPs only)

%A

the hostname corresponding to the contents of the agent-addr field of the PDU, if
available, otherwise the contents of the agent-addr field of the PDU(v1 TRAPs only).

%b

PDU source address (Note: this is not necessarily an IPv4 address)

%B

PDU source hostname if available, otherwise PDU source address (see note above)

%h

current hour on the local system

%H

the hour field from the sysUpTime.0 varbind

%j

current minute on the local system

%J

the minute field from the sysUpTime.0 varbind

%k

current second on the local system

%K

the seconds field from the sysUpTime.0 varbind

%l

current day of month on the local system

%L

the day of month field from the sysUpTime.0 varbind

%m

current (numeric) month on the local system

%M

the numeric month field from the sysUpTime.0 varbind

%N

enterprise string

%q

trap sub-type (numeric, in decimal)

%P

security information from the PDU (community name for v1/v2c, user and context for v3)

%t

decimal number of seconds since the operating system epoch

%T

the value of the sysUpTime.0 varbind in seconds

%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

%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 the sysUpTime.0 varbind

In addition to these values, optional fields width and precision may also be specified, just as in printf(3), and a flag value. The following flags are supported:

  • ‘-‘ (left justify)

  • ‘0’ (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 time zone)

  • 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"