summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-12-21 01:24:11 +0100
committertv <tv@krebsco.de>2017-12-21 01:26:49 +0100
commit13be61e360e769ad28fc48df20524e483cf00efc (patch)
tree0b1dc27e65e54cd20d5e136b803c02a6df6d81a5
parent7f10d9526c3418197e198578eb5c4d8e7eadfc2e (diff)
eximlog: init
-rw-r--r--krebs/5pkgs/simple/eximlog.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/eximlog.nix b/krebs/5pkgs/simple/eximlog.nix
new file mode 100644
index 000000000..2d64e13e9
--- /dev/null
+++ b/krebs/5pkgs/simple/eximlog.nix
@@ -0,0 +1,28 @@
+{ jq, systemd, writeDashBin }:
+
+let
+ lib = import <stockholm/lib>;
+ user = "exim"; # TODO make this configurable
+in
+
+# TODO execute eximlog only if journalctl doesn't fail
+# bash's set -o pipefail isn't enough
+
+writeDashBin "eximlog" ''
+ ${systemd}/bin/journalctl \
+ -u ${lib.shell.escape user} \
+ -o short-unix \
+ "$@" \
+ |
+ ${jq}/bin/jq -Rr '
+ # Only select lines that start with a timestamp
+ select(test("^[0-9]")) |
+
+ split(" ") |
+ (.[0] | tonumber) as $time |
+ (.[3:] | join(" ")) as $message |
+
+ "\($time | strftime("%Y-%m-%d %H:%M:%S %z")) \($message)"
+
+ '
+''