Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds metrics and tests for UDP receive and send buffer errors #1534

Merged
merged 6 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions collector/fixtures/e2e-64k-page-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,12 @@ node_netstat_Udp6_NoPorts 0
# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams.
# TYPE node_netstat_Udp6_OutDatagrams untyped
node_netstat_Udp6_OutDatagrams 0
# HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors.
# TYPE node_netstat_Udp6_RcvbufErrors untyped
node_netstat_Udp6_RcvbufErrors 9
# HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors.
# TYPE node_netstat_Udp6_SndbufErrors untyped
node_netstat_Udp6_SndbufErrors 8
# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors.
# TYPE node_netstat_UdpLite6_InErrors untyped
node_netstat_UdpLite6_InErrors 0
Expand All @@ -1906,6 +1912,12 @@ node_netstat_Udp_NoPorts 120
# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams.
# TYPE node_netstat_Udp_OutDatagrams untyped
node_netstat_Udp_OutDatagrams 53028
# HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors.
# TYPE node_netstat_Udp_RcvbufErrors untyped
node_netstat_Udp_RcvbufErrors 9
# HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors.
# TYPE node_netstat_Udp_SndbufErrors untyped
node_netstat_Udp_SndbufErrors 8
# HELP node_network_address_assign_type address_assign_type value of /sys/class/net/<iface>.
# TYPE node_network_address_assign_type gauge
node_network_address_assign_type{device="eth0"} 3
Expand Down
12 changes: 12 additions & 0 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,12 @@ node_netstat_Udp6_NoPorts 0
# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams.
# TYPE node_netstat_Udp6_OutDatagrams untyped
node_netstat_Udp6_OutDatagrams 0
# HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors.
# TYPE node_netstat_Udp6_RcvbufErrors untyped
node_netstat_Udp6_RcvbufErrors 9
# HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors.
# TYPE node_netstat_Udp6_SndbufErrors untyped
node_netstat_Udp6_SndbufErrors 8
# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors.
# TYPE node_netstat_UdpLite6_InErrors untyped
node_netstat_UdpLite6_InErrors 0
Expand All @@ -1906,6 +1912,12 @@ node_netstat_Udp_NoPorts 120
# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams.
# TYPE node_netstat_Udp_OutDatagrams untyped
node_netstat_Udp_OutDatagrams 53028
# HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors.
# TYPE node_netstat_Udp_RcvbufErrors untyped
node_netstat_Udp_RcvbufErrors 9
# HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors.
# TYPE node_netstat_Udp_SndbufErrors untyped
node_netstat_Udp_SndbufErrors 8
# HELP node_network_address_assign_type address_assign_type value of /sys/class/net/<iface>.
# TYPE node_network_address_assign_type gauge
node_network_address_assign_type{device="eth0"} 3
Expand Down
2 changes: 1 addition & 1 deletion collector/fixtures/proc/net/snmp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ IcmpMsg: 104 120
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0
Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors
Udp: 88542 120 0 53028 0 0 0
Udp: 88542 120 0 53028 9 8 0
UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors
UdpLite: 0 0 0 0 0 0 0
4 changes: 2 additions & 2 deletions collector/fixtures/proc/net/snmp6
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Udp6InDatagrams 0
Udp6NoPorts 0
Udp6InErrors 0
Udp6OutDatagrams 0
Udp6RcvbufErrors 0
Udp6SndbufErrors 0
Udp6RcvbufErrors 9
Udp6SndbufErrors 8
Udp6InCsumErrors 0
Udp6IgnoredMulti 0
UdpLite6InDatagrams 0
Expand Down
2 changes: 1 addition & 1 deletion collector/netstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
)

var (
netStatFields = kingpin.Flag("collector.netstat.fields", "Regexp of fields to return for netstat collector.").Default("^(.*_(InErrors|InErrs)|Ip_Forwarding|Ip(6|Ext)_(InOctets|OutOctets)|Icmp6?_(InMsgs|OutMsgs)|TcpExt_(Listen.*|Syncookies.*|TCPSynRetrans)|Tcp_(ActiveOpens|InSegs|OutSegs|PassiveOpens|RetransSegs|CurrEstab)|Udp6?_(InDatagrams|OutDatagrams|NoPorts))$").String()
netStatFields = kingpin.Flag("collector.netstat.fields", "Regexp of fields to return for netstat collector.").Default("^(.*_(InErrors|InErrs)|Ip_Forwarding|Ip(6|Ext)_(InOctets|OutOctets)|Icmp6?_(InMsgs|OutMsgs)|TcpExt_(Listen.*|Syncookies.*|TCPSynRetrans)|Tcp_(ActiveOpens|InSegs|OutSegs|PassiveOpens|RetransSegs|CurrEstab)|Udp6?_(InDatagrams|OutDatagrams|NoPorts|RcvbufErrors|SndbufErrors))$").String()
)

type netStatCollector struct {
Expand Down
30 changes: 30 additions & 0 deletions collector/netstat_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

func TestNetStats(t *testing.T) {
testNetStats(t, "fixtures/proc/net/netstat")
testSNMPStats(t, "fixtures/proc/net/snmp")
testSNMP6Stats(t, "fixtures/proc/net/snmp6")
}

Expand All @@ -44,6 +45,27 @@ func testNetStats(t *testing.T, fileName string) {
}
}

func testSNMPStats(t *testing.T, fileName string) {
file, err := os.Open(fileName)
if err != nil {
t.Fatal(err)
}
defer file.Close()

snmpStats, err := parseNetStats(file, fileName)
if err != nil {
t.Fatal(err)
}

if want, got := "9", snmpStats["Udp"]["RcvbufErrors"]; want != got {
t.Errorf("want netstat Udp RcvbufErrors %s, got %s", want, got)
}

if want, got := "8", snmpStats["Udp"]["SndbufErrors"]; want != got {
t.Errorf("want netstat Udp SndbufErrors %s, got %s", want, got)
}
}

func testSNMP6Stats(t *testing.T, fileName string) {
file, err := os.Open(fileName)
if err != nil {
Expand All @@ -63,4 +85,12 @@ func testSNMP6Stats(t *testing.T, fileName string) {
if want, got := "8", snmp6Stats["Icmp6"]["OutMsgs"]; want != got {
t.Errorf("want netstat ICPM6 OutMsgs %s, got %s", want, got)
}

if want, got := "9", snmp6Stats["Udp6"]["RcvbufErrors"]; want != got {
t.Errorf("want netstat Udp6 RcvbufErrors %s, got %s", want, got)
}

if want, got := "8", snmp6Stats["Udp6"]["SndbufErrors"]; want != got {
t.Errorf("want netstat Udp6 SndbufErrors %s, got %s", want, got)
}
}