网络监控:Smokeping
最近工作中需要监测某个分公司到IDC机房的网络情况,到网络上找了不少软件,发现一款叫smokeping的开源软件还不错,它是rrdtool的作者制作的,在图形显示方面很漂亮,可以用来很好的检测网络状态和稳定性。
下面介绍一下软件的安装配置方法:
一.安装软件
1.使用yum 命令安装所需的工具
yum install gcc freetype-devel zlib-devel libpng-devel libart_lgpl-devel httpd-devel apr-util-devel apr-devel cairo cairo-devel pango pango-devel libxml2 libxml2-devel perl-XML-Simple.noarch perl-Crypt-SSLeay perl-Digest-HMAC
2. 安装rrdtool
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.6.tar.gz tar zxvf rrdtool-1.3.6.tar.gz cd rrdtool-1.3.6 ./configure --disable-tcl make make install
3. 安装cgilib
wget http://down1.chinaunix.net/distfiles/cgilib-0.5.tar.gz tar zxvf cgilib-0.5.tar.gz cd cgilib-0.5 make cp libcgi.a /usr/local/lib cp cgi.h /usr/include
4. 安装fping
wget http://fping.sourceforge.net/download/fping.tar.gz tar zxvf fping.tar.gz cd fping-2.4b2_to ./configure make make check make install
5.安装 echoping
wget http://jaist.dl.sourceforge.net/project/echoping/echoping/6.0.0/echoping-6.0.0.tar.gz tar zxvf echoping-6.0.0.tar.gz cd echoping-6.0.0 ./configure make make test make install
6.安装 CGI-SpeedyCGI
wget ftp://195.220.108.108/linux/epel/5/x86_64/mod_speedycgi-2.22-4.el5.x86_64.rpm wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/5/x86_64/perl-CGI-SpeedyCGI-2.22-4.el5.x86_64.rpm rpm -ivh --force perl-CGI-SpeedyCGI-2.22-4.el5.x86_64.rpm rpm -ivh mod_speedycgi-2.22-4.el5.x86_64.rpm wget http://mirrors.163.com/cpan/authors/id/H/HO/HORROCKS/CGI-SpeedyCGI-2.22.tar.gz tar zxvf CGI-SpeedyCGI-2.22.tar.gz cd CGI-SpeedyCGI-2.22 perl Makefile.PL 遇到问题选择默认选项(no) make make test make install
7.安装smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.3.6.tar.gz tar zxvf smokeping-2.3.6.tar.gz mv smokeping-2.3.6 /usr/local/smokeping cd /usr/local/smokeping
二.配置smokeping
1. 修改文件名
修改/usr/local/smokeping/bin下的smokeping.dist cp smokeping.dist smokeping 修改etc/ 下的 basepage.html.dist,config.dist,smokemail.dist cp basepage.html.dist basepage.html cp config.dist config cp smokemail.dist smokemail chmod 600 smokeping_secrets.dist 修改htdoc/下的smokeping.cgi.dist cp smokeping.cgi.dist smokeping.cgi
2. 修改配置文件
配置 bin/smokeping
vi /usr/local/smokeping/bin/smokeping
在这个文件里面我们需要修改前面两个 lib 和后面 config 文件的 path。
两个 lib 分别是 smokeping 的 lib 和 rrdtool 的 lib (红色为修改后的内容)
#!/usr/sepp/bin/perl-5.8.4 -w #!/usr/bin/perl -w use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl); use lib qw(/usr/local/rrdtool-1.3.6/lib/perl); use lib qw(lib); use lib qw(/usr/local/smokeping/lib); use Smokeping 2.003006; Smokeping::main("etc/config.dist"); Smokeping::main("/usr/local/smokeping/etc/config");
配置 htdocs/smokeping.cgi,方法与上面相同
vi /usr/local/smokeping/htdocs/smokeping.cgi ************************ #!/usr/sepp/bin/speedy -w #-*-perl-*- #!/usr/bin/speedy -w # -*-perl-*- # use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl); use lib qw(/usr/local/rrdtool-1.3.6/lib/perl/); # use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib); use lib qw(usr/local/smokeping//lib); use Smokeping 2.003006; Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config"); Smokeping::cgi("/usr/local/smokeping/etc/config");
配置 etc/config
vi usr/local/smokeping/etc/config 将以下几行替换为已经安装的相关软件的路径 *** General *** imgcache = /home/oetiker/public_html/smokeping-ms/cache imgcache = /usr/local/smokeping/htdocs/cache imgurl = cache imgurl = cache datadir = /tmp/smokeping-ms/data datadir = /usr/local/smokeping/var piddir = /tmp/smokeping-ms/var piddir = /usr/local/smokeping/var cgiurl = http://some.url/smokeping.cgi cgiurl = http://本机IP/htdocs/smokeping.cgi ; smokemail = /home/oetiker/checkouts/smokeping/trunk/software/etc/smokemail.dist smokemail = /usr/local/smokeping/etc/smokemail tmail = /home/oetiker/checkouts/smokeping/trunk/software/etc/tmail.dist tmail = /usr/local/smokeping/etc/tmail.dist *** Presentation *** template= /home/oetiker/checkouts/smokeping/trunk/software/etc/basepage.html.dist template = /usr/local/smokeping-2.3.6/etc/basepage.html *** Probes *** + FPing binary = /usr/sbin/fping binary = /usr/local/sbin/fping #** Database *** step = 60 pings = 10
修改ping的频率,默认为300秒ping20 次,我们可以根据需要调整,这里修改为60秒 ping 10次。
*** 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 #=================================
3. 添加目录
建立下面三个目录用于保存smokeping的数据等
mkdir /usr/local/smokeping/data mkdir /usr/local/smokeping/var mkdir /usr/local/smokeping/htdocs/cache chown –R apache:apache /usr/local/smokeping
4. 修改apache配置文件
vi /etc/httpd/conf/httpd.conf 添加下面内容: Alias /smokeping/ "/usr/local/smokeping/htdocs/" Alias /cache/ "/usr/local/smokeping/cache/" <Directory "/usr/local/smokeping/htdocs"> Options FollowSymLinks ExecCGI AllowOverride None AddHandler cgi-script cgi Order allow,deny Allow from all </Directory>
三.启动
1.重启apache
service httpd restart
2.重启smokeping
/usr/local/smokeping/bin/smokeping restart
完成。
效果图:
作者:罗阿红
出处:http://www.cnblogs.com/luoahong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。