HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //proc/self/root/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"