slave配置:
echo passwd > /usr/local/smokeping/etc/smokeping_secrets
chown smokeping: /usr/local/smokeping/etc/smokeping_secrets
chmod 600 /usr/local/smokeping/etc/smokeping_secrets
mkdir /usr/local/smokeping/cache
chown smokeping: -R /usr/local/smokeping/cache/
service:
[Unit]
Description=Smokeping Service, Network Latency Graphical Viewer
After=network.service
[Service]
Type=forking
Environment=MASTER=https://www.haiyun.me/
Environment=CACHEDIR=/usr/local/smokeping/cache
Environment=SECRET=/usr/local/smokeping/etc/smokeping_secrets
Environment=NAME=bj
#Environment=DEBUG=--debug-daemon
RuntimeDirectory=smokeping
RuntimeDirectoryMode=0775
PIDFile=/run/smokeping/smokeping.pid
User=smokeping
Group=smokeping
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/bin/sh -c "/usr/local/smokeping/bin/smokeping --master-url=${MASTER} --cache-dir=${CACHEDIR} --slave-name=${NAME} --shared-secret=${SECRET} --pid-dir=/run/smokeping/ ${DEBUG-DAEMON}"
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=default.target
master配置:
cat /etc/smokeping/config.d/Slaves
*** Slaves ***
secrets=/etc/smokeping/smokeping_secrets
+ bj # slave的名字
display_name=bj # slave的别名
#location=beijing
color=0000ff # slave收集的数据在图像中显示的颜色
cat /etc/smokeping/smokeping_secrets
bj:passwd
cat /etc/smokeping/config.d/Targets
+ Ping
menu = Ping
title = Ping
++ TEST
menu = test
title = test
host = www.haiyun.me
slaves = bj
chown www-data: /etc/smokeping/smokeping_secrets
chmod 600 /etc/smokeping/smokeping_secrets
mkdir /data/d/smokeping/data/__cgi/Ping
chown www-data: /data/d/smokeping/data/__cgi/Ping
chgrp www-data /data/d/smokeping/data/Ping/ -R
chmod g+w /data/d/smokeping/data/Ping/ -R
chown smokeping: /data/smokeping/data/__sortercache/ -R
master service可添加:
PermissionsStartOnly=true
ExecReload=/bin/sleep 3
ExecReload=/usr/bin/chgrp www-data /data/d/smokeping/data/Ping/ -R
ExecReload=/usr/bin/chmod g+w /data/d/smokeping/data/Ping/ -R
ExecStartPost=/bin/sleep 3
ExecStartPost=/usr/bin/chgrp www-data /data/d/smokeping/data/Ping/ -R
ExecStartPost=/usr/bin/chmod g+w /data/d/smokeping/data/Ping/ -R
遇到的问题:
1.ERROR: the shared secret file (/usr/local/smokeping/etc/smokeping_secrets) is world-readable or writable
解决:修改权限/usr/local/smokeping/etc/smokeping_secrets
2.WARNING: Opening secrets file /etc/smokeping/smokeping_secrets: Permission denied
解决:启动时添加--debug发现是master的错误,修改web server可读此文件
3.WARNING: Data from was signed with which does not match our expectation
解决:slave配置smokeping_secrets只添加密码
4.slave发送数据到master ok,但是无图表数据
解决:修改/data/d/smokeping/data/Ping/对应的rrd web可写
5.还是不行,查看nginx日志Could not lock /data/d/smokeping/data/__cgi//Ping/*.bj.slave_cache (No such file or directory).
解决:创建相应目录并给予web server可写权限
6.当master停机一段时间后slave积累大量数据提交WARNING Master said 413 Request Entity Too Large:
解决:nginx配置修改client_max_body_size 100m;