refactor(discovery): use ping for discovery and fill MAC via SSH

This commit is contained in:
12600k-rog-d4
2026-08-12 21:45:51 +08:00
parent 906bb54aaa
commit 175c5e8c6c
21 changed files with 542 additions and 310 deletions

37
auto-check/scripts/cpu.sh Normal file
View File

@@ -0,0 +1,37 @@
echo "===TEST:cpu==="
# 后台采样 CPU 使用率 + 温度
SAMPLE_LOG=/tmp/auto-check-cpu-sample.log
> "$SAMPLE_LOG"
(
while true; do
TS=$(date +%H:%M:%S)
CPU=$(top -bn1 2>/dev/null | grep "Cpu(s)" | sed 's/.*,\s*\([0-9.]*\)%*\s*id.*/\1/' | awk '{printf "%.1f", 100-$1}' || echo 0)
TEMP=$(sensors 2>/dev/null | grep -iE 'Package|Core\s*0|temp1|CPU' | head -1 | grep -oP '\d+\.?\d*' | head -1 || echo 0)
echo "${TS},${CPU},${TEMP}" >> "$SAMPLE_LOG"
sleep "${AUTOCHECK_SAMPLE_INTERVAL:-2}"
done
) &
SAMPLE_PID=$!
START_TIME=$(date +%s%N)
set +e
OUTPUT=$(stress-ng --cpu "${AUTOCHECK_THREADS:-4}" --cpu-method all --timeout "${AUTOCHECK_DURATION:-30}s" --metrics-brief --temp-path /tmp 2>&1)
EXIT_CODE=$?
set -e
END_TIME=$(date +%s%N)
kill $SAMPLE_PID 2>/dev/null || true
wait $SAMPLE_PID 2>/dev/null || true
DURATION_MS=$(( (END_TIME - START_TIME) / 1000000 ))
if [ "$EXIT_CODE" -eq 0 ]; then echo 'status:pass'; else echo 'status:fail'; fi
echo "duration:${DURATION_MS}ms"
echo "output:${OUTPUT}"
# 输出采样数据
echo "===SAMPLES==="
cat "$SAMPLE_LOG"
echo "===END_SAMPLES==="
echo ''