smokeping是对IDC网络质量,稳定性等最好的检测工具,包括常规的 ping,dig,echoping,curl等,可以 监视 www 服务器性能,监视 dns 查询性能,监视 ssh 性能等。选择smokeping我觉得有以下原因: 1,最佳的画图功能,延迟和丢包用颜色和阴影表示很直观。
2,免费和开源,作者是MRTG和RRDtool作者。
3,支持主从的分布式模式。
4,可以自定义报警功能。 前言: 本文使用YUM安装其他资源包,编译安装smokeping方式。apt.sw.be这个第三方软件仓库,我觉得很不错,更新很快,资源很全。但是这个源很不稳定。 1 使用apt.sw.be源(安装前的准备): #yum update 2 安装smokeping
# 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
# 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.1 /opt/smokeping
# cd /opt/smokeping/bin
# cp smokeping.dist smokeping
# cd ../htdocs/
# cp smokeping.cgi.dist smokeping.cgi
# 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
3 配置smokeping
编辑/opt/smokeping/bin/smokeping
修改一下内容: #!/usr/sepp/bin/perl-5.8.4 -w
# -*-perl-*-
use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl);
use lib qw(lib);
use Smokeping 2.004002;
Smokeping::main("etc/config.dist"); 为 #!/usr/bin/perl -w
# -*-perl-*-
use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs/);(这个和编译安装的路径不同,注意)
use lib qw(/opt/smokeping/lib);
use Smokeping 2.004002;
Smokeping::main("/opt/smokeping/etc/config"); 编辑/opt/smokeping/htdocs/smokeping.cgi 修改以下内容: #!/usr/sepp/bin/speedy -w
# -*-perl-*-
use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl);
use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib);
use CGI::Carp qw(fatalsToBrowser);
use Smokeping 2.004002;
smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config"); 为 #!/usr/bin/speedy -w
# -*-perl-*-
use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs);
use lib qw(/opt/smokeping/lib);
use CGI::Carp qw(fatalsToBrowser);
use Smokeping 2.004002;
Smokeping::cgi("/opt/smokeping/etc/config"); 编辑/opt/smokeping/htdocs/tr.cgi 修改以下内容: #!/usr/sepp/bin/speedy-5.8.8 -w
use strict;
use lib qw(/home/oposs/smokeping/software/lib);
use lib qw(perl); 为 #!/usr/bin/speedy -w
use strict;
use lib qw(/opt/smokeping/lib);
use lib qw(perl); 修改traceroute权限 chmod 4775 /bin/traceroute 编辑apache配置: 去掉AddHandler cgi-script .cgi前面的注释 编辑/opt/smokeping/etc/basepage.html 修改以下内容 <script src="cropper/lib/prototype.js" type="text/javascript"></script>
<script src="cropper/lib/scriptaculous.js?load=builder,dragdrop" type="text/javascript"></script>
<script src="cropper/cropper.js" type="text/javascript"></script>
<script src="cropper/smokeping-zoom.js" type="text/javascript"></script> 为
<script src="/smokeping/cropper/lib/prototype.js" type="text/javascript"></script>
<script src="/smokeping/cropper/lib/scriptaculous.js?load=builder,dragdrop" type="text/javascript"></script>
<script src="/smokeping/cropper/cropper.js" type="text/javascript"></script>
<script src="/smokeping/cropper/smokeping-zoom.js" type="text/javascript"></script> 编辑/opt/smokeping/htdocs/tr.html
修改为:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SmokeTrace</title>
<script src="/script/Tr.js"></script>
</head>
</html> 编辑/opt/smokeping/etc/config
*** General ***
owner = DONGWM
contact = dongwm@dongwm.com
mailhost = dongwm.com
sendmail = /usr/sbin/sendmail
imgcache = /opt/smokeping/htdocs/cache
imgurl = http://192.168.9.100/cache
datadir = /opt/smokeping/data
piddir = /opt/smokeping/var
cgiurl = http://192.168.9.100/smokeping/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 = alertee@address.somewhere
from = autopost@dongwm.com
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row
*** Database ***
step = 300
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
+ 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
*** Probes ***
+ FPing
binary = /usr/sbin/fping
*** Targets ***
menuextra = <a target='_blank' href='/smokeping/tr.html{HOST}' class='{CLASS}' \
onclick="window.open(this.href,this.target, \
'width=800,height=500,toolbar=no,location=no,status=no,scrollbars=no'); \
return false;">(TR)</a>
probe = FPing
menu = Top
title = Dongwm.com
remark = Welcome to dongwm.com
+ hosts
menu= Targets
++ dongwm.com
menu = dongwm.com
title = dongwm.com
alerts = someloss
host = dongwm.com
++ salogs.com
menu = salogs.cm
title = salogs.com
alerts = someloss
host = salogs.com
smokeping 图像支持中文显示: 1,首先安装中文包,用于图像的中文显示 fonts-chinese.noarch 3.02-12.el5 installed
fontconfig.i386 2.4.1-7.el5 installed
fontconfig.x86_64 2.4.1-7.el5 installed
fontconfig-devel.i386 2.4.1-7.el5 installed
fontconfig-devel.x86_64 2.4.1-7.el5 installed
2,locale 设置
LANG=zh_CN.GB18030
LC_CTYPE="zh_CN.GB18030"
LC_NUMERIC="zh_CN.GB18030"
LC_TIME="zh_CN.GB18030"
LC_COLLATE="zh_CN.GB18030"
LC_MONETARY="zh_CN.GB18030"
LC_MESSAGES="zh_CN.GB18030"
LC_PAPER="zh_CN.GB18030"
LC_NAME="zh_CN.GB18030"
LC_ADDRESS="zh_CN.GB18030"
LC_TELEPHONE="zh_CN.GB18030"
LC_MEASUREMENT="zh_CN.GB18030"
LC_IDENTIFICATION="zh_CN.GB18030"
LC_ALL=
3,修改:/opt/smokeping/lib/Smokeping.pm
修改:
$ENV{LC_NUMERIC}='C';
if (POSIX::setlocale(&POSIX::LC_NUMERIC,"") ne "C") {
die("Resetting LC_NUMERIC failed - try removing LC_ALL from the environment");
}
为:
$ENV{LC_ALL}='zh_CN.GB18030';
if (POSIX::setlocale(&POSIX::LC_ALL,"") ne "zh_CN.GB18030") {
die("Resetting LC_NUMERIC failed - try removing LC_ALL from the environment");
}
修改:
my ($graphret,$xs,$ys) = RRDs::graph
($cfg->{General}{imgcache}.$dir."/${prop}_mini.png",
# '--lazy',
'--start','-'.exp2seconds($cfg->{Presentation}{overview}{range}),
'--title',$phys_tree->{title},
'--height',$cfg->{Presentation}{overview}{height},
'--width',$cfg->{Presentation}{overview}{width},
'--vertical-label', $ProbeUnit,
'--imgformat','PNG',
'--alt-autoscale-max',
'--alt-y-grid',
'--rigid',
'--lower-limit','0',
'--font','TITLE:10:/usr/share/fonts/zh_TW/TrueType/bsmi00lp.ttf',
(新增这一行,指定中文字体的路径)
@G,
"COMMENT:$date\\r");
4, 重启 smokeping ,强制刷新页面 # pkill smokeping # /opt/smokeping/bin/smokeping |