19

Smokeping 多机配置

 3 years ago
source link: https://www.taterli.com/7350/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

实验的主机系统是Debian,应该只要是Debian系的系统应该都可以.主机系统版本是Raspberrry Pi OS(Debian 10),从机是各种VPS的Debian 10.

首先安装spawn-fcgi和nginx,smokeping,通过apt就可以安装,从机不需要安装nginx,主机Web端口必须可以被访问(不一定是80).

首先理清几个概念:

主机负责布置所有任务,从机通过HTTP POST和主机通信,数据库都在主机.权限是个很麻烦的事情,需要反复折腾,在AMAZ Lightsail Debian 10上没测试成功,最后在Raspbian上实践,问题比较奇怪,暂时不明白.如果出现什么错误,先试试运行:

smokeping --restart

(主机)第一步,安装必要的软件:

apt install smokeping nginx spawn-fcgi

(主机)第二步新建fcgi的映射文件/etc/systemd/system/smokeping-fcgi.service,内容如下:

[Unit]
Description=SmokePing FastCGI Service
After=network.target smokeping.service
Wants=smokeping.service
[Service]
User=root
Group=root
StandardOutput=null
StandardError=syslog
ExecStart=/usr/bin/spawn-fcgi -u smokeping -s /run/smokeping-fcgi.sock -M 755 -n -U www-data -G www-data -- /usr/share/smokeping/smokeping.cgi
Restart=always
[Install]
WantedBy=multi-user.target

(主机)第三步,给Nginx配置反向代理.

location = /smokeping/ {
    fastcgi_pass unix:/run/smokeping-fcgi.sock;
    include /etc/nginx/fastcgi_params;
}
location /smokeping/ {
    alias /usr/share/smokeping/www/;
}

(主机)第四步,按照正常smokeping配置那样,配置目标等等各种参数.

(主机)第五步,设置/var/lib/smokeping的所属为smokeping:www-data,权限为755,设置,最后使用smokeping –restart重启.

(主机)从机配置文件,可以写很多行,这个是Slaves文件.

*** Slaves ***
secrets=/etc/smokeping/smokeping_secrets
+ap-northeast-2
display_name=韩国 首尔
color=0000ff

(主机)而smokeping_secrets是对应密码文件,格式如下:

ap-northeast-2:065538606019

(从机)把从机密码字符串放在/etc/smokeping/secrets,设定权限600,然后新建服务/etc/systemd/system/smokeping.service,内容如下:

[Unit]
Description=Smokeping Service, Network Latency Graphical Viewer
After=network.service
[Service]
Type=forking
Environment=MASTER=18.183.217.124
Environment=CACHEDIR=/usr/local/smokeping/cache/
Environment=SECRET=/etc/smokeping/secrets
Environment=SLAVENAME=eu-west-3
ExecStart=/bin/sh -c "/usr/sbin/smokeping --master-url=http://${MASTER}/smokeping/ --cache-dir=${CACHEDIR} --slave-name=${SLAVENAME} --shared-secret=${SECRET} --logfile=/usr/local/smokeping/slave.log --debug-daemon"
KillSignal=SIGTERM
ExecReload=/bin/sh -c "/usr/sbin/smokeping --master-url=http://${MASTER}/smokeping/ --cache-dir=${CACHEDIR} --slave-name=${SLAVENAME} --shared-secret=${SECRET} --logfile=/usr/local/smokeping/slave.log --debug-daemon --reload"
User=smokeping
Group=smokeping
[Install]
WantedBy=default.target

(从机)新建缓存目录,使能服务,重启服务,就可以等待上线了.

mkdir /usr/local/smokeping/cache -p
chown smokeping:smokeping /usr/local/smokeping -R

批量检查下从机服务是不是正常(pssh):

jQni6jf.png!mobile

结果:

Jryyiqa.png!mobile

实验完毕记得删机,多机费钱啊.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK