On Tue, 19 Aug 2014, Rainer Gerhards wrote:
On Tue, Aug 19, 2014 at 9:34 AM, David Lang <[email protected]> wrote:
On Mon, 18 Aug 2014, [email protected] wrote:
Is it possible to make hostname-specific $IncludeConfig statements in
rsyslog.conf?
For example, If I arrange a shared /etc/rsyslog.d directory as
/etc/rsyslog.d
common-app1.conf
common-app2.conf
...
common-appN.conf
/hostname1/
hostname1-app1.conf
/hostname2/
hostname2-app1.conf
I'd like to be able to do something equivalent to
$IncludeConfig /etc/rsyslog.d/*.conf
$IncludeConfig /etc/rsyslog.d/$hostname/*.conf
So that any give host includes all the 'common' configs, as well as its
host-specific ones.
That config ^^ doesn't cause any errors on rsyslog startup. It also
doesn't work -- the $hostname-specific directory's files are NOT included.
Can you do this in rsyslog? I'm running rsyslogd 8.2.2, fyi.
I don't believe so, you can't use variables everywhere, only where it's
been specifically setup.
well, it would really make no sense here. Remember that rsyslog loads the
config *during initialization*. So how shall it know at this time which
hostnames exist?
ahh, I was reading this that he wanted to include a file based on the name of
the server it's running on, so that he could push out identical files to a lot
of machines and they would behave differently based on their local hostname.
yeah, trying to include a file based on what's in the message can't be done
sanely.
David Lang
IIRC, you may go away with
$IncludeConfig /etc/rsyslog.d/*/*.conf
but not sure if it works.
I guess, however, that the real question is a different one. Let's assume
for a moment that the $hostname include would work. What would you gain
from it? After all, it would just dynamically extend the rsyslog
configuration when a new host would be seen the first time. Remember that
in any case all messages are being run through the whole config.
$IncludeConfig is just like copy&paste - no logic is part of it.
To me, it sounds like you would like to do a lookup on a hostname and
select a set of rules for execution based on the lookup result.
You cannot do this either (we are open for sponsorship and patches ;)), but
you can do
if $hostname == "host1" then {
...
} else if $hostname == "host2" then {
...
}
you can even use includes if you really want this. Name them
host-incl-nnnn.conf
with nnnn being a number (use leading zeros just to be sure)
the, reseve
host-incl-0000.conf to:
if 0 then continue
and for all others
host-incl-0001.conf:
else if $hostname == "host1" {
...
}
and finally use
$IncludeConfig /etc/rsyslog.d/hosts/*.conf
That should do the trick. Note how the if-elseif chain is created from the
snippets inside the individual include files.
HTH
Rainer
make a symlink to the file from a common name at bootup and have rsyslog
include that.
David Lang
Terry
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad
of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you
DON'T LIKE THAT.
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad
of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you
DON'T LIKE THAT.
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE
THAT.
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE
THAT.