We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4e60c95 commit e2a8537Copy full SHA for e2a8537
2 files changed
monitor_server/__init__.py
@@ -0,0 +1,4 @@
1
+#!/usr/bin/env python
2
+# -*- coding:utf-8 -*-
3
+__author__ = 'MFC'
4
+__time__ = '18/11/26 15:51'
monitor_server/netstat_connection.py
@@ -0,0 +1,29 @@
+__time__ = '18/11/26 15:52'
5
+
6
+import time
7
+import os
8
9
+"""
10
+脚本: 监控服务器连接状态
11
12
+usage:
13
+In terminal:
14
+python netstat_connection.py
15
16
+end:
17
+Ctrl + C
18
19
+### 查看并发连接数
20
+#### netstat -nat|grep ESTABLISHED|wc -l
21
22
+### 查看其他类型连接数
23
+#### netstat -nat|grep CLOSE_WAIT|wc -l
24
25
26
+while True:
27
+ time.sleep(0.5) # 单位:秒
28
+ os.system("clear")
29
+ os.system("netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'")
0 commit comments