码迷,mamicode.com
首页 > 其他好文 > 详细

网络检测工具smokeping安装配置

时间:2014-07-29 18:23:43      阅读:346      评论:0      收藏:0      [点我收藏+]

标签:smokeping安装   smokeping配置   网络检测工具   

smokeping是MRTG和RRDtool作者Tobi Oetiker的作品,主要用于对IDC网络质量,稳定性等做检测,主要功能包括常规的ping,dig,echoping,curl等,依赖rrdtool来画图。选择smokeping我觉得有以下原因:

1,最佳的画图功能,延迟和丢包用颜色和阴影表示很直观。

2,免费和开源。

3,支持主从的分布式模式。

4,可以自定义报警功能。

smokeping官方网站:http://oss.oetiker.ch/smokeping/

如下安装配置的系统为:redhat 5.8 + Perl 5.8.8

smokeping官方对perl版本要求:Perl 5.8.8 or later

一,安装

官方下载地址:http://oss.oetiker.ch/smokeping/pub/

1,安装yum源,这个rpmforge源中有smokeping所需的依赖包:

# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

安装成功之后会在yum仓库配置中多一个repo文件:

[root@yd_82_215 soft]# ls /etc/yum.repos.d/
5AS.repo  5ASU5.repo  mirrors-rpmforge  redhat.repo  rhel-debuginfo.repo  rpmforge.repo


2,安装依赖包:

# yum install httpd

# yum install rrdtool

# yum install fping

# yum install echoping

# yum install curl

# yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI

3,安装最新版smokeping:

# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz

# tar xf smokeping-2.6.9.tar.gz 

# cd smokeping-2.6.9/

# ./configure --prefix=/opt/smokeping

注意:

1,configure之后,如果依赖的perl module没有安装好,会提示用脚本进行安装。根据提示,直接运行脚本即可。如果脚本运行之后,仍然有问题,参考第2条

2,如果configure时候,出现如下报错,则是FCGI模块没有安装:

checking checking for perl module ‘FCGI‘... Failed
checking checking for perl module ‘CGI‘... Ok
checking checking for perl module ‘CGI::Fast‘... Failed

安装FCGI模块:

# perl -MCPAN -e ‘install FCGI‘

如果提示未安装cpan,则用yum进行安装

# yum install cpan

然后在安装:

# ./configure --prefix=/opt/smokeping

# make install

查看安装目录:

[root@yd_82_215 smokeping]# ls
bin  etc  htdocs  lib  share  thirdparty

4,在smokeping目录中有很多以dist结尾的配置文件,需要把dist结尾的文件重命名,配置才能生效:

# cd htdocs

# cp smokeping.fcgi.dist smokeping.fcgi

# cp tr.cgi.dist tr.cgi

# cd ../etc/

# cp config.dist config

# cp basepage.html.dist basepage.html

# cp smokemail.dist smokemail

# cp tmail.dist tmail

# cp smokeping_secrets.dist smokeping_secrets

# chmod 600 /opt/smokeping/etc/smokeping_secrets

二,修改smokeping和apache配置文件

1,修改二进制命令权限:

# chmod 4775 /bin/traceroute

2,建立下面三个目录用于保存smokeping的数据等

# mkdir /opt/smokeping/data

# mkdir /opt/smokeping/var

# mkdir /opt/smokeping/htdocs/cache

# mkdir -p /opt/smokeping/htdocs/img

# chown -R apache:apache /opt/smokeping

3,指定rrdtool的perl模块库文件路径

先找到系统上库文件位置:(不同系统或者不同的perl-rrdtool的安装方法,位置会不同)

[root@yd_82_215 ~]# rpm -qa|grep rrdtool
perl-rrdtool-1.4.7-1.el5.rf
rrdtool-1.2.27-4.el5
rrdtool-1.4.7-1.el5.rf

[root@yd_82_215 ~]# rpm -ql perl-rrdtool-1.4.7-1.el5.rf
/usr/lib/perl5/vendor_perl/5.8.8/RRDp.pm
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/RRDs.pm
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs/RRDs.bs
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs/RRDs.so
/usr/share/doc/perl-rrdtool-1.4.7
/usr/share/doc/perl-rrdtool-1.4.7/MANIFEST
/usr/share/doc/perl-rrdtool-1.4.7/README
/usr/share/man/man3/RRDp.3pm.gz
/usr/share/man/man3/RRDs.3pm.gz

# vim /opt/smokeping/bin/smokeping_cgi

把如下行:

#use lib qw(); # PERL5LIB

修改为:
use lib qw(/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs); # PERL5LIB

4,修改apache配置文件

# vim /etc/httpd/conf/httpd.conf 

添加下面虚拟主机: 

<VirtualHost *:80>
    ServerAdmin root@localhost
    ServerName 10.13.82.215
    DocumentRoot /opt/smokeping/htdocs
    ErrorLog logs/174-error_log
    CustomLog logs/174-access_log common
    <Directory "/opt/smokeping/htdocs">
      Options FollowSymLinks ExecCGI
      AllowOverride None
      DirectoryIndex index.html smokeping.fcgi
      AddHandler cgi-script fcgi .cgi
      Order allow,deny
      Allow from all
      </Directory>
</VirtualHost>

重启apache:

# /etc/init.d/httpd restart

5,修改smokeping配置文件

# vim config
*** General ***

owner    = shengjiali
contact  = shengjiali@com
mailhost = mail.com
sendmail = /usr/lib/sendmail

# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /opt/smokeping/htdocs/img
imgurl   = http://10.13.82.215/img
datadir  = /opt/smokeping/data
piddir  = /opt/smokeping/var
cgiurl   = http://10.13.82.215/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail
tmail = /opt/smokeping/etc/tmail
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no

*** Alerts ***
to = shengjiali@com 
from = shengjiali@com

+someloss
type = loss
# in percent
#pattern = >0%,*12*,>0%,*12*,>0%
pattern = >0%,*10*,>0%,*10*,>0%

comment = loss 3 times  in a row

+manyloss

type = loss

pattern = >15%,*30*,>15%,*30*,>15%

comment = loss 5 packages in 30 continuous 3 times.

+rttbad
type = rtt
pattern = ==S,>50,>50 # in milliseconds
comment = For more than two consecutive 50-millisecond delay

*** Database ***

step     = 60
pings    = 20

# consfn mrhb steps total

AVERAGE  0.5   1  1008
AVERAGE  0.5  12  4320
    MIN  0.5  12  4320
    MAX  0.5  12  4320
AVERAGE  0.5 144   720
    MAX  0.5 144   720
    MIN  0.5 144   720

*** Presentation ***

template = /opt/smokeping/etc/basepage.html
charset=UTF-8

+ charts

menu = Charts
title = The most interesting destinations

++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f

++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds

++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f

++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds

+ overview 

width = 600
height = 50
range = 10h

+ detail

width = 600
height = 200
unison_tolerance = 2

"Last 3 Hours"    3h
"Last 30 Hours"   30h
"Last 10 Days"    10d
"Last 400 Days"   400d


#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location

#如下所示,定义多个FPing,然后在最下面node定义的时候(如下配置中的红色字体),使用不同的probe,就实现了探测的多进程,多与机器多的检测,提升了效率。
*** Probes ***

+ FPing

binary = /usr/sbin/fping
blazemode = true

++ FPing

++ FPing1
pings = 20
step = 60

++ FPing2
pings = 20
step = 60

++ FPing3
pings = 20
step = 60

++ FPing4
pings = 20
step = 60

++ FPing5
pings = 20
step = 60

++ FPing6
pings = 20
step = 60

++ FPing7
pings = 20
step = 60

++ FPing8
pings = 20
step = 60

++ FPing9
pings = 20
step = 60

++ FPing10
pings = 20
step = 60

*** Slaves ***
secrets=/opt/smokeping/etc/smokeping_secrets
+boomer
display_name=boomer
color=0000ff

+slave2
display_name=another
color=00ff00

*** Targets ***

probe = FPing

menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of SoHu Company. \
         Here you will learn all about the latency of our network.

+ net_yd_eth1
menu = 移动机房外网
title = yd-->外网

++ baidu_node
probe = FPing1
menu = 百度_node
#alerts = someloss
title = yd--->61.135.169.125(百度)
host = 61.135.169.125

++ sohu_node
probe = FPing2
menu = 搜狐_node
#alerts = someloss
title = yd--->123.125.116.12(搜狐)
host = 123.125.116.12

++ zong_yd_eth1
menu = 移动机房外网_汇总 
title = yd--->移动机房外网_汇总
host = /net_yd_eth1/baidu_node /net_yd_eth1/sohu_node

注意:

1),配置文件如果有中文的话,不仅如上配置文件中要设置charset=UTF-8,系统也要设置中文字符集在/etc/profile中加入export LANG=zh_CN.UTF-8,并且所有的xshell或者crt中断也要设置成utf-8格式,这样就不会影响中文在配置文件中的编辑和中文在访问页面的展示。

2),配置的详细信息可以参考官方网站:http://oss.oetiker.ch/smokeping/doc/smokeping_config.en.html

6,重启脚本定制

# vim /etc/init.d/smokeping

添加如下内容:

#!/bin/bash
#
# chkconfig: 2345 80 05
# Description: Smokeping init.d script
# Hacked by : How2CentOS - http://www.how2centos.com
# Get function from functions library
. /etc/init.d/functions
# Start the service Smokeping
start() {
        echo -n "Starting Smokeping: "
        /opt/smokeping/bin/smokeping >/dev/null 2>&1
        ### Create the lock file ###
        touch /var/lock/subsys/smokeping
        success $"Smokeping startup"
        echo
}
# Restart the service Smokeping
stop() {
        echo -n "Stopping Smokeping: "
        kill -9 `ps ax | grep "/opt/smokeping/bin/smokeping" | grep -v grep | awk ‘{ print $1 }‘` >/dev/null 2>&1
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/smokeping
        success $"Smokeping shutdown"
        echo
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status smokeping
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac
exit 0

增加执行权限

# chmod +x /etc/init.d/smokeping

7,smokeping服务启动

正常启动:

# /etc/init.d/smokeping start

# /opt/smokeping/bin/smokeping

调试故障时,使用debug模式启动:

/opt/smokeping/bin/smokeping --config=/opt/smokeping/etc/config --debug

三,访问页面

http://10.13.82.215/

页面效果如下:


bubuko.com,布布扣

bubuko.com,布布扣


本文出自 “” 博客,请务必保留此出处http://leejia.blog.51cto.com/4356849/1532245

网络检测工具smokeping安装配置,布布扣,bubuko.com

网络检测工具smokeping安装配置

标签:smokeping安装   smokeping配置   网络检测工具   

原文地址:http://leejia.blog.51cto.com/4356849/1532245

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!