Gibt eine Übersicht über die Postfix Mail Queue
mailq-2html.sh
#!/bin/bash
# Script zum Aufruf aus Cron heraus
# $Revision: 1.3 $
# C GPL2 whisper 2021.03.27
# Am 4.07.2022 auf server2 angepasst
# Crontab:
#1 6,8,10,12,14,16,18,20,22 * * * /usr/local/sbin/mailq-2html.sh 2>/dev/null
#
# Gibt eine Übersicht über die Postfix Mail Queue
#
OUTPUT_HTML="/path/to/domain/mailq-status.html"
# HTML-Kopf erstellen
cat <<EOF > "$OUTPUT_HTML"
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Server Status</title>
<style>
body {
background-image: url('/img/bg2.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
font-family: Arial, sans-serif;
color: white;
padding: 30px;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
height: 100vh;
}
h1 {
color: white;
font-size: 20px;
}
pre {
color: white;
font-size: 20px;
}
</style>
<title>Übersicht über die Mail queue</title>
<body>
<h1>Übersicht über die Mail queue</h1>
EOF
echo -n "Stand: " >>"$OUTPUT_HTML"
date >>"$OUTPUT_HTML"
echo '<pre>' >>"$OUTPUT_HTML"
for q in active bounce corrupt deferred flush "hold " incoming maildrop saved
do
count=$(find /var/spool/postfix/$q ! -type d -print | wc -l)
printf "$q \t$count<br>" >>"$OUTPUT_HTML"
done
echo '</pre>' >>"$OUTPUT_HTML"
echo '<hr>' >>"$OUTPUT_HTML"
echo "<h1>Detaillierte Liste der Ziel-Domains</h1>" >>"$OUTPUT_HTML"
echo '<pre><b>' >>"$OUTPUT_HTML"
echo " 1Tag 2Tage 3Tage länger " >>"$OUTPUT_HTML"
echo " 6h 12h 18h 24h 30h 36h 42h 48h 54h >54h</b>" >>"$OUTPUT_HTML"
# der export von PATH ist notwendig, weil das perl-script qshape intern noch postconf ausführt welches sonst nicht gefunden wird
# gezielt /usr/sbin/qhape aufrufen reicht also nicht.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
qshape -t 360 -l deferred >>"$OUTPUT_HTML"
echo '</pre>' >>"$OUTPUT_HTML"
echo "<b>Hinweis:</b> <i>Nach 4 Tagen wird der Zustellungsversuch abgebrochen und die E-Mail gelöscht.</i>" >>"$OUTPUT_HTML"
echo '</body></html>' >>"$OUTPUT_HTML"