前言
gatus 是一套以 golang 編寫的監控面板,性能優於我前一個選擇的 uptime-kuma (畢竟是用js寫的),後者在我的 Raspberry pi 3上 跑地十分吃力
轉換的契機是看到 eduroam 監測網站 轉為使用gatus
這次是
安裝
主流方法是使用 docker ,但 3B 的性能孱弱,故這裡選擇手動配置
1
2
3
4
5
|
# build from source code
git clone https://github.com/TwiN/gatus.git
cd ./gatus
go mod download && go build -o gatus .
mv gatus /usr/local/bin
|
1
2
|
# install via go
go install github.com/TwiN/gatus/v5@latest
|
systemd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[Unit]
Description=Gatus Monitoring Service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=gatus
Group=gatus
Environment="GATUS_CONFIG_PATH=/etc/gatus/config/"
ExecStart=/usr/local/bin/gatus
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
|
其中 GATUS_CONFIG_PATH 是設定檔的存放位置,user 另開了一個專給 gatus 使用
使用範例
這裡放上了個人的使用例
需要注意,假如有多個設定,gatus 是會將所有設定融成一份,在命名上要注意
endpoint
一個最基本的監控設定,至少需要有以下三個,要更換協議的話直接替換 url 裡的字段
1
2
3
4
5
|
endpoints:
- name: "zip"
url: "https://silvercow.zip/"
conditions:
- "[CONNECTED] == true"
|
此外可在 ui: 中設定資訊可見度(hide-hostname、hide-url、hide-conditions)
alert
通知支援的類型十分多,官方文檔感覺上有 1/2 是在接紹這部份的
以我使用的 telegram 舉例,需要先在 alerting 區塊設定 api,再到需要的 endpoints 裡添加
用 yaml anchors 會較方便
1
2
3
4
5
6
|
alerting:
telegram:
token: "8964190083:03Aw4nO0aZIofuaQij6ab5"
id: "10027462"
topic-id: "1"
description: "AAAAaaaAAAAaaaa"
|
1
2
3
4
5
6
|
endpoints:
...
alerts:
- type: telegram
send-on-resolved: on
...
|
web
設定 web 介面 port,目前是開在本地再過 cloudflare tunnel
proxy-url
可以設定 proxy 讓測試封包能正確路由,方便 endpoint 在防火牆後的情境
比較特殊部分,這邊是接 tor ,未來會在可能會再加上 DN42 橋接,努力讓這東西成為一個大雜燴
1
2
3
|
client:
proxy-url: "socks5h://localhost:9999"
timeout: 20s
|
ref:
- TwiN/gatus