如何在Linux下统计高速网络中的流量
举个例子,eth0的网口上分析报告会输出到这些文件中:
/sys/class/net/eth0/statistics/rx_packets: 收到的数据包数据
/sys/class/net/eth0/statistics/tx_packets: 传输的数据包数量
/sys/class/net/eth0/statistics/rx_bytes: 接收的字节数
/sys/class/net/eth0/statistics/tx_bytes: 传输的字节数
/sys/class/net/eth0/statistics/rx_dropped: 收包时丢弃的数据包
/sys/class/net/eth0/statistics/tx_dropped: 发包时丢弃的数据包
netpps.sh---测量网口每秒数据包
if [ -z "$1" ]; then
echo usage: $0 [network-interface]
echo e.g. $0 eth0
echo shows packets-per-second
exit
fi
while true
do
R1=`cat /sys/class/net/$1/statistics/rx_packets`
T1=`cat /sys/class/net/$1/statistics/tx_packets`
sleep $INTERVAL
R2=`cat /sys/class/net/$1/statistics/rx_packets`
T2=`cat /sys/class/net/$1/statistics/tx_packets`
TXPPS=`expr $T2 - $T1`
RXPPS=`expr $R2 - $R1`
echo "TX $1: $TXPPS pkts/s RX $1: $RXPPS pkts/s"
done
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
echo
exit
fi
IF=$1
while true
do
R1=`cat /sys/class/net/$1/statistics/rx_bytes`
T1=`cat /sys/class/net/$1/statistics/tx_bytes`
sleep $INTERVAL
R2=`cat /sys/class/net/$1/statistics/rx_bytes`
T2=`cat /sys/class/net/$1/statistics/tx_bytes`
TBPS=`expr $T2 - $T1`
RBPS=`expr $R2 - $R1`
TKBPS=`expr $TBPS / 1024`
RKBPS=`expr $RBPS / 1024`
echo "TX $1: $TKBPS kb/s RX $1: $RKBPS kb/s"
done
如何在Linux下统计高速网络中的流量的更多相关文章
- Linux下统计高速网络中的流量
netpps.sh统计每秒数据量,包含接收(RX)或发送(TX) netpps.sh eth0 #!/bin/bash INTERVAL=" # update interval in sec ...
- 如何在Linux下写无线网卡的驱动【转】
转自:http://www.crifan.com/files/doc/docbook/linux_wireless/release/html/linux_wireless.html 版本:v0.3 H ...
- 如何在Linux下使用Rsync
如何在Linux下使用Rsync 吐槽 昨天对scp进行总结之后看到最后有说到Rsync,俗语有云:好奇心害死猫.抱着学习的态度将Rsync给找了出来,然后进行了一些简单的学习.下面介绍一些个常用的命 ...
- 一步一步教你如何在linux下配置apache+tomcat(转)
一步一步教你如何在linux下配置apache+tomcat 一.安装前准备. 1. 所有组件都安装到/usr/local/e789目录下 2. 解压缩命令:tar —vxzf 文件名(. ...
- Linux下统计出现次数最多的指定字段值
假设桌面上有一个叫“data.txt”的文本,内容如下: {id='xxx' info='xxx' kk='xxx' target='111111' dd='xxx'}{id='xxx' info=' ...
- Linux下高并发网络编程
Linux下高并发网络编程 1.修改用户进程可打开文件数限制 在Linux平台上,无论编写客户端程序还是服务端程序,在进行高并发TCP连接处理时, 最高的并发数量都要受到系统对用户单一进程同时可打 ...
- 如何在linux下开启FTP服务
如何在linux下开启FTP服务 1. 首先服务器要安装ftp软件,查看是否已经安装ftp软件下: #which vsftpd 如果看到有vsftpd的目录说明服务器已经安装了ftp软件 2. ...
- Dcloud课程6 php脚本如何在Linux下定时更新数据
Dcloud课程6 php脚本如何在Linux下定时更新数据 一.总结 一句话总结:linux下用crontab命令实现定时任务. 1.linux下执行php脚本用什么命令? 直接用php命令php ...
- 如何在Linux下安装JDK1.8
本文会详细介绍如何在Linux下安装JDK1.8 首先要设置虚拟机的IP地址,不知道如何设置的话可以 翻看我的前一篇博客 http://www.cnblogs.com/xiaoxiaoSMILE/ ...
随机推荐
- [Interview] 程序员如何制作一份漂亮的面试简历
简历模板 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; ...
- springmvc-框架学习
https://www.androiddev.net/springmvc-框架学习一-helloworld/
- vs 代理登入
https://msdn.microsoft.com/zh-cn/vstudio/dn771556.aspx
- ASP.NET Core 1.0基础之静态文件处理
来源 这些HTML , CSS files, image files, 和JavaScript这些静态文件,是ASP.NET能够直接响应给客户端的.本文详述下ASP.NET和静态文件的关系. Serv ...
- iOS开发学习 阶段过程简述
下面就简单介绍一下我iOS开发的感受,也是学习iOS开发的一个体系架构. 1 iOS开发环境 1.1 开发环境 标准的配置是Mac OS X + Xcode. MacOSX的话首选用苹果电脑,macm ...
- html语义化小记录
1.头部标签 <header></header> 2.大块集合 <article></article> 3.主要集和 <main></ ...
- JS 创建长度为100的数组,数值为角标
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 46. Permutations 排列数
46. Permutations 题目 Given a collection of distinct numbers, return all possible permutations. For ex ...
- Python 爬基金数据
爬科学基金共享服务网中基金数据 #coding=utf-8 import json import requests from lxml import etree from HTMLParser imp ...
- [TypeScript] Dynamically initialize class properties using TypeScript decorators
Decorators are a powerful feature of TypeScript that allow for efficient and readable abstractions w ...