Skip to content

Instantly share code, notes, and snippets.

@x684867
Created November 20, 2014 23:37
Show Gist options
  • Save x684867/c7522f268b842e3665b7 to your computer and use it in GitHub Desktop.
Save x684867/c7522f268b842e3665b7 to your computer and use it in GitHub Desktop.
Syslog centralization script
#centralizedSyslog
#
SET -e
apt-get update --fix-missing -y
apt-get install rsyslog-gnutls -y
echo '# /etc/rsyslog.conf
\$ModLoad imuxsock # provides support for local system logging
\$ModLoad imklog # provides kernel logging support
# Configure file capturing for SYSLOG so that we can collect data
# from non syslog file sources.
\$ModLoad imfile
\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
\$FileOwner root
\$FileGroup adm
\$FileCreateMode 0640
\$DirCreateMode 0755
\$Umask 0022
\$WorkDirectory /var/spool/rsyslog
#TLS Encryption for syslog.
\$ActionSendStreamDriver gtls
\$ActionSendStreamDriverMode 1
\$ActionSendStreamDriverAuthMode x509/name
# --------------------------------
# Include config files identifying
# any external files to be loaded.
# --------------------------------
\$IncludeConfig /etc/rsyslog.d/*.conf
*.* @syslog.mydomain.tld
'>/etc/rsyslog.conf
#syslogNginx
#
echo '
$InputFileName /var/log/nginx/access.log
$InputFileTag nginx.access.log:
$InputFileStateFile nginx-access-log
$InputFileSeverity info
$InputFileFacility local7
$InputRunFileMonitor
#
$InputFileName /var/log/nginx/error.log
$InputFileTag nginx.error.log:
$InputFileStateFile nginx-error-log
$InputFileSeverity error
$InputFileFacility error
$InputRunFileMonitor
#
' > /etc/rsyslog.d/nginx.syslog.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment