原文:
Linux查看网络流量的脚本
# cat stream
#! /bin/bash
# Write by Neil.xu qq:37391319 email: xurongzhong@gmail.com
# 2008-8-19 we need to monitor streams of LTS channels, so write this script
typeset in in_old dif_in dif_in1 dif_out1
typeset out out_old dif_out
in_old=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $1 }' )
out_old=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $9 }')
while true
do
sleep 1
in=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $1 }')
out=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $9 }')
dif_in=$((in-in_old))
dif_in1=$((dif_in * 8 / 1024 / 1024 ))
dif_out=$((out-out_old))
echo " IN: ${dif_in} bytes OUT: ${dif_out} bytes "
dif_out1=$((dif_out * 8 / 1024 / 1024 ))
echo "IN: ${dif_in1} mbps OUT: ${dif_out1} mbps"
in_old=${in}
out_old=${out}
done
运行效果:
# ./stream
IN: 349179 bytes OUT: 1363936 bytes
IN: 2 mbps OUT: 10 mbps
IN: 349612 bytes OUT: 1361852 bytes
IN: 2 mbps OUT: 10 mbps
IN: 348684 bytes OUT: 1358952 bytes
IN: 2 mbps OUT: 10 mbps
分享到:
相关推荐
Linux流量监控脚本 上下行流量监控shell脚本
shell脚本实现的监控linux服务器上的网卡流量的脚本,可选择网卡,可查看统计数据和连接情况
linux 网卡流量统计脚本
linux流量监控脚本
此脚本用于linux主机流量实时监控,目前提供eth0-9网卡,暂不支持虚拟化网卡,如果有需要,可以自行修改脚本。
linux性能查看脚本:可远程查看linux服务器的性能
Linux批量ping的脚本(Linux工具箱).pdf
Linux运维自动化运维脚本.zip,自动化运维脚本 介绍 Linux系统运维中各种一键脚本 使用教程 openssh一键升级脚本,支持centos6、centos7、centos8。 Linux运维自动化运维脚本.zip,自动化运维脚本 介绍 Linux系统...
Linux命令与shell 脚本大全,内容丰富,包含了shell脚本的技术命令 以及大量的实践内容
教程名称:Linux搭建网络服务命令脚本合集课程目录:【】在linux中通过脚本安装apache网站web服务(完善版)【】在linux中通过脚本安装lamp架构(完善版)【】在linux中通过脚本安装mysql数据库服务(完善版)【】在...
Linux系统基线加固脚本
Linux操作系统Shell脚本.zipLinux操作系统Shell脚本.zipLinux操作系统Shell脚本.zip Linux操作系统Shell脚本.zipLinux操作系统Shell脚本.zipLinux操作系统Shell脚本.zip Linux操作系统Shell脚本.zipLinux操作系统...
利用python语言,利用division、sys、os、signal包,监控linux系统的网络流入、流出量。实时记录网络流入总量、网络流出总量、当前网络流入速度、网络流出速度等,并记录日志
一款轻巧的流量监控脚本,本脚本都是源代码 可以直接运行。
linux脚本sftp上传文件
Linux系统安全基线检查脚本
linux抓取僵尸网络进程脚本
linux脚本+命令总结
Linux_shell脚本全面学习 Linux_shell脚本全面学习