SmokePing安装部署
SmokePing简介
Smokeping是一款用于网络性能监测的开源监控软件,主要用于对IDC的网络状况,网络质量,稳定性等做检测,通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况。
SmokePing的特点
SmokePing keeps track of your network latency:
- Best of breed latency visualisation.(最佳图形展示功能,延时丢包等可以很直观的可视化展现)
- Interactive graph explorer.(交互式浏览器图表)
- Wide range of latency measurement plugins.(丰富的网络状况测量插件)
- Master/Slave System for distributed measurement.(支持主从的分布式部署模式)
- Highly configurable alerting system.(自定义报警功能)
- Live Latency Charts with the most ‘interesting‘ graphs.(漂亮、免费、开源)
- Free and OpenSource Software written in Perl written by Tobi Oetiker, the creator of MRTG and RRDtool
SmokePing安装
[[email protected] ~]# cat /etc/redhat-release #查看系统环境
CentOS Linux release 7.2.1511 (Core)
[[email protected] ~]# uname -r
3.10.0-327.18.2.el7.x86_64
[[email protected] ~]# yum install -y perl perl-Net-Telnet perl-Net-DNS perl-LDAP
perl-libwww-perl perl-IO-Socket-SSL perl-Socket6 perl-Time-HiRes perl-CGI-SpeedyCGI perl-FCGI perl-ExtUtils-MakeMaker
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 freetype freetype-devel #安装所需包
[[email protected] ~]# cd /usr/local/src
[[email protected] src]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz #下载smokeping
[[email protected] src]# tar xf smokeping-2.6.11.tar.gz #解压
[[email protected] src]# cd smokeping-2.6.11
[[email protected] smokeping-2.6.11]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty #远程下东东,需要点时间,需要build都ok,不然编译会报错
[[email protected] smokeping-2.6.11]# ./configure --prefix=/usr/local/smokeping #编译
Ready to install Smokeping ******************************
Settings:
PERL5LIB = not set
PERL = /usr/bin/perl
The Smokeping Makefiles use GNU make functionality.
Continue installation with
/usr/bin/gmake install
#出现这个提示就可以用gmake安装了
[[email protected] smokeping-2.6.11]# /usr/bin/gmake install #安装
#出现错误 Can't locate Sys/Syslog.pm in @INC (@INC contains: /usr/local/smokeing/thirdparty/lib/perl5/x86_64-linux-thread-multi /usr/local/smokeing/thirdparty/lib/perl5 ../lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ../lib/Smokeping.pm line 16.
[[email protected] smokeping-2.6.11]# yum -y install perl-Sys-Syslog #缺包了,安装这个就OK
[[email protected] smokeping-2.6.11]# cd /usr/local/smokeping/ #进入smokeping安装目录
[[email protected] smokeping-2.6.11]# mkdir cache data var #创建所需文件夹
[[email protected] smokeping-2.6.11]# touch /var/log/smokeping.log #创建日志文件
[[email protected] smokeping-2.6.11]# chown apache.apache cache data var /var/log/smokeping.log #修改文件属主
[[email protected] smokeping]# cd htdocs
[[email protected] htdocs]# mv smokeping.fcgi.dist smokeping.fcgi #修改文件名
[[email protected] htdocs]# mv /usr/local/smokeping/etc/config.dist /usr/local/smokeping/etc/config #添加配置文件
[[email protected] htdocs]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist #密码配置文件只让root能访问
修改smokeping配置文件
[[email protected] ~]# sed -i 's#cgiurl = http://some.url/smokeping.cgi#cgiurl = http://192.168.182.152/smokeping.cgi#g' /usr/local/smokeping/etc/config
[[email protected] ~]# sed -i 's#300#60#g' /usr/local/smokeping/etc/config #改为60,一分钟采集一次数据
[[email protected] ~]# sed -i 's#20#60#g' /usr/local/smokeping/etc/config #改为一分钟ping60次
[[email protected] ~]# vim /usr/local/smokeping/etc/config #添加utf-8中文字符集支持
*** Presentation ***
charset = utf-8
[[email protected] ~]# egrep "cgiurl|\<60\>|utf-8" /usr/local/smokeping/etc/config #查看修改的配置
cgiurl = http://192.168.56.11/smokeping.cgi
step = 60 #一分钟采集一次数据
pings = 60
charset = utf-8
修改apache配置文件
[[email protected] htdocs]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd luchuangao
New password:
Re-type new password:
Adding password for user luchuangao #设置登陆密码
[[email protected] htdocs]# vim /etc/httpd/conf/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
Order allow,deny
Allow from all
AuthName "Smokeping" #登陆密码认证配置
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
创建Smokeping启动脚本
[[email protected] etc]# cat /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: "
/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
stop() {
echo -n "Stopping Smokeping: "
kill -9 `ps ax | grep "/usr/local/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
[[email protected] etc]# chmod 755 /etc/init.d/smokeping
启动服务访问smokeping
[[email protected] ~]# systemctl start httpd.service #启动apache
[[email protected] ~]# /etc/init.d/smokeping start #启动smokeping
在浏览器输入http://192.168.5182.152/smokeping,输入之前设定的密码:
效果展示,略!
中文支持及添加监控节点
如果需要展示界面支持中文,需要安装中文编码:
[[email protected] etc]# yum -y install wqy-zenhei-fonts.noarch
[[email protected] etc]# vi /usr/local/smokeping/lib/Smokeping/Graphs.pm
for my $host (@hosts){
my ($graphret,$xs,$ys) = RRDs::graph
("dummy",
'--start', $tasks[0][1],
'--end', $tasks[0][2],
'--font TITLE:20:"WenQuanYi Zen Hei Mono"', #添加这行即可
vim /usr/local/smokeping/etc/config
#添加监测源的IP库,加入到config中,修改后重启smokeping才会生效
#添加监控节点示例:注意+是第一层,++是第二层,+++ 是第三层
+ Unicom
menu = 各地网络连通性监控
title = 监控统计
++ Telecom
menu = 电信网络监控
title = 电信网络监控列表
host = /Unicom/Telecom/telecom-xian /Unicom/Telecom/telecom-shanghai /Unicom/Telecom/telecom-sichuan /Unicom/Telecom/telecom-shenzhen /Unicom/Telecom/telecom-zhejiang /Unicom/Telecom/telecom-changsha /Unicom/Telecom/telecom-wuhan /Unicom/Telecom/telecom-jiangsu /Unicom/Telecom/telecom-chongqing /Unicom/Telecom/telecom-fujian /Unicom/Telecom/telecom-neimeng /Unicom/Telecom/telecom-xinjiang /Unicom/Telecom/telecom-guizhou /Unicom/Telecom/telecom-tianjin /Unicom/Telecom/telecom-hubei /Unicom/Telecom/telecom-beijing
+++ telecom-xian
menu = 西安电信
title = 西安电信
alerts = someloss
host = 61.150.91.55
+++ telecom-shanghai
menu = 上海电信
title = 上海电信
alerts = someloss
host = 180.169.22.226
+++ telecom-sichuan
menu = 四川电信
title = 四川电信
alerts = someloss
host = 211.149.224.160
+++ telecom-shenzhen
menu = 深圳电信
title = 深圳电信
alerts = someloss
host = 183.63.53.120
+++ telecom-zhejiang
menu = 浙江电信
title = 浙江电信
alerts = someloss
host = 122.226.223.82
+++ telecom-changsha
menu = 长沙电信
title = 长沙电信
alerts = someloss
host = 124.232.150.171
+++ telecom-wuhan
menu = 武汉电信
title = 武汉电信
alerts = someloss
host = 59.173.18.243
+++ telecom-jiangsu
menu = 江苏电信
title = 江苏电信
alerts = someloss
host = 58.215.186.208
+++ telecom-chongqing
menu = 重庆电信
title = 重庆电信
alerts = someloss
host = 219.153.71.238
+++ telecom-fujian
menu = 福建电信
title = 福建电信
alerts = someloss
host = 218.6.9.4
+++ telecom-neimeng
menu = 内蒙电信
title = 内蒙电信
alerts = someloss
host = 101.53.100.113
+++ telecom-xinjiang
menu = 乌鲁木齐电信
title = 乌鲁木齐电信
alerts = someloss
host = 124.119.87.204
+++ telecom-guizhou
menu = 贵州电信
title = 贵州电信
alerts = someloss
host = 222.87.128.7
+++ telecom-tianjin
menu = 天津电信
title = 天津电信
alerts = someloss
host = 221.238.254.118
+++ telecom-hubei
menu = 十堰电信
title = 十堰电信
alerts = someloss
host = 61.183.41.197
+++ telecom-beijing
menu = 北京电信
title = 北京电信
alerts = someloss
host = 119.90.3.2
++ Mobile
menu = 移动网络监控
title = 移动网络监控列表
host = /Unicom/Mobile/mobile-zhejiang /Unicom/Mobile/mobile-shanghai /Unicom/Mobile/mobile-tianjin /Unicom/Mobile/mobile-jinan /Unicom/Mobile/mobile-beijing /Unicom/Mobile/mobile-suzhou /Unicom/Mobile/mobile-wuhan /Unicom/Mobile/mobile-shenyang /Unicom/Mobile/mobile-quanzhou /Unicom/Mobile/mobile-xiamen
+++ mobile-zhejiang
menu = 浙江移动
title = 浙江移动
alerts = someloss
host = 211.140.143.3
+++ mobile-shanghai
menu = 上海移动
title = 上海移动
alerts = someloss
host = 117.135.137.82
+++ mobile-tianjin
menu = 天津移动
title = 天津移动
alerts = someloss
host = 117.131.207.163
+++ mobile-jinan
menu = 济南移动
title = 济南移动
alerts = someloss
host = 223.99.238.104
+++ mobile-beijing
menu = 北京移动
title = 北京移动
alerts = someloss
host = 111.13.56.26
+++ mobile-suzhou
menu = 苏州移动
title = 苏州移动
alerts = someloss
host = 112.25.230.238
+++ mobile-wuhan
menu = 武汉移动
title = 武汉移动
alerts = someloss
host = 111.47.111.229
+++ mobile-shenyang
menu = 沈阳移动
title = 沈阳移动
alerts = someloss
host = 223.100.7.69
+++ mobile-quanzhou
menu = 泉州移动
title = 泉州移动
alerts = someloss
host = 112.5.16.13
+++ mobile-xiamen
menu = 厦门移动
title = 厦门移动
alerts = someloss
host = 218.207.194.109
++ Unicom
menu = 联通网络监控
title = 联通网络监控列表
host = /Unicom/Unicom/unicom-dalian /Unicom/Unicom/unicom-beijing /Unicom/Unicom/unicom-jinan /Unicom/Unicom/unicom-shanghai /Unicom/Unicom/unicom-henan /Unicom/Unicom/unicom-heilongjiang /Unicom/Unicom/unicom-tianjin /Unicom/Unicom/unicom-shijiazhuang /Unicom/Unicom/unicom-taiyuan
+++ unicom-dalian
menu = 大连联通
title = 大连联通
alerts = someloss
host = 218.61.8.10
+++ unicom-beijing
menu = 北京联通
title = 北京联通
alerts = someloss
host = 118.186.222.66
+++ unicom-jinan
menu = 济南联通
title = 济南联通
alerts = someloss
host = 124.133.28.7
+++ unicom-shanghai
menu = 上海联通
title = 上海联通
alerts = someloss
host = 58.246.45.89
+++ unicom-henan
menu = 河南联通
title = 河南联通
alerts = someloss
host = 125.46.54.236
+++ unicom-heilongjiang
menu = 黑龙江联通
title = 黑龙江联通
alerts = someloss
host = 125.211.202.138
+++ unicom-tianjin
menu = 天津联通
title = 天津联通
alerts = someloss
host = 60.28.24.236
+++ unicom-shijiazhuang
menu = 石家庄联通
title = 石家庄联通
alerts = someloss
host = 110.249.209.130
+++ unicom-taiyuan
menu = 太原联通
title = 太原联通
alerts = someloss
host = 221.204.238.54
参考链接:
https://chegva.com/528.html
http://www.xuliangwei.com/xubusi/507.html
原文地址:https://www.cnblogs.com/luchuangao/p/8277262.html
时间: 2024-10-28 22:44:54