ROOTPLOIT
Server: Apache
System: Linux node6122.myfcloud.com 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64
User: bashacomputer (1004)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/nagios/plugins/check_smartermail_queue
#!/bin/bash

usage() {
    echo "check_smartermail_queue - Icinga SmarterMail queue check"
    echo ""
    echo "Usage: check_smartermail_queue -w <warning queue size> -c <critical queue size> [ -h ]"
    echo ""
    echo "       -w  Queue size at which a warning is triggered"
    echo "       -c  Queue size at which a critical is triggered"
    echo "       -h  Show this page"
    echo ""
}

cmdopts() {
    if [ $# -gt 0 ]; then
        while getopts w:c:h myarg; do
            case $myarg in
                h|\?)
                    usage
                    exit 0;;
                w)
                    WARNING=$OPTARG;;
                c)
                    CRITICAL=$OPTARG;;
                *)  # Default
                    usage
                    exit 1;;
            esac
        done
    else
        usage
        exit 1
    fi
}

cmdopts "$@"

if [ -z "$WARNING" ] || [ -z "$CRITICAL" ]; then
    echo "Error: Both -w (warning) and -c (critical) thresholds must be provided."
    usage
    exit 1
fi

SPOOL_DIR="/var/lib/smartermail/Spool"

EMAIL_COUNT=$(find "$SPOOL_DIR" -type f -name "*.eml" 2>/dev/null | wc -l)

if [ "$EMAIL_COUNT" -ge "$CRITICAL" ]; then
    echo "CRITICAL: $EMAIL_COUNT mail(s) in queue (Threshold: $CRITICAL)"
    exit 2  # Critical status
elif [ "$EMAIL_COUNT" -ge "$WARNING" ]; then
    echo "WARNING: $EMAIL_COUNT mail(s) in queue (Threshold: $WARNING)"
    exit 1  # Warning status
else
    echo "OK: $EMAIL_COUNT mail(s) in queue (Threshold is below $WARNING)"
    exit 0  # OK status
fi