From 672443b738c3eef42ca6bf307e46c503021a3c9c Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 31 Oct 2026 00:08:04 +0900 Subject: [PATCH] =?UTF-8?q?scripts/resume-log.sh:=20=EC=A0=88=EC=A0=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B9=A8=EC=96=B4=EB=82=9C=20=EC=A7=81?= =?UTF-8?q?=ED=9B=84=20"=EB=88=84=EA=B0=80=20=EA=B9=A8=EC=9B=A0=EB=82=98"?= =?UTF-8?q?=20=EB=8B=A8=EC=84=9C=20=EA=B8=B0=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit logind의 PrepareForSleep 신호를 듣고(루트 불필요), 잠들기 직전 깨우기 장치 카운터를 저장했다가 깨어난 직후 늘어난 장치·IRQ·이웃 테이블·커널의 깨우기 관련 줄을 ~/wake-watch/resume.log에 남긴다. 10-30 z840 WOL 문제(I210은 못 깨우고 eno1은 깨움) 분석에 쓰였다. Co-Authored-By: Claude Sonnet 5.5 --- scripts/resume-log.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/resume-log.sh diff --git a/scripts/resume-log.sh b/scripts/resume-log.sh new file mode 100755 index 0000000..a9b1eab --- /dev/null +++ b/scripts/resume-log.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# 절전에서 깨어난 직후 "누가 깨웠나" 단서를 기록한다. 루트 없이 logind의 PrepareForSleep 신호만 듣는다. +# 잠들기 직전에 깨우기 장치 카운터를 저장해 두고, 깨어난 직후 늘어난 장치와 IRQ·이웃 테이블을 남긴다. +LOG=/home/kim/wake-watch/resume.log +mkdir -p "$(dirname "$LOG")" + +snap() { + for w in /sys/class/wakeup/wakeup*; do + [ -r "$w/name" ] || continue + echo "$(cat "$w/name")|$(cat "$w/wakeup_count" 2>/dev/null)|$(cat "$w/event_count" 2>/dev/null)|$(cat "$w/active_count" 2>/dev/null)" + done +} + +PRE="" +gdbus monitor --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 2>/dev/null | +while read -r line; do + case "$line" in + *PrepareForSleep*true*) PRE=$(snap); SLEPT=$(date +%s) ;; + *PrepareForSleep*false*) + sleep 3 # 깨어난 직후 장치가 올라오길 잠깐 기다림 + { + echo "=== 깨어남 $(date '+%F %T') (잠든 시각 $( [ -n "$SLEPT" ] && date -d @"$SLEPT" '+%T' || echo ?))" + echo "wakeup_irq: $(cat /sys/power/pm_wakeup_irq 2>&1)" + irq=$(cat /sys/power/pm_wakeup_irq 2>/dev/null); [ -n "$irq" ] && grep -E "^ *$irq:" /proc/interrupts | cut -c1-160 + echo "-- 늘어난 깨우기 장치 (이름: 이전→이후, wakeup_count/event/active)" + NOW=$(snap) + diff <(echo "$PRE") <(echo "$NOW") | grep '^[<>]' | sed 's/^/ /' + echo "-- 이웃 테이블(최근 접촉)" + ip -s neigh show 2>/dev/null | grep -E "REACHABLE|DELAY|PROBE" | head -8 | sed 's/^/ /' + echo "-- 커널 최근 로그(깨우기 관련)" + journalctl -k --since "-20s" --no-pager 2>/dev/null | grep -iE "wake|wol|magic|pme|usb.*(connect|new)|button" | head -6 | sed 's/^/ /' + } >> "$LOG" + ;; + esac +done