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

How to check the number of ip connections through awk in linux system

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Today, I will talk to you about how to check the number of ip connections through awk in the linux system. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The code is as follows:

[chengmo@localhost ~] $awk 'BEGIN {

While ("netstat-an" | getline) {

If ($5 ~ / [1-255] /)

{

Split ($5 T1, ":")

Tarr [T1 [1]] + +

}

}

For (k in tarr)

{

Print KJR Tarr [k] | "sort-r-n-k2"

}

};'

$5 is the fifth field of netstat-an. By default, the other party is connected to the ip and the port.

[chengmo@localhost ~] $time awk 'BEGIN {while ("netstat-an" | getline) {if ($5 ~ / [1-255] /) {split ($5 tarr T1, ":"); tarr [T1 [1]] +;}} for (k in tarr) {print kjintarr [k] | "sort-r-n-K2";};};'

211.151.33.14 28

113.65.21.200 14

121.32.89.106 13

60.191.178.230 12

118.133.177.104 12

58.61.152.154 11

219.137.58.20 11

124.117.248.52 11

122.198.80.145 11

222.88.15.138 10

222.44.13.191 10

222.161.47.34 10

221.4.202.210 10

218.79.64.12 10

183.17.92.193 10

120.72.128.254 10

118.118.121.244 10

116.252.38.236 10

113.248.75.44 10

Real 0m1.149s

User 0m0.032s

Sys 0m1.055s

After reading the above, do you have any further understanding of how to check the number of ip connections through awk in the linux system? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report