Beszel介绍,摘自项目官网:
Lightweight: Much smaller and less demanding than leading solutions.
Docker stats: CPU and memory usage history for each container.
Alerts: Configurable alerts for CPU, memory, and disk usage, and system status.
Multi-user: Each user has their own systems. Admins can share systems across users.
Simple: Easy setup and doesn’t require anything to be publicly available online.
OAuth / OIDC: Supports many OAuth2 providers. Password auth can be disabled.
Automatic backups: Save and restore your data to / from disk or S3-compatible storage.
REST API: Use your metrics in your own scripts and applications.
简而言之,类似于哪吒监控。
Beszel分为两个部分,一个是hub,一个是agent。我们先部署hub:
apt -y update apt -y install curl wget nginx python3-certbot-nginx curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh
准备目录新建compose文件:
mkdir -p /opt/beszel && cd /opt/beszel && nano docker-compose.yml
写入如下配置:
services: beszel: image: 'henrygd/beszel' container_name: 'beszel' restart: unless-stopped ports: - '8090:8090' volumes: - ./beszel_data:/beszel_data
启动:
docker compose up -d
配置NGINX反向代理:
nano /etc/nginx/sites-available/beszel
写入如下配置:
server { listen 80; listen [::]:80; server_name beszel.example.com; location / { proxy_pass http://127.0.0.1:8090; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto "https"; client_max_body_size 0; } }
启用站点:
ln -s /etc/nginx/sites-available/beszel /etc/nginx/sites-enabled/beszel
签发TLS证书:
certbot --nginx --email imlala@example.com --agree-tos --no-eff-email
访问域名beszel.example.com,注册一个账号,第一个注册的用户自动成为管理员,点击添加新系统:
填写被监控机器的公网IP,然后复制docker compose配置,接下来在被监控机器上安装docker:
apt -y update apt -y install curl curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh
准备目录新建compose文件:
mkdir -p /opt/beszel-agent && cd /opt/beszel-agent && nano docker-compose.yml
粘贴之前在hub上复制的docker compose配置,内容类似于:
services: beszel-agent: image: "henrygd/beszel-agent" container_name: "beszel-agent" restart: unless-stopped network_mode: host volumes: - /var/run/docker.sock:/var/run/docker.sock:ro environment: PORT: 45876 KEY: "ssh-ed25519 AAAAC3Nzahidden" FILESYSTEM: /dev/sda1
这里需要注意FILESYSTEM这个环境变量,为了让Beszel能监控磁盘IO,需要根据当前机器的分区情况来配置FILESYSTEM。你可以使用下面的命令查看机器的分区情况:
df -h lsblk fdisk -l
比如我这台机器,假设我想监控/的磁盘IO,那么这里就配置成/dev/sda1:
我添加了2台机器测试:
可以正常监控:
Beszel支持多用户,还支持配置SMTP报警,有需要的可以自己研究一下。
几天不上,更新好几篇
试试哪吒、ServerStatus