【发布时间】:2022-01-22 20:50:37
【问题描述】:
我正在尝试获取在 nginx access.log 中找到的 IP 地址的具体出现次数。 access.log格式如下
xxx.xxx.xxx.xxx - - [21/Dec/2021:12:59:30 +0100] "GET /<some/path/on/webserver>" 200 1028 "<referrer>" "Mozilla/5.0 (Linux; Android 11; SM-A202F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.104 Mobile Safari/537.36" "-"
我目前使用的awk是
awk '$7 ~ /^\/rest\/default\/V1\/products-render-info?/ {print $1, $5}' /var/log/nginx/access.log.1 | sort -u > test.txt
并且保存在文本文件中的结果是,只有唯一的 IP 地址,
127.0.0.1
/rest/default/V1/products-render-info?searchCriteria.... <snip>
但是,我想知道 IP 地址的出现次数以及类似
127.0.0.1
<number of times this IP address has been found in the access.log>
/rest/default/V1/products-render-info?searchCriteria.... <snip>
非常感谢任何帮助!
谢谢
【问题讨论】: