smokeping Master/Slave 安装配置
官方网站:
smokeping的作者也是rrdtool,mrtg的作者,是一款分布式的网络可视化监控工具
环境:
CentOS 7.1/6.5
smokeping-2.6.11
fping-3.10
一.安装smokeping
1.smokeping
yum -y install gcc gcc-c++ make rrdtool rrdtool-perl curl
wget perl-devel
tar -xvf smokeping-2.6.11.tar.gz
cd smokeping-2.6.11/
./setup/build-perl-modules.sh
/opt/smokeping/thirdparty
./configure --prefix=/opt/smokeping
make install
提示:很多光盘不自带的库都可以通过CPAN来自动安装 ,如:perl
-MCPAN -e 'install Time::HiRes'前提是要有公网
2.fping
请参看fping安装及应用
3.echoping(可选)
echoping is no
longer maintained.
注意:echoping已经不再维护了
二.配置smokeping
cd /opt/smokeping
mkdir cache data var logs
mv htdocs/smokeping.fcgi.dist htdocs/smokeping.fcgi
chmod 600
/opt/smokeping/etc/smokeping_secrets.dist
cp etc/config.dist etc/config
sed -i '/^step/c step = 60' etc/config #多少秒采集一次数据
sed -i '/fping/
s#/usr#/usr/local#p' /opt/smokeping/etc/config
#fping所在的绝对路径
sed -i
'/Presentation/a charset = UTF-8' /opt/smokeping/etc/config
#中文支持,一定要加在*** Presentation ***段落,否则会报语法错误
setfacl -R -m apache:rwx /opt/smokeping/
setfacl -R -m d:apache:rwx /opt/smokeping/
注意:web用户要能读写smokeping的数据
启动
/opt/smokeping/bin/smokeping
--logfile=/opt/smokeping/logs/smokeping.log
重启
/opt/smokeping/bin/smokeping --logfile=/opt/smokeping/logs/smokeping.log --restart
重载
/opt/smokeping/bin/smokeping --logfile=/opt/smokeping/logs/smokeping.log --reload
调式--debug
四.配置web
以apache为例:
yum -y install httpd
cat >/etc/httpd/conf.d/smokeping.conf <<HERE
-
Alias
/cache "/opt/smokeping/cache/" -
Alias
/cropper "/opt/smokeping/htdocs/cropper/" -
Alias
/smokeping "/opt/smokeping/htdocs/smokeping.fcgi" -
-
AllowOverride
None -
Options
All -
AddHandler
cgi-script .fcgi .cgi -
Order
allow,deny -
Allow
from all -
DirectoryIndex
smokeping.fcgi -
HERE
service httpd restart
说明:sina博客 php对代码块支持度不好,很多<>显示不出来,所以贴上配置截图
192.168.192.10/smokeping
五.测试
提示:可以删除默认的test Targets---James
cat >>/opt/smokeping/etc/config
<<HERE
+ Other
menu = ChinaNet &
ChinaUnicom & ChinaMobile
title = Test
smokeping
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
host =
/Other/dianxin/dianxin-bj /Other/dianxin/dianxin-hlj
/Other/dianxin/dianxin-tj
/Other/dianxin/dianxin-sc
/Other/dianxin/dianxin-sh
/Other/dianxin/dianxin-gz
+++
dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host =
202.96.199.133
+++
dianxin-hlj
menu = 黑龙江电信
title = 黑龙江电信
alerts = someloss
host =
219.147.198.242
+++ dianxin-tj
menu = 天津电信
title = 天津电信
alerts = someloss
host =
219.150.32.132
+++
dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
+++
dianxin-sh
menu = 上海电信
title = 上海电信
alerts = someloss
host =
116.228.111.118
+++
dianxin-gz
menu = 广东电信
title = 广东电信
alerts = someloss
host =
113.111.211.22
++ liantong
menu = 联通网络监控
title = 联通网络监控列表
host =
/Other/liantong/liantong-bj /Other/liantong/liantong-hlj
/Other/liantong/liantong-tj
/Other/liantong/liantong-sc
/Other/liantong/liantong-sh
/Other/liantong/liantong-gz
+++
liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host =
61.135.169.121
+++
liantong-hlj
menu = 黑龙江联通
title = 黑龙江联通
alerts = someloss
host =
202.97.224.69
+++ liantong-tj
menu = 天津联通
title = 天津联通
alerts = someloss
host =
202.99.96.68
+++
liantong-sc
menu = 四川联通
title = 四川联通
alerts = someloss
host = 119.6.6.6
+++
liantong-sh
menu = 上海联通
title = 上海联通
alerts = someloss
host = 210.22.84.3
+++
liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
++
yidong
menu = 移动网络监控
title = 移动网络监控列表
host = /Other/yidong/yidong-bj
/Other/yidong/yidong-hlj /Other/yidong/yidong-tj
/Other/yidong/yidong-sc
/Other/yidong/yidong-sh
/Other/yidong/yidong-gz
+++
yidong-bj
menu = 北京移动
title = 北京移动
alerts = someloss
host =
221.130.33.52
+++
yidong-hlj
menu = 黑龙江移动
title = 黑龙江移动
alerts = someloss
host =
211.137.241.35
+++ yidong-tj
menu = 天津移动
title = 天津移动
alerts = someloss
host =
211.137.160.5
+++
yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
+++
yidong-sh
menu = 上海移动
title = 上海移动
alerts = someloss
host =
117.131.19.23
+++
yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host =
211.136.192.6
HERE
/opt/smokeping/bin/smokeping --restart
六.Master/Slave
1.安装smokeping Slave
说明: Slave不需要web服务器,只需要安装smokeping组件
安装同上,略
2.配置Master
a.在配置文件*** Slaves
***段落指定主辅通信密码文件路径及slave名称
*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets.dist
+myslave1
display_name=smoke-s.example.com
color=ff0000
b.在使用的一级目录下添加slaves=smoke-s.example.com
+ Other
menu = ChinaNet & ChinaUnicom &
ChinaMobile
title = Test smokeping
slaves=smoke-s.example.com
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
slaves=smoke-s.example.com
host = /Other/dianxin/dianxin-bj
/Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj
/Other/dianxin/dianxin-sc
/Other/dianxin/dianxin-sh
/Other/dianxin/dianxin-gz
+++ dianxin-bj
menu = 北京电信
title = 北京电信
slaves=smoke-s.example.com
alerts = someloss
host = 202.96.199.133
...
...
注意:
slaves必须是主机名或ip
c.在主辅通信密码文件添加slave主机及密码
echo smoke-s.example.com: slaveSmokepingP@ssw0rd
>>/opt/smokeping/etc/smokeping_secrets.dist
d.重启Master smokeping
/opt/smokeping/bin/smokeping --restart
3.配置Slave
a.创建主辅通信密码文件
echo slaveSmokepingP@ssw0rd
>/opt/smokeping/etc/slave_secret
chmod
600 /opt/smokeping/etc/slave_secret
b.记动slave
/opt/smokeping/bin/smokeping
--master-url=http://192.168.192.10/smokeping
--cache-dir=/opt/smokeping/cache/
--shared-secret=/opt/smokeping/etc/slave_secret --logfile=/opt/smokeping/logs/smokeping.log
提示:如果发现Slave
smokeping有图显示,但确没有数据,请开启debug日志查看
1.主辅通信问题
2.权限问题
(本地测试时,等了好久仍有图没数据,开debug也显示通信正常,但就是没数据,后来看了下Slave到Master的传输方式,应该是通过REST接口来写数据,如果用root用户启动则apache用户没有权限来写数据,加上ACL写入权限后数据不一会就过来了)