dargslan-socket-stats 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dargslan_socket_stats-1.0.0/PKG-INFO +66 -0
- dargslan_socket_stats-1.0.0/README.md +44 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats/__init__.py +187 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats/cli.py +105 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats.egg-info/PKG-INFO +66 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats.egg-info/SOURCES.txt +9 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats.egg-info/dependency_links.txt +1 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats.egg-info/entry_points.txt +2 -0
- dargslan_socket_stats-1.0.0/dargslan_socket_stats.egg-info/top_level.txt +1 -0
- dargslan_socket_stats-1.0.0/pyproject.toml +32 -0
- dargslan_socket_stats-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dargslan-socket-stats
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Linux socket statistics analyzer — TCP/UDP/Unix socket states, connection tracking, and network diagnostics.
|
|
5
|
+
Author-email: Dargslan <info@dargslan.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://dargslan.com
|
|
8
|
+
Project-URL: Documentation, https://dargslan.com/blog
|
|
9
|
+
Project-URL: Repository, https://github.com/Dargslan
|
|
10
|
+
Project-URL: Free Cheat Sheets, https://dargslan.com/cheat-sheets
|
|
11
|
+
Project-URL: Linux & DevOps Books, https://dargslan.com/books
|
|
12
|
+
Keywords: linux,socket,network,tcp,udp,monitoring,sysadmin,diagnostics
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: System :: Networking
|
|
19
|
+
Classifier: Topic :: System :: Monitoring
|
|
20
|
+
Requires-Python: >=3.7
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# dargslan-socket-stats
|
|
24
|
+
|
|
25
|
+
Linux socket statistics analyzer — TCP/UDP/Unix socket states, connection tracking, listening ports, and network diagnostics.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install dargslan-socket-stats
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
dargslan-socket report # Full socket statistics report
|
|
37
|
+
dargslan-socket tcp # TCP connections
|
|
38
|
+
dargslan-socket udp # UDP sockets
|
|
39
|
+
dargslan-socket listen # Listening sockets
|
|
40
|
+
dargslan-socket states # TCP state breakdown
|
|
41
|
+
dargslan-socket audit # Issues only
|
|
42
|
+
dargslan-socket json # JSON output
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- TCP connection state analysis (ESTABLISHED, TIME-WAIT, CLOSE-WAIT)
|
|
48
|
+
- UDP socket listing with process info
|
|
49
|
+
- Listening socket inventory
|
|
50
|
+
- Detect high TIME-WAIT and CLOSE-WAIT counts
|
|
51
|
+
- Receive queue overflow detection
|
|
52
|
+
- Zero dependencies — pure Python
|
|
53
|
+
|
|
54
|
+
## Part of dargslan-toolkit
|
|
55
|
+
|
|
56
|
+
Install all 48 Linux sysadmin tools: `pip install dargslan-toolkit`
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- [Free Linux Cheat Sheets](https://dargslan.com/cheat-sheets)
|
|
61
|
+
- [Linux & DevOps Books](https://dargslan.com/books)
|
|
62
|
+
- [Blog & Tutorials](https://dargslan.com/blog)
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# dargslan-socket-stats
|
|
2
|
+
|
|
3
|
+
Linux socket statistics analyzer — TCP/UDP/Unix socket states, connection tracking, listening ports, and network diagnostics.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install dargslan-socket-stats
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
dargslan-socket report # Full socket statistics report
|
|
15
|
+
dargslan-socket tcp # TCP connections
|
|
16
|
+
dargslan-socket udp # UDP sockets
|
|
17
|
+
dargslan-socket listen # Listening sockets
|
|
18
|
+
dargslan-socket states # TCP state breakdown
|
|
19
|
+
dargslan-socket audit # Issues only
|
|
20
|
+
dargslan-socket json # JSON output
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- TCP connection state analysis (ESTABLISHED, TIME-WAIT, CLOSE-WAIT)
|
|
26
|
+
- UDP socket listing with process info
|
|
27
|
+
- Listening socket inventory
|
|
28
|
+
- Detect high TIME-WAIT and CLOSE-WAIT counts
|
|
29
|
+
- Receive queue overflow detection
|
|
30
|
+
- Zero dependencies — pure Python
|
|
31
|
+
|
|
32
|
+
## Part of dargslan-toolkit
|
|
33
|
+
|
|
34
|
+
Install all 48 Linux sysadmin tools: `pip install dargslan-toolkit`
|
|
35
|
+
|
|
36
|
+
## Links
|
|
37
|
+
|
|
38
|
+
- [Free Linux Cheat Sheets](https://dargslan.com/cheat-sheets)
|
|
39
|
+
- [Linux & DevOps Books](https://dargslan.com/books)
|
|
40
|
+
- [Blog & Tutorials](https://dargslan.com/blog)
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
MIT
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""dargslan-socket-stats — Linux socket statistics analyzer."""
|
|
2
|
+
|
|
3
|
+
__version__ = "1.0.0"
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
import re
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from collections import defaultdict
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _run(cmd):
|
|
14
|
+
try:
|
|
15
|
+
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
|
|
16
|
+
return r.stdout.strip()
|
|
17
|
+
except Exception:
|
|
18
|
+
return ""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_tcp_sockets():
|
|
22
|
+
sockets = []
|
|
23
|
+
out = _run("ss -tnp 2>/dev/null")
|
|
24
|
+
for line in out.splitlines()[1:]:
|
|
25
|
+
parts = line.split()
|
|
26
|
+
if len(parts) >= 5:
|
|
27
|
+
sock = {
|
|
28
|
+
"state": parts[0],
|
|
29
|
+
"recv_q": int(parts[1]) if parts[1].isdigit() else 0,
|
|
30
|
+
"send_q": int(parts[2]) if parts[2].isdigit() else 0,
|
|
31
|
+
"local": parts[3],
|
|
32
|
+
"remote": parts[4],
|
|
33
|
+
}
|
|
34
|
+
if len(parts) > 5:
|
|
35
|
+
pm = re.search(r'users:\(\("([^"]+)",pid=(\d+)', parts[5])
|
|
36
|
+
if pm:
|
|
37
|
+
sock["process"] = pm.group(1)
|
|
38
|
+
sock["pid"] = int(pm.group(2))
|
|
39
|
+
sockets.append(sock)
|
|
40
|
+
return sockets
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_udp_sockets():
|
|
44
|
+
sockets = []
|
|
45
|
+
out = _run("ss -unp 2>/dev/null")
|
|
46
|
+
for line in out.splitlines()[1:]:
|
|
47
|
+
parts = line.split()
|
|
48
|
+
if len(parts) >= 5:
|
|
49
|
+
sock = {
|
|
50
|
+
"state": parts[0],
|
|
51
|
+
"recv_q": int(parts[1]) if parts[1].isdigit() else 0,
|
|
52
|
+
"send_q": int(parts[2]) if parts[2].isdigit() else 0,
|
|
53
|
+
"local": parts[3],
|
|
54
|
+
"remote": parts[4],
|
|
55
|
+
}
|
|
56
|
+
if len(parts) > 5:
|
|
57
|
+
pm = re.search(r'users:\(\("([^"]+)",pid=(\d+)', parts[5])
|
|
58
|
+
if pm:
|
|
59
|
+
sock["process"] = pm.group(1)
|
|
60
|
+
sock["pid"] = int(pm.group(2))
|
|
61
|
+
sockets.append(sock)
|
|
62
|
+
return sockets
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_unix_sockets():
|
|
66
|
+
sockets = []
|
|
67
|
+
out = _run("ss -xlp 2>/dev/null")
|
|
68
|
+
for line in out.splitlines()[1:]:
|
|
69
|
+
parts = line.split()
|
|
70
|
+
if len(parts) >= 5:
|
|
71
|
+
sock = {
|
|
72
|
+
"state": parts[0] if not parts[0].startswith("u_") else parts[1],
|
|
73
|
+
"type": parts[0] if parts[0].startswith("u_") else "unix",
|
|
74
|
+
"local": parts[4] if len(parts) > 4 else "",
|
|
75
|
+
}
|
|
76
|
+
sockets.append(sock)
|
|
77
|
+
return sockets
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def get_listening_sockets():
|
|
81
|
+
sockets = []
|
|
82
|
+
out = _run("ss -tlnp 2>/dev/null")
|
|
83
|
+
for line in out.splitlines()[1:]:
|
|
84
|
+
parts = line.split()
|
|
85
|
+
if len(parts) >= 4:
|
|
86
|
+
sock = {
|
|
87
|
+
"state": "LISTEN",
|
|
88
|
+
"local": parts[3],
|
|
89
|
+
"protocol": "tcp",
|
|
90
|
+
}
|
|
91
|
+
if len(parts) > 5:
|
|
92
|
+
pm = re.search(r'users:\(\("([^"]+)",pid=(\d+)', ' '.join(parts[5:]))
|
|
93
|
+
if pm:
|
|
94
|
+
sock["process"] = pm.group(1)
|
|
95
|
+
sock["pid"] = int(pm.group(2))
|
|
96
|
+
sockets.append(sock)
|
|
97
|
+
out = _run("ss -ulnp 2>/dev/null")
|
|
98
|
+
for line in out.splitlines()[1:]:
|
|
99
|
+
parts = line.split()
|
|
100
|
+
if len(parts) >= 4:
|
|
101
|
+
sock = {
|
|
102
|
+
"state": "UNCONN",
|
|
103
|
+
"local": parts[3],
|
|
104
|
+
"protocol": "udp",
|
|
105
|
+
}
|
|
106
|
+
if len(parts) > 5:
|
|
107
|
+
pm = re.search(r'users:\(\("([^"]+)",pid=(\d+)', ' '.join(parts[5:]))
|
|
108
|
+
if pm:
|
|
109
|
+
sock["process"] = pm.group(1)
|
|
110
|
+
sock["pid"] = int(pm.group(2))
|
|
111
|
+
sockets.append(sock)
|
|
112
|
+
return sockets
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_state_summary():
|
|
116
|
+
out = _run("ss -s 2>/dev/null")
|
|
117
|
+
summary = {}
|
|
118
|
+
for line in out.splitlines():
|
|
119
|
+
if "TCP:" in line:
|
|
120
|
+
m = re.search(r'TCP:\s+(\d+)', line)
|
|
121
|
+
if m:
|
|
122
|
+
summary["tcp_total"] = int(m.group(1))
|
|
123
|
+
states = re.findall(r'(\w+)\s+(\d+)', line)
|
|
124
|
+
for s, c in states:
|
|
125
|
+
summary[f"tcp_{s.lower()}"] = int(c)
|
|
126
|
+
elif "UDP:" in line:
|
|
127
|
+
m = re.search(r'UDP:\s+(\d+)', line)
|
|
128
|
+
if m:
|
|
129
|
+
summary["udp_total"] = int(m.group(1))
|
|
130
|
+
return summary
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def get_connection_states():
|
|
134
|
+
states = defaultdict(int)
|
|
135
|
+
out = _run("ss -tn 2>/dev/null")
|
|
136
|
+
for line in out.splitlines()[1:]:
|
|
137
|
+
parts = line.split()
|
|
138
|
+
if parts:
|
|
139
|
+
states[parts[0]] += 1
|
|
140
|
+
return dict(states)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def generate_report():
|
|
144
|
+
tcp = get_tcp_sockets()
|
|
145
|
+
udp = get_udp_sockets()
|
|
146
|
+
listening = get_listening_sockets()
|
|
147
|
+
conn_states = get_connection_states()
|
|
148
|
+
summary = get_state_summary()
|
|
149
|
+
issues = []
|
|
150
|
+
|
|
151
|
+
time_wait = conn_states.get("TIME-WAIT", 0)
|
|
152
|
+
close_wait = conn_states.get("CLOSE-WAIT", 0)
|
|
153
|
+
if time_wait > 1000:
|
|
154
|
+
issues.append({
|
|
155
|
+
"severity": "warning",
|
|
156
|
+
"message": f"High TIME-WAIT count: {time_wait}"
|
|
157
|
+
})
|
|
158
|
+
if close_wait > 100:
|
|
159
|
+
issues.append({
|
|
160
|
+
"severity": "warning",
|
|
161
|
+
"message": f"High CLOSE-WAIT count: {close_wait} (possible connection leak)"
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
high_recv_q = [s for s in tcp if s["recv_q"] > 100]
|
|
165
|
+
if high_recv_q:
|
|
166
|
+
issues.append({
|
|
167
|
+
"severity": "warning",
|
|
168
|
+
"message": f"{len(high_recv_q)} sockets with high receive queue"
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
wildcard_listen = [s for s in listening if "0.0.0.0:" in s.get("local", "") or ":::"]
|
|
172
|
+
return {
|
|
173
|
+
"timestamp": datetime.now().isoformat(),
|
|
174
|
+
"tcp_connections": len(tcp),
|
|
175
|
+
"udp_sockets": len(udp),
|
|
176
|
+
"listening": len(listening),
|
|
177
|
+
"connection_states": conn_states,
|
|
178
|
+
"state_summary": summary,
|
|
179
|
+
"listening_sockets": listening,
|
|
180
|
+
"issues": issues,
|
|
181
|
+
"issues_count": len(issues),
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def audit():
|
|
186
|
+
report = generate_report()
|
|
187
|
+
return report["issues"]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""CLI for dargslan-socket-stats."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import json
|
|
5
|
+
from . import generate_report, get_tcp_sockets, get_udp_sockets, get_listening_sockets, get_connection_states, audit, __version__
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def print_report(data):
|
|
9
|
+
print(f"Socket Statistics Report")
|
|
10
|
+
print(f"{'=' * 60}")
|
|
11
|
+
print(f"Timestamp: {data['timestamp']}")
|
|
12
|
+
print(f"TCP Connections: {data['tcp_connections']}")
|
|
13
|
+
print(f"UDP Sockets: {data['udp_sockets']}")
|
|
14
|
+
print(f"Listening: {data['listening']}")
|
|
15
|
+
print()
|
|
16
|
+
|
|
17
|
+
if data["connection_states"]:
|
|
18
|
+
print("TCP Connection States:")
|
|
19
|
+
print(f"{'-' * 40}")
|
|
20
|
+
for state, count in sorted(data["connection_states"].items(), key=lambda x: x[1], reverse=True):
|
|
21
|
+
bar = "#" * min(count, 40)
|
|
22
|
+
print(f" {state:<15} {count:>6} {bar}")
|
|
23
|
+
print()
|
|
24
|
+
|
|
25
|
+
if data["listening_sockets"]:
|
|
26
|
+
print("Listening Sockets:")
|
|
27
|
+
print(f"{'-' * 40}")
|
|
28
|
+
for s in data["listening_sockets"][:20]:
|
|
29
|
+
proc = s.get("process", "unknown")
|
|
30
|
+
print(f" {s['protocol']:<5} {s['local']:<25} {proc}")
|
|
31
|
+
print()
|
|
32
|
+
|
|
33
|
+
if data["issues"]:
|
|
34
|
+
print(f"Issues Found: {data['issues_count']}")
|
|
35
|
+
for issue in data["issues"]:
|
|
36
|
+
print(f" [{issue['severity'].upper()}] {issue['message']}")
|
|
37
|
+
else:
|
|
38
|
+
print("No issues found.")
|
|
39
|
+
|
|
40
|
+
print(f"\nMore Linux tools: https://dargslan.com/cheat-sheets")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main():
|
|
44
|
+
args = sys.argv[1:]
|
|
45
|
+
if not args or args[0] in ("-h", "--help"):
|
|
46
|
+
print(f"dargslan-socket-stats v{__version__}")
|
|
47
|
+
print(f"Linux socket statistics analyzer")
|
|
48
|
+
print(f"\nUsage: dargslan-socket <command>")
|
|
49
|
+
print(f"\nCommands:")
|
|
50
|
+
print(f" report Full socket statistics report")
|
|
51
|
+
print(f" tcp TCP connections only")
|
|
52
|
+
print(f" udp UDP sockets only")
|
|
53
|
+
print(f" listen Listening sockets")
|
|
54
|
+
print(f" states TCP connection state breakdown")
|
|
55
|
+
print(f" audit Security audit (issues only)")
|
|
56
|
+
print(f" json Full report as JSON")
|
|
57
|
+
print(f" version Show version")
|
|
58
|
+
print(f"\nhttps://dargslan.com — Linux & DevOps Books")
|
|
59
|
+
return
|
|
60
|
+
|
|
61
|
+
cmd = args[0]
|
|
62
|
+
if cmd == "version":
|
|
63
|
+
print(f"dargslan-socket-stats v{__version__}")
|
|
64
|
+
elif cmd == "report":
|
|
65
|
+
print_report(generate_report())
|
|
66
|
+
elif cmd == "tcp":
|
|
67
|
+
socks = get_tcp_sockets()
|
|
68
|
+
print(f"TCP Connections: {len(socks)}")
|
|
69
|
+
for s in socks[:30]:
|
|
70
|
+
proc = s.get("process", "?")
|
|
71
|
+
print(f" {s['state']:<13} {s['local']:<25} → {s['remote']:<25} {proc}")
|
|
72
|
+
elif cmd == "udp":
|
|
73
|
+
socks = get_udp_sockets()
|
|
74
|
+
print(f"UDP Sockets: {len(socks)}")
|
|
75
|
+
for s in socks[:30]:
|
|
76
|
+
proc = s.get("process", "?")
|
|
77
|
+
print(f" {s['local']:<25} → {s['remote']:<25} {proc}")
|
|
78
|
+
elif cmd == "listen":
|
|
79
|
+
socks = get_listening_sockets()
|
|
80
|
+
print(f"Listening Sockets: {len(socks)}")
|
|
81
|
+
for s in socks:
|
|
82
|
+
proc = s.get("process", "?")
|
|
83
|
+
print(f" {s['protocol']:<5} {s['local']:<30} {proc}")
|
|
84
|
+
elif cmd == "states":
|
|
85
|
+
states = get_connection_states()
|
|
86
|
+
total = sum(states.values())
|
|
87
|
+
print(f"TCP Connection States (total: {total}):")
|
|
88
|
+
for state, count in sorted(states.items(), key=lambda x: x[1], reverse=True):
|
|
89
|
+
pct = (count / total * 100) if total > 0 else 0
|
|
90
|
+
print(f" {state:<15} {count:>6} ({pct:.1f}%)")
|
|
91
|
+
elif cmd == "audit":
|
|
92
|
+
issues = audit()
|
|
93
|
+
if not issues:
|
|
94
|
+
print("No issues found.")
|
|
95
|
+
for i in issues:
|
|
96
|
+
print(f"[{i['severity'].upper()}] {i['message']}")
|
|
97
|
+
elif cmd == "json":
|
|
98
|
+
print(json.dumps(generate_report(), indent=2))
|
|
99
|
+
else:
|
|
100
|
+
print(f"Unknown command: {cmd}. Use --help for usage.")
|
|
101
|
+
sys.exit(1)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if __name__ == "__main__":
|
|
105
|
+
main()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dargslan-socket-stats
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Linux socket statistics analyzer — TCP/UDP/Unix socket states, connection tracking, and network diagnostics.
|
|
5
|
+
Author-email: Dargslan <info@dargslan.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://dargslan.com
|
|
8
|
+
Project-URL: Documentation, https://dargslan.com/blog
|
|
9
|
+
Project-URL: Repository, https://github.com/Dargslan
|
|
10
|
+
Project-URL: Free Cheat Sheets, https://dargslan.com/cheat-sheets
|
|
11
|
+
Project-URL: Linux & DevOps Books, https://dargslan.com/books
|
|
12
|
+
Keywords: linux,socket,network,tcp,udp,monitoring,sysadmin,diagnostics
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: System :: Networking
|
|
19
|
+
Classifier: Topic :: System :: Monitoring
|
|
20
|
+
Requires-Python: >=3.7
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# dargslan-socket-stats
|
|
24
|
+
|
|
25
|
+
Linux socket statistics analyzer — TCP/UDP/Unix socket states, connection tracking, listening ports, and network diagnostics.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install dargslan-socket-stats
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
dargslan-socket report # Full socket statistics report
|
|
37
|
+
dargslan-socket tcp # TCP connections
|
|
38
|
+
dargslan-socket udp # UDP sockets
|
|
39
|
+
dargslan-socket listen # Listening sockets
|
|
40
|
+
dargslan-socket states # TCP state breakdown
|
|
41
|
+
dargslan-socket audit # Issues only
|
|
42
|
+
dargslan-socket json # JSON output
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- TCP connection state analysis (ESTABLISHED, TIME-WAIT, CLOSE-WAIT)
|
|
48
|
+
- UDP socket listing with process info
|
|
49
|
+
- Listening socket inventory
|
|
50
|
+
- Detect high TIME-WAIT and CLOSE-WAIT counts
|
|
51
|
+
- Receive queue overflow detection
|
|
52
|
+
- Zero dependencies — pure Python
|
|
53
|
+
|
|
54
|
+
## Part of dargslan-toolkit
|
|
55
|
+
|
|
56
|
+
Install all 48 Linux sysadmin tools: `pip install dargslan-toolkit`
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- [Free Linux Cheat Sheets](https://dargslan.com/cheat-sheets)
|
|
61
|
+
- [Linux & DevOps Books](https://dargslan.com/books)
|
|
62
|
+
- [Blog & Tutorials](https://dargslan.com/blog)
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
dargslan_socket_stats/__init__.py
|
|
4
|
+
dargslan_socket_stats/cli.py
|
|
5
|
+
dargslan_socket_stats.egg-info/PKG-INFO
|
|
6
|
+
dargslan_socket_stats.egg-info/SOURCES.txt
|
|
7
|
+
dargslan_socket_stats.egg-info/dependency_links.txt
|
|
8
|
+
dargslan_socket_stats.egg-info/entry_points.txt
|
|
9
|
+
dargslan_socket_stats.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dargslan_socket_stats
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dargslan-socket-stats"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Linux socket statistics analyzer — TCP/UDP/Unix socket states, connection tracking, and network diagnostics."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.7"
|
|
12
|
+
authors = [{name = "Dargslan", email = "info@dargslan.com"}]
|
|
13
|
+
keywords = ["linux", "socket", "network", "tcp", "udp", "monitoring", "sysadmin", "diagnostics"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: System Administrators",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: POSIX :: Linux",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: System :: Networking",
|
|
21
|
+
"Topic :: System :: Monitoring",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://dargslan.com"
|
|
26
|
+
Documentation = "https://dargslan.com/blog"
|
|
27
|
+
Repository = "https://github.com/Dargslan"
|
|
28
|
+
"Free Cheat Sheets" = "https://dargslan.com/cheat-sheets"
|
|
29
|
+
"Linux & DevOps Books" = "https://dargslan.com/books"
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
dargslan-socket = "dargslan_socket_stats.cli:main"
|