diff options
-rw-r--r-- | collector/fixtures/e2e-64k-page-output.txt | 12 | ||||
-rw-r--r-- | collector/fixtures/e2e-output.txt | 12 | ||||
-rw-r--r-- | collector/fixtures/proc/net/snmp | 2 | ||||
-rw-r--r-- | collector/fixtures/proc/net/snmp6 | 4 | ||||
-rw-r--r-- | collector/netstat_linux.go | 2 | ||||
-rw-r--r-- | collector/netstat_linux_test.go | 30 |
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 |
1905 | node_netstat_Udp6_OutDatagrams 0 | 1905 | node_netstat_Udp6_OutDatagrams 0 |
1906 | # HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors. | ||
1907 | # TYPE node_netstat_Udp6_RcvbufErrors untyped | ||
1908 | node_netstat_Udp6_RcvbufErrors 9 | ||
1909 | # HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors. | ||
1910 | # TYPE node_netstat_Udp6_SndbufErrors untyped | ||
1911 | node_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 |
1908 | node_netstat_UdpLite6_InErrors 0 | 1914 | node_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 |
1923 | node_netstat_Udp_OutDatagrams 53028 | 1929 | node_netstat_Udp_OutDatagrams 53028 |
1930 | # HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors. | ||
1931 | # TYPE node_netstat_Udp_RcvbufErrors untyped | ||
1932 | node_netstat_Udp_RcvbufErrors 9 | ||
1933 | # HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors. | ||
1934 | # TYPE node_netstat_Udp_SndbufErrors untyped | ||
1935 | node_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 |
1926 | node_network_address_assign_type{device="eth0"} 3 | 1938 | node_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 |
1926 | node_netstat_Udp6_OutDatagrams 0 | 1926 | node_netstat_Udp6_OutDatagrams 0 |
1927 | # HELP node_netstat_Udp6_RcvbufErrors Statistic Udp6RcvbufErrors. | ||
1928 | # TYPE node_netstat_Udp6_RcvbufErrors untyped | ||
1929 | node_netstat_Udp6_RcvbufErrors 9 | ||
1930 | # HELP node_netstat_Udp6_SndbufErrors Statistic Udp6SndbufErrors. | ||
1931 | # TYPE node_netstat_Udp6_SndbufErrors untyped | ||
1932 | node_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 |
1929 | node_netstat_UdpLite6_InErrors 0 | 1935 | node_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 |
1944 | node_netstat_Udp_OutDatagrams 53028 | 1950 | node_netstat_Udp_OutDatagrams 53028 |
1951 | # HELP node_netstat_Udp_RcvbufErrors Statistic UdpRcvbufErrors. | ||
1952 | # TYPE node_netstat_Udp_RcvbufErrors untyped | ||
1953 | node_netstat_Udp_RcvbufErrors 9 | ||
1954 | # HELP node_netstat_Udp_SndbufErrors Statistic UdpSndbufErrors. | ||
1955 | # TYPE node_netstat_Udp_SndbufErrors untyped | ||
1956 | node_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 |
1947 | node_network_address_assign_type{device="eth0"} 3 | 1959 | node_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 | |||
7 | Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors | 7 | Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors |
8 | Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0 | 8 | Tcp: 1 200 120000 -1 3556 230 341 161 0 57252008 54915039 227 5 1003 0 |
9 | Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors | 9 | Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors |
10 | Udp: 88542 120 0 53028 0 0 0 | 10 | Udp: 88542 120 0 53028 9 8 0 |
11 | UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors | 11 | UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors |
12 | UdpLite: 0 0 0 0 0 0 0 | 12 | UdpLite: 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 | |||
72 | Udp6NoPorts 0 | 72 | Udp6NoPorts 0 |
73 | Udp6InErrors 0 | 73 | Udp6InErrors 0 |
74 | Udp6OutDatagrams 0 | 74 | Udp6OutDatagrams 0 |
75 | Udp6RcvbufErrors 0 | 75 | Udp6RcvbufErrors 9 |
76 | Udp6SndbufErrors 0 | 76 | Udp6SndbufErrors 8 |
77 | Udp6InCsumErrors 0 | 77 | Udp6InCsumErrors 0 |
78 | Udp6IgnoredMulti 0 | 78 | Udp6IgnoredMulti 0 |
79 | UdpLite6InDatagrams 0 | 79 | UdpLite6InDatagrams 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 | ||
36 | var ( | 36 | var ( |
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 | ||
40 | type netStatCollector struct { | 40 | type 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 | ||
21 | func TestNetStats(t *testing.T) { | 21 | func 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 | ||
48 | func 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 | |||
47 | func testSNMP6Stats(t *testing.T, fileName string) { | 69 | func 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 | } |