跳转到主内容
趣航编程网 - 趣学编程,启航技术之路!

Linux怎么安装和配置Gatus Linux健康检查仪表盘详解

Gatus是开箱即用的静态链接二进制文件,官方仅提供GitHub预编译包,未纳入apt/yum等发行版源;需手动下载、配置YAML、通过systemd托管运行,且conditions等关键字段不可省略。 Gatus 不能直接“安装”成传统意义上的系统服务,它本身就是一个开箱即用的二进制可执行文件,没有依赖、不需编译、不改系统配置——你下载完就能跑。 为什么不用 apt/yum 安装 Gatus Gatus 没有进入任何 Linux 发行版的官方软件源(Debian/Ubuntu 的
apt
、CentOS/RHEL 的
yum
或
dnf
),也没有提供 RPM/DEB 包。官方只维护 GitHub Release 页面上的预编译二进制文件,这是它的设计哲学:极简交付,避免包管理器引入的版本碎片和权限干扰。 常见错误现象:
apt install gatus
或
yum search gatus
返回空结果或
No package gatus available
;手动添加第三方 repo 后仍失败,因为根本不存在适配你系统的仓库配置。 它不依赖 libc 版本兼容性(静态链接 Go 运行时) 不需要
systemd
单元文件也能运行(但建议加,下文说明) 不写入
/etc
、不修改
PATH
、不注册服务用户——所有配置靠一个 YAML 文件驱动 正确下载与启动 Gatus 的三步操作 以 amd64 架构的 Linux 服务器为例(x86_64),直接从 GitHub 获取最新稳定版:
cd /tmp curl -fsSL https://github.com/TwiN/gatus/releases/download/v4.12.0/gatus_4.12.0_linux_amd64.tar.gz | tar xz sudo mv gatus /usr/local/bin/ sudo chmod +x /usr/local/bin/gatus
创建最小可用配置(
gatus.yaml
):
echo 'web: http: port: 8080 endpoints: - name: api-health url: https://api.example.com/health interval: 30s' | sudo tee /etc/gatus.yaml
立即运行验证:
gatus -c /etc/gatus.yaml
—— 成功则访问
http://your-server-ip:8080
看到仪表盘;Ctrl+C 停止。 Trae linux Trae Linux 官方版本现已全面上线,开发者可直接访问 Trae 官网(trae.cn 国内版或 trae.ai 国际版)获取专属安装包。该版本完美适配主流 Linux 发行版,提供 .deb(适配 Ubuntu/Debian)、.rpm(适配 RHEL/Fedora)以及通用 .tar.gz 格式,并全面支持 x64 与 ARM64 架构。 下载 必须指定
-c
参数,否则报错
failed to load configuration: open gatus.yaml: no such file or directory
端口若被占用(如 8080 已运行 Nginx),会直接 panic 并退出,不会自动降级或提示“请换端口” URL 必须带协议(
https://
或
http://
),
api.example.com/health
会解析失败 如何让 Gatus 在后台长期运行(systemd 方式) 生产环境不能靠前台
nohup
或
&
启动——它无法自动重启、没日志轮转、不响应
systemctl stop
。正确做法是写一个轻量
systemd
service:
sudo tee /etc/systemd/system/gatus.service <<'EOF' [Unit] Description=Gatus Health Dashboard After=network.target

[Service] Type=simple User=nobody WorkingDirectory=/etc ExecStart=/usr/local/bin/gatus -c /etc/gatus.yaml Restart=always RestartSec=10 StandardOutput=journal StandardError=journal

[Install] WantedBy=multi-user.target EOF

启用并启动:
sudo systemctl daemon-reload sudo systemctl enable --now gatus
检查状态:
systemctl status gatus
应显示
active (running)
;
journalctl -u gatus -n 20 -f
可实时看探测日志。 别用 root 用户跑,
User=nobody
是安全底线(Gatus 不需要特权)
WorkingDirectory
必须设为配置文件所在目录,否则相对路径引用会失败 如果配置里用了
notifications
(如 Slack webhook),确保防火墙放行出站 HTTPS(
ufw allow out 443
) 配置文件里最容易被忽略的三个细节 Gatus 的
gatus.yaml
表面简单,但几个字段不填对会导致探测静默失败或误报:
conditions
字段必须显式定义,否则即使 HTTP 状态码是 200,也会标为
FAILED
;例如:
- "[STATUS] == 200"
group
不是必填,但多个 endpoint 共享 group 后,仪表盘会自动聚合显示整体健康率(比如
group: "backend-api"
)
icon
值只能是
✅
、
❌
、
⚠️
等 Unicode 符号,填
"success"
或
"up"
会被忽略,图标不显示 真实场景中,很多人卡在第一个条件没写,看着页面全是红叉,但日志里却显示
status=200
——其实是默认无条件判定为失败。

相关文章