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 ,如需转载请自行联系原作者
相关文章
|
6天前
|
资源调度 JavaScript 搜索推荐
Linux系统之部署envlinks极简个人导航页
【4月更文挑战第11天】Linux系统之部署envlinks极简个人导航页
40 2
|
9天前
|
安全 Linux 虚拟化
网络名称空间在Linux虚拟化技术中的位置
网络名称空间(Network Namespaces)是Linux内核特性之一,提供了隔离网络环境的能力,使得每个网络名称空间都拥有独立的网络设备、IP地址、路由表、端口号范围以及iptables规则等。这一特性在Linux虚拟化技术中占据了核心位置🌟,它不仅为构建轻量级虚拟化解决方案(如容器📦)提供了基础支持,也在传统的虚拟机技术中发挥作用,实现资源隔离和网络虚拟化。
网络名称空间在Linux虚拟化技术中的位置
|
9天前
|
网络协议 安全 Linux
Linux网络名称空间之独立网络资源管理
Linux网络名称空间是一种强大的虚拟化技术🛠️,它允许用户创建隔离的网络环境🌐,每个环境拥有独立的网络资源和配置。这项技术对于云计算☁️、容器化应用📦和网络安全🔒等领域至关重要。本文将详细介绍在Linux网络名称空间中可以拥有的独立网络资源,并指出应用开发人员在使用时应注意的重点。
|
9天前
|
安全 网络协议 Linux
Linux网络名称空间概述
Linux网络名称空间是操作系统级别的一种虚拟化技术🔄,它允许创建隔离的网络环境🌐,使得每个环境拥有自己独立的网络资源,如IP地址📍、路由表🗺️、防火墙规则🔥等。这种技术是Linux内核功能的一部分,为不同的用户空间进程提供了一种创建和使用独立网络协议栈的方式。本文旨在全方面、多维度解释Linux网络名称空间的概念、必要性和作用。
Linux网络名称空间概述
|
16天前
|
存储 前端开发 Linux
Linux系统之部署ToDoList任务管理工具
【4月更文挑战第1天】Linux系统之部署ToDoList任务管理工具
61 1
|
17天前
|
Linux
Linux中centos桌面消失网络图标
Linux中centos桌面消失网络图标
13 0
|
17天前
|
存储 安全 网络安全
云端防御战线:云计算环境下的网络安全与信息保护
在信息技术迅猛发展的今天,云计算作为支撑数字转型的重要基石,其安全性牵动着企业生存与发展的命脉。本文深入探讨了云计算环境中面临的安全威胁和挑战,并提出了一系列创新的安全策略和技术解决方案。通过综合分析公有云、私有云以及混合云服务模型中的安全需求,文章构建了一个多层次、全方位的网络安全防护体系。此外,针对数据加密、身份验证、访问控制等关键技术进行了深入剖析,旨在为读者提供一套系统的信息安全保护指南,确保在享受云计算带来的便利时,数据和资源的安全性不被妥协。
33 8
|
7天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
20 6
|
9天前
|
网络协议 Linux
在Linux中,管理和配置网络接口
在Linux中管理网络接口涉及多个命令,如`ifconfig`(在新版本中被`ip`取代)、`ip`(用于网络设备配置)、`nmcli`(NetworkManager的CLI工具)、`nmtui`(文本界面配置)、`route/ip route`(处理路由表)、`netstat/ss`(显示网络状态)和`hostnamectl/systemctl`(主机名和服务管理)。这些命令帮助用户启动接口、设置IP地址、查看连接和路由信息。不同发行版可能有差异,建议参考相应文档。
19 4
|
3天前
|
监控 安全 网络安全
云端防御:云计算环境中的网络安全策略与实践
【4月更文挑战第15天】 在数字化转型的时代,云计算已成为企业运营不可或缺的技术支撑。然而,随着云服务模式的广泛采纳,网络安全挑战亦随之而来。本文深入探讨了云计算环境下的安全威胁,分析了云服务模型对安全策略的影响,并提出了一系列创新的网络安全防护措施。通过研究最新的加密技术、访问控制机制和持续监控方法,文章旨在为企业提供一个综合性的网络安全框架,以确保其云基础设施和数据的安全性和完整性。
20 8