设为首页 收藏本站
查看: 3715|回复: 0

[经验分享] 网络检测工具smokeping安装配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-7-30 08:40:38 | 显示全部楼层 |阅读模式
本帖最后由 2341232 于 2014-7-30 08:42 编辑

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/i ... 6-1.el5.rf.i386.rpm
安装成功之后会在yum仓库配置中多一个repo文件:
[iyunv@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
查看安装目录:
[iyunv@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的安装方法,位置会不同)
[iyunv@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
[iyunv@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
# 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/
页面效果如下:

wKiom1PXTXTzZCcmAATc7gtUiLw231.jpg


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-22896-1-1.html 上篇帖子: CentOS中Smokeping+Nginx搭建.详解 下篇帖子: Smokeping 邮件告警问题 检测 网络
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表