谈批处理实现网络流量实时监控
2011年7月12日
| 发布: admin
点击图片查看更多内容
Linux 有个大牛写个了Shell可以查看实时的流量,根据他的实现原理搬到了Windows上面。
@echo off & setlocal ENABLEDELAYEDEXPANSION
TITLE Powered By www.xtgly.com
MODE con: COLS=22 LINES=10
for /f "tokens=2,3" %%i in ('netstat -e ^|findstr "Bytes"') do (
set oldrec=%%i
set oldsent=%%j
)
:loop
echo WScript.Sleep 1000 > %temp%\tmp$$$.vbs
cscript //nologo %temp%\tmp$$$.vbs
for /f "tokens=2,3" %%i in ('netstat -e ^|findstr "Bytes"') do (
set newrec=%%i
set newsent=%%j
)
set /a rec=(%newrec%-%oldrec%)*8/1024
set /a sent=(%newsent%-%oldsent%)*8/1024
cls
echo 下载流量:%rec% kbits
echo 上传流量:%sent% kbits
set /a oldrec=newrec
set /a oldsent=newsent
goto :loop
请对我们的文章进行评论
发表评论
