Use socketee to relay syslog messages

Use socketee to relay syslog messages

From 89d43d0e6e99b7b578642276880908423dfd63fd Mon Sep 17 00:00:00 2001
From: Matt Palmer <mpalmer@hezmatt.org>
Date: Wed, 17 Oct 2018 11:36:49 +1100
Subject: [PATCH] Use socketee to relay syslog messages


diff --git a/Dockerfile b/Dockerfile
index 36c59e7..d9877b9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -26,4 +26,7 @@ COPY receive-mail discourse-smtp-fast-rejection /usr/local/bin/
 COPY lib/ /usr/local/lib/ruby/site_ruby/
 COPY boot /sbin/
 
+ADD https://github.com/mpalmer/socketee/releases/download/v0.0.2/socketee /usr/local/bin/
+RUN chmod 0755 /usr/local/bin/socketee
+
 CMD ["/sbin/boot"]
diff --git a/README.md b/README.md
index 95be549..1d51c36 100644
--- a/README.md
+++ b/README.md
@@ -51,12 +51,9 @@ out-of-the-box syslog integration, this container runs a tiny script which
 reads all syslog data and dumps it to the container's `stderr` (which is
 then examinable by `docker logs`).
 
-If, by some chance, you have a system which can inject itself into a
-container and process syslog entries intelligently (such as, say,
-[syslogstash](https://github.com/discourse/syslogstash)), you can set the
-`SYSLOG_SOCKET` environment variable to an alternate path, and the
-`/dev/log` syslog socket will be symlinked to that alternate path.
-
+If, by some chance, you want to process your Postfix logs more extensively,
+you can set `SOCKETEE_RELAY_SOCKET` and all syslog messages will also be
+sent to that socket for further processing.
 
 
 # Theory of Operation
diff --git a/boot b/boot
index 0248970..7611e26 100755
--- a/boot
+++ b/boot
@@ -2,12 +2,12 @@
 
 set -e
 
-# First, fire up possibly the world's *worst* syslog server, unless there's
-# somewhere else meaningful to send syslog data to
-if [ -z "$SYSLOG_SOCKET" ]; then
+# Send syslog messages to stderr, optionally relaying them to another socket
+# for postfix-exporter to take a look at
+if [ -z "$SOCKETEE_RELAY_SOCKET" ]; then
 	/usr/bin/socat UNIX-RECV:/dev/log,mode=0666 stderr &
 else
-	ln -sf "$SYSLOG_SOCKET" /dev/log
+	/usr/local/bin/socketee /dev/log "$SOCKETEE_RELAY_SOCKET" &
 fi
 
 echo "Operating environment:" >&2

GitHub

1 Like