workbuddy.xpcool.com/.workbuddy/memory/2026-09-11.md

4 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 2026-09-11 工作日志
- 22:40 | FIX | 服务器监控脚本告警去重改造fail2ban 封禁 IP 改为「仅新增封禁推送一次」。**原因**=IP `157.230.37.93` 被 fail2ban 封禁后bantime 1h脚本每 10 分钟重复推送 Bark 告警(日志 21:40~22:30 连续 6 条 ALERT。**根因**=脚本第 3 段逻辑为「Banned IP list 非空即 alert」无状态记忆。**改法**=新增状态文件 `/var/lib/server-monitor/banned-ips.state`(记录当前已封禁 IP 集合),仅对不在集合中的 IP 告警;状态同步为当前封禁列表,已解封 IP 自动移出(日后再被封视为新事件、可再提醒)。**验证**=真实环境当前封禁「本轮告警=无→静默」;模拟 5 轮全部符合预期(新封→提醒 / 列表不变→静默 / 解封→剔除 / 再封→再提醒 / 全解封→清空);`bash -n` 语法通过。**留档**=脚本备份 `/usr/local/bin/server-monitor.sh.bak.20260911`;本地副本 `.workbuddy/tmp/server-monitor.sh`。**顺带记录**=cron 位置确认为 xxcool crontab`*/10 * * * * sudo /usr/local/bin/server-monitor.sh`bantime=1h/findtime=10m/maxretry=5`/etc/fail2ban/jail.local`);日志 204K 暂无需轮转。