ms133 发表于 2019-1-17 11:08:03

CentOS6.2 上搭建smokeping

一    介绍
smokeping是rrdtool的作者Tobi Oetiker的作品,所以它在图形显示方面有很大优势,也是一个很有特点的opensource工具:
多种探测方式,包括fping、echoping、dig、curl等。


二    安装环境


虚拟机版本:    VMware Workstation 8.0.4 build-744019
OS 版本 :    CentOS 6.2 i686
IP 地址:192.168.1.115


三    安装步骤
a.查看系统版本及内核

http://s3.运维网.com/wyfs02/M00/46/38/wKioL1PvVn7S5AxAAAHs45-LQ-Q265.jpg
##################################################
b. 查看selinux是否关闭
http://s3.运维网.com/wyfs02/M02/46/36/wKiom1PvVYSzK6E8AAD1CPwUhKk110.jpg
#################################################

c. 本文使用YUM安装其他资源包,编译安装smokeping方式。apt.sw.be这个第三方软件仓库,更新很快,资源很全。
   下载跟系统适合的对应rpmforge RPM包进行安装,这样安装好rpmforge包后,在/etc/yum.repos.d/目录下会生成.repo文件
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# yum clean
# yum makecache   ############################################

    d.安装rrdtool与依赖库
# yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echopinghttpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pangopango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi screen#######################################################

    e.安装smokeping
# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
# tar zxvf smokeping-2.6.9.tar.gz
# ./configure --prefix=/usr/local/smokeping          *******编译过程中checking checking for perl module 'Config::Grammar'... Failed,这是缺少Config::Grammar这个模块(这个模块的作用是生成smokeping的配置文件,运行下面脚本会自动从网上下载安装需要的模块。否则在smokeping的安装目录下的etc目录下缺少config.dist这个文件。

            *******备注:下面几个模块是安装smokeping缺一不可的

                        FCGI (The module for supporting FastCGI operation.)

                        CGI, CGI::Fast (Perl CGI/FastCGI support. Might already be installed localy.)
                        Config::Grammar (The configuration file parser used in smokeping)
                           LWP (The master/slave functionality introduced a dependency on LWP::UserAgent from the libwww-perl (also known as LWP) library. The module isrequired even if the master/slave mode is not enabled)
# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
# /usr/bin/gmake install
***** smokeping 安装完毕 **********      ##################################################
    f.安装中文语言支持
# yum groupinstall "Chinese Support"      ###################################################

    g.配置smokeping

      1.创建cache . data . var目录   
# cd /usr/local/smokeping/
# mkdir cache data var
# ll
      总用量 36
drwxr-xr-x. 2 root root 4096 8月17 02:13 bin
drwxr-xr-x. 2 root root 4096 8月17 02:19 cache
drwxr-xr-x. 2 root root 4096 8月17 02:19 data
drwxr-xr-x. 3 root root 4096 8月17 02:14 etc
drwxr-xr-x. 3 root root 4096 8月17 02:14 htdocs
drwxr-xr-x. 3 root root 4096 8月17 02:14 lib
drwxr-xr-x. 3 root root 4096 8月17 02:14 share
drwxr-xr-x. 6 root root 4096 8月17 02:11 thirdparty
drwxr-xr-x. 2 root root 4096 8月17 02:19 var      2.创建日志文件          
# touch /var/log/smokeping.log      3.授权      
# chown apache:apache cache data var
# chown apache:apache /var/log/smokeping.log
      4.修改配置文件

            
# touch /var/log/smokeping.log
# chown apache:apache cache data var
# chown apache:apache /var/log/smokeping.log
# cd /usr/local/smokeping/htdocs/
# mv smokeping.fcgi.dist smokeping.fcgi
# cd /usr/local/smokeping/etc/
# mv config.dist config
# vi config

               修改配置文件以下内容
            
*** General ***
cgiurl   = http://some.url/smokeping.cgi将some.url改为你的IP或域名
cgiurl   = http://192.168.1.115/smokeping.cgi这里改为本机器的IP
*** Database ***
step   = 300将300改为60,这个是检测的时间
pings    = 20    这个不用修改
*** Presentation ***
charset = zh_CN.UTF-8在*** Presentation ***这个下面添加这行
*** Probes ***
binary = /usr/sbin/fping根据实际情况该此处fping程序路径(依实际情况而定,不能照搬)
######修改binary参数时要依据实际情况改,不能照搬
####### type fping
######fping is /usr/sbin/fping
######运行上面的命令确定fping这个二进制程序的位置




          5.配置完成之后修改密码文件
# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist      

##########修改apache配置文件 httpd.conf ,让监控数据可以在浏览器上呈现。

修改配置httpd.conf文件
# vi /etc/httpd/conf/httpd.conf在此文件最后位置加入如下访问控制参数
                   #########changed by kl 2014/08/15##############
                  Alias /cache "/usr/local/smokeping/cache/"
                  Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
                  Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
                  
                  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
                  
6.设置登录帐号与密码             
# vi /etc/httpd/conf/httpd.conf
# cd /usr/local/smokeping/htdocs/
# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
   New password:
   Re-type new password:
   Adding password for user admin
7.设置smokeping开机启动             
# echo "/usr/local/smokeping/bin/smokeping -- logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local 8.启动http和smokeping服务         
# service httpd restart
停止 httpd:                                             [失败]
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for localcentos.localdomain
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                             [确定]修改httpd.conf文件

276 #ServerName www.example.com:80-------> 去掉#注释 我更改为我自己的ServerName 192.168.1.115:80

# service httpd restart
# chkconfig --level 25 httpd on
# /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &                

OK,打开页面看看http://192.168.1.115/smokeping 输入用户名和密码 看看

h.将本机纳入监控
# vi /usr/local/smokeping/etc/config
         在此文件*** Targets *** 最末尾加入
         ++ Localhost
            menu = Localhos               
            title = Localhost
            alerts = someloss
            #slaves = boomer slave2
            host = 192.168.1.115
            加入上面targets后,需要重启smokeping进程才能生效,否则会报错的
# ps -ef | grep smokeping
root      1585   10 04:13 ?      00:00:00 /usr/local/smokeping/bin/smokeping         
root      196516220 04:26 pts/0    00:00:00 grep smokeping
# kill -HUP 1585** 每次加入监控点的时候都需要重启smokeping进程,切记。

    四.后记

下面是实际配置好的例子,smokeping配置文件config和httpd.conf在附件中,可以下载查看。

          http://s3.运维网.com/wyfs02/M01/46/36/wKiom1PvVhji_Dq0AARHXjE2rrI794.jpg   

   
  



附件:http://down.运维网.com/data/2364759

页: [1]
查看完整版本: CentOS6.2 上搭建smokeping