当前位置:网站首页>[TCP] TCP connection status JSON output on the server
[TCP] TCP connection status JSON output on the server
2022-07-05 10:53:00 【HunterMichaelG】
print_tcp_conection.sh
#!/bin/bash
STATS=(UNKNOWN:0 ESTABLISHED:0 SYN_SENT:0 SYN_RECV:0 FIN_WAIT1:0 FIN_WAIT2:0 TIME_WAIT:0 CLOSED:0 CLOSE_WAIT:0 LAST_ACK:0 LISTEN:0 CLOSING:0)
CONN="$(awk '{print $4}' /proc/net/tcp /proc/net/tcp6 | grep -v st | sort | uniq -c | sed -e s/' 0'/' '/g -e s/'A'/'10'/g -e s/'B'/'11'/g | awk '{print $2":"$1}')"
if [ ! -z "$CONN" ];then
for s in $CONN
do
STATS[${s%%:*}]=${STATS[${s%%:*}]%%:*}":"${s#*:}
done
fi
echo ${STATS[@]} | sed -e s/' '/',"'/g -e s/':'/'":'/g -e s/^/'{"tcp_conn":{"'/g -e s/'WAIT_'/'WAIT'/g -e s/'$'/'}}'/g
# sh print_tcp_conection.sh
{"tcp_conn":{"UNKNOWN":0,"ESTABLISHED":4,"SYN_SENT":0,"SYN_RECV":0,"FIN_WAIT1":0,"FIN_WAIT2":0,"TIME_WAIT":0,"CLOSED":0,"CLOSE_WAIT":0,"LAST_ACK":0,"LISTEN":6,"CLOSING":0}}
# sh print_tcp_conection.sh | python -m json.tool
{
"tcp_conn": {
"CLOSED": 0,
"CLOSE_WAIT": 0,
"CLOSING": 0,
"ESTABLISHED": 4,
"FIN_WAIT1": 0,
"FIN_WAIT2": 0,
"LAST_ACK": 0,
"LISTEN": 6,
"SYN_RECV": 0,
"SYN_SENT": 0,
"TIME_WAIT": 0,
"UNKNOWN": 0
}
}
边栏推荐
- NAS与SAN
- 一次edu证书站的挖掘
- Process control
- 32: Chapter 3: development of pass service: 15: Browser storage media, introduction; (cookie,Session Storage,Local Storage)
- 【广告系统】Parameter Server分布式训练
- 基于昇腾AI丨以萨技术推出视频图像全目标结构化解决方案,达到业界领先水平
- 使用GBase 8c数据库过程中报错:80000502,Cluster:%s is busy,是怎么回事?
- 【js学习笔记五十四】BFC方式
- A mining of edu certificate station
- PWA (Progressive Web App)
猜你喜欢
Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
About the use of Vray 5.2 (self research notes) (II)
2022 Pengcheng cup Web
2022鹏城杯web
2022 mobile crane driver examination question bank and simulation examination
关于 “原型” 的那些事你真的理解了吗?【上篇】
Talk about the understanding of fault tolerance mechanism and state consistency in Flink framework
[observation] with the rise of the "independent station" model of cross-border e-commerce, how to seize the next dividend explosion era?
双向RNN与堆叠的双向RNN
随机推荐
Do you really understand the things about "prototype"? [part I]
Applet framework taro
iframe
Honing · fusion | know that the official website of Chuangyu mobile terminal is newly launched, and start the journey of digital security!
关于vray 5.2的使用(自研笔记)
Bracket matching problem (STL)
PWA (Progressive Web App)
DOM//
【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
vite//
go语言学习笔记-初识Go语言
LSTM applied to MNIST dataset classification (compared with CNN)
Process control
谈谈对Flink框架中容错机制及状态的一致性的理解
Solution to the length of flex4 and Flex3 combox drop-down box
Go language learning notes - first acquaintance with go language
How can gbase 8C database view the login information of the login user, such as the date, time and IP of the last login authentication?
字符串、、
2022鹏城杯web
DGL中的消息传递相关内容的讲解