Linux下smokeping网络监控环境部署记录

简介:

 

smokeping是一款监控网络状态和稳定性的开源软件(它是rrdtool的作者开发的),通过它可以监控到公司IDC的网络状况,如延时,丢包率,是否BGP多线等;
smokeping会向目标设备和系统发送各种类型的测试数据包,测量、记录,并通过rrdtool制图方式,图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况;

通过smokeping来监控IDC机房网络质量情况,可以从监控图上的延时与丢包情况分辨出机房的网络是否稳定,是否为多线,是否为BGP机房以及到各城市的三个运行商网络各是什么情况。如果出现问题,可以有针对性的去处理;如果选择新机房的时候,还可以根据smokeping的监控结果来判断这个机房是否适合。
需要注意的是:smokeping监控的是网络稳定性,而cacti或zabbix监控的是带宽使用情况(即进出口流量)

下面就smokeping网络监控环境部署过程做一记录:
1)安装相关源
下载地址:https://pan.baidu.com/s/1pKBtm11
提取密码:erte
[root@bastion-IDC ~]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

2)安装rrdtool与依赖库
[root@bastion-IDC ~]# 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

下载fping并编译安装
[root@bastion-IDC ~]# cd /usr/local/src/
[root@bastion-IDC src]# wget http://fping.org/dist/fping-3.10.tar.gz
[root@bastion-IDC src]# tar -zvxf fping-3.10.tar.gz 
[root@bastion-IDC src]# cd fping-3.10
[root@bastion-IDC fping-3.10]# ./configure && make && make install

下载echoping并编译安装
[root@bastion-IDC ~]# cd /usr/local/src/
[root@bastion-IDC src]# wget http://down1.chinaunix.net/distfiles/echoping-5.2.0.tar.gz
[root@bastion-IDC src]# tar -zvxf echoping-5.2.0.tar.gz 
[root@bastion-IDC src]# yum install -y popt libidn popt-devel libidn-devel          //安装echoping依赖的包
[root@bastion-IDC src]# cd echoping-5.2.0
[root@bastion-IDC echoping-5.2.0]# ./configure && make && make install

3)下载与安装smokeping
[root@bastion-IDC ~]# cd /usr/local/src/
[root@bastion-IDC src]# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
[root@bastion-IDC src]# tar -zvxf smokeping-2.6.8.tar.gz 
[root@bastion-IDC src]# cd smokeping-2.6.8
[root@bastion-IDC smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping
出现下面报错信息:
** Aborting Configure ******************************

If you know where perl can find the missing modules, set
the PERL5LIB environment variable accordingly.

FIRST though, make sure that 'perl' starts the perl
binary you want to use for SmokePing.

Now you can install local copies of the missing modules
by running

./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty

The RRDs perl module is part of RRDtool. Either use the rrdtool
package provided by your OS or install rrdtool from source.
If you install from source, the RRDs module is located
PREFIX/lib/perl

出现问题是因为需要安装perl的模块,所以运行下面内容即可:
[root@bastion-IDC smokeping-2.6.8]# ./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
[root@bastion-IDC smokeping-2.6.8]# ./configure --prefix=/usr/local/smokeping
[root@bastion-IDC smokeping-2.6.8]# /usr/bin/gmake install

4)配置smokeping
创建cache、data、var目录
[root@bastion-IDC yum.repos.d]# cd /usr/local/smokeping
[root@bastion-IDC smokeping]# mkdir cache data var

创建日志
[root@bastion-IDC smokeping]# touch /var/log/smokeping.log

授权
[root@bastion-IDC smokeping]# chown apache:apache cache data var
[root@bastion-IDC smokeping]# chown apache:apache /var/log/smokeping.log

修改配置文件
[root@bastion-IDC smokeping]# cd /usr/local/smokeping/htdocs/
[root@bastion-IDC htdocs]# mv smokeping.fcgi.dist smokeping.fcgi
[root@bastion-IDC htdocs]# cd /usr/local/smokeping/etc
[root@bastion-IDC etc]# mv config.dist config
[root@bastion-IDC etc]# cp config config.bak
[root@bastion-IDC etc]# vim config
........
cgiurl = http://smokeping.wangshibo.com/smokeping.cgi              //默认是cgiurl = http://some.url/smokeping.cgi,把some.url修改为你的ip或者域名

*** Database ***

step = 60                   //默认是300,这是检测的时间

配置完成之后修改密码文件权限
[root@bastion-IDC etc]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

修改apache的配置
[root@bastion-IDC etc]# vim /etc/httpd/conf/httpd.conf                //添加下面内容
.......
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"       //smokeping访问地址就是http://smokeping.wangshibo.com/smokeping
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
</Directory>

图像浏览界面的中文支持
[root@bastion-IDC etc]# yum -y install wqy-zenhei-fonts.noarch

编辑smokeping的配置文件
[root@bastion-IDC etc]# vim /usr/local/smokeping/etc/config
charset = utf-8              //第50行下面添加此行内容

编辑Graphs.pm
[root@bastion-IDC etc]# vim /usr/local/smokeping/lib/Smokeping/Graphs.pm
'--font TITLE:20:"WenQuanYi Zen Hei Mono"',                  //第147行下面插入边一行内容

接着进行测试数据的自定义(可以将smokeping部署在公司网络下,然后自定义监控各个IDC的网络情况,监控设置如下定义)
[root@bastion-IDC etc]# vim /usr/local/smokeping/etc/config          //在最后面添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+ 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

修改smokeping的config配置文件中fping路径
[root@bastion-IDC etc]# which fping
/usr/local/sbin/fping
[root@bastion-IDC etc]# vim config
......
binary = /usr/local/sbin/fping                 //默认配置的是/usr/sbin/fping

启动http
[root@bastion-IDC etc]# /etc/init.d/httpd start            //最好将httpd.conf中的ServerName www.example.com:80这一行的注释打开

启动smokeping
[root@bastion-IDC etc]# /usr/local/smokeping/bin/smokeping

设置smokeping开机启动
[root@bastion-IDC etc]# echo "/usr/local/smokeping/bin/smokeping" >> /etc/rc.local

设置smokeping环境变量
[root@bastion-IDC etc]# echo 'export PATH=/usr/local/smokeping/bin/:$PATH' >> /etc/profile

本地hosts绑定smokeping.wangshibo.com,然后访问上面部署的smokeping界面:
http://smokeping.wangshibo.com/smokeping    (首次访问,采集数据需要一段时间,等一会就会有数据图形展示)

以上为实验环境,可根据自己实际的网络情况进行监控配置的修改。

如果按照上面操作后,直接在网上访问是十分的不安全,需要加入安全访问控制
修改apache的httpd.conf配置(将上面添加的apache配置直接如下覆盖或再添加如下红色字体内容)
[root@bastion-IDC etc]# vim /etc/httpd/conf/httpd.conf 
....
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
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>

设置访问的用户名和密码(比如admin/admin)
[root@bastion-IDC etc]# htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin
New password: 
Re-type new password: 
Adding password for user admin

重启apache
[root@bastion-IDC etc]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

再次访问smokeping界面

***************当你发现自己的才华撑不起野心时,就请安静下来学习吧***************
分类:  监控系统
本文转自散尽浮华博客园博客,原文链接:http://www.cnblogs.com/kevingrace/p/5570488.html ,如需转载请自行联系原作者
相关文章
|
12天前
|
资源调度 JavaScript 搜索推荐
Linux系统之部署envlinks极简个人导航页
【4月更文挑战第11天】Linux系统之部署envlinks极简个人导航页
52 2
|
13天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
37 6
|
3天前
|
机器学习/深度学习 缓存 监控
linux查看CPU、内存、网络、磁盘IO命令
`Linux`系统中,使用`top`命令查看CPU状态,要查看CPU详细信息,可利用`cat /proc/cpuinfo`相关命令。`free`命令用于查看内存使用情况。网络相关命令包括`ifconfig`(查看网卡状态)、`ifdown/ifup`(禁用/启用网卡)、`netstat`(列出网络连接,如`-tuln`组合)以及`nslookup`、`ping`、`telnet`、`traceroute`等。磁盘IO方面,`iostat`(如`-k -p ALL`)显示磁盘IO统计,`iotop`(如`-o -d 1`)则用于查看磁盘IO瓶颈。
|
1天前
|
网络协议 Linux Shell
【linux网络(一)】初识网络, 理解四层网络模型
【linux网络(一)】初识网络, 理解四层网络模型
|
1天前
|
安全 Ubuntu Linux
Linux 网络操作命令Telnet
Linux 网络操作命令Telnet
6 0
Linux 网络操作命令Telnet
|
1天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
19 1
|
1天前
|
Ubuntu Linux
Linux(22) Linux设置网络优先级顺序
Linux(22) Linux设置网络优先级顺序
2 0
|
1天前
|
存储 监控 安全
云端防御战线:云计算环境下的网络安全策略与实践
【4月更文挑战第23天】在数字化转型的浪潮中,云计算已成为推动企业敏捷性、可扩展性和成本效率的关键因素。然而,随着数据和服务迁移至云端,传统的网络边界逐渐模糊,给网络安全带来了前所未有的挑战。本文探讨了在多租户云环境中维护信息安全的先进策略和技术,分析了云服务模型(IaaS, PaaS, SaaS)特有的安全风险,并提出了一系列针对性的安全措施和最佳实践。通过深入讨论身份与访问管理、数据加密、入侵检测系统以及合规性监控等关键技术,本文旨在为读者提供一套全面的云计算安全防护框架。
5 0
|
2天前
|
Ubuntu 网络协议 Linux
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
23 0
|
2天前
|
机器学习/深度学习 人工智能 安全
云端防御战线:云计算环境中的网络安全策略
【4月更文挑战第22天】 在数字化时代,云计算已成为企业运营的关键基础设施。然而,随着其广泛应用,云服务也成为了网络攻击者的主要目标。本文深入探讨了云计算环境下的网络安全挑战,分析了云服务提供者和使用者面临的安全威胁,并提出了综合性的安全策略。这些策略不仅包括传统的加密和身份验证技术,还涉及更先进的入侵检测系统、行为分析和机器学习算法。文章旨在为读者提供一个关于如何在享受云计算带来的便利同时确保数据和操作安全的综合指南。