我正在尝试在 syslog 中添加系统/设备 mac 地址。没有解决方案对我有用。以下命令提供了 mac 地址,只是想在 rsyslog 模板中使用。
mac_addr=$(ifconfig en0 | awk '/ether/ {print $2}')
模板
template(name="tpl3" type="string" string="%TIMESTAMP:::date-rfc3339% %HOSTNAME% MAC=%$mac_addr% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n")
想要用值替换 $mac_addr。
rsyslogd 版本
rsyslogd 8.2112.0 (aka 2021.12) compiled with:
PLATFORM: x86_64-pc-linux-gnu
PLATFORM (lsb_release -d):
FEATURE_REGEXP: Yes
GSSAPI Kerberos 5 support: Yes
FEATURE_DEBUG (debug build, slow code): No
32bit Atomic operations supported: Yes
64bit Atomic operations supported: Yes
memory allocator: system default
Runtime Instrumentation (slow code): No
uuid support: Yes
systemd support: Yes
Config file: /etc/rsyslog.conf
PID file: /run/rsyslogd.pid
Number of Bits in RainerScript integers: 64
See https://www.rsyslog.com for more information.