I have configured rsyslog
and set following value:
$template serverlog, "/var/log/TEST/%HOSTNAME%/server.log"
local4.* ?serverlog
Now the code will create folder based on %HOSTNAME%
, but I would like to create folder First on server name (company name) and then HOSTNAME
.
For example: I have 3 servers for the 2 different companies ABCD
and xyz
, and their 3 server names (hostname) is: abcdapp-1t
abcdapp-2t
abcdapp-3t
xyzapp-1t xyzapp-2t xyzapp-3t
Now if I run the above template, it will create different folders according to hostname under /var/log/TEST/
, but I need to create 2 different folders ABCD
and XYZ
and relative hostname will go under specific directory and create subfolder.
For example: required to looks like this:
/var/log/TEST/ABCD/abcdapp-1t/server.log
/var/log/TEST/ABCD/abcdapp-2t/server.log
/var/log/TEST/ABCD/abcdapp-3t/server.log
/var/log/TEST/XYZ/xyzapp-1t/server.log
/var/log/TEST/XYZ/xyzapp-2t/server.log
/var/log/TEST/XYZ/xyzapp-3t/server.log
As I have more than 15 different servers of clients, I can not do it in one statement.
How can I use If else IF
statements in rsyslog
, so I can filter by HOSTNAME
and move to specific folder?
Is there any suggestion?