× Post Fix is a great tool that comes usually bundled with vps servers and handles the mailboxes.

Set ALERTS to Monit when qeueu is more than 20 mails

Περισσότερα
3 Ημέρες 11 Ώρες πριν #334 από infogate
First edit /scripts/check_postqueue
nano /scripts/check_postqueue

add the following checks
#!/bin/bash

THRESHOLD="${1:-20}"

QUEUE_COUNT=$(mailq | tail -n 1 | sed -n 's/.*in \([0-9][0-9]*\) [Rr]equests\?.*/\1/p')
[ -z "$QUEUE_COUNT" ] && QUEUE_COUNT=0

if [ "$QUEUE_COUNT" -ge "$THRESHOLD" ]; then
    echo "Postfix queue alert: $QUEUE_COUNT messages in queue (threshold: $THRESHOLD)"
    echo
    echo "Top queued senders:"
    postqueue -p | awk '
        /^[A-F0-9]/ {qid=$1}
        /^[[:space:]]*[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+$/ {
            gsub(/[<>]/,"",$1)
            print $1
        }
    ' | sort | uniq -c | sort -nr | head -10

    echo
    echo "Recent authenticated SMTP users:"
    grep "sasl_username=" /var/log/maillog | tail -300 | \
    sed -n 's/.*sasl_username=\([^ ,]*\).*/\1/p' | \
    sort | uniq -c | sort -nr | head -10

    exit 1
else
    echo "Postfix queue OK: $QUEUE_COUNT messages in queue (threshold: $THRESHOLD)"
    exit 0
fi


Save it, then run:
chmod +x /scripts/check_postqueue
Test it:
/scripts/check_postqueue 20
echo $?


set /etc/monit.d/postfix-queue.conf
check program postfix-queue with path "/scripts/check_postqueue 20"
 if status != 0 then alert 
group mail

Set correct configuration
set daemon 300
    with start delay 45

set logfile /var/log/monit.log

set pidfile /var/run/monit.pid
set idfile /var/.monit.id
set statefile /var/.monit.state

set mailserver 127.0.0.1 port 25
set alert support@yourdomain

set eventqueue
    basedir /var/monit
    slots 100

set httpd port 2812 and
    use address 127.0.0.1
    allow 127.0.0.1
    allow admin:addhereyourpassword

include /etc/monit.d/*

check it
monit -t

Reload and fix
monit reload
systemctl restart monit

verify
monit status


The best possible way to start your online marketing : fspirits.com/go/leadsleap-home
Explode Your Web Site Traffice: fspirits.com/go/sparktraffic
Start your affiliate journey here: fspirits.com/go/olsp-academy
Best Solution To Create Videos: fspirits.com/go/create-studio-pro
Best Solution To Create Graphics: fspirits.com/go/clickdesigns
Smart Chat Automation: fspirits.com/go/chatterpal
Multi-Purpose Video Maker: fspirits.com/go/avatar-builder
Multi-Purpose Video Creator: fspirits.com/go/video-creator
AI Human Spokesperson Videos: fspirits.com/go/humanpal

Παρακαλούμε Σύνδεση ή Δημιουργία λογαριασμού για να συμμετάσχετε στη συζήτηση.

Χρόνος δημιουργίας σελίδας: 0.098 δευτερόλεπτα
Powered by Kunena Φόρουμ