0

I am trying to add system/device mac address in syslog. No solution is working for me. Following command gives me mac address, just wanted to use in rsyslog template.

mac_addr=$(ifconfig en0 | awk '/ether/ {print $2}')

template

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

Want to replace $mac_addr with value.

rsyslogd version

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.

0 Answers0