1、基础环境 yum安装
yum -y install freetype freetype-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel
libiconv libiconv-devel pango pango-devel qpixman qpixman-devel glib glib-devel cairo cairo-devel libart* gettext gettext-devel libjpeg libjpeg-devel perl-XML-Simple.noarch perl-Crypt-SSLeay perl-Digest-HMAC
yum install httpd
yum install httpd-devel
yum install fping
2、安装支持中文
yum -y install wqy-zenhei-fonts.noarch “图片中文显示”
vim /usr/local/smokeping/lib/Smokeping/Graphs.pm “在smokeping中修改”
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[0][1],
'--end', $tasks[0][2],
后,添加 '--font TITLE:20:"WenQuanYi Zen Hei Mono"',
/usr/local/smokeping/etc/config “smokeping配置文件添加”
*** Presentation ***
charset = utf-8
3、安装smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
tar zxvf smokeping-2.4.2.tar.gz
mv smokeping-2.4.2 /usr/local/smokeping
cd /usr/local/smokeping/
./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/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
根据提示,运行./setup/build-perl-modules.sh /usr/local/thirdparty
可以查看./setup/build-perl-modules.sh脚本内容,发现其实就是在安装smokeping所依赖的一些perl模块
export PERL5LIB=/usr/local/smokeping/thirdparty/lib/perl5/
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install
4、复制 所有带*.dist
cd /usr/local/smokeping/etc
cp smokemail.dist smokemail
cp tmail.dist tmail
cp config.dist config
cd /usr/local/smokeping/htdocs
cp smokeping.fcgi.dist smokeping.fcgi
5、修改httpd.conf 配置文件
DocumentRoot "/var/www/html"
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>
6、修改 /usr/local/smokeping/etc/config
*** :标示的区块属于不同类型的内容
+ :代表一级菜单 +下面的++是继承上面的+成为二级菜单。 而且可以有多个一级菜单和二级菜单。
第一部分General区块,属于基本配置
owner = daemon smokeping运行的用户
contact = [email protected] smokeping管理员联系邮件地址
mailhost = localhost 邮件服务器地址
sendmail = /usr/sbin/sendmail 发送邮件件的二进制可执行程序
imgcache = /usr/local/smokeping/cache smokeping图片缓存
imgurl = cache 定义cgi程序显示图片的url目录
datadir = /usr/local/smokeping/data smokeping保存rrd文件的目录
piddir = /usr/local/smokeping/var 顾名思义,其pid目录
cgiurl = http://some.url/smokeping.cgi 完整的smokeping的url路径
smokemail = /usr/local/smokeping/etc/smokemail.dist 发送邮件的邮件内容模板
tmail = /usr/local/smokeping/etc/tmail.dist HTML邮件模板的路径
syslogfacility = local0 syslog日志记录的设备编号
第二部分Alter区块,属于报警配置
to = [email protected] 报警邮件接收人地址
from = [email protected] 报警邮件发送人地址
+someloss 定义一个名为someloss的报警
type = loss 类型为丢包
pattern = >0%,*12*,>0%,*12*,>0% 对监控内容进行阀值的模式匹配
comment = loss 3 times in a row 检测12次,出现了3次丢包的情况,不论丢多少个包,就进行报警
+70_rttbad
type = rtt
pattern = >70,>70,>70 # in milliseconds
comment = For more than three consecutive 70-millisecond delay.
#comment = rttbad表示连续3个包延迟超过70ms就发送报警
+80_rttbad
type = rtt
pattern = >80,>80,>80 # in milliseconds
comment = For more than three consecutive 80-millisecond delay.
#comment = rttbad表示连续3个包延迟超过80ms就发送报警
第三部分Database区块,属于RRDTOOL数据库的配置
step = 300 步长,也就是多长时间为一个周期
pings = 20 ping的次数,这两项的组合意思是,每300秒进行20此的ping操作
# 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区块,属于网络状态,web显示的一些配置项
这块还没看,暂时先放这
第五部分Probes区块,属于Fping指针的配置
+ FPing
binary = /usr/sbin/fping
第六部分Slave区块,属于Matster,Slave架构的配置
暂时先将其注释起来,并连带上下文中所涉及的项注释下,否则待会启动时会报错
第七部分Targets区块,属于监控目标的配置
probe = FPing 指定监控指针
menu = Top 定义一个菜单,类型为Top,titile 注释等信息,均可自定义
title = Network Latency Grapher
remark = Welcome to the SmokePing website of xxx Company. \
Here you will learn all about the latency of our network.
+ Test
menu= Targets 定义一个一级菜单
#parents = owner:/Test/James location:/
++ James 定义一个主机为James
menu = James 菜单名为James
title =James
alerts = someloss 报警阀值为上文定义的someloss
#slaves = boomer slave2
host = blog.coocla.org 监控的主机blog.coocla.org
7、启动smokeping httpd
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist
chown apache:apache ../smokeping -R “允许apache读取信息”
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 “启动smokeping”
/usr/local/smokeping/bin/smokeping --reload “重新加载配置文件”
8、首页的集中显示和报警的分别设置
以下实例 70_rttbad表示延迟23ms 80_rttbad表示延迟20ms
++ Dianxin
menu =电信网络
title = 电信网络
host = /moniter/Dianxin/dx1 /moniter/Dianxin/dx2
+++ dx1
menu = 电信网络 140.205.203.152
title = 电信网络 140.205.203.152
alerts = someloss,70_rttbad
host = 140.205.203.152
+++ dx2
menu = 电信网络 140.205.195.2
title = 电信网络 140.205.195.2
alerts = someloss,80_rttbad
host = 1140.205.195.2