node_exporter
node_exporter copied to clipboard
netstat_freebsd: add new metrics
This PR adds a number of new metrics to the netstat_freebsd module.
The first commit is a refactoring to make it easier to add new metrics. It also fixes the netstat_freebsd tests, which were completely broken. I added a function to return fake raw data so the code can be tested without calling the low level functions.
The new metrics are:
IPv4
ip4_transmit_packets_total
ip4_transmit_raw_packets_total
ip4_receive_packets_total
ip4_receive_fragments_total
ip4_forward_total
ip4_fast_forward_total
ip4_delivered_total
IPv6
ip6_transmit_packets_total
ip6_transmit_raw_packets_total
ip6_receive_packets_total
ip6_receive_fragments_total
ip6_forward_total
ip6_delivered_total
UDP
udp_transmit_packets_total
udp_receive_packets_total
TCP states
node_netstat_tcp_connections{state="CLOSED"}
node_netstat_tcp_connections{state="CLOSE_WAIT"}
node_netstat_tcp_connections{state="CLOSING"}
node_netstat_tcp_connections{state="ESTABLISHED"}
node_netstat_tcp_connections{state="FIN_WAIT_1"}
node_netstat_tcp_connections{state="FIN_WAIT_2"}
node_netstat_tcp_connections{state="LAST_ACK"}
node_netstat_tcp_connections{state="LISTEN"}
node_netstat_tcp_connections{state="SYN_RCVD"}
node_netstat_tcp_connections{state="SYN_SENT"}
node_netstat_tcp_connections{state="TIME_WAIT"}
Each commit has the list of metrics added, but here is the full list (including the ones that already existed):
# HELP node_netstat_ip4_delivered_total IPv4 packets delivered to the upper layer (packets for this host)
# TYPE node_netstat_ip4_delivered_total counter
node_netstat_ip4_delivered_total 1.5222157e+07
# HELP node_netstat_ip4_fast_forward_total IPv4 packets fast forwarded
# TYPE node_netstat_ip4_fast_forward_total counter
node_netstat_ip4_fast_forward_total 3.029054e+06
# HELP node_netstat_ip4_forward_total IPv4 packets forwarded
# TYPE node_netstat_ip4_forward_total counter
node_netstat_ip4_forward_total 1.0136014e+07
# HELP node_netstat_ip4_receive_fragments_total IPv4 fragments received
# TYPE node_netstat_ip4_receive_fragments_total counter
node_netstat_ip4_receive_fragments_total 0
# HELP node_netstat_ip4_receive_packets_total IPv4 packets received
# TYPE node_netstat_ip4_receive_packets_total counter
node_netstat_ip4_receive_packets_total 2.9040874e+07
# HELP node_netstat_ip4_transmit_packets_total IPv4 packets sent from this host
# TYPE node_netstat_ip4_transmit_packets_total counter
node_netstat_ip4_transmit_packets_total 1.308442e+07
# HELP node_netstat_ip4_transmit_raw_packets_total IPv4 raw packets generated
# TYPE node_netstat_ip4_transmit_raw_packets_total counter
node_netstat_ip4_transmit_raw_packets_total 262462
# HELP node_netstat_ip6_delivered_total IPv6 packets delivered to the upper layer (packets for this host)
# TYPE node_netstat_ip6_delivered_total counter
node_netstat_ip6_delivered_total 8.272913e+06
# HELP node_netstat_ip6_forward_total IPv6 packets forwarded
# TYPE node_netstat_ip6_forward_total counter
node_netstat_ip6_forward_total 0
# HELP node_netstat_ip6_receive_fragments_total IPv6 fragments received
# TYPE node_netstat_ip6_receive_fragments_total counter
node_netstat_ip6_receive_fragments_total 0
# HELP node_netstat_ip6_receive_packets_total IPv6 packets received
# TYPE node_netstat_ip6_receive_packets_total counter
node_netstat_ip6_receive_packets_total 8.363273e+06
# HELP node_netstat_ip6_transmit_packets_total IPv6 packets sent from this host
# TYPE node_netstat_ip6_transmit_packets_total counter
node_netstat_ip6_transmit_packets_total 5.106645e+06
# HELP node_netstat_ip6_transmit_raw_packets_total IPv6 raw packets generated
# TYPE node_netstat_ip6_transmit_raw_packets_total counter
node_netstat_ip6_transmit_raw_packets_total 0
# HELP node_netstat_tcp_connections Number of TCP connections per state
# TYPE node_netstat_tcp_connections gauge
node_netstat_tcp_connections{state="CLOSED"} 1
node_netstat_tcp_connections{state="CLOSE_WAIT"} 0
node_netstat_tcp_connections{state="CLOSING"} 138
node_netstat_tcp_connections{state="ESTABLISHED"} 39
node_netstat_tcp_connections{state="FIN_WAIT_1"} 0
node_netstat_tcp_connections{state="FIN_WAIT_2"} 0
node_netstat_tcp_connections{state="LAST_ACK"} 2
node_netstat_tcp_connections{state="LISTEN"} 10
node_netstat_tcp_connections{state="SYN_RCVD"} 0
node_netstat_tcp_connections{state="SYN_SENT"} 0
node_netstat_tcp_connections{state="TIME_WAIT"} 0
# HELP node_netstat_tcp_receive_packets_total TCP packets received
# TYPE node_netstat_tcp_receive_packets_total counter
node_netstat_tcp_receive_packets_total 2.1505317e+07
# HELP node_netstat_tcp_transmit_packets_total TCP packets sent
# TYPE node_netstat_tcp_transmit_packets_total counter
node_netstat_tcp_transmit_packets_total 1.6645327e+07
# HELP node_netstat_udp_receive_packets_total UDP packets received
# TYPE node_netstat_udp_receive_packets_total counter
node_netstat_udp_receive_packets_total 1.987699e+06
# HELP node_netstat_udp_transmit_packets_total UDP packets sent
# TYPE node_netstat_udp_transmit_packets_total counter
node_netstat_udp_transmit_packets_total 1.170068e+06