注意:master与slave按同样的方法进行安装,并且slave端,smokeping不需要配置文件,也不需要配置httpd,这些只在master上配置即可。
文章目录
规划:
- master的ip:223.84.153.89,os为centos7.3
- slave的ip:119.29.4.98,os为centos7.3,并且主机名为tengxunyun
第一,第二:分别在master与slave上安装smokeping
master与slave端的smokeping安装步骤,都请参看此文章的第一和第二步步骤
第三:在master上配置httpd
vim /etc/httpd/conf/httpd.conf
Alias /cache "/opt/smokeping/cache/"
Alias /cropper "/opt/smokeping/htdocs/cropper/"
Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"
<Directory "/opt/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
#拒绝所有用户访问
Deny from all
#允许所有用户访问
#Require all granted
#对某些ip允许访问
Require ip 119.29.4.98
Require ip 223.84.153.82/28
#Order allow,deny
Allow from all
#AuthName "Smokeping"
#AuthType Basic
#AuthUserFile /opt/smokeping/htdocs/htpasswd
#Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
第四:在master上启动相关服务,并加入开机自起
systemctl start httpd
/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
chmod +x /etc/rc.d/rc.local
systemctl enable httpd
echo "/opt/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
定义slave节点
第五:在master上修改smokeping的配置文件
vim /opt/smokeping/etc/config
*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets.dist
#定义slave节点,其tengxunyun必须是slave主机的主机名,即在slave上执行hostname命令,显示的内容
+tengxunyun
display_name=腾讯云slave
location=China
color=ff0000
*** Targets ***
+ Other
menu = 全国DNS网络监控
title = 全国DNS网络监控
++ gg
menu = 公共DNS
title = 公共DNS网络监控列表
host = /Other/gg/gg-114 /Other/gg/gg-ali
+++ gg-114
menu = 114-DNS
title = 114-DNS
alerts = someloss
#添加slaves,让slave节点,tengxunyun也监测114.114.114.114这个ip的网络质量
slaves = tengxunyun
#若是应用多个slave,应该这样写
#slaves = tengxunyun aliyun-host
host = 114.114.114.114
+++ gg-ali
menu = 阿里-DNS
title = 阿里-DNS
alerts = someloss
#slaves = slave1 slave2
slaves = tengxunyun
host = 223.5.5.5
第六:在master上创建与slave端通信的密码(主辅验证)
#格式 echo "slave的主机名:密码" >> /opt/smokeping/etc/smokeping_secrets.dist
echo "tengxunyun:12345678" >> /opt/smokeping/etc/smokeping_secrets.dist
第七:在slave上需创建一个存放密码的文件,并授权600,(这个文件只需包含密码,不要有主机名)
touch /opt/smokeping/etc/slave_secrets
echo "12345678" >> /opt/smokeping/etc/slave_secrets
chmod 600 /opt/smokeping/etc/slave_secrets
第八:修改部分目录及文件的权限,避免slave端启动出错
#在master端执行
chown apache /opt/smokeping/etc/smokeping_secrets.dist
#在slave端,运行
chown apache /opt/smokeping/data/ -R
第九:在slave端启动smokeping
/opt/smokeping/bin/smokeping --master-url=http://223.84.153.89:80/smokeping/smokeping.fcgi --cache-dir=/opt/smokeping/cache --shared-secret=/opt/smokeping/etc/slave_secrets --logfile=/tmp/slave.log
下面是成果图
FAQ区
一:若是slave端启动时报错
WARNING Master said 401 Unauthorized
ERROR: we did not get config from the master. Maybe we are not configured as a slave for any of the targets on the master ?
原因是:master端的httpd设置了访问验证,
cat /etc/httpd/conf/httpd.conf
Alias /cache "/opt/smokeping/cache/"
Alias /cropper "/opt/smokeping/htdocs/cropper/"
Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"
<Directory "/opt/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /opt/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
解决办法:取消master端的httpd设置了访问验证
cat /etc/httpd/conf/httpd.conf
Alias /cache "/opt/smokeping/cache/"
Alias /cropper "/opt/smokeping/htdocs/cropper/"
Alias /smokeping "/opt/smokeping/htdocs/smokeping.fcgi"
<Directory "/opt/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
#Require all granted
#将slave的IP加入到下面的允许范围里,一行一个
Require ip 149.129.132.1
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /opt/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
二:若是slave端启动时报错
WARNING: Opening secrets file /opt/smokeping/etc/smokeping_secrets.dist: Permission denied
ERROR: we did not get config from the master. Maybe we are not configured as a slave for any of the targets on the master ?
原因是:master上的/opt/smokeping/etc/smokeping_secrets.dist文件拒绝了连接
解决办法:修改smokeping_secrets.dist的所有这为apache
chown apache /opt/smokeping/etc/smokeping_secrets.dist
三:若是slave端的smokeping正常启动,但是master上的http展示页没有slave返回的数据
原因分析:可能是存放rrd的文件没有写权限
解决办法:同时在master上执行
chown apache -R /opt/smokeping/data
如果文章对你有帮助,欢迎点击上方按钮打赏作者
暂无评论