????

Your IP : 216.73.217.84


Current Path : /proc/1724857/root/usr/lib/check_mk_agent/local/
Upload File :
Current File : //proc/1724857/root/usr/lib/check_mk_agent/local/Status_Purefptd

#!/bin/bash
# CheckMK Local Check - Status_PureFTPd

SERVICE_NAME="pure-ftpd"
CONN_WARN=50        # FTP abuse warning threshold
CONN_CRIT=80        # Critical threshold

# Check if service exists
if ! systemctl list-units --type=service | grep -q "$SERVICE_NAME"; then
    echo "3 Status_PureFTPd - UNKNOWN - Service not found"
    exit 0
fi

# Check if service is running
if systemctl is-active --quiet "$SERVICE_NAME"; then
    STATE=0
    STATE_TEXT="RUNNING"
else
    echo "2 Status_PureFTPd - CRITICAL - $SERVICE_NAME is DOWN"
    exit 0
fi

# Count active FTP connections (only ESTABLISHED to port 21)
CONN_COUNT=$(ss -tan '( dport = :21 )' | grep ESTAB | wc -l)

# Apply thresholds
if (( CONN_COUNT > CONN_CRIT )); then
    STATE=2
    STATE_TEXT="CRITICAL FTP Load"
elif (( CONN_COUNT > CONN_WARN )); then
    STATE=1
    STATE_TEXT="HIGH FTP Load"
fi

# Output to CheckMK format
echo "$STATE Status_PureFTPd connections=${CONN_COUNT};${CONN_WARN};${CONN_CRIT};; - PureFTPD $STATE_TEXT | CONN=$CONN_COUNT"