因工作需要,安装了个smokeping系统!
最近,有个客户老是担心自己的专线质量有问题,特别是访问外省网的问题。我回复说“大哥,现在国内的网络ISP,一般只保证本地接入没问题就可以了。谁都保证不了大网的问题”。但没办法,人家是客户,怎么也得做点功夫。于是,我决定搭个smokeping系统,然后设定几个外省测试点,生成质量给他看。
刚刚创建了一个技术交流群:
smokeping 学习QQ群 交流QQ群 研究QQ群:154040577
jffnms 学习QQ群 交流QQ群 研究QQ群:154040577
cacti 学习QQ群 交流QQ群 研究QQ群:154040577
欢迎加入!
安装环境:centos 5.4
安装步骤:
1、centos安装,省略,我默认大家都会了。呵呵
2、yum update
更新一下系统软件
3、更新一下安装源
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
4、安装httpd
yum install httpd
5、安装探针
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
5、下载安装smokeping
wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
//下载smokeping软件,我是保存到/root目录下的
tar zxvf smokeping-2.4.2.tar.gz
//解压软件包
mv smokeping-2.4.2 /opt/smokeping
//把软件包移动到/opt目录下,本软件不需要安装,直接解压即可使用
cd /opt/smokeping
cd 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
//修改权限
6、修改配置文件:
1)vim /opt/smokeping/bin/smokeping
Replace this:
!/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.004000;
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.004000;
Smokeping::main("/opt/smokeping/etc/config");
2) vim /opt/smokeping/htdocs/smokeping.cgi
Replace this:
!/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.004000;
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.004000;
Smokeping::cgi("/opt/smokeping/etc/config");
3)vim /opt/smokeping/htdocs/tr.cgi
Change this:
!/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);
7、创建HTTP访问的目录与文件
mkdir -p /var/www/html/smokeping/img /var/www/html/smokeping/script/ /opt/smokeping/data /opt/smokeping/var
chown -R apache:apache /var/www/html/smokeping/img
ln -s /opt/smokeping/htdocs/cropper /var/www/html/smokeping/cropper
ln -s /opt/smokeping/htdocs/resource /var/www/html/smokeping/resource
ln -s /opt/smokeping/htdocs/script/Tr.js /var/www/html/smokeping/script/Tr.js
ln -s /opt/smokeping/htdocs/smokeping.cgi /var/www/html/smokeping/smokeping.cgi
ln -s /opt/smokeping/htdocs/tr.cgi /var/www/html/smokeping/tr.cgi
8、修改traceroute权限
chmod 4775 /bin/traceroute
9、修改http配置文件
vim /etc/httpd/conf/httpd.conf
change > AddHandler cgi-script .cgi
to > AddHandler cgi-script .cgi
Under <Directory “/var/www/html”>
change> Options Indexes FollowSymLinks
to > Options Indexes FollowSymLinks ExecCGI
10、修改basepage.html配置文件
vim /opt/smokeping/etc/basepage.html
Change this:
<script src=\'#\'" /lib/prototype.js" type="text/javascript"></script>
<script src=\'#\'" /lib/scriptaculous.js?load=builder,dragdrop" type="text/javascript"></script>
<script src=\'#\'" /cropper.js" type="text/javascript"></script>
<script src=\'#\'" /smokeping-zoom.js" type="text/javascript"></script>
To this:
<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>
11、修改tr.html配置
vim /opt/smokeping/htdocs/tr.html
Change this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SmokeTrace</title>
<script type="text/javascript" src=\'#\'" /Tr.js"></script>
</head>
</html>
To this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SmokeTrace</title>
<script type="text/javascript" src=\'#\'" /script/Tr.js"></script>
</head>
</html>
12、软连接
ln -s /opt/smokeping/htdocs/tr.html /var/www/html/smokeping/tr.html
13、修改配置文件,我的配置文件如下:
*** General ***
owner = Kang
contact = [email protected]
mailhost = smtp.qq.com
sendmail = /usr/lib/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /var/www/html/smokeping/img
imgurl = http://120.X.X.X/smokeping/img
datadir = /opt/smokeping/data
piddir = /opt/smokeping/var
cgiurl = http://120.X.X.Xsmokeping/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 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
#*** Slaves ***
#secrets=/opt/smokeping/etc/smokeping_secrets
#+boomer
#display_name=boomer
#color=0000ff
#+slave2
#display_name=another
#color=00ff00
*** 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 = Network Latency Grapher
remark = Welcome to the SmokePing website of Kang Company. \
Here you will learn all about the latency of our network.
+ web
menu= web
#parents = owner:/Test/James location:/
title = web
++ cu-guangzhou
menu = cu-guangzhou
title = cu-guangzhou
+++ cu-guangzhou-1
menu = cu-guangzhou-1
title = cu-guangzhou-120.80.149.58
host = 120.80.149.58
+++ cu-guangzhou-2
menu = cu-guangzhou-2
title = cu-guangzhou-221.4.65.65
host = 221.4.65.65
+++ cu-guangzhou-3
menu = cu-guangzhou-3
title = cu-guangzhou-120.80.237.57
host = 120.80.237.57
+++ cu-guangzhou-4
menu = cu-guangzhou-4
title = cu-guangzhou-120.80.153.10
host = 120.80.153.10
++ cu-shanghai
menu = cu-shanghai
title = cu-shanghai
+++ cu-shanghai-1
menu = cu-shanghai-1
title = cu-shanghai-112.64.245.1
host = 112.64.245.1
+++ cu-shanghai-2
menu = cu-shanghai-2
title = cu-shanghai-112.64.245.158
host = 112.64.245.158
+++ cu-shanghai-3
menu = ct-shanghai-3
title = ct-shanghai-112.64.247.1
host = 112.64.247.1
++ cu-beijing
menu = cu-beijing
title = cu-beijing
+++ cu-beijing-1
menu = cu-beijing-1
title = cu-beijing-219.158.4.1
host = 219.158.4.1
+++ cu-beijing-2
menu = cu-beijing-2
title = cu-beijing-219.158.4.2
host = 219.158.4.2
+++ cu-beijing-3
menu = cu-beijing-3
title = cu-beijing-219.158.4.45
host = 219.158.4.45
+++ cu-beijing-4
menu = cu-beijing-4
title = cu-beijing-61.148.25.95
host = 61.148.25.95
+++ cu-beijing-5
menu = cu-beijing-5
title = cu-beijing-61.148.25.94
host = 61.148.25.94
++MAN-guangzhou
menu = MAN-guangzhou
title = MAN-guangzhou
+++MAN-guangzhou-1
menu = MAN-guangzhou-1
title = MAN-guangzhou-58.248.0.1
host = 58.248.0.1
+++MAN-guangzhou-2
menu = MAN-guangzhou-2
title = MAN-guangzhou-58.248.1.1
host = 58.248.1.1
+++MAN-guangzhou-3
menu = MAN-guangzhou-3
title = MAN-guangzhou-58.248.3.1
host = 58.248.3.1
+++ MAN-guangzhou-4
menu = MAN-guangzhou-4
title = MAN-guangzhou-58.248.4.1
host = 58.248.4.1
+++ MAN-guangzhou-5
menu = MAN-guangzhou-5
title = MAN-guangzhou-58.248.9.1
host = 58.248.9.1
++MAN-shenzhen
menu = MAN-shenzhen
title = MAN-shenzhen
+++MAN-shenzhen-1
menu = MAN-shenzhen-1
title = MAN-shenzhen-58.251.49.202
host = 58.251.49.202
+++MAN-shenzhen-2
menu = MAN-shenzhen-2
title = MAN-shenzhen-58.251.49.129
host = 58.251.49.129
+++MAN-shenzhen-3
menu = MAN-shenzhen-3
title = MAN-shenzhen-58.251.49.130
host = 58.251.49.130
+++MAN-shenzhen-4
menu = MAN-shenzhen-4
title = MAN-shenzhen-58.251.50.2
host = 58.251.50.2
+++MAN-shenzhen-5
menu = MAN-shenzhen-5
title = MAN-shenzhen-58.251.50.1
host = 58.251.50.1
++MAN-dongguan
menu = MAN-dongguan
title = MAN-dongguan
+++MAN-dongguan-1
menu = MAN-dongguan-1
title = MAN-dongguan-58.252.3.20
host = 58.252.3.20
+++MAN-dongguan-2
menu = MAN-dongguan-2
title = MAN-dongguan-58.252.3.1
host = 58.252.3.1
+++MAN-dongguan-3
menu = MAN-dongguan-3
title = MAN-dongguan-120.86.124.18
host = 120.86.124.18
+++MAN-dongguan-4
menu = MAN-dongguan-4
title = MAN-dongguan-120.86.124.21
host = 120.86.124.21
14、创建smokeping执行脚本
touch /etc/init.d/smokeping
//创建脚本文件
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
//增加可执行权限
15、自动运行等配置:
# chkconfig smokeping on
# chkconfig httpd on
# service smokeping start
Starting Smokeping: [ OK ]
# service httpd start
Starting httpd: [ OK ]
补充:
今天重新安装另外一台服务器,发现到了这和步,有个报错:
Mon May 23 19:59:58 2011] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Mon May 23 20:00:56 2011] [error] [client 192.168.10.103] Directory index forbidden by Options directive: /var/www/html/
[Mon May 23 20:00:57 2011] [error] [client 192.168.10.103] File does not exist: /var/www/html/favicon.ico
[Mon May 23 20:01:07 2011] [error] [client 192.168.10.103] Symbolic link not allowed or link target not accessible: /var/www/html/smokeping/smokeping.cgi
[Mon May 23 20:02:32 2011] [error] [client 192.168.10.103] Symbolic link not allowed or link target not accessible: /var/www/html/smokeping/smokeping.cgi
解决办法:
vi /etc/selinux/config
修改如下:
SELINUX=disabled
重启系统后恢复正常
16、截图如下:
本文出自 “从此,献身网络!” 博客,转载请与作者联系!