mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Report persistent connections in states other than ESTABLISHED
This aligns the `/proc` connection tracking (persistent connections) with conntrack (short-lived connections).
This commit is contained in:
@@ -9,17 +9,15 @@ import (
|
||||
type ProcNet struct {
|
||||
b []byte
|
||||
c Connection
|
||||
wantedState uint
|
||||
bytesLocal, bytesRemote [16]byte
|
||||
seen map[uint64]struct{}
|
||||
}
|
||||
|
||||
// NewProcNet gives a new ProcNet parser.
|
||||
func NewProcNet(b []byte, wantedState uint) *ProcNet {
|
||||
func NewProcNet(b []byte) *ProcNet {
|
||||
return &ProcNet{
|
||||
b: b,
|
||||
c: Connection{},
|
||||
wantedState: wantedState,
|
||||
seen: map[uint64]struct{}{},
|
||||
}
|
||||
}
|
||||
@@ -40,16 +38,12 @@ again:
|
||||
}
|
||||
|
||||
var (
|
||||
local, remote, state, inode []byte
|
||||
local, remote, inode []byte
|
||||
)
|
||||
_, b = nextField(b) // 'sl' column
|
||||
local, b = nextField(b)
|
||||
remote, b = nextField(b)
|
||||
state, b = nextField(b)
|
||||
if parseHex(state) != p.wantedState {
|
||||
p.b = nextLine(b)
|
||||
goto again
|
||||
}
|
||||
_, b = nextField(b) // 'st' column
|
||||
_, b = nextField(b) // 'tx_queue' column
|
||||
_, b = nextField(b) // 'rx_queue' column
|
||||
_, b = nextField(b) // 'tr' column
|
||||
|
||||
@@ -7,10 +7,6 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
const (
|
||||
tcpEstablished = 1 // according to /include/net/tcp_states.h
|
||||
)
|
||||
|
||||
// Connection is a (TCP) connection. The Proc struct might not be filled in.
|
||||
type Connection struct {
|
||||
Transport string
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *linuxScanner) Connections(processes bool) (ConnIter, error) {
|
||||
}
|
||||
|
||||
return &pnConnIter{
|
||||
pn: NewProcNet(buf.Bytes(), tcpEstablished),
|
||||
pn: NewProcNet(buf.Bytes()),
|
||||
buf: buf,
|
||||
procs: procs,
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user