Files
homelab-monitoring/scripts/check-temperature.sh
PVE Monitoring System 3a14fd2736 Initial backup: 18 monitoring scripts + timers + docs
- 18 comprehensive monitoring checks
- 5 systemd timers (5min, 15min, hourly, daily, weekly)
- Complete documentation
- NTFY secure notification system
- Fixed debianvm disk space (91% to 57%)
- Fixed CloudReve integration
- Date: 2026-01-07
2026-01-07 16:30:34 +08:00

31 lines
1.0 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
TEMPS=$(sensors 2>/dev/null | grep -E "Core.*:.*°C" || echo "")
if [ -n "$TEMPS" ]; then
# Extract highest temperature
MAX_TEMP=$(echo "$TEMPS" | grep -oP '\+\K[0-9]+' | sort -n | tail -1)
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