Score:0

Add mac address in rsyslog template

cg flag

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.
vidarlo avatar
ar flag
Why would you want this?
sandip karanjekar avatar
cg flag
I need to send syslogs to a central place and filter using Mac address.
Paul avatar
cn flag
Can the program that generates the log add the mac address itself ? I'm not sure that rsyslog can run commands like you want. Otherwise you could have a look to "omprog" plugin.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.