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: //lib/check_mk_agent/local/status_exim
#!/bin/bash

SERVICE="exim"

# 1. Service Status
if systemctl is-active --quiet "$SERVICE"; then
    STATE=0
    MSG_STATUS="RUNNING"
else
    STATE=2
    MSG_STATUS="NOT RUNNING"
fi

# 2. Mail Queue Size
QUEUE=$(exim -bpc 2>/dev/null)
QUEUE=${QUEUE:-0}

# 3. CPU Usage (%)
CPU=$(ps -C exim -o %cpu --no-headers 2>/dev/null | awk '{sum+=$1} END {print sum}')
CPU=${CPU:-0}

# 4. RAM Usage (MB)
RAM=$(ps -C exim -o rss --no-headers 2>/dev/null | awk '{sum+=$1} END {print int(sum/1024)}')
RAM=${RAM:-0}

# 5. Uptime (if available)
UPTIME_RAW=$(systemctl show exim -p ActiveEnterTimestamp | awk -F'= ' '{print $2}')
if [ -n "$UPTIME_RAW" ]; then
    UPTIME_TS=$(date -d "$UPTIME_RAW" +%s 2>/dev/null)
    NOW=$(date +%s)
    UPTIME=$((NOW - UPTIME_TS))
else
    UPTIME=0
fi

# ✅ THRESHOLD: Queue >150 warn, >200 critical
# ✅ CPU warn 70 / crit 90 — kamu bisa override via CheckMK rule juga

echo "$STATE Status_Exim queue=${QUEUE};2000;3000;; cpu=${CPU}%;70;90;0;100 ram_mb=${RAM}MB;;400;; uptime=${UPTIME}s - Exim $MSG_STATUS | QUEUE=$QUEUE CPU=$CPU RAM_MB=$RAM UPTIME=$UPTIME"