#  /etc/rsyslog.conf    Configuration file for rsyslog.
#
#                       For more information see
#                       /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
#  Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad immark  # provides --MARK-- message capability

# commented in container (eole-conteneur/lxc_install.sh l.216-7)
$ModLoad imklog   # provides kernel logging support (previously done by rklogd)
$KLogPath /proc/kmsg

$PreserveFQDN on
%if %%getVar("rsyslog_envoi_tls", "non") == 'oui' or %%getVar("rsyslog_reception_tls", "non") == "oui"
# utilisation du chiffrement

# configuration general pour le chiffrement
$DefaultNetstreamDriver gtls
$DefaultNetstreamDriverCAFile %%rsyslog_ca_file
$DefaultNetstreamDriverCertFile  %%rsyslog_cert_file
$DefaultNetstreamDriverKeyFile  %%rsyslog_privkey_file

%end if

%if %%mode_conteneur_actif == 'oui' or %%getVar("activer_reception_logs_relp", "non") == 'oui'
# utilisation du protocole RELP

$ModLoad imrelp
$InputRELPServerRun 20514

%end if

%if %%getVar("activer_reception_logs_tcp", "non") == 'oui'
# utilisation du protocole TCP

$ModLoad imtcp

%if %%getVar("rsyslog_reception_tls", "non") == "oui"
# configuration TLS propre a la reception

$InputTCPServerStreamDriverMode 1
$InputTCPServerStreamDriverAuthMode anon

%end if

$AllowedSender TCP%slurp
%for %%tcp_client in %%adresses_ip_clients_logs_tcp
, %%tcp_client/%%calc_classe(%%tcp_client.netmask_client_logs_tcp)%slurp
%end for

$InputTCPServerRun 10514
%end if

%if %%getVar("activer_reception_logs_udp", "non") == 'oui'
# utilisation du protocole UDP

$ModLoad imudp
$AllowedSender UDP%slurp
%for %%udp_client in %%adresses_ip_clients_logs_udp
, %%udp_client/%%calc_classe(%%udp_client.netmask_client_logs_udp)%slurp
%end for

$UDPServerRun 514

%end if

###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
# $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#
$DirOwner syslog
$DirGroup adm
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup adm

%if %%getVar("activer_envoi_logs", "non") == "oui" and %%getVar("rsyslog_envoi_tls", "non") == 'non'
#
# Use omrelp module to send logs.
#

$ModLoad omrelp
%end if

#
# Include config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/aggregation/*.conf
$IncludeConfig /etc/rsyslog.d/templates/*.conf
$IncludeConfig /etc/rsyslog.d/eole-views/*.conf
$IncludeConfig /etc/rsyslog.d/custom-views/*.conf
$IncludeConfig /etc/rsyslog.d/custom-traps/*.conf
$IncludeConfig /etc/rsyslog.d/eole-traps/*.conf
$IncludeConfig /etc/rsyslog.d/default_dispatching.conf
