매일 아침 디스크 점검 결과 보존 + 점검 기록 조회 - #7
Draft
eondcom wants to merge 1 commit into
Draft
Conversation
기존 자동 감시는 매일 07:30 에 돌지만 **이상이 있을 때만** 로그를 남겼다.
그래서 정상인 날은 한 줄도 안 남고, 결과적으로
- 어제 대비 수치가 늘었는지 비교할 기준이 없다
(디스크 고장은 절대값보다 '증가'로 드러난다)
- 감시가 죽어도 조용하다 — 이상 없는 날과 구분이 안 된다
를 못 잡았다. 이상 유무와 무관하게 매일 기록을 남기도록 바꾼다.
기록 보존
/var/log/hostmover/disk/<날짜>.log 그날 결과 전문 (보존일수 설정, 기본 90일)
/var/lib/hm-disk-monitor/history.tsv 하루 한 줄 추이 요약 (계속 누적)
/var/lib/hm-disk-monitor/scrub.tsv 주간 무결성 검사 이력
/var/lib/hm-disk-monitor/last-run 마지막 점검 시각 (감시 생존 확인용)
/etc/logrotate.d/hm-disk-monitor 경보 로그 로테이션(월간·12개월)
점검 항목 보강
- 재할당/대기중 불량섹터는 절대값이 아니라 '증가'를 경보
- inode 사용률 90% 경보 추가 (용량은 남아도 파일 생성이 막힌다)
- RO 재마운트 감지
- ext 장치를 하나도 못 찾으면 그 사실을 기록 (조용한 미점검 방지)
점검 기록 보기 (신규, 읽기 전용)
build_disk_history — cron 등록·마지막 실행 시각(36시간 초과 시 경고)
→ 일자별 추이 → 최근 결과 전문 → 경보/스크럽 이력 → 보존 현황
설정
기록 보존일수, "이상이 없어도 매일 결과 메일 받기" 옵션 추가.
기본은 이상 시에만 발송 — 매일 오는 정상 메일은 곧 안 읽게 되고
진짜 경보까지 같이 묻힌다.
부수 수정
`echo > /proc/sys/vm/drop_caches 2>/dev/null` 은 리다이렉트 실패 메시지를
못 막는다({ } 로 감싸야 한다). 주간 cron 이 매번 stderr 를 뱉고 있었다.
검증: 셸 shim 으로 정상/이상 시나리오를 실제 실행 — 경보 8건 감지, 하루 1행
갱신, 보존기간 정리(4개→1개), 스크럽 기록, 매일메일 옵션, cron 중단 감지(76시간
전 경고) 확인. cargo test 30 passed, 릴리스 빌드 경고 없음.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxEiSzFMdeAzvohAQ39nyJ
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
왜
기존 자동 감시(매일 07:30 cron)는 이상이 있을 때만 로그를 남겼다. 그래서 정상인 날은 기록이 없고:
재할당섹터 3 → 7 → 15같은 증가로 드러나는데, 정상인 날의 값이 없으면 늘었는지 알 수 없다.무엇을
이상 유무와 관계없이 매일 기록을 남기고, 그 기록을 앱에서 조회한다.
/var/log/hostmover/disk/<날짜>.log/var/lib/hm-disk-monitor/history.tsv/var/lib/hm-disk-monitor/scrub.tsv/var/lib/hm-disk-monitor/last-run/etc/logrotate.d/hm-disk-monitor점검 항목 보강: 불량섹터는 절대값이 아닌 증가를 경보 · inode 90% 경보 추가 · RO 재마운트 감지 · ext 장치를 못 찾으면 그 사실을 기록(조용한 미점검 방지).
점검 기록 보기(신규, 읽기 전용): cron 등록·마지막 실행 시각(36시간 초과 시 경고) → 일자별 추이 → 최근 결과 전문 → 경보/스크럽 이력 → 보존 현황.
설정: 보존일수, "이상이 없어도 매일 결과 메일 받기"(기본 off — 매일 오는 정상 메일은 곧 안 읽게 되고 진짜 경보까지 묻힌다).
부수 수정:
echo > /proc/sys/vm/drop_caches 2>/dev/null는 리다이렉트 실패 메시지를 못 막아서 주간 cron 이 매번 stderr 를 뱉고 있었다.{ }로 감쌌다.검증
셸 shim 으로 가짜 디스크를 만들어 생성되는 감시 스크립트를 실제로 실행했다.
[판정] OK 경보 0건, 기록 정상 생성scrub.tsv기록 + 임시파일 정리 확인cargo test30 passed (디스크 전용 테스트 신규 추가), 릴리스 빌드 경고 없음참고
문서:
docs/disk-check.mdbase 가
main이 아니라wp-bulk-update-stable(#3) 입니다 — 그 위에 쌓았습니다. #3 머지 후 base 를 main 으로 바꾸면 됩니다.🤖 Generated with Claude Code
https://claude.ai/code/session_01WxEiSzFMdeAzvohAQ39nyJ