日志采用真实 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、温度和风扇告警、网卡
monit
CPU、内存和磁盘阈值,健康检查,证书到期
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 limit
CPU 越过了阈值
monit: '{host}' mem usage of {pct}% matches resource limit
RAM 接近上限
monit: 'rootfs' space usage {pct}% matches resource limit
某个分区正在被填满
rsyslogd: ... No space left on device
分区已满;写入失败
kernel: CPU0: Core temperature above threshold, cpu clock throttled
CPU 因过热而降频
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: M
N 在等待 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