CentOS消息推送故障排查技巧
一 快速定位路径与日志
journalctl -u 服务名 -fjournalctl --since "2025-01-01 10:00:00" --until "2025-01-01 12:00:00"journalctl _COMM=crond --since today 或 cat /var/log/crontail -n50 /var/log/maillogcat /var/log/messages、cat /var/log/secure二 常见故障场景与处理要点
journalctl _COMM=crond --since todaytail -n50 /var/log/maillog,常见错误如:
fatal: parameter inet_interfaces: no local interface for ::1(IPv6 回环未配置)warning: unable to look up public/pickup: No such file or directory(Postfix 队列缺失)mkfifo /var/spool/postfix/public/pickup && chown postfix:postdrop /var/spool/postfix/public/pickup;systemctl restart postfix;systemctl status rabbitmq-server、rabbitmqctl list_connections、rabbitmqctl list_queuesdf -h、iostat -x 1 10(若 %util≈100% 表示 I/O 饱和)yum clean all)、必要时重启服务;磁盘满会导致 broker 阻塞/链接异常,清理后通常可恢复。三 性能与资源瓶颈排查
iostat -x 1 10,关注 %util、await、svctm、r/s、w/s;iotop/pidstat -d 定位进程,必要时用 pt-ioprofile 从吞吐角度定位热点文件/设备。top/htop、free -m、df -h;journalctl -p err..alert 聚焦高优先级错误;四 推送频率与定时推送的正确做法
/usr/bin/wall "系统将在5分钟后维护"0 8 * * * /usr/bin/wall "早安通知"(每天 08:00)/etc/systemd/system/notify.service:[Unit]
Description=Send scheduled message
[Service]
ExecStart=/usr/bin/wall "定时消息内容"
/etc/systemd/system/notify.timer:[Unit]
Description=Daily message at 08:00
[Timer]
OnCalendar=*-*-* 08:00:00
Persistent=true
Unit=notify.service
[Install]
WantedBy=timers.target
systemctl daemon-reload && systemctl enable --now notify.timercurl -X POST -H 'Content-type: application/json' --data '{"text":"消息内容"}' https://hooks.example.com/TOKEN五 一键排查清单与最小化复现
systemctl is-active 服务名、ss -lntp | grep 端口journalctl -u 服务名 -b、tail -n100 /var/log/maillog /var/log/cron /var/log/messagesdf -h、free -m、iostat -x 1 10、top -b -d 1 -n 20 | headcurl -Iv 目标地址、firewall-cmd --list-allnc -vz 目标 端口 / curl 到 Webhook)wall 命令)