File: //usr/lib/check_mk_agent/local/Status_Litespeed_HotDomain
#!/bin/bash
RTREPORT="/tmp/lshttpd/.rtreport"
WARN_CONN=500
CRIT_CONN=750
STATE=0
MSG="No domain exceeds connection threshold"
if [ ! -r "$RTREPORT" ]; then
echo "3 Status_Litespeed_HotDomainConnections - Cannot read $RTREPORT"
exit 0
fi
ALERT_DOMAIN=""
ALERT_CONN=0
while read -r line; do
if [[ "$line" =~ ^REQ_RATE\ \[APVH_ ]]; then
# Extract domain and connection count
DOMAIN=$(echo "$line" | sed -E 's/^REQ_RATE \[APVH_([^]:]+).*/\1/')
CONN=$(echo "$line" | sed -E 's/.*REQ_PROCESSING: ([0-9]+).*/\1/')
# Track only if above threshold
if [ "$CONN" -ge "$CRIT_CONN" ]; then
STATE=2
ALERT_DOMAIN=$DOMAIN
ALERT_CONN=$CONN
MSG="CRITICAL - $DOMAIN has $CONN active connections"
break
elif [ "$CONN" -ge "$WARN_CONN" ] && [ "$STATE" -lt 2 ]; then
STATE=1
ALERT_DOMAIN=$DOMAIN
ALERT_CONN=$CONN
MSG="WARNING - $DOMAIN has $CONN active connections"
fi
fi
done <<< "$(grep '^REQ_RATE \[APVH_' "$RTREPORT")"
echo "$STATE Status_Litespeed_HotDomain conn=${ALERT_CONN};${WARN_CONN};${CRIT_CONN};; - $MSG | HOTDOMAIN_CONN=${ALERT_CONN}"