当前位置:网站首页>[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
}
}
边栏推荐
猜你喜欢

Basic testing process of CSDN Software Testing Introduction

赛克瑞浦动力电池首台产品正式下线

2022 mobile crane driver examination question bank and simulation examination

谈谈对Flink框架中容错机制及状态的一致性的理解

Honing · fusion | know that the official website of Chuangyu mobile terminal is newly launched, and start the journey of digital security!

csdn软件测试入门的测试基本流程

微信核酸检测预约小程序系统毕业设计毕设(6)开题答辩PPT

2022 chemical automation control instrument examination questions and online simulation examination

Go语言-1-开发环境配置

Based on shengteng AI Yisa technology, it launched a full target structured solution for video images, reaching the industry-leading level
随机推荐
Explanation of message passing in DGL
DOM//
flex4 和 flex3 combox 下拉框长度的解决办法
What are the top ten securities companies? Is it safe to open an account online?
[可能没有默认的字体]Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename……
SQL Server monitoring statistics blocking script information
DOM//
Node の MongoDB Driver
BOM//
How to close the log window in vray5.2
Some understandings of heterogeneous graphs in DGL and the usage of heterogeneous graph convolution heterographconv
About the use of Vray 5.2 (self research notes) (II)
Sqlserver regularly backup database and regularly kill database deadlock solution
BOM//
SqlServer定时备份数据库和定时杀死数据库死锁解决
Network security of secondary vocational group 2021 Jiangsu provincial competition 5 sets of topics environment + analysis of all necessary private messages I
32:第三章:开发通行证服务:15:浏览器存储介质,简介;(cookie,Session Storage,Local Storage)
【tcp】服务器上tcp连接状态json形式输出
Scaffold development foundation
regular expression