一 介绍
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.查看系统版本及内核
##################################################
b. 查看selinux是否关闭
#################################################
c. 本文使用YUM安装其他资源包,编译安装smokeping方式。apt.sw.be这个第三方软件仓库,更新很快,资源很全。
下载跟系统适合的对应rpmforge RPM包进行安装,这样安装好rpmforge包后,在/etc/yum.repos.d/目录下会生成.repo文件
[root@localcentos upload]# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm [root@localcentos upload]# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.i686.rpm [root@localcentos upload]# yum clean [root@localcentos upload]# yum makecache
############################################
d.安装rrdtool与依赖库
[root@localcentos yum.repos.d]# 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 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 screen
#######################################################
e.安装smokeping
[root@localcentos upload]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz [root@localcentos upload]# tar zxvf smokeping-2.6.9.tar.gz [root@localcentos smokeping-2.6.9]# ./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 is required even if the master/slave mode is not enabled)
[root@localcentos smokeping-2.6.9]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty [root@localcentos smokeping-2.6.9]# /usr/bin/gmake install ***** smokeping 安装完毕 **********
##################################################
f.安装中文语言支持
[root@localcentos smokeping-2.6.9]# yum groupinstall "Chinese Support"
###################################################
g.配置smokeping
1.创建cache . data . var目录
[root@localcentos smokeping-2.6.9]# cd /usr/local/smokeping/ [root@localcentos smokeping]# mkdir cache data var [root@localcentos smokeping]# 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.创建日志文件
[root@localcentos smokeping]# touch /var/log/smokeping.log
3.授权
[root@localcentos smokeping]# chown apache:apache cache data var [root@localcentos smokeping]# chown apache:apache /var/log/smokeping.log
4.修改配置文件
[root@localcentos smokeping]# touch /var/log/smokeping.log [root@localcentos smokeping]# chown apache:apache cache data var [root@localcentos smokeping]# chown apache:apache /var/log/smokeping.log [root@localcentos smokeping]# cd /usr/local/smokeping/htdocs/ [root@localcentos htdocs]# mv smokeping.fcgi.dist smokeping.fcgi [root@localcentos htdocs]# cd /usr/local/smokeping/etc/ [root@localcentos etc]# mv config.dist config [root@localcentos etc]# 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参数时要依据实际情况改,不能照搬 ######[root@localcentos etc]# type fping ######fping is /usr/sbin/fping ######运行上面的命令确定fping这个二进制程序的位置
5.配置完成之后修改密码文件
[root@localcentos etc]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
##########修改apache配置文件 httpd.conf ,让监控数据可以在浏览器上呈现。
修改配置httpd.conf文件
[root@localcentos etc]# 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.设置登录帐号与密码
[root@localcentos etc]# vi /etc/httpd/conf/httpd.conf [root@localcentos etc]# cd /usr/local/smokeping/htdocs/ [root@localcentos htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin New password: Re-type new password: Adding password for user admin
7.设置smokeping开机启动
[root@localcentos htdocs]# echo "/usr/local/smokeping/bin/smokeping -- logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
8.启动http和smokeping服务
[root@localcentos htdocs]# 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
[root@localcentos htdocs]# service httpd restart [root@localcentos htdocs]# chkconfig --level 25 httpd on [root@localcentos htdocs]# /usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &
OK,打开页面看看http://192.168.1.115/smokeping 输入用户名和密码 看看
h.将本机纳入监控 [root@localcentos ~]# vi /usr/local/smokeping/etc/config 在此文件*** Targets *** 最末尾加入 ++ Localhost menu = Localhos title = Localhost alerts = someloss #slaves = boomer slave2 host = 192.168.1.115 加入上面targets后,需要重启smokeping进程才能生效,否则会报错的 [root@localcentos ~]# ps -ef | grep smokeping root 1585 1 0 04:13 ? 00:00:00 /usr/local/smokeping/bin/smokeping [FPing] root 1965 1622 0 04:26 pts/0 00:00:00 grep smokeping [root@localcentos ~]# kill -HUP 1585
** 每次加入监控点的时候都需要重启smokeping进程,切记。
四.后记
下面是实际配置好的例子,smokeping配置文件config和httpd.conf在附件中,可以下载查看。