跳到正文

日志特征

SysAdmin Crisis 诊断日志行的参考,按子系统标签分组,并以固定格式列出,便于识别问题。

最后更新:

每一行日志都是模板化的,所以格式是固定的,也是可以学会的。本页列出的是诊断行——告诉人出了问题的那些。行动之后出现的确认行,则刻意略去。

如何读一行

日志采用真实 Linux 机器会写出的格式:时间、主机名、写入它的服务,以及消息。在游戏中,用 cat、tail、grep 和 awk 读取 /var/log 下的文件;另外还有 journalctl。

03:11:42 web-02 kernel: nf_conntrack: nf_conntrack: table full, dropping packet
│        │      │       └─ message: the thing that is out of the ordinary
│        │      └─ the service that wrote it (kernel, monit, nginx, postgres, CRON ...)
│        └─ the machine reporting about itself
└─ in-game timestamp

谁在说话

服务写入的内容
kernel网络表、OOM killer、温度和风扇告警、网卡
monitCPU、内存和磁盘阈值,健康检查,证书到期
nginx配置和 TLS 错误,上游状态
postgres慢查询、锁等待、连接耗尽
CRON计划任务启动
sshd / sudo登录尝试和管理员命令
Deniz:导师;第 1 夜,以及每个战役之夜的开始

网络

日志行含义
kernel: TCP: request_sock_TCP: Possible SYN flooding on port 443到达边缘的连接数远高于正常水平
kernel: nf_conntrack: table full, dropping packet连接表已满;数据包正在被丢弃
nginx: upstream timed out (110: Connection timed out) while reading response header from upstream负载均衡器收不到后端的响应

指标

日志行含义
monit: '{host}' cpu usage of {pct}% matches resource limitCPU 越过了阈值
monit: '{host}' mem usage of {pct}% matches resource limitRAM 接近上限
monit: 'rootfs' space usage {pct}% matches resource limit某个分区正在被填满
rsyslogd: ... No space left on device分区已满;写入失败
kernel: CPU0: Core temperature above threshold, cpu clock throttledCPU 因过热而降频
kernel: nct6775 ... fan1: alarm, input 0 RPM风扇停转
kernel: thermal thermal_zone0: critical temperature reached过热关机
monit: 'shop-api' failed protocol test ... response time整个服务器群变慢;未说明原因

进程与任务

日志行含义
monit: '{name}' mem usage of {pct}%内存正在增长的进程
monit: '{name}' cpu usage of {pct}%占着 CPU 的进程
kernel: {name} invoked oom-killer内存耗尽;写出的名字是调用 killer 的那个,而不是泄漏的那个
CRON: (root) CMD (/opt/jobs/{name})一个计划任务启动

数据库

日志行含义
postgres: process N still waiting for ShareLock ... Process holding the lock: MN 在等待 M 持有的锁
postgres: duration: {ms} ms statement: ...持有锁的查询的耗时
postgres: FATAL: remaining connection slots are reserved ...连接池已耗尽

TLS

日志行含义
monit: 'shop-tls' certificate expiry test failed -- certificate expires in less than 1 day唯一的一次早期预警
nginx: [crit] SSL_do_handshake() failed ... certificate expired太迟了;客户端已无法连接