31 lines
1.1 KiB
Bash
Executable File
31 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Monitor system temperatures
|
|
set -euo pipefail
|
|
|
|
SEND_NTFY="/usr/local/bin/send-ntfy.sh"
|
|
|
|
# Check if sensors command exists
|
|
if ! command -v sensors &>/dev/null; then
|
|
# Try to install lm-sensors
|
|
apt-get install -y lm-sensors >/dev/null 2>&1 || logger -t temp-monitor "Cannot install lm-sensors"
|
|
exit 0
|
|
fi
|
|
|
|
# Get CPU temperature - only extract the actual reading (first temperature value after colon)
|
|
TEMPS=$(sensors 2>/dev/null | grep -E 'Core.*:' | grep -oP ':\s+\+\K[0-9]+\.[0-9]+' || echo "")
|
|
|
|
if [ -n "$TEMPS" ]; then
|
|
# Extract highest temperature (rounded to integer)
|
|
MAX_TEMP=$(echo "$TEMPS" | sort -n | tail -1 | cut -d. -f1)
|
|
|
|
if [ "$MAX_TEMP" -gt 90 ]; then
|
|
$SEND_NTFY critical "Temperature Critical" "🔴 CRITICAL: PVE CPU temperature at ${MAX_TEMP}°C! System may shut down!" "fire,skull,thermometer"
|
|
elif [ "$MAX_TEMP" -gt 80 ]; then
|
|
$SEND_NTFY warning "Temperature High" "🟡 WARNING: PVE CPU temperature at ${MAX_TEMP}°C - check cooling" "fire,warning,thermometer"
|
|
fi
|
|
|
|
logger -t temp-monitor "Max CPU temp: ${MAX_TEMP}°C"
|
|
else
|
|
logger -t temp-monitor "No temperature sensors found"
|
|
fi
|