监控网卡centos,centos启用网卡

很多朋友对于监控网卡centos和centos启用网卡不太懂,今天就由小编来为大家分享,希望可以帮助到大家,下面一起来看看吧!

CentOS下千兆网卡带宽测试详解

iperf是一个基于C/S模型的纯带宽测试软件,可以测试网卡的吞吐量。

iperf的好处是纯粹发包和接收,防止硬盘拖后腿,影响测试结果。

本文以千兆网卡Bcom 5720进行测试,环境CentOS 6.4 x64

在两台机器上分别安装iperf

yuminstalliperf--enablerepo=epel

在其中一台以服务端方式启动,并开放防火墙5001端口

iperf-s-i 1-w 448k

启动结果如下:

Server listening on TCP port 5001

TCP window size: 448 KByte

在另一台上,以客户端方式连接到服务端,测试10分钟

iperf-c 10.10.10.22-i 1-w 448k-t 600

此时,服务端会显示如下信息

[ 4]local10.10.10.22 port 5001 connected with 10.10.10.11 port 56251

[ ID] Interval Transfer Bandwidth

[ 4] 0.0- 1.0 sec 112 MBytes 941 Mbits/sec

[ 4] 1.0- 2.0 sec 112 MBytes 941 Mbits/sec

[ 4] 2.0- 3.0 sec 112 MBytes 941 Mbits/sec

[ 4] 3.0- 4.0 sec 112 MBytes 941 Mbits/sec

[ 4] 4.0- 5.0 sec 112 MBytes 941 Mbits/sec

[ 4] 5.0- 6.0 sec 112 MBytes 941 Mbits/sec

[ 4] 6.0- 7.0 sec 112 MBytes 941 Mbits/sec

[ 4] 7.0- 8.0 sec 112 MBytes 941 Mbits/sec

客户端信息则是

3] 46.0-47.0 sec 112 MBytes 942 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 47.0-48.0 sec 112 MBytes 941 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 48.0-49.0 sec 112 MBytes 942 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 49.0-50.0 sec 112 MBytes 941 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 50.0-51.0 sec 112 MBytes 942 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 51.0-52.0 sec 112 MBytes 941 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 52.0-53.0 sec 112 MBytes 941 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 53.0-54.0 sec 112 MBytes 942 Mbits/sec

[ ID] Interval Transfer Bandwidth

[ 3] 54.0-55.0 sec 112 MBytes 941 Mbits/sec

以上信息显示,当前网卡传输速度约为940Mbit/s,接近理论速度1G/s,下载速度112M/s,也接近理论速度125M/s,通过cacti带宽监控,也显示上述统计结果。

至此,千兆网卡验明正身。

补充说明,影响带宽的可能原因有很多:

1、交换机是百兆的,通信枢纽

2、千兆网卡工作在百兆模式,参与测试的机器任意一台工作在百兆都不行

3、用真实的硬盘文件进行测试,硬盘速度拖后腿

centos查看实时网络带宽占用情况方法

Linux中查看网卡流量工具有iptraf、iftop以及nethogs等,iftop可以用来监控网卡的实时流量(可以指定网段)、反向解析IP、显示端口信息等。

1、安装iftop

centos安装iftop的命令如下:

yum install iftop-y

2、查看网卡实时流量命令:

iftop-i eth1

执行命令查看外网占用带宽情况,能查看到相应IP占用带宽的情况,从而判断哪个占用带宽最多,是否恶意连接:

如上图,将占用带宽最多的IP,用防火墙或者安全组屏蔽访问即可。当然,最好是观察一段时间,如果是持续占用带宽,加上IP是外地的,那就完全可以屏蔽它。为了更好的监控某个特定IP的带宽访问情况,可以执行命令:

iftop-i eth1-B-F 182.92.***.20

显示182.92.***.20这个IP与服务器的网卡eth1交互的数据量,单位是Byte。

界面说明:

"<="与"=>",表示的是流量的方向

"TX":从网卡发出的流量

"RX":网卡接收流量

"TOTAL":网卡发送接收总流量

"cum":iftop开始运行到当前时间点的总流量

"peak":网卡流量峰值

"rates":分别表示最近2s、10s、40s的平均流量

可以通过键盘的"q"键退出iftop

64位CentOS64安装配置流量监控工具ntopng

ntopng是网络流量实时监控显示工具,能够自动从网络上识别有用的信息,不少人在安装的时候出现了不少问题,下面小编就给大家介绍下CentOS 6.4如何安装ntopng,一起来了解下吧。

64位CentOS 6.4安装网络监控 ntopng

1、配置默认yum源

实验使用阿里的镜像

1、备份

mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.def

2、下载新的CentOS-Base.repo到/etc/yum.repos.d/

CentOS 5

wget-O/etc/yum.repos.d/CentOS-Base.repo

CentOS 6

wget-O/etc/yum.repos.d/CentOS-Base.repo

3、之后运行yum makecache生成缓存

2、安装epel源及给国内镜像

1、下载安装

wget

chmod u+x epel-release-6-8.noarch.rpm

rpm-ivh epel-release-6-8.noarch.rpm

2、备份(如有配置其他epel源)

mv/etc/yum.repos.d/epel.repo/etc/yum.repos.d/epel.repo.backup

mv/etc/yum.repos.d/epel-testing.repo/etc/yum.repos.d/epel-testing.repo.backup

3、下载新repo到/etc/yum.repos.d/

epel(RHEL 6)

wget-O/etc/yum.repos.d/epel.repo

3、安装依赖库

yum install libpcap-devel glib2-devel GeoIP GeoIP-devel libxml2-devel libxml2-devel redis wget rrdtool

下载安装libzmq3,网站为:

wget

chmod u+x libzmq3-3.2.2-5.1.x86_64.rpm

rpm-ivh libzmq3-3.2.2-5.1.x86_64.rpm

解决如下出错:

[root@net1~]# rpm-ivh ntopng-1.2.2-8420.x86_64.rpm

warning: ntopng-1.2.2-8420.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7921df34: NOKEY

error: Failed dependencies:

librrd.so.4()(64bit) is needed by ntopng-1.2.2-8420.x86_64

libzmq.so.3()(64bit) is needed by ntopng-1.2.2-8420.x86_64

rrdtool》= 1.3.8 is needed by ntopng-1.2.2-8420.x86_64

4、安装及配置ntopng

1、下载

网站:

wget

wget

2、安装

chmod u+x ntopng-1.2.2-8420.x86_64.rpm ntopng-data-1.2.2-8420.noarch.rpm

rpm-ivh ntopng-1.2.2-8420.x86_64.rpm

rpm-ivh ntopng-data-1.2.2-8420.noarch.rpm

5、配置ntopng

1、查看默认配置文件

[root@net1~]# cd/etc/ntopng/

[root@net1 ntopng]# ls

ntopng.conf.sample ntopng.start

注,ntopng.conf.sample文件是配置文件样例,ntopng.start是ntopng启动时需要的配置文件(测试的ntopng版本此文件为空)。

[root@net1 ntopng]# cat ntopng.conf.sample

-G=/var/tmp/ntopng.gid

注,-G指定运行所用进程号文件。

修改后的内容为:

[root@net1 ntopng]# cat ntopng.conf

-G=/var/tmp/ntopng.pid

--local-networks“10.1.1.0/24”

--interface eth1

--user nobody

--http-port 8888

注,--local-network“指定本地子网段”;--interface eth1指定监听eth1网卡上的流量;--user z指定ntopng运行时使用的账户为nobody;--http-port指定web服务端口为8888,如果不指定默认为3000。

6、启动ntopng

注,在运行ntopng之前,要确认先启动redis服务,redis为ntopng提供键值存储。我们这边重新启动一下redis服务。

service redis start

service ntopng start

7、测试访问一下

默认的用户名和密码是admin。

上面就是CentOS 6.4安装ntopng的介绍了,在安装完ntopng后,记得要测试访问,且在安装前,需要配置yum源并进行相关备份。

阅读剩余
THE END