smokeping是对IDC网络质量,稳定性等最好的检测工具,包括常规的 ping,dig,echoping,curl等,可以监视www服务器性能,监视dns查询性能,监视ssh性能等。底层也是 rrdtool 做支持,特点是画的图非常漂亮,网络丢包和延迟用颜色和阴影来表示。
smokeping的优点:
最佳的画图功能,延迟和丢包用颜色和阴影表示很直观。
免费和开源,作者是MRTG和RRDtool作者。
支持主从的分布式模式。
可以自定义报警功能。
smokeping安装方法:使用yum安装其他资源包,编译安装smokeping方式。
一、使用apt.sw.be源(安装前的准备)
# yum update # rpm -Uvh http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
使用yum安装,在 /etc/yum.repos.d/下面新建dag.repo文件在文件中输入源地址:
# cat dag.repo [dag] name=Dag RPM Repository for Red Hat Enterprise Linuxbaseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag gpgcheck=1 gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt enabled=1 # yum -y install rrdtool
这样就可以完成RRDTool安装…
二、软件包的安装(安装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
三、配置smokeping
1. 编辑文件:/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");
2. 编辑文件:/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");
3. 编辑文件:/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);
4. 编辑文件:/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>
5. 修改traceroute权限
# chmod 4775 /bin/traceroute
6. 编辑apache配置文件(去掉AddHandler cgi-script .cgi前面的注释)
修改以下内容:
<script src="cropper/lib/prototype.js" type="text/javascript"></script> <pre><script src="cropper/lib/scriptaculous.js?load=builder,dragdrop"></script></pre> <pre><script src="cropper/cropper.js"></script></pre> <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>
7. 编辑文件:/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>
8. 编辑文件:/opt/smokeping/etc/config
*** General *** owner = server1 contact = [email protected] mailhost = linuxde.netsendmail = /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 = [email protected] from = [email protected] +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 timemenu = 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 = linuxde.net remark = Welcome to linuxde.net + hosts menu= Targets ++ linuxde.net menu = linuxde.net title = linuxde.net alerts = someloss host = linuxde.net ++ linuxde.net menu = salogs.cm title = linuxde.net alerts = someloss host = linuxde.net
9. 创建一个启动脚本
# vim /etc/init.d/smokeping
添加为以下内容:
#!/bin/bash # # chkconfig: 2345 80 05 # Description: Smokeping init.d script # Hacked by : How2CentOS - http://www.how2centos.com # Get function from functions library . /etc/init.d/functions # Start the service Smokeping start() {echo -n "Starting Smokeping: " /opt/smokeping/bin/smokeping >/dev/null 2>&1 ### Create the lock file ###touch /var/lock/subsys/smokeping success $"Smokeping startup" echo } # Restart the service Smokeping stop() { echo -n "Stopping Smokeping: "kill -9 `ps ax | grep "/opt/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 } ### main logic ### case "$1" in start) start ;; stop) stop ;; status) status Smokeping ;; restart|reload|condrestart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}"exit 1 esac exit 0# chmod 755 /etc/init.d/smokeping