必威体育Betway必威体育官网
当前位置:首页 > IT技术

smokeping网络监控

时间:2019-08-15 15:15:30来源:IT技术作者:seo实验室小编阅读:72次「手机版」
 

smokeping

smokeping网络监控

一、smokeping介绍

我们在选择机房的时候,如何知道这个机房的网络情况,这个时候就要用到网络监控软件:smokeping  

本文主要介绍如何使用smokeping来监控idc机房的网络质量情况,从监控图上的延时与丢包能分辨出你机房的网络是否稳定,是否为多线,是否为BGP机房,到各城市的3个运营商之间的网络,各是什么情况,如果出现问题,如何有针对性的解决。而且如果选择新机房的时候,你可以根据smokeping的监控结果来判断这个机房是否适合。

smokeping是rrdtool的作者Tobi Oetiker的作品,所以它在图形显示方面有很大优势,也是一个很 有特点的opensource工具

1、多种探测方式,包括fping、echoping、dig、curl等;

2、易用可扩展的插件

3、master/slave 的 工作方式,可以在多个节点收集同一个监测点的数据

二、安装smokeping

1、软件环境

[root@MJ-Zabbix ~]# cat /etc/redhat-release 

centos release 6.9 (final)

[root@MJ-Zabbix ~]# uname -r

2.6.32-696.1.1.el6.x86_64

[root@MJ-Zabbix ~]# 

2、软件下载

wget http://www.fping.org/dist/fping-3.10.tar.gz

wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz

3、安装软件

1、安装依赖包:

yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-IO-socket-SSL perl-Socket6 perl-Time-HiRes perl-ExtUtils-MakeMaker rrdtool rrdtool-perl curl 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 popt popt-devel libidn libidn-devel -y

2、解压、编译安装fping

tar xf fping-3.10.tar.gz

cd fping-3.10

./configure

make && make install

3、解压、编译安装echoping

tar xf echoping-6.0.2.tar.gz

cd echoping-6.0.2

./configure

make && make install

4、解压、编译安装smokeping

tar xf smokeping-2.6.9.tar.gz

cd smokeping-2.6.9

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

./configure --prefix=/usr/local/smokeping

/usr/bin/gmake install

5、配置 smokeping 

cd /usr/local/smokeping/

mkdir cache data var

touch /var/log/smokeping.log

chown apache:apache cache data var

chown apache:apache /var/log/smokeping.log

chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

cd /usr/local/smokeping/htdocs

mv smokeping.fcgi.dist smokeping.fcgi

cd /usr/local/smokeping/etc

mv config.dist config

6、更改配置文件

vim /usr/local/smokeping/etc/config

主要修改如下内容

#cgiurl = http://some.url/smokeping.cgi

cgiurl = http://10.0.0.62/smokeping.cgi

*** Database ***

#step = 300

step = 60 #此处建议改为 60 , 一分钟采集一次数据

pings = 20

7、编辑apache配置文件

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

order allow,deny

Allow from all

DirectoryIndex smokeping.fcgi

</Directory>

8、图像浏览界面的中文支持

安装字体

yum -y install wqy-zenhei-fonts.noarch

编辑smokeping的配置文件

vim /usr/local/smokeping/etc/config

第50行添加

charset = utf-8 #添加此行,解决出图乱码问题

编辑Graphs.pm

vim /usr/local/smokeping/lib/Smokeping/Graphs.pm

#第147行下边插入下边一行

'--font title:20:"WenQuanYi Zen Hei Mono"',

设置开机启动:

echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local

#########################################################

if ($mode =~ /[anc]/){

my $val = 0;

for my $host (@hosts){

    my ($graphret,$xs,$ys) = RRDs::graph

    ("dummy",

    '--start', $tasks[0][1],

    '--end', $tasks[0][2],

    "DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:average",

    '--font TITLE:20:"WenQuanYi Zen Hei Mono"',

    'print:maxping:MAX:%le' );

    my $ERROR = RRDs::error();

    return "<p>RRDtool did not understand your input: $ERROR.</p>" if $ERROR;

    $val = $graphret->[0] if $val < $graphret->[0];

}

$val = 1e-6 if $val =~ /nan/i;

$max = { $tasks[0][1] => $val * 1.5 };

}

#########################################################

9、Config 配置文件的最后边

vim /usr/local/smokeping/etc/config

##################################################

+ Test

menu= Targets

#parents = owner:/Test/James location:/

#++ James

#menu = James

#title =James

#alerts = someloss

#slaves = boomer slave2

#host = james.address

#++ MultiHost

#menu = Multihost

#title = James and James as seen from Boomer

#host = /Test/James /Test/James~boomer

+ Internet

menu = Internet

title = Internet

++ IDC

menu = IDC

title = IDC

+++ MJ-Baidu

menu = MJ-Baidu

title = MJ-Baidu

host = 61.135.169.121

+++ MJ-163

menu = MJ-163

title = MJ-163

host = 61.149.9.224

+++ ZW-IDC

menu = ZW-IDC

title = ZW-IDC

host = 101.251.x.x

+++ SD-IDC

menu = SD-IDC

title = SD-IDC

host = 219.143.x.x

++ Office-DS

menu = office-DS

title = office-DS

+++ UC-500M

menu = UC-500M

title = UC-500M

host = 103.36.x.x

+++ CT-50M

menu = CT-50M

title = CT-50M

host = 124.127.x.x

+++ UC-100M

menu = UC-100M

title = UC-100M

host = 114.255.x.x

++ Office-FenBu

menu = office-FenBu

title = office-FenBu

+++ JN-CT-100M

menu = JN-100M

title = JN-100M

host = 123.168.x.x

+++ WT-CT-50M

menu = WT-50M

title = WT-50M

host = 58.132.x.x

+++ JiuJiang

menu = JiuJiang

title = JiuJiang

++++ JiuJiang-CT

menu = CT-50M

title = CT-50M

host = 218.87.90.x

++++ JiuJiang-UC

menu = CT-20M

title = CT-20M

host = 58.17.120.x

10.启动服务:

httpd:

[root@MJ-Zabbix etc]# /etc/init.d/httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd:                                            [  OK  ]

11.启动问题

smokeping:

[root@MJ-Zabbix etc]# /usr/local/smokeping/bin/smokeping    看到如下信息说明smokeping 配置无问题,可出图

Note: logging to syslog as local0/info.

Daemonizing /usr/local/smokeping/bin/smokeping ...

如果启动有问题:

1、File '/usr/local/smokeping/etc/smokeping_secrets.dist' is world-readable

2、ERROR: /usr/local/smokeping/bin/../etc/config, line 112: File '/usr/local/smokeping/etc/smokeping_secrets.dist' is world-readable or writable, refusing it

查看smokeping_secrets.dist文件属性是否为400,如不是请按照如下修改:

[root@MJ-Zabbix etc]# ll

total 24

-rw-r--r-- 1 root root 2041 Feb 27 17:21 basepage.html.dist

-rw-r--r-- 1 root root 3829 Mar  1 10:19 config

drwxr-xr-x 2 root root 4096 Feb 27 17:21 examples

-rw-r--r-- 1 root root 1563 Feb 27 17:21 smokemail.dist

-rw-r--r-- 1 root root   59 Feb 27 17:21 smokeping_secrets.dist

-rw-r--r-- 1 root root 3815 Feb 27 17:21 tmail.dist

注意etc/smokeping_secrets.dist文件属性必须400

chmod 400 smokeping_secrets.dist    修改权限

/usr/local/smokeping/bin/smokeping  --check   检查语法

[root@MJ-Zabbix etc]# ps -ef |grep smokeping

root     15946     1  0 10:20 ?        00:00:02 /usr/local/smokeping/bin/smokeping [FPing]

root     21066 20350  0 11:49 pts/1    00:00:00 grep smokeping

注意:每次修改smokeping配置文件/usr/local/smokeping/etc/config都要先杀进程,然后重启服务才生效

[root@MJ-Zabbix etc]# kill -9 15946     

[root@MJ-Zabbix etc]# /usr/local/smokeping/bin/smokeping

Note: logging to syslog as local0/info.

Daemonizing /usr/local/smokeping/bin/smokeping ...

12. Zabbix和Smokeping部署在同一台服务器,占用端口80

修改端口80为8080,重启httpd服务

[root@MJ-Zabbix /]# cd /etc/httpd/conf/http.conf

13、验证测试:

10.2.66.200:8080/zabbix

10.2.66.200:8080/smokeping

############################

补充:

14、smokeping的默认配置文件110行的fping安装目录与此次安装目录不相符需修改!

vim /usr/local/smokeping/etc/config

#第110更改fping的目录为

binary = /usr/local/sbin/fping

15、启动apache和smokeping&设置环境变量

/etc/init.d/httpd start

/usr/local/smokeping/bin/smokeping

echo 'export PATH=/usr/local/smokeping/bin/:$PATH' >> /etc/profile

相关阅读

smokeping的安装和使用笔记

Smokeping 是一款用于网络性能监测的监控软件,通过它可以在自己公司IDC的网络状况,如延时,丢包率,是否BGP多线等,通过rrdtool制图方式,

分享到:

栏目导航

推荐阅读

热门阅读