Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use awk array to count log access status and network connection status

2025-03-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Count ip and pv number visited by ip

#awk '{s[$1]++}END{for(key in s) print key,s[key]}' 12.log | sort -k2rn | head

Count the number of connections in various states of the current network

#netstat -na | awk '/^tcp/{s[$6]++}END{for(key in s) print key,s[key]}'

Note: awk also supports filtering/^tcp/filtering lines starting with tcp

Counting IP and connection times currently being established

#netstat -an | grep ESTAB | awk -F "[ :]+" '{print $6}' | sort | uniq -c

#netstat -an | grep "^tcp\>" | awk -F "[ :]+" '{s[$6]++}END{for(key in s) print key,s[key]}'

Count the number of connections in various states

netstat -an | grep "^tcp\>" | awk -F "[ :]+" '{s[$8]++}END{for(key in s) print key,s[key]}'

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report