Continued struggle with getting shell env vars into log statements
Greetings, I'm trying to get an environment variable (As defined in the shell - take for example "HOSTNAME"). echo $HOSTAME provides the expected string.... I then would like to append this to a set of messages based upon a specific destination. I'm using syslog-ng 3.2.5. In this case the 'hostname' is just an example, I know that the sending hostname is automatically prepended - used here because it's commonly defined on systems. I've included the following config lines from my syslog-ng.conf file. destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSGHDR$MSG host=`HOSTNAME` \n") template_escape(no)); }; filter f_web_call { facility(local1) and ( match("^.*apache-call.*$" value("MSGHDR")) );}; log { source(s_sys); filter(f_web_call); destination (d_web_call); flags(final,flow-control); }; Using the following test string: /usr/bin/logger -t apache-call-tst -p local1.notice "This is a test message 25" I get the following: <141> Sep 26 17:21:18 lab.xxxx.com apache-call-tst: This is a test message25 host= I've received a few pointers from folks here (including going to 3.5 which can't be completed in the short term....). If tried things with 'define' and using the '$' but not back-tick for the shell variable. It is not clear when this value is set (if at all) within the config file. Thanks, Jim.
participants (1)
-
jetjnkr@gmail.com