#!/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