snmptrap() source options
The snmptrap()
driver has the following options. Only the filename()
option is required, the others are optional.
filename()
Type: | path |
Default: |
Description: The log file of snmptrapd
. The AxoSyslog application reads the traps from this file.
In addition to traps, the log of snmptrapd
may contain other messages (for example, daemon start/stop information, debug logs) as well. Currently AxoSyslog discards these messages.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
persist-name()
Type: | string |
Default: | N/A |
Description: If you receive the following error message during AxoSyslog startup, set the persist-name()
option of the duplicate drivers:
Error checking the uniqueness of the persist names, please override it with persist-name option. Shutting down.
This error happens if you use identical drivers in multiple sources, for example, if you configure two file sources to read from the same file. In this case, set the persist-name()
of the drivers to a custom string, for example, persist-name("example-persist-name1")
.
prefix()
Synopsis: | prefix() |
Description: Insert a prefix before the name part of the parsed name-value pairs to help further processing. For example:
-
To insert the
my-parsed-data.
prefix, use theprefix(my-parsed-data.)
option. -
To refer to a particular data that has a prefix, use the prefix in the name of the macro, for example,
${my-parsed-data.name}
. -
If you forward the parsed messages using the IETF-syslog protocol, you can insert all the parsed data into the SDATA part of the message using the
prefix(.SDATA.my-parsed-data.)
option.
Names starting with a dot (for example, .example
) are reserved for use by AxoSyslog. If you use such a macro name as the name of a parsed value, it will attempt to replace the original value of the macro (note that only soft macros can be overwritten, see Hard versus soft macros for details). To avoid such problems, use a prefix when naming the parsed values, for example, prefix(my-parsed-data.)
Default value: .snmp.
option.
set-message-macro()
Type: | `yes |
Default: | yes |
Description: The snmptrap()
source automatically parses the traps into name-value pairs, so you can handle the content of the trap as a structured message. Consequently, you might not even need the ${MESSAGE}
part of the log message. If set-message-macro()
is set to no
, AxoSyslog leaves the ${MESSAGE}
part empty. If set-message-macro()
is set to yes
, AxoSyslog generates a regular log message from the trap.