Add collector for /proc/net/tcp
This commit is contained in:
parent
aaf01e52e2
commit
e4da771b21
4 changed files with 181 additions and 0 deletions
27
collector/tcpstat_test.go
Normal file
27
collector/tcpstat_test.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTCPStat(t *testing.T) {
|
||||
file, err := os.Open("fixtures/tcpstat")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
tcpStats, err := parseTCPStats(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := 1, int(tcpStats[TCP_ESTABLISHED]); want != got {
|
||||
t.Errorf("want tcpstat number of established state %d, got %d", want, got)
|
||||
}
|
||||
|
||||
if want, got := 1, int(tcpStats[TCP_LISTEN]); want != got {
|
||||
t.Errorf("want tcpstat number of listen state %d, got %d", want, got)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue