Linux的网络监控工具Smokeping
Smokeping主要是监控网络性能,包括常规的ping,用echoping 监控www 服务器性能,监控dns 查询性能,监控ssh 性能等。Smokeping底层是用rrdtool做支持,特点是画图漂亮,网络丢包和延迟用颜色和阴影来表示。Smokeping 由以下组件组成: RRDtool、Fping、Echoping、Curl、Dig、SSh、Perl 模块。
虽然Smokeping 可以探测网络性能,但如果仅仅从单个节点去探测网络性能,往往是不够的。庆幸的是smokeping提供了分布式探测网络性能的功能也就是可以从多个节点去探测到某个地区的网络状态,这样才是我们监控网络希望看到的情况。在这里博主不做探讨,感兴趣的博友可以通过访问smokeping的官网进一步学习和研究。本文仅对如何在CentOS5.8下安装smokeping工具提供一些有价值的参考和建议。
具体安装步骤如下所示:
1、安装web服务
yum install httpd
yum install httpd-devel
2、安装fping
# yum install fping
3、安装echoping
# yum install echoping
# yum install curl
4、安装CGI-SpeedyCGI
#wget http://daemoninc.com/SpeedyCGI/CGI-SpeedyCGI-2.22.tar.gz
#tar -zxvf CGI-SpeedyCGI-2.22.tar.gz
#cd CGI-SpeedyCGI-2.22
#perl Makefile.PL
#make
#make test
#make install
5、安装rrdtool
1)rrdtool所依赖的库
#yum -y install libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel
2)安装rrdtool
#wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.26.tar.gz
#tar -zxvf rrdtool-1.2.26.tar.gz
#cd rrdtool-1.2.26
#./configure --prefix=/usr/local/rrdtool
#make
#make install
6、 安装smokeping
#wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
#tar zxvf smokeping-2.4.2.tar.gz
#mv smokeping-2.4.2 /usr/local/smokeping
7、配置smokeping
A)建立两个目录:
#mkdir /usr/local/smokeping/cache
#mkdir /usr/local/smokeping/var
B)修改如下几个配置文件:
(1) 配置文件/usr/local/smokeping/etc/config.dist
imgcache = /usr/local/smokeping/cache
imgurl = ../cache
datadir = /usr/local/smokeping/var
piddir = /usr/local/smokeping/var
cgiurl = http://smokeping.sso.cn/htdocs/smokeping.cgi
smokemail = /usr/local/smokeping/etc/smokemail.dist
tmail = /usr/local/smokeping/etc/tmail.dist
template = /usr/local/smokeping/etc/basepage.html.dist
注释掉如下配置项:
#*** Slaves ***
#secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
#+boomer
#display_name=boomer
#color=0000ff
#+slave2
(2)配置文件 /usr/local/smokeping/htdocs/smokeping.cgi
cp smokeping.cgi.dist smokeping.cgi //生成smokeping.cgi
#!/usr/bin/speedy -w
use lib qw(/usr/local/rrdtool/lib/perl);
use lib qw(/usr/local/smokeping/lib);
Smokeping::cgi("/usr/local/smokeping/etc/config.dist");
(3) 配置文件/usr/local/smokeping/bin/smokeping.dist
#!/usr/bin/perl -w
use lib qw(/usr/local/rrdtool/lib/perl);
use lib qw(/usr/local/smokeping/lib);
Smokeping::main("/usr/local/smokeping/etc/config.dist");
8、启动smokeping
/usr/local/smokeping/bin/smokeping.dist start
9、配置apache/conf/httpd.conf
DocumentRoot /usr/local/smokeping
ServerName smokeping.sso.cn
AddHandler cgi-script .cgi
AllowOverride None
Options ExecCGI Indexes
Order allow,deny
Allow from all
ErrorLog logs/ping-error_log
CustomLog logs/ping-access_log common
10、重启apache服务serv ice httpd restart
11、访问http://192.168.163.126/smokeping/smokeping.fcgi
现在可以使用我们刚刚搭建的smokeping服务实施对我们的网络进行监控了。