ARTIFACT // PI5-SENSOR-LOG-GUARDIAN.SH (SHELL)
Raspberry Pi 5 Thermal & Journalctl Log Anomaly Explainer Daemon (pi5-sensor-log-guardian.sh)
Deterministic threshold guard that checks CPU/sensor temperature first and invokes local Ollama 3B only when an anomaly or systemd error occurs.
[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Raspberry Pi 5 Thermal & Journalctl Log Anomaly Explainer Daemon" (pi5-sensor-log-guardian.sh, SHELL) is paired with Tinker AI Lab's hardware-verified guide "pi5-local-sensor-log-guardian". It exposes 2 customizable browser variables (TEMP_THRESHOLD_C=68, GUARDIAN_MODEL=qwen2.5:3b) with loopback-first security defaults.
03 // MAKERAI Maker / STEM Projects· Verified: 2026-10-23
Browse All 42 Artifacts →pi5-sensor-log-guardian.sh
View Paired Guide →Raspberry Pi 5 Thermal & Journalctl Log Anomaly Explainer Daemon
Deterministic threshold guard that checks CPU/sensor temperature first and invokes local Ollama 3B only when an anomaly or systemd error occurs.
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
#!/usr/bin/env bash
# Tinker AI Maker Lab — Rule-First Thermal & Log Anomaly Explainer (Guide #9)
set -euo pipefail
THRESHOLD="68"
MODEL="qwen2.5:3b"
RAW_MILLI=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null || echo "45000")
TEMP_C=$((RAW_MILLI / 1000))
RECENT_ERRS=$(journalctl -p err..warning -n 15 --no-pager 2>/dev/null || echo "No systemd errors.")
echo "[Rule Check] Current Temp: ${TEMP_C}°C (Threshold: ${THRESHOLD}°C)"
if [ "$TEMP_C" -ge "$THRESHOLD" ]; then
echo "[Anomaly Triggered] Invoking local $MODEL for root-cause synthesis..."
curl -sS http://127.0.0.1:11434/api/generate -d "{
\"model\": \"$MODEL\",
\"stream\": false,
\"options\": { \"temperature\": 0.1, \"num_ctx\": 2048 },
\"prompt\": \"Hardware alert: Pi 5 temperature reached ${TEMP_C}C. Summarize likely cause and 2 check commands from logs: \n${RECENT_ERRS}\"
}" | python3 -c 'import sys,json; print(json.load(sys.stdin).get("response",""))'
else
echo "[OK] Within safe thermal boundary; skipping LLM inference (0% CPU overhead)."
fi
PARAMETER SPECIFICATION // 参数化变量规范说明表
Customizable Parameter Reference for pi5-sensor-log-guardian.sh
This SHELL artifact exposes 2 template variables compiled client-side in your browser.
| Template Token | Parameter Description | Verified Default | Example Format |
|---|---|---|---|
{{TEMP_THRESHOLD_C}} | Alert Temp Threshold (°C) | 68 | 68 |
{{GUARDIAN_MODEL}} | Local Edge Model Tag | qwen2.5:3b | qwen2.5:3b |
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录
Verified Environment for "STEM Project: Raspberry Pi Local Sensor & HomeLab Log Explainer with Zero Cloud Dependency"
Tested Hardware & OS
Raspberry Pi 5 (8GB) · BME280 I2C Temp/Humidity Sensor (or journalctl system logs)
Pinned Stack & Model Versions
Python 3.11Ollama 0.5.7qwen2.5:3b
Offline Boundary (100% Local LAN / Loopback Execution)
No external cloud keys required; safe for student labs without credit cards.
Known Operational Limits & Failure Modes
- Do not feed raw thousand-line log files directly into a 3B model on Pi 5; pre-filter with grep/awk to < 30 lines first so prompt eval stays under 3 seconds.
- I2C pins (GPIO 2 / SDA and GPIO 3 / SCL) must be enabled via `sudo raspi-config` -> Interface Options -> I2C and require a reboot.
DEPLOYMENT CHECKLIST // 配置落地核验步骤
3-Step Verification Checklist After Deploying pi5-sensor-log-guardian.sh
- Confirmed deterministic threshold filter runs before invoking the local LLM.
- Set explicit 30-second HTTP timeout on local inference requests.
- Verified sensor wiring (3.3V Pin 1, SDA Pin 3, SCL Pin 5) or enabled `--simulate-sensor` mode.