Smokeping架构组件有:rrdtool、Fping、Echoping、Curl、Perl、Perl模块、SpeedyCGI、apache等。
//为了方便直接使用yum安装
[root@vps ~]# yum -y install httpd httpd-devel gcc make curl wget
[root@vps ~]# yum -y install libxml2-devel libpng-devel pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel dejavu-sans-mono-fonts
[root@vps ~]# wget http://www.rpmfind.net/linux/centos/7.6.1810/os/x86_64/Packages/rrdtool-1.4.8-9.el7.x86_64.rpm
[root@vps ~]# rpm -ivh rrdtool-1.4.8-9.el7.x86_64.rpm
[root@vps ~]# yum install mod_fcgid bind-utils
[root@vps ~]# wget http://www.fping.org/dist/fping-3.10.tar.gz
[root@vps ~]# wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
[root@vps ~]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
[root@vps ~]# yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl httpd httpd-devel gcc make wget libxml2-devel libpng-devel pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel popt popt-devel libidn libidn-devel
[root@vps ~]# tar xf fping-3.10.tar.gz
[root@vps ~]# cd fping-3.10
[root@vps fping-3.10]# ./configure
[root@vps fping-3.10]# make && make instal
[root@vps ~]# tar xf echoping-6.0.2.tar.gz
[root@vps ~]# cd echoping-6.0.2
[root@vps echoping-6.0.2]# ./configure
[root@vps echoping-6.0.2]# make && make install
[root@vps ~]# tar xf smokeping-2.6.9.tar.gz
[root@vps ~]# cd smokeping-2.6.9
[root@vps smokeping-2.6.9]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
[root@vps smokeping-2.6.9]# ./configure --prefix=/usr/local/smokeping
[root@vps smokeping-2.6.9]# /usr/bin/gmake install
出现错误 Can’t locate Sys/Syslog.pm in @INC (@INC contains: /usr/local/smokeing/thirdparty/lib/perl5/x86_64-linux-thread-multi /usr/local/smokeing/thirdparty/lib/perl5 …/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at …/lib/Smokeping.pm line 16.
[root@vps smokeping-2.6.9]# yum -y install perl-Sys-Syslog //缺包了,安装这个就OK
执行安装的时候还是会报一个错误,在执行/usr/bin/gmake install 就可以了
smokeping的主配置文件是:/usr/local/smokeping/etc/config
[root@vps ~]# cd /usr/local/smokeping/
[root@vps smokeping]# mkdir cache var data
[root@vps smokeping]# touch /var/log/smokeping.log
[root@vps smokeping]# chown apache.apache cache data var
[root@vps smokeping]# chown apache.apache /var/log/smokeping.log
[root@vps smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
[root@vps smokeping]# cd /usr/local/smokeping/htdocs/
[root@vps htdocs]# mv smokeping.fcgi.dist smokeping.fcgi
[root@vps htdocs]# cd /usr/local/smokeping/etc/
[root@vps etc]# mv config.dist config
[root@vps etc]# vim config
修改如下内容:
cgiurl=http://你的ip/smokeping.cgi
*** Database ***
step = 300 此处建议改为 120
*** General ***
owner = Peter Random //身份
contact = [email protected] //联系方式(邮箱)
mailhost = my.mail.host //SMTP服务器的地址
sendmail = /usr/sbin/sendmail //sendmial的绝对路径
mgcache = /usr/local/smokeping/cache
imgurl = cache
datadir = /usr/local/smokeping/data
piddir = /usr/local/smokeping/var
cgiurl = http://45.193.56.155/smokeping.cgi //默认是cgiurl = http://some.url/smokeping.cgi,把some.url修改为你的ip或者域名
smokemail = /usr/local/smokeping/etc/smokemail.dist
tmail = /usr/local/smokeping/etc/tmail.dist
syslogfacility = local0 //指定这个来获取syslog记录
第二部分Alerts是属于报警配置
第三部分数据库RRD数据库配置.step和ping这两个参数要在启动smokeping之前配置好,如果在smokeping启动后再配置这两个参数,需要把原来的rrd文件都删除,然后再启动smokeping才可以。所以这个一定要先配置好。默认是step = 300 pings = 20应该是每300s内执行20次ping的动作
第四部分介绍是关于网络状态的一些配置和解释,基本不需要更改
第五部分Porbes指针配置,我们一般只用到fping所以就只要以下配置就可以了,确定路径是否正确,这里还可以设置fping包的大小,参数
第六分部Slaves主从关系里面的从服务器相关配置,smokeping里面从服务器只需要安装好就可以了,不需要配置,smokeping的所有配置都是在master上面设置。这里主要设置好秘密密码文件和从服务器配置就可以了。
第七部分Targets目标配置。在这里可以单独配置一台服务器的监控情况,需要从从服务器上取值的配置也是在这里配置。
主/从做分布式监控的时候有几点需要注意
1.主从服务器上面的密码文件权限必须为600而且主服务器上面的密码文件的属主必须为apache的启动用户
2.从服务器上面的密码文件只需要一个密码就行,也就是主上面为它配置的那个密码。同样从服务器上面的密码文件的属主必须为smokeping的启动用户
[root@vps ~]# vim /etc/httpd/conf/httpd.conf
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi" //smokeping访问地址就是http://smokeping.wangshibo.com/smokeping
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
smokeping的默认配置文件110行的fping安装目录与此次安装目录不相符需修改
[root@vps etc]# vim config
#第110更改fping的目录为
binary = /usr/local/sbin/fping
# 如果是没有修改过此项配置,那默认的配置如下:
AllowOverride none
Require all denied
# 将默认设置改成如下配置:
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
[root@vps ~]# yum -y install wqy-zenhei-fonts.noarch
[root@vps ~]# vim /usr/local/smokeping/etc/config
charset = utf-8 //第50行下面添加此行内容
[root@vps ~]# vim /usr/local/smokeping/lib/Smokeping/Graphs.pm
'--font TITLE:20:"WenQuanYi Zen Hei Mono"', //第147行下面插入边一行内容
[root@vps ~]# vim /usr/local/smokeping/etc/config //在最后面添加
+ Other
menu = 三大网络监控
title = 监控统计
++ 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
[root@vps ~]# systemctl start httpd
[root@vps ~]# systemctl enable httpd
[root@vps ~]# /usr/local/smokeping/bin/smokeping
Note: logging to syslog as local0/info.
Daemonizing /usr/local/smokeping/bin/smokeping ...
如果按照上面操作后,直接在网上访问是十分的不安全,需要加入安全访问控制
修改apache的httpd.conf配置(将上面添加的apache配置直接如下覆盖或再添加如下红色字体内容)
[root@vps ~]# vim /etc/httpd/conf/httpd.conf
....
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
//设置访问的用户名和密码(比如admin/admin)
[root@vps ~]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
New password:
Re-type new password:
Adding password for user admin
//重启apache,再次访问smokeping界面