原文参考:http://www.xuliangwei.com/xubusi/507.html?utm_source=tuicool&utm_medium=referral
1.1安装smokeping
[root@linux-node2 ~]# cat /etc/redhat-release #查看服务器信息
CentOS release 6.7 (Final)
[root@linux-node2 ~]# uname -r
2.6.32-573.el6.x86_64
[root@linux-node2 ~]# yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-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 #通过yum安装所依赖的库以及环境
[root@linux-node2 ~]# cd /usr/local/src/ #进入默认源码包存放路径
[root@linux-node2 ~]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz #下载smokeping包
[root@linux-node2 src]# tar xf smokeping-2.6.9.tar.gz #解压smokeping
[root@linux-node2 src]# cd smokeping-2.6.9 #进入smokeping目录
[root@linux-node2 smokeping-2.6.9]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty #
[root@linux-node2 smokeping-2.6.9]# ./configure --prefix=/usr/local/smokeping #编译smokeping到/usr/local
[root@linux-node2 smokeping-2.6.9]# cd /usr/local/smokeping/ #进入smokeping目录
[root@linux-node2 smokeping]# mkdir cache data var #创建三个目录
[root@linux-node2 smokeping]# touch /var/log/smokeping.log #创建smokeping日志文件
[root@linux-node2 smokeping]# chown apache.apache cache/ data/ var/ /var/log/smokeping.log #授权属主属组为apache
[root@linux-node2 smokeping]# cd /usr/local/smokeping/htdocs/ #进入smokeping下htdocs目录
[root@linux-node2 htdocs]# mv smokeping.fcgi.dist smokeping.fcgi #修改smokeping文件名
[root@linux-node2 smokeping]# mv /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config #修改smokeping下etc目录smokeping
1.2修改smokeping配置文件
[root@linux-node2 smokeping]# sed -i 's#cgiurl = http://some.url/smokeping.cgi#cgiurl =
http://10.0.0.8/smokeping.fcgi#g' /usr/local/smokeping/etc/config
[root@linux-node2 smokeping]# sed -i 's#300#60#g' /usr/local/smokeping/etc/config #默认检测时间300秒修改60秒
[root@linux-node2 smokeping]# sed -i 's#20#60#g' /usr/local/smokeping/etc/config
#默认ping20次,修改为60秒ping60次
[root@linux-node2 ~]# vim /usr/local/smokeping/etc/config #在presentation添加utf-8中文字符集
Presentation
charset = utf-8
[root@linux-node2 smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist #修改密码权限为root只读
1.3修改apache配置文件
[root@linux-node2 htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd darker #设置登录密码认证 通过apache自带验证功能
New password:
Re-type new password:
Adding password for user darker
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
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex
smokeping.fcgi
</Directory>
1.4设置smokeping启动脚本
[root@linux-node2 ~]# cat /etc/init.d/smokeping #smokeping启动脚本
#!/bin/bash
#
chkconfig: 2345 80 05
Description: Smokeping init.d script
Write by : linux-Leon_xiedi
Get function from functions library
. /etc/init.d/functions
Start the service Smokeping
function start() {
echo -n "Starting Smokeping: "
/usr/local/smokeping/bin/smokeping >/dev/null 2>&1
Create the lock file
touch /var/lock/subsys/smokeping
success $"Smokeping startup"
echo
}
Restart the service Smokeping
function stop() {
echo -n "Stopping Smokeping: "
kill -9 ps ax |grep "/usr/local/smokeping/bin/smokeping" |<br/>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
}
#Show status about Smokeping
function status() {
NUM="ps -ef|grep smokeping|grep -v grep|wc -l
"
if [ "$NUM" == "0" ];then
echo "Smokeping is not run"
else
echo "Smokeping is running"
fi
}
main logic
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload)
stop
start
;;
*)
echo $"Usage: $0
{start|stop|restart|reload|status}"
exit 1
esac
exit 0
1.5启动服务以及访问smokeping
[root@linux-node2 ~]# chmod 755 /etc/init.d/smokeping #添加脚本755权限
[root@linux-node2 ~]# chkconfig --add smokeping #将smokeping加入开机启动
[root@linux-node2 ~]# chkconfig smokeping on #设置smokeping为开机启动
[root@linux-node2 ~]# chkconfig httpd on #设置apache为开机启动
[root@linux-node2 ~]# /etc/init.d/httpd restart #重启apache服务
[root@linux-node2 ~]# /etc/init.d/smokeping restart #重启smokeping服务
1.通过浏览器访问smokeping,如图1-1
图1-1
1.6添加需要监控的网站和节点
注意事项:
1)在/usr/local/smokeping/etc/config中添加
2)smokeping就这点不好,添加节点不能在前台Web页面添加,一定要在后台的配置文件中添加。
3)修改/usr/local/smokeping/etc/config 后,必须重启smokeping 程序,配置才会生效
4)smokeping 会根据配置文件config
在/usr/local/smokeping/data 之下添加moniter文件夹,其下包含website子文件夹
5)用vmware
workstation的虚拟机测试有一点好处,workstation下的虚拟网卡可以设置出入的丢包率,适合smokeping做丢包测试, 经过测试smokeping检测出的丢包率与vmware worksation虚拟网卡设置的丢包率基本相同,也就是说smokeping 能够反应网络的真实状况。
添加监控节点示例:注意+是第一层,++是第二层,+++ 是第三层
- Other
menu = 三大网络监控
title = 监控统计
++ dianxin
menu = 电信网络监控
title = 电信网络监控列表
host = /Other/dianxin/dianxin-bj
/Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj /Other/dianxin/dianxin-sc /Other/dianxin/dianxin-sh
/Other/dianxin/dianxin-gz
+++ dianxin-bj
menu = 北京电信
title = 北京电信
alerts = someloss
host = 202.96.199.133
+++ dianxin-hlj
menu = 黑龙江电信
title = 黑龙江电信
alerts = someloss
host = 219.147.198.242
+++ dianxin-tj
menu = 天津电信
title = 天津电信
alerts = someloss
host = 219.150.32.132
+++ dianxin-sc
menu = 四川电信
title = 四川电信
alerts = someloss
host = 61.139.2.69
+++ dianxin-sh
menu = 上海电信
title = 上海电信
alerts = someloss
host = 116.228.111.118
+++ dianxin-gz
menu = 广东电信
title = 广东电信
alerts = someloss
host = 113.111.211.22
++ liantong
menu = 联通网络监控
title = 联通网络监控列表
host = /Other/liantong/liantong-bj /Other/liantong/liantong-hlj
/Other/liantong/liantong-tj
/Other/liantong/liantong-sc
/Other/liantong/liantong-sh /Other/liantong/liantong-gz
+++ liantong-bj
menu = 北京联通
title = 北京联通
alerts = someloss
host = 61.135.169.121
+++ liantong-hlj
menu = 黑龙江联通
title = 黑龙江联通
alerts = someloss
host = 202.97.224.69
+++ liantong-tj
menu = 天津联通
title = 天津联通
alerts = someloss
host = 202.99.96.68
+++ liantong-sc
menu = 四川联通
title = 四川联通
alerts = someloss
host = 119.6.6.6
+++ liantong-sh
menu = 上海联通
title = 上海联通
alerts = someloss
host = 210.22.84.3
+++ liantong-gz
menu = 广东联通
title = 广东联通
alerts = someloss
host = 221.5.88.88
++ yidong
menu = 移动网络监控
title = 移动网络监控列表
host = /Other/yidong/yidong-bj
/Other/yidong/yidong-hlj /Other/yidong/yidong-tj /Other/yidong/yidong-sc /Other/yidong/yidong-sh
/Other/yidong/yidong-gz
+++ yidong-bj
menu = 北京移动
title = 北京移动
alerts = someloss
host = 221.130.33.52
+++ yidong-hlj
menu = 黑龙江移动
title = 黑龙江移动
alerts = someloss
host = 211.137.241.35
+++ yidong-tj
menu = 天津移动
title = 天津移动
alerts = someloss
host = 211.137.160.5
+++ yidong-sc
menu = 四川移动
title = 四川移动
alerts = someloss
host = 218.201.4.3
+++ yidong-sh
menu = 上海移动
title = 上海移动
alerts = someloss
host = 117.131.19.23
+++ yidong-gz
menu = 广东移动
title = 广东移动
alerts = someloss
host = 211.136.192.6
最后访问:http://10.4.208.209:8080/smokeping
smokeping 图片断点问题: https://www.iyunv.com/thread-26502-1-1.html
本文转自Tenderrain 51CTO博客,原文链接:http://blog.51cto.com/tenderrain/2062721,如需转载请自行联系原作者