Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在linux嗅探器中动态解析结果?_Linux_Sniffer_Tshark - Fatal编程技术网

如何在linux嗅探器中动态解析结果?

如何在linux嗅探器中动态解析结果?,linux,sniffer,tshark,Linux,Sniffer,Tshark,我想排序和计算客户端从我的服务器下载了多少文件(3种类型) 我安装了tshark并运行了以下命令,该命令应捕获GET请求: `./tshark 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -R'http.request.method == "GET"'` 我需要做什么来将结果类型和计数(如/pids/*****.bin存储到其他文件中)。 我

我想排序和计算客户端从我的服务器下载了多少文件(3种类型)

我安装了
tshark
并运行了以下命令,该命令应捕获
GET
请求:

`./tshark  'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -R'http.request.method == "GET"'`
我需要做什么来将结果类型和计数(如
/pids/*****.bin
存储到其他文件中)。 我在linux中不是很强,但我确信它可以用1-3行脚本来完成

也许使用
awk
,但我不知道读取嗅探器结果的技术是什么


谢谢你,

你能不能把你的Web服务器的日志文件放进去

无论如何,要提取相对于服务器文件捕获的http流量行,只需使用

./tshark  'tcp port 80 and \
           (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
           -R'http.request.method == "GET"' | \
  egrep "HTTP GET /pids/.*.bin"
/tshark'tcp端口80和\
((ip[2:2]-((ip[0]&0xf)2))!=0)\
-R'http.request.method==“GET”'|\
egrep“HTTP GET/pids/*.bin”

当然,我可以解析日志,但有时我会得到10-20G的文件大小,这会导致高CPU。因此我尝试嗅探它。如果从现在开始需要数据,只需像这样解析输出
tail-f/path/logfile | grep等
./tshark  'tcp port 80 and \
           (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
           -R'http.request.method == "GET"' | \
  egrep "HTTP GET /pids/.*.bin"