debug mode

This commit is contained in:
Paolo Asperti 2023-07-07 17:44:45 +02:00
parent 130cd41438
commit e6977298f4
Signed by: paspo
GPG Key ID: 06D46905D19D5182
3 changed files with 13 additions and 1 deletions

View File

@ -11,5 +11,6 @@ EXPOSE 514/udp
ENV TARGET_HOST="127.0.0.1" ENV TARGET_HOST="127.0.0.1"
ENV TARGET_PROTO="tcp" ENV TARGET_PROTO="tcp"
ENV TARGET_PORT="514" ENV TARGET_PORT="514"
ENV DEBUG="0"
ENTRYPOINT ["/bin/sh", "/run.sh"] ENTRYPOINT ["/bin/sh", "/run.sh"]

View File

@ -15,10 +15,11 @@ docker build . -t docker.asperti.com/paspo/syslog-forwarder
## environment ## environment
Variable | Default | Description Variable | Default | Description
--------------|-----------|--------------------------- --------------|-----------|----------------------------------------------------
TARGET_HOST | 127.0.0.1 | target server IP/hostname TARGET_HOST | 127.0.0.1 | target server IP/hostname
TARGET_PROTO | tcp | `tcp` or `udp` TARGET_PROTO | tcp | `tcp` or `udp`
TARGET_PORT | 514 | target server syslog port TARGET_PORT | 514 | target server syslog port
DEBUG | 0 | if != 0, every received log line is shown on stdout
## run ## run

10
run.sh
View File

@ -9,6 +9,9 @@ TARGET_PROTO=${TARGET_PROTO:-tcp}
# 514 is the common default # 514 is the common default
TARGET_PORT=${TARGET_PORT:-514} TARGET_PORT=${TARGET_PORT:-514}
# DEBUG MODE ENABLED if != 0
DEBUG=${DEBUG:-0}
cat >/etc/rsyslog.conf <<EOF cat >/etc/rsyslog.conf <<EOF
\$WorkDirectory /var/lib/rsyslog \$WorkDirectory /var/lib/rsyslog
@ -34,6 +37,13 @@ if (\$hostname == '') then set \$!hostname = \$fromhost;
EOF EOF
if [ "${DEBUG}" != "0" ] ; then
cat >>/etc/rsyslog.conf <<EOF
module(load="omstdout")
action(type="omstdout")
EOF
fi
if [ "${TARGET_PROTO}" = "udp" ] ; then if [ "${TARGET_PROTO}" = "udp" ] ; then
cat >>/etc/rsyslog.conf <<EOF cat >>/etc/rsyslog.conf <<EOF
action(type="omfwd" protocol="udp" target="${TARGET_HOST}" port="${TARGET_PORT}" Template="RSYSLOG_SyslogRFC5424Format" ) action(type="omfwd" protocol="udp" target="${TARGET_HOST}" port="${TARGET_PORT}" Template="RSYSLOG_SyslogRFC5424Format" )