监控软件之SmokePing
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了监控软件之SmokePing相关的知识,希望对你有一定的参考价值。
一、SmokePing简介
Smokeping 是rrdtool 的作者Tobi Oetiker 的作品,是用Perl 写的,主要是监视网络性能,包括常规的ping,用echoping监控www 服务器性能,监视dns 查询性能,监视ssh 性能等。底层也是rrdtool做支持,特点是画的图非常漂亮,网络丢包和延迟用颜色和阴影来表示。在企业中运用较少。
二、系统设置
2.1系统设置
安装wget下载工具
yum -y install wget
修改本地源,先备份现有的源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
切换到阿里云的源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
安装源数据缓存
yum makecache
系统升级
yum -y update
安装"Compatibility libraries" "Base" "Development tools"这三个组套件
yum groupinstall "Compatibility libraries" "Base" "Development tools" -y
2.2、关闭SeLinux
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
2.3、关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
2.4、设置NTP
ntpdate times.aliyun.com
三、SmokePing安装
Smokeping 需要多个包的支持,下面我们逐个安装,这里通过yum和编译安装两种方式。
yum install -y ntpdate perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker perl-Sys-Syslog rrdtool rrdtool-perl curl httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel popt popt-devel libidn libidn-devel perl-core wqy-zenhei-fonts.noarch
下面这个三个安装包无法通过yum安装,需要通过wget工具下载本地编译安装
smokeping-2.6.8、fping 4.0、echoping 6.0.2
下载链接如下:
wget http://fping.org/dist/fping-4.0.tar.gz
wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
根据个人爱好选择下载目录,下面以/tmp/smokeping/为下载目录说明安装
fping编译安装:
tar xf fping-4.0.tar.gz
cd fping-4.0
./configure
make && make install
echoping编译安装:
tar xf echoping-6.0.2.tar.gz
cd echoping-6.0.2
./configure
make && make install
smokeping 编译安装
tar xf smokeping-2.6.8.tar.gz
cd smokeping-2.6.8
#exportPERL5LIB=/usr/local/smokeping/thirdparty/lib/perl5/
安装perl的模块
./setup/build-perl-modules.sh /etc/smokeping/thirdparty
如果没有安装perl的模块,直接安装会出现下面的错误
-------------------------------------------------------------
Aborting Configure
If you know where perl can find the missing modules, set
the PERL5LIB environment variable accordingly.
FIRST though, make sure that ‘perl‘ starts the perl
binary you want to use for SmokePing.
Now you can install local copies of the missing modules
by running
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
The RRDs perl module is part of RRDtool. Either use the rrdtool
package provided by your OS or install rrdtool from source.
If you install from source, the RRDs module is located
PREFIX/lib/perl
-------------------------------------------------------------
./configure --prefix=/etc/smokeping
/usr/bin/gmake install
四、下面就是SmokePing的配置了
1、进入/etc/smokeping/目录
cd /etc/smokeping/
2、新建目录cache、data、var,日志log,并修改宿主权限
mkdir cache data var
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log
touch /var/log/smokeping.log
chown apache:apache /var/log/smokeping.log
修改smokeping_secrets.dist权限
chmod 600 /etc/smokeping/etc/smokeping_secrets.dist
cd /etc/smokeping/htdocs
cp smokeping.fcgi.dist smokeping.fcgi
创建软连接
ln -sd ../cache cache
cd /etc/smokeping/etc
cp config.dist config
修改配置文件
vi config
主要修改如下内容:
#cgiurl = http://some.url/smokeping.cgi
cgiurl = http://10.0.0.62/smokeping.cgi
Database
#step = 300
step = 60 #此处建议改为 60 , 一分钟采集一次数据
pings = 20
修改apache配置
vi /etc/httpd/conf/httpd.conf
末尾添加如下:
# SmokePing
Alias /cache "/etc/smokeping/cache/"
Alias /cropper "/etc/smokeping/htdocs/cropper/"
Alias /smokeping "/etc/smokeping/htdocs/"
<Directory "/etc/smokeping/">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
DirectoryIndex smokeping.fcgi
Require all granted
</Directory>
如果需要支持中文,需要安装中文编码:
vim /etc/smokeping/etc/config
Presentation
charset = utf-8 #添加此行
vim /etc/smokeping/lib/Smokeping/Graphs.pm
#第160行下边插入下边一行
‘--font TITLE:20:"WenQuanYi Zen Hei Mono"‘,
"DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
设置开机启动
chmod +x /etc/rc.d/rc.local
echo "/etc/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
设置完毕,启动Apache、SmorkePing服务
systemctl restart httpd.service
/etc/smokeping/bin/smokeping
好了,SmokePing设置就好了,打开浏览器输入ip/smokeping,如下图所示:
设置检测源ip,填入到/etc/smokeping/etc/config中
vi /etc/smokeping/etc/config
- MyServer
menu = 出口网络监控
title = 监控统计
++ dianxin-xa
menu = 西安电信
title = 西安电信
alerts = someloss
host = 36.40.36.106 - Tencent
menu = 腾讯
title = 腾讯监控
++ Tencent-Video
menu = 腾讯视频
title = v.qq.com
alerts = someloss
host = 113.142.52.149
++ Tencent-Index
menu = 腾讯首页
title = www.qq.com
alerts = someloss
host = www.qq.com - yy
menu = 歪歪
title =歪歪监控
++waiwai-Video
menu = 歪歪直播
title = www.yy.com
alerts = someloss
host = www.yy.com
修改完配置,需要重启SmokePing服务,重启服务必须先杀掉正在运行的服务,才能重新启动,负责是没办法重启的。
查看PID
pgrep -l smokeping
杀掉pid
kill pid
重启启动服务
/etc/smokeping/bin/smokeping
再打开,如图所示:
从效果图和配置文件对比来理解,显示效果测层次感是根据+的数量逐层递增的,123层。
以上为测试内容,可根据实际需求情况进行调测。
上述配置web访问是直接访问的,不安全,如果需要加入安全访问控制,请修改apache的httpd.conf配置,下面粗体标记部分
# SmokePing
Alias /cache "/etc/smokeping/cache/"
Alias /cropper "/etc/smokeping/htdocs/cropper/"
Alias /smokeping "/etc/smokeping/htdocs/"
<Directory "/etc/smokeping/">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "smokeping"
AuthType Basic
AuthUserFile /etc/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
设置访问的用户名和密码
htpasswd -c /etc/smokeping/htdocs/htpasswd admin
New password:
Re-type new password:
Adding password for user admin
重启apache
systemctl restart httpd.service
输入用户名密码就OK了。
以上是关于监控软件之SmokePing的主要内容,如果未能解决你的问题,请参考以下文章