aboutsummaryrefslogtreecommitdiff
path: root/collector
diff options
context:
space:
mode:
authorPhil Porada <pgporada@users.noreply.github.com>2020-02-19 08:41:40 -0500
committerGitHub <noreply@github.com>2020-02-19 14:41:40 +0100
commit14eafab0167483b82757adccfd221bd1d2495a54 (patch)
tree8586d3f67ee697332c6393278b24c28eef2430d4 /collector
parentcfcaeee1458f1e8dd66e155bff98716ce8d8ce76 (diff)
downloadprometheus_node_collector-14eafab0167483b82757adccfd221bd1d2495a54.tar.bz2
prometheus_node_collector-14eafab0167483b82757adccfd221bd1d2495a54.tar.xz
prometheus_node_collector-14eafab0167483b82757adccfd221bd1d2495a54.zip
Adds metrics and tests for UDP receive and send buffer errors (#1534)
* Adds metrics for UDP receive and send buffer errors Signed-off-by: Phil Porada <philporada@gmail.com>
Diffstat (limited to 'collector')
-rw-r--r--collector/fixtures/e2e-64k-page-output.txt12
-rw-r--r--collector/fixtures/e2e-output.txt12
-rw-r--r--collector/fixtures/proc/net/snmp2
-rw-r--r--collector/fixtures/proc/net/snmp64
-rw-r--r--collector/netstat_linux.go2
-rw-r--r--collector/netstat_linux_test.go30
6 files changed, 58 insertions, 4 deletions
diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt
index aab19fc..58ea964 100644
--- a/collector/fixtures/e2e-64k-page-output.txt
+++ b/collector/fixtures/e2e-64k-page-output.txt
@@ -1903,6 +1903,12 @@ node_netstat_Udp6_NoPorts 0
1903# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams. 1903# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams.
1904# TYPE node_netstat_Udp6_OutDatagrams untyped 1904# TYPE node_netstat_Udp6_OutDatagrams untyped
1905node_netstat_Udp6_OutDatagrams 0 1905node_netstat_Udp6_OutDatagrams 0
1906# HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors.
1907# TYPE node_netstat_Udp6_RcvbufErrors untyped
1908node_netstat_Udp6_RcvbufErrors 9
1909# HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors.
1910# TYPE node_netstat_Udp6_SndbufErrors untyped
1911node_netstat_Udp6_SndbufErrors 8
1906# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors. 1912# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors.
1907# TYPE node_netstat_UdpLite6_InErrors untyped 1913# TYPE node_netstat_UdpLite6_InErrors untyped
1908node_netstat_UdpLite6_InErrors 0 1914node_netstat_UdpLite6_InErrors 0
@@ -1921,6 +1927,12 @@ node_netstat_Udp_NoPorts 120
1921# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams. 1927# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams.
1922# TYPE node_netstat_Udp_OutDatagrams untyped 1928# TYPE node_netstat_Udp_OutDatagrams untyped
1923node_netstat_Udp_OutDatagrams 53028 1929node_netstat_Udp_OutDatagrams 53028
1930# HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors.
1931# TYPE node_netstat_Udp_RcvbufErrors untyped
1932node_netstat_Udp_RcvbufErrors 9
1933# HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors.
1934# TYPE node_netstat_Udp_SndbufErrors untyped
1935node_netstat_Udp_SndbufErrors 8
1924# HELP node_network_address_assign_type address_assign_type value of /sys/class/net/<iface>. 1936# HELP node_network_address_assign_type address_assign_type value of /sys/class/net/<iface>.
1925# TYPE node_network_address_assign_type gauge 1937# TYPE node_network_address_assign_type gauge
1926node_network_address_assign_type{device="eth0"} 3 1938node_network_address_assign_type{device="eth0"} 3
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt
index 38b7649..d0f49b2 100644
--- a/collector/fixtures/e2e-output.txt
+++ b/collector/fixtures/e2e-output.txt
@@ -1924,6 +1924,12 @@ node_netstat_Udp6_NoPorts 0
1924# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams. 1924# HELP node_netstat_Udp6_OutDatagrams Statistic Udp6OutDatagrams.
1925# TYPE node_netstat_Udp6_OutDatagrams untyped 1925# TYPE node_netstat_Udp6_OutDatagrams untyped
1926node_netstat_Udp6_OutDatagrams 0 1926node_netstat_Udp6_OutDatagrams 0
1927# HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors.
1928# TYPE node_netstat_Udp6_RcvbufErrors untyped
1929node_netstat_Udp6_RcvbufErrors 9
1930# HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors.
1931# TYPE node_netstat_Udp6_SndbufErrors untyped
1932node_netstat_Udp6_SndbufErrors 8
1927# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors. 1933# HELP node_netstat_UdpLite6_InErrors Statistic UdpLite6InErrors.
1928# TYPE node_netstat_UdpLite6_InErrors untyped 1934# TYPE node_netstat_UdpLite6_InErrors untyped
1929node_netstat_UdpLite6_InErrors 0 1935node_netstat_UdpLite6_InErrors 0
@@ -1942,6 +1948,12 @@ node_netstat_Udp_NoPorts 120
1942# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams. 1948# HELP node_netstat_Udp_OutDatagrams Statistic UdpOutDatagrams.
1943# TYPE node_netstat_Udp_OutDatagrams untyped 1949# TYPE node_netstat_Udp_OutDatagrams untyped
1944node_netstat_Udp_OutDatagrams 53028 1950node_netstat_Udp_OutDatagrams 53028
1951# HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors.
1952# TYPE node_netstat_Udp_RcvbufErrors untyped
1953node_netstat_Udp_RcvbufErrors 9
1954# HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors.
1955# TYPE node_netstat_Udp_SndbufErrors untyped
1956node_netstat_Udp_SndbufErrors 8
1945# HELP node_network_address_assign_type address_assign_type value of /sys/class/net/<iface>. 1957# HELP node_network_address_assign_type address_assign_type value of /sys/class/net/<iface>.
1946# TYPE node_network_address_assign_type gauge 1958# TYPE node_network_address_assign_type gauge
1947node_network_address_assign_type{device="eth0"} 3 1959node_network_address_assign_type{device="eth0"} 3
diff --git a/collector/fixtures/proc/net/snmp b/collector/fixtures/proc/net/snmp
index 80a92b4..271073a 100644
--- a/collector/fixtures/proc/net/snmp
+++ b/collector/fixtures/proc/net/snmp
@@ -7,6 +7,6 @@ IcmpMsg: 104 120
7Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors 7Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
8Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0 8Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0
9Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors 9Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors
10Udp: 88542 120 0 53028 0 0 0 10Udp: 88542 120 0 53028 9 8 0
11UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors 11UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors
12UdpLite: 0 0 0 0 0 0 0 12UdpLite: 0 0 0 0 0 0 0
diff --git a/collector/fixtures/proc/net/snmp6 b/collector/fixtures/proc/net/snmp6
index 8442d98..3640bb1 100644
--- a/collector/fixtures/proc/net/snmp6
+++ b/collector/fixtures/proc/net/snmp6
@@ -72,8 +72,8 @@ Udp6InDatagrams 0
72Udp6NoPorts 0 72Udp6NoPorts 0
73Udp6InErrors 0 73Udp6InErrors 0
74Udp6OutDatagrams 0 74Udp6OutDatagrams 0
75Udp6RcvbufErrors 0 75Udp6RcvbufErrors 9
76Udp6SndbufErrors 0 76Udp6SndbufErrors 8
77Udp6InCsumErrors 0 77Udp6InCsumErrors 0
78Udp6IgnoredMulti 0 78Udp6IgnoredMulti 0
79UdpLite6InDatagrams 0 79UdpLite6InDatagrams 0
diff --git a/collector/netstat_linux.go b/collector/netstat_linux.go
index f0aca26..9b4be49 100644
--- a/collector/netstat_linux.go
+++ b/collector/netstat_linux.go
@@ -34,7 +34,7 @@ const (
34) 34)
35 35
36var ( 36var (
37 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() 37 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()
38) 38)
39 39
40type netStatCollector struct { 40type netStatCollector struct {
diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go
index fde77a0..a27382b 100644
--- a/collector/netstat_linux_test.go
+++ b/collector/netstat_linux_test.go
@@ -20,6 +20,7 @@ import (
20 20
21func TestNetStats(t *testing.T) { 21func TestNetStats(t *testing.T) {
22 testNetStats(t, "fixtures/proc/net/netstat") 22 testNetStats(t, "fixtures/proc/net/netstat")
23 testSNMPStats(t, "fixtures/proc/net/snmp")
23 testSNMP6Stats(t, "fixtures/proc/net/snmp6") 24 testSNMP6Stats(t, "fixtures/proc/net/snmp6")
24} 25}
25 26
@@ -44,6 +45,27 @@ func testNetStats(t *testing.T, fileName string) {
44 } 45 }
45} 46}
46 47
48func testSNMPStats(t *testing.T, fileName string) {
49 file, err := os.Open(fileName)
50 if err != nil {
51 t.Fatal(err)
52 }
53 defer file.Close()
54
55 snmpStats, err := parseNetStats(file, fileName)
56 if err != nil {
57 t.Fatal(err)
58 }
59
60 if want, got := "9", snmpStats["Udp"]["RcvbufErrors"]; want != got {
61 t.Errorf("want netstat Udp RcvbufErrors %s, got %s", want, got)
62 }
63
64 if want, got := "8", snmpStats["Udp"]["SndbufErrors"]; want != got {
65 t.Errorf("want netstat Udp SndbufErrors %s, got %s", want, got)
66 }
67}
68
47func testSNMP6Stats(t *testing.T, fileName string) { 69func testSNMP6Stats(t *testing.T, fileName string) {
48 file, err := os.Open(fileName) 70 file, err := os.Open(fileName)
49 if err != nil { 71 if err != nil {
@@ -63,4 +85,12 @@ func testSNMP6Stats(t *testing.T, fileName string) {
63 if want, got := "8", snmp6Stats["Icmp6"]["OutMsgs"]; want != got { 85 if want, got := "8", snmp6Stats["Icmp6"]["OutMsgs"]; want != got {
64 t.Errorf("want netstat ICPM6 OutMsgs %s, got %s", want, got) 86 t.Errorf("want netstat ICPM6 OutMsgs %s, got %s", want, got)
65 } 87 }
88
89 if want, got := "9", snmp6Stats["Udp6"]["RcvbufErrors"]; want != got {
90 t.Errorf("want netstat Udp6 RcvbufErrors %s, got %s", want, got)
91 }
92
93 if want, got := "8", snmp6Stats["Udp6"]["SndbufErrors"]; want != got {
94 t.Errorf("want netstat Udp6 SndbufErrors %s, got %s", want, got)
95 }
66} 96}