Smokeping 是一款用于网络性能监测的监控软件,通过它可以在自己公司IDC的网络状况,如延时,丢包率,是否BGP多线等,通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况,
Smokeping 需要多个包的支持,下面我们逐个安装,这里通过yum和编译安装两种方式。(有内置yum包直接yum,没有的编译安装)
yum install -y perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perlperl-IO-Socket-SSL perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtoolrrdtool-perl curl httpd httpd-devel gcc make wget libxml2-devellibpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairocairo-devel libart_lgpl libart_lgpl-devel
下载fping并编译:
wget http://fping.org/dist/fping-3.10.tar.gz
解压缩后,直接 configure && make && make install 即可
下载echoping并编译安装:
wgethttp://jaist.dl.sourceforge.net/project/echoping/echoping/6.0.2/echoping-6.0.2.tar.gz
yum install -y popt
yum install -y libidn (安装两个echoping依赖的包)
若没有,可以下载软件包,用源码安装
安装依赖包后解压缩,直接 configure && make && make install 即可
下载smokeping
http://download.csdn.net/download/fairplay_li/8711829
解压; cd smokeping-2.6.9
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
以下开始配置 smokeping
- cd /usr/local/smokeping/
- mkdir cache data var
- touch /var/log/smokeping.log
- chown apache:apache cache data var
- chown apache:apache /var/log/smokeping.log
- chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
- cd /usr/local/smokeping/htdocs
- mv smokeping.fcgi.dist smokeping.fcgi
- cd /usr/local/smokeping/etc
- mv config.dist config
vim config
主要修改如下内容:
cgiurl = http://some.url/smokeping.cgi
*** Database ***
step = 300
此处建议改为 60 , 一分钟采集一次数据
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"
- <Directory "/usr/local/smokeping">
- AllowOverride None
- Options All
- AddHandler cgi-script .fcgi .cgi
- Order allow,deny
- Allow from all
- DirectoryIndex smokeping.fcgi
- </Directory>
如果需要支持中文,需要安装中文编码:
yum -y installwqy-zenhei-fonts.noarch
vim /usr/local/smokeping/lib/Smokeping/Graphs.pm
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[0][1],
'--end', $tasks[0][2],
后,添加
'--font TITLE:20:"WenQuanYi ZenHei Mono"',
设置开机启动
echo "/usr/local/smokeping/bin/smokeping--logfile=/var/log/smokeping.log 2>&1 &"
>> /etc/rc.local
监测源的IP库,填入到 config 中
*** Targets ***
#=================================
#这里用于配置监控目标,以+号分层,+为首页,++为子层,我们以百度和搜狐为例。
+TEST
menu= TEST
title = TEST
++ baidu
menu = baidu
title = baidu
host = 115.239.210.27
++ sohu
menu = sohu
title = sohu
host = 121.14.0.97
#=================================
三.启动
1.重启apache
service httpd restart
2.重启smokeping
/usr/local/smokeping/bin/smokeping restart
若重启报错 rm-rf /usr/local/smokeping/var/smokeping.pid杀掉PID
完成。
效果图: