SmokePing主从模式 ,从端不启动网页界面,可以同步主端的配置,在主端可以看到从端的测试结果。
缺陷:主端修改配置后,从端不能自动跟进,重启从端服务才能更新。
假设服务端访问地址为 http://smokeping.keesir.com:8899 ,
slave 端主要有三个参数:
1、名称: slave-1
2、密码: SLAVE_SECRET=a_password
3、主端的网址: MASTER_URL=http://smokeping.keesir.com:8899/smokeping/smokeping.cgi
Master端配置
编辑Slave从端的配置文件
vim ~/myserver/smokeping/config/Slaves
里面内容如下,被注释的就是 slave 的注册,第一行名称随意,下面行是个性化配置,包括从端名称、显示名称、显示颜色代码,删除注释后自定义
*** Slaves *** secrets=/etc/smokeping/smokeping_secrets #+boomer #display_name=boomer #color=0000ff #+slave2 #display_name=another #color=00ff00
添加从端VPS1和VPS2
*** Slaves *** secrets=/etc/smokeping/smokeping_secrets +VPS1 display_name=VPS1 color=afeee1 +VPS2 display_name=VPS2 color=00ff00
添加通信密码
vim ~/myserver/smokeping/smokeping_secrets
VPS1:a_password VPS2:a_password
配置Targets
vim ~/myserver/smokeping/config/Targets
*** Targets *** probe = FPing menu = Top title = Network Latency Grapher remark = Welcome to this SmokePing website. slaves = VPS1 VPS2 # 设置全局的从端,如果在 + / ++ / +++ 下设置,那就是只对对应的生效
Slave端配置
创建工作目录并开放端口
curl -fsSL https://get.docker.com | bash -s docker #安装docke# myserver="smokeping" #容器名# sudo ufw allow 8899/tcp comment $myserver && sudo ufw reload #如果有防火墙需要放行端口# mkdir -p ~/myserver/$myserver && cd ~/myserver/$myserver && mkdir config data #建立数据文件夹#
修改启动脚本,配置镜像使用slave模式
vim run
#!/usr/bin/with-contenv bash if [ "x$MASTER_URL" == "x" ]; then echo "Please define a master URL in \$MASTER_URL env variable. Detected value: $MASTER_URL" fi if [ "x$SHARED_SECRET" == "x" ]; then echo "Please define a shared secret in \$SHARED_SECRET env variable. Detected value: $SHARED_SECRET" fi echo $SHARED_SECRET > /config/smokeping_secrets && \ chown abc:abc /config/smokeping_secrets && \ chmod 640 /config/smokeping_secrets exec s6-setuidgid abc /usr/sbin/smokeping --config="/etc/smokeping/config" --master-url="$MASTER_URL" --shared-secret=/config/smokeping_secrets --cache-dir=/tmp --nodaemon
插入镜像,开启slave模式
vim Dockerfile
FROM lscr.io/linuxserver/smokeping:latest LABEL maintainer="Daniel Graziotin <[email protected]>" ENV SHARED_SECRET= \ MASTER_URL= COPY run /etc/services.d/smokeping/run
创建 docker-compose.yml 文件
cat > docker-compose.yml << EOF --- version: "2.1" services: smokeping-slave: build: context: . dockerfile: Dockerfile container_name: smokeping-slave hostname: SG-Yxvm environment: - PUID=1000 - PGID=1000 - TZ=Asia/Shanghai - SHARED_SECRET=a_password - MASTER_URL=http://smokeping.keesir.com:8899/smokeping/smokeping.cgi volumes: - ./config:/config - ./data:/data ports: - 8899:80 restart: unless-stopped EOF
重新构造镜像
docker compose build
启动容器
docker compose up -d
关闭容器
docker compose down
查看日志
docker logs -f smokeping-slave
进入容器
docker exec -it smokeping-slave /bin/bash