diff --git a/unit-files/mail-mon.service b/unit-files/mail-mon.service new file mode 100644 index 0000000000000000000000000000000000000000..9c61a3d5fa6d6902a8dcb05891e0c08f92e188b4 --- /dev/null +++ b/unit-files/mail-mon.service @@ -0,0 +1,3 @@ +[Service] +Type=oneshot +ExecStart=/libre.sh/utils/mail-mon.sh diff --git a/unit-files/mail-mon.timer b/unit-files/mail-mon.timer new file mode 100644 index 0000000000000000000000000000000000000000..2f1368dfeafe13627cc0f97d2c8b854c8a4d9aa1 --- /dev/null +++ b/unit-files/mail-mon.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run mail mon hourly and on boot + +[Timer] +OnBootSec=15min +OnUnitActiveSec=1h + +[Install] +WantedBy=timers.target diff --git a/utils/mail-mon.sh b/utils/mail-mon.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ff0b1addf0635b8626dc7b1e8cd791025bb2208 --- /dev/null +++ b/utils/mail-mon.sh @@ -0,0 +1,3 @@ +#!/bin/bash -eux + +/usr/bin/journalctl --since '1 hour ago' | grep postfix/cleanup | grep "from=" | sed -n 's/.*from=<\(.*\)> to=<\(.*\)> pro.*/\1/p' | sort |uniq -c | sort | awk 'BEGIN {FS=" ";} {printf "mail_sent{domain_name=\"%s\"} %s\n", $2, $1}' > /system/metrics-collection/textfiles/mail.prom