[syslog-ng] Get host IP inside source { file ( ); } driver

Fabien Wernli wernli at in2p3.fr
Thu Feb 26 09:31:24 CET 2015


Hi,

On Thu, Feb 26, 2015 at 12:02:36PM +0530, Thanuje Ashwin Nallaperuma wrote:
> I want to read a file which is in the name of the IP of syslog-ng client
> machine
> I tried with $HOST macro
> 
> source { file (/mnt/$HOST); };
> 
> But this does not work
> Any help on doing this ?

I guess the file() source doesn't expand templates, so it actually tries to
open a file called "/mnt/$HOST" (literally).
If you're using  relatively recent version of syslog-ng (starting 3.2 I
*think*) you should be able to achieve this however using environmental
variables (see chapter 5.6 from the v3.6 guide):

| source { file (/mnt/`HOSTNAME`); };

This would only work of course if HOSTNAME is exported when running syslog-ng



More information about the syslog-ng mailing list