From b61b58ce2c1371d6f904f108fa7feed3abfbe5c7 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 8 Apr 2026 13:18:14 +0900 Subject: * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated-commit-by: dots Signed-off-by: Robert Günzler --- bin/msmtp-queue-stat | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 bin/msmtp-queue-stat (limited to 'bin/msmtp-queue-stat') diff --git a/bin/msmtp-queue-stat b/bin/msmtp-queue-stat new file mode 100755 index 0000000..bb83784 --- /dev/null +++ b/bin/msmtp-queue-stat @@ -0,0 +1,17 @@ +#!/bin/sh +set -eu + +throttle_by=10 +throttle_cookie=/tmp/throttle.msmtp-queue-stat +throttle() { + last_called=$(stat -c %Y $throttle_cookie 2>/dev/null || printf 0) + now=$(date +%s) + touch $throttle_cookie + if [ $((now - last_called)) -gt $throttle_by ]; then + "$@" + else + false + fi +} + +throttle sh -c "msmtpq --q-mgmt -d | grep id= | wc -l | tee $throttle_cookie" || cat "$throttle_cookie" -- cgit 1.4.1