最新文章:

首页 运维技术

smokeping网络监控环境部署记录

发布时间:2018年08月30日 评论数:抢沙发 阅读数:3633

    smokeping是一款监控网络状态和稳定性的开源软件(它是rrdtool的作者开发的),通过它可以监控到公司IDC的网络状况,如延时,丢包率,是否BGP多线等;smokeping会向目标设备和系统发送各种类型的测试数据包,测量、记录,并通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况;通过smokeping来监控IDC机房网络质量情况,可以从监控图上的延时与丢包情况分辨出机房的网络是否
    稳定,是否为多线,是否为BGP机房以及到各城市的三个运行商网络各是什么情况。如果出现问题,可以有针对性的去处理;如果选择新机房的时候,还可以根据smokeping的监控结果来判断这个机房是否适合。
    需要注意的是:smokeping监控的是网络稳定性,而cacti或zabbix监控的是带宽使用情况(即进出口流量)

    下面就smokeping网络监控环境部署过程做一记录:

    1)安装相关源

    下载地址:https://pan.baidu.com/s/1pKBtm11
    提取密码:erte
    [root@localhost ~]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

    2)安装rrdtool与依赖库
    [root@localhost ~]# yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi

    下载fping并编译安装
    [root@localhost ~]# cd /usr/local/src/
    [root@localhost src]# wget http://fping.org/dist/fping-3.10.tar.gz
    [root@localhost src]# tar -zvxf fping-3.10.tar.gz 
    [root@localhost src]# cd fping-3.10
    [root@localhost fping-3.10]# ./configure && make && make install

    下载echoping并编译安装
    http://pan.baidu.com/s/1hrJiLBA

    [root@localhost ~]# cd /usr/local/src/
    [root@localhost src]# tar -zvxf echoping-5.2.0.tar.gz 
    [root@localhost src]# yum install -y popt libidn popt-devel libidn-devel          //安装echoping依赖的包
    [root@localhost src]# cd echoping-5.2.0
    [root@localhost echoping-5.2.0]# ./configure && make && make install

    3)下载与安装smokeping

    [root@localhost ~]# cd /usr/local/src/
    [root@localhost src]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
    [root@localhost src]# tar -zvxf smokeping-2.6.8.tar.gz 
    [root@localhost src]# cd smokeping-2.6.8
    [root@localhost smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping

    出现下面报错信息:

    ** Aborting Configure ******************************

    If you know where perl can find the missing modules, set
    the PERL5LIB environment variable accordingly.
    FIRST though, make sure that 'perl' starts the perl
    binary you want to use for SmokePing.

    Now you can install local copies of the missing modules
    by running

    ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
    The RRDs perl module is part of RRDtool. Either use the rrdtool
    package provided by your OS or install rrdtool from source.
    If you install from source, the RRDs module is located
    PREFIX/lib/perl

    出现问题是因为需要安装perl的模块,所以运行下面内容即可:

    [root@localhost smokeping-2.6.8]# ./setup/build-perl-modules.sh 

    /usr/local/smokeping/thirdparty
    [root@localhost smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping
    [root@localhost smokeping-2.6.8]# /usr/bin/gmake install

    4)配置smokeping
    创建cache、data、var目录
    [root@localhost yum.repos.d]# cd /usr/local/smokeping
    [root@localhost smokeping]# mkdir cache data var

    创建日志
    [root@localhost smokeping]# touch /var/log/smokeping.log

    授权
    [root@localhost smokeping]# chown apache:apache cache data var
    [root@localhost smokeping]# chown apache:apache /var/log/smokeping.log

    修改配置文件
    [root@localhost smokeping]# cd /usr/local/smokeping/htdocs/
    [root@localhost htdocs]# mv smokeping.fcgi.dist smokeping.fcgi
    [root@localhost htdocs]# cd /usr/local/smokeping/etc
    [root@localhost etc]# mv config.dist config
    [root@localhost etc]# cp config config.bak
    [root@localhost etc]# vim config
     1.png
    默认是cgiurl = http://some.url/smokeping.cgi,把some.url修改为你的ip或者域名
    step = 60           //60秒       
    pings = 30    //ping30次
    配置完成之后修改密码文件权限
    [root@localhost etc]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
    修改apache的配置
    vim /etc/httpd/conf/httpd.conf                //添加下面内容
     2.png
    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
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
    AuthName "Smokeping"
    AuthType Basic
    AuthUserFile /usr/local/smokeping/htdocs/htpasswd
    Require valid-user
    DirectoryIndex smokeping.fcgi
    </Directory>
    图像浏览界面的中文支持
    [root@localhost etc]# yum -y install wqy-zenhei-fonts.noarch
    编辑smokeping的配置文件
    [root@localhost etc]# vim /usr/local/smokeping/etc/config
    charset = utf-8              
    编辑Graphs.pm
    [root@localhost etc]# vim /usr/local/smokeping/lib/Smokeping/Graphs.pm
    '--font TITLE:20:"WenQuanYi Zen Hei Mono"',                  //第147行下面插入边一行内容
      3.png
    接着进行测试数据的自定义(可以将smokeping部署在公司网络下,然后自定义监控各个IDC的网络情况,监控设置如下定义)
    要添加站点或主机ip地址的话,只能再smokeping的配置文件中添加,无法通过smokeping的web界面添加,在添加完站点后重启smokeping,会在在/usr/local/smokeping/data 之下添加moniter文件夹,其下包含website子文件夹
    注意添加监控节点方式为:+是第一层,++是第二层,+++ 是第三层
    [root@localhost etc]# vim /usr/local/smokeping/etc/config          //在最后面添加
    + Other 

    menu = 全国网络监控 

    title = 全国网络监控统计 

    ++ dianxin 

    menu = 电信网络监控 

    title = 电信网络监控列表 

    host = /Other/dianxin/dianxin-cd /Other/dianxin/dianxin-js

    alerts = hostdown,bigloss,lossdetect,someloss,rttdetect


    +++ dianxin-cd

    menu = 成都电信

    title = 成都电信-222.210.111.210

    alerts = bigloss,hostdown,rttdetect

    host = 222.210.111.210


    +++ dianxin-js

    menu = 江苏电信

    title = 江苏电信-222.191.242.254

    alerts = bigloss,hostdown,rttdetect

    host = 222.191.242.254

    ++ liantong 

    menu = 联通网络监控 

    title = 联通网络监控列表 

    host = /Other/liantong/liantong-sz /Other/liantong/liantong-bj


    +++ liantong-sz 

    menu = 深圳联通 

    title = 深圳联通-210.21.196.6

    alerts = bigloss,hostdown,rttdetect 

    host = 210.21.196.6s 


    +++ liantong-bj

    menu = 北京联通 

    title = 北京联通-222.131.121.101

    alerts = bigloss,hostdown,rttdetect 

    host = 222.131.121.101


    ++ yidong 

    menu = 移动网络监控 

    title = 移动网络监控列表 

    host = /Other/yidong/yidong-sz /Other/yidong/yidong-sc 


    +++ yidong-sz

    menu = 深圳移动

    title = 深圳移动-183.240.194.33

    alerts = bigloss,hostdown,rttdetect

    host = 183.240.194.33

    +++ yidong-sc

    menu = 四川移动

    title = 四川移动-211.137.96.205

    alerts = bigloss,hostdown,rttdetect

    host = 211.137.96.205

    修改smokeping的config配置文件中fping路径
    [root@localhost etc]# which fping
    /usr/local/sbin/fping
    [root@localhost etc]# vim config
    ......
    binary = /usr/local/sbin/fping                 //默认配置的是/usr/sbin/fping
    启动http
    [roo@tlocalhost etc]# /etc/init.d/httpd start   
    启动smokeping
    [root@localhost etc]# /usr/local/smokeping/bin/smokeping
    设置smokeping开机启动
    [root@localhost etc]# echo "/usr/local/smokeping/bin/smokeping" >> /etc/rc.local
    设置smokeping环境变量
     
    设置访问的用户名和密码(比如admin/admin)
    [root@localhost etc]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
    New password: 
    Re-type new password: 
    Adding password for user admin
    重启apache
    [root@localhost etc]# /etc/init.d/httpd restart
    Stopping httpd: [ OK ]
    Starting httpd: [ OK ]
    再次访问smokeping界面

     5.png

    6.png

    创建smokeping的启动脚本,让smokeping可以启动、停止、重启、开机自启动等
    #!/bin/bash
    #
    # chkconfig: 2345 80 05
    # Description: Smokeping init.d script
    # Write by : goser
    # Get function from functions library
    . /etc/init.d/functions
    # Start the service Smokeping
    function start() {
    echo -n "Starting Smokeping: "
    /usr/local/smokeping/bin/smokeping >/dev/null 2>&1
    ### Create the lock file ###
    touch /var/lock/subsys/smokeping
    success $"Smokeping startup"
    echo
    }
    # Restart the service Smokeping
    function stop() {
    echo -n "Stopping Smokeping: "
    kill -9 `ps ax |grep "/usr/local/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
    }
    #Show status about Smokeping
    function status() {
    NUM="`ps -ef|grep smokeping|grep -v grep|wc -l`"
    if [ "$NUM" == "0" ];then
        echo "Smokeping is not run"
    else
        echo "Smokeping is running"
    fi
    }
    ### main logic ###
    case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    restart|reload)
        stop
        start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
        ;;
    esac
    exit 0

    启动httpd、smokeping服务并设置其开机自启动

    [root@localhost ~]# chmod 755 /etc/init.d/smokeping   #添加脚本755权限
    [root@localhost ~]# chkconfig --add smokeping    #将smokeping加入开机启动
    [root@localhost ~]# chkconfig smokeping on   #设置smokeping为开机启动
    [root@localhost ~]# chkconfig httpd on    #设置apache为开机启动
    [root@localhost ~]# /etc/init.d/httpd start    #启动apache服务
    [root@localhost ~]# /etc/init.d/smokeping start   #启动smokeping服务
二维码加载中...
本文作者:Mr.linus      文章标题: smokeping网络监控环境部署记录
本文地址:http://www.90qj.com/492.html  本文已经被百度收录,点击查看详情
版权声明:若无注明,本文皆为“挨踢 Blog”原创,转载请保留文章出处。
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论