initial commit

This commit is contained in:
Karol Broda
2025-12-16 22:42:49 +01:00
commit 371f4d13a6
61 changed files with 6872 additions and 0 deletions

18
cmd/testdata/golden/README.md vendored Normal file
View File

@@ -0,0 +1,18 @@
# Golden Files
This directory contains golden files for output contract verification tests.
These files are automatically generated and should not be edited manually.
To regenerate them, run:
go test ./cmd -update-golden
## Files
- *_table.golden: Table format output
- *_json.golden: JSON format output
- *_csv.golden: CSV format output
- *_wide.golden: Wide table format output
- stats_*.golden: Statistics command output
Each file represents expected output for specific test scenarios.

2
cmd/testdata/golden/csv_output.golden vendored Normal file
View File

@@ -0,0 +1,2 @@
PID,PROCESS,USER,PROTO,STATE,LADDR,LPORT,RADDR,RPORT
1234,test-app,test-user,tcp,ESTABLISHED,localhost,8080,localhost,9090

1
cmd/testdata/golden/empty_json.golden vendored Normal file
View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1 @@
PID PROCESS USER PROTO STATE LADDR LPORT RADDR RPORT

View File

@@ -0,0 +1,2 @@
PID PROCESS USER PROTO STATE LADDR LPORT RADDR RPORT
1 tcp-server tcp LISTEN 0.0.0.0 http 0

View File

@@ -0,0 +1,65 @@
[
{
"ts": "2025-01-15T10:30:00Z",
"pid": 1,
"process": "tcp-server",
"user": "",
"uid": 0,
"proto": "tcp",
"ipversion": "",
"state": "LISTEN",
"laddr": "0.0.0.0",
"lport": 80,
"raddr": "",
"rport": 0,
"interface": "eth0",
"rx_bytes": 0,
"tx_bytes": 0,
"rtt_ms": 0,
"mark": "",
"namespace": "",
"inode": 0
},
{
"ts": "2025-01-15T10:30:01Z",
"pid": 2,
"process": "udp-server",
"user": "",
"uid": 0,
"proto": "udp",
"ipversion": "",
"state": "CONNECTED",
"laddr": "0.0.0.0",
"lport": 53,
"raddr": "",
"rport": 0,
"interface": "eth0",
"rx_bytes": 0,
"tx_bytes": 0,
"rtt_ms": 0,
"mark": "",
"namespace": "",
"inode": 0
},
{
"ts": "2025-01-15T10:30:02Z",
"pid": 3,
"process": "unix-app",
"user": "",
"uid": 0,
"proto": "unix",
"ipversion": "",
"state": "CONNECTED",
"laddr": "/tmp/test.sock",
"lport": 0,
"raddr": "",
"rport": 0,
"interface": "unix",
"rx_bytes": 0,
"tx_bytes": 0,
"rtt_ms": 0,
"mark": "",
"namespace": "",
"inode": 0
}
]

View File

@@ -0,0 +1,4 @@
PID PROCESS USER PROTO STATE LADDR LPORT RADDR RPORT
1 tcp-server tcp LISTEN 0.0.0.0 http 0
2 udp-server udp CONNECTED 0.0.0.0 domain 0
3 unix-app unix CONNECTED /tmp/test.sock 0 0

View File

@@ -0,0 +1,23 @@
[
{
"ts": "2025-08-25T19:24:18.530991+02:00",
"pid": 1234,
"process": "test-app",
"user": "test-user",
"uid": 1000,
"proto": "tcp",
"ipversion": "IPv4",
"state": "ESTABLISHED",
"laddr": "127.0.0.1",
"lport": 8080,
"raddr": "127.0.0.1",
"rport": 9090,
"interface": "lo",
"rx_bytes": 1024,
"tx_bytes": 512,
"rtt_ms": 1,
"mark": "0x0",
"namespace": "init",
"inode": 99999
}
]

View File

@@ -0,0 +1,2 @@
PID PROCESS USER PROTO STATE LADDR LPORT RADDR RPORT
1234 test-app test-user tcp ESTABLISHED localhost 8080 localhost 9090

View File

@@ -0,0 +1,3 @@
TIMESTAMP NORMALIZED_TIMESTAMP
TOTAL CONNECTIONS 0

View File

@@ -0,0 +1,12 @@
timestamp,metric,key,value
NORMALIZED_TIMESTAMP,total,,3
NORMALIZED_TIMESTAMP,proto,tcp,1
NORMALIZED_TIMESTAMP,proto,udp,1
NORMALIZED_TIMESTAMP,proto,unix,1
NORMALIZED_TIMESTAMP,state,LISTEN,1
NORMALIZED_TIMESTAMP,state,CONNECTED,2
NORMALIZED_TIMESTAMP,process,tcp-server,1
NORMALIZED_TIMESTAMP,process,udp-server,1
NORMALIZED_TIMESTAMP,process,unix-app,1
NORMALIZED_TIMESTAMP,interface,eth0,2
NORMALIZED_TIMESTAMP,interface,unix,1

View File

@@ -0,0 +1,40 @@
{
"ts": "2025-08-25T19:24:18.541531+02:00",
"total": 3,
"by_proto": {
"tcp": 1,
"udp": 1,
"unix": 1
},
"by_state": {
"CONNECTED": 2,
"LISTEN": 1
},
"by_proc": [
{
"pid": 1,
"process": "tcp-server",
"count": 1
},
{
"pid": 2,
"process": "udp-server",
"count": 1
},
{
"pid": 3,
"process": "unix-app",
"count": 1
}
],
"by_if": [
{
"if": "eth0",
"count": 2
},
{
"if": "unix",
"count": 1
}
]
}

View File

@@ -0,0 +1,19 @@
TIMESTAMP NORMALIZED_TIMESTAMP
TOTAL CONNECTIONS 3
BY PROTOCOL:
PROTO COUNT
TCP 1
UDP 1
UNIX 1
BY STATE:
STATE COUNT
CONNECTED 2
LISTEN 1
BY PROCESS (TOP 10):
PID PROCESS COUNT
1 tcp-server 1
2 udp-server 1
3 unix-app 1

View File

@@ -0,0 +1,2 @@
PID PROCESS USER PROTO STATE LADDR LPORT RADDR RPORT
1 tcp-server tcp LISTEN 0.0.0.0 http 0

View File

@@ -0,0 +1,23 @@
[
{
"ts": "2025-01-15T10:30:01Z",
"pid": 2,
"process": "udp-server",
"user": "",
"uid": 0,
"proto": "udp",
"ipversion": "",
"state": "CONNECTED",
"laddr": "0.0.0.0",
"lport": 53,
"raddr": "",
"rport": 0,
"interface": "eth0",
"rx_bytes": 0,
"tx_bytes": 0,
"rtt_ms": 0,
"mark": "",
"namespace": "",
"inode": 0
}
]

2
cmd/testdata/golden/wide_table.golden vendored Normal file
View File

@@ -0,0 +1,2 @@
PID PROCESS USER PROTO STATE LADDR LPORT RADDR RPORT
1234 test-app test-user tcp ESTABLISHED localhost 8080 localhost 9090