Add sys/class/net parsing from procfs and expose its metrics (#851)
* add sys/class/net parsing from procfs and expose its metrics Signed-off-by: Jan Klat <jenik@klatys.cz> * change code to use int pointers per procfs change, move netclass to separate collector, change metric naming Signed-off-by: Jan Klat <jenik@klatys.cz> * bump year in licence, remove redundant newline, correct fixtures Signed-off-by: Jan Klat <jenik@klatys.cz> * fix style Signed-off-by: Jan Klat <jenik@klatys.cz> * change carrier changes to counter type Signed-off-by: Jan Klat <jenik@klatys.cz> * fix e2e output Signed-off-by: Jan Klat <jenik@klatys.cz> * add fixtures Signed-off-by: Jan Klat <jenik@klatys.cz> * update vendor, use fixtures correctly Signed-off-by: Jan Klat <jenik@klatys.cz> * change fixtures (device in /sys/class/net should be symlinked) Signed-off-by: Jan Klat <jenik@klatys.cz> * correct fixtures for 64k page, updated readme Signed-off-by: Jan Klat <jenik@klatys.cz>
This commit is contained in:
parent
09b4305090
commit
c4102f1175
9 changed files with 849 additions and 36 deletions
|
|
@ -1669,6 +1669,51 @@ 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_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{interface="eth0"} 3
|
||||
# HELP node_network_carrier carrier value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier gauge
|
||||
node_network_carrier{interface="eth0"} 1
|
||||
# HELP node_network_carrier_changes_total carrier_changes_total value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier_changes_total counter
|
||||
node_network_carrier_changes_total{interface="eth0"} 2
|
||||
# HELP node_network_carrier_down_changes_total carrier_down_changes_total value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier_down_changes_total counter
|
||||
node_network_carrier_down_changes_total{interface="eth0"} 1
|
||||
# HELP node_network_carrier_up_changes_total carrier_up_changes_total value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier_up_changes_total counter
|
||||
node_network_carrier_up_changes_total{interface="eth0"} 1
|
||||
# HELP node_network_device_id device_id value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_device_id gauge
|
||||
node_network_device_id{interface="eth0"} 32
|
||||
# HELP node_network_dormant dormant value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_dormant gauge
|
||||
node_network_dormant{interface="eth0"} 1
|
||||
# HELP node_network_flags flags value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_flags gauge
|
||||
node_network_flags{interface="eth0"} 4867
|
||||
# HELP node_network_iface_id iface_id value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_iface_id gauge
|
||||
node_network_iface_id{interface="eth0"} 2
|
||||
# HELP node_network_iface_link iface_link value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_iface_link gauge
|
||||
node_network_iface_link{interface="eth0"} 2
|
||||
# HELP node_network_iface_link_mode iface_link_mode value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_iface_link_mode gauge
|
||||
node_network_iface_link_mode{interface="eth0"} 1
|
||||
# HELP node_network_mtu_bytes mtu_bytes value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_mtu_bytes gauge
|
||||
node_network_mtu_bytes{interface="eth0"} 1500
|
||||
# HELP node_network_name_assign_type name_assign_type value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_name_assign_type gauge
|
||||
node_network_name_assign_type{interface="eth0"} 2
|
||||
# HELP node_network_net_dev_group net_dev_group value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_net_dev_group gauge
|
||||
node_network_net_dev_group{interface="eth0"} 0
|
||||
# HELP node_network_protocol_type protocol_type value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_protocol_type gauge
|
||||
node_network_protocol_type{interface="eth0"} 1
|
||||
# HELP node_network_receive_bytes_total Network device statistic receive_bytes.
|
||||
# TYPE node_network_receive_bytes_total counter
|
||||
node_network_receive_bytes_total{device="docker0"} 6.4910168e+07
|
||||
|
|
@ -1765,6 +1810,9 @@ node_network_receive_packets_total{device="tun0"} 24
|
|||
node_network_receive_packets_total{device="veth4B09XN"} 8
|
||||
node_network_receive_packets_total{device="wlan0"} 1.3899359e+07
|
||||
node_network_receive_packets_total{device="💩0"} 105557
|
||||
# HELP node_network_speed_bytes speed_bytes value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_speed_bytes gauge
|
||||
node_network_speed_bytes{interface="eth0"} 1.25e+08
|
||||
# HELP node_network_transmit_bytes_total Network device statistic transmit_bytes.
|
||||
# TYPE node_network_transmit_bytes_total counter
|
||||
node_network_transmit_bytes_total{device="docker0"} 2.681662018e+09
|
||||
|
|
@ -1861,6 +1909,12 @@ node_network_transmit_packets_total{device="tun0"} 934
|
|||
node_network_transmit_packets_total{device="veth4B09XN"} 10640
|
||||
node_network_transmit_packets_total{device="wlan0"} 1.17262e+07
|
||||
node_network_transmit_packets_total{device="💩0"} 304261
|
||||
# HELP node_network_transmit_queue_length transmit_queue_length value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_transmit_queue_length gauge
|
||||
node_network_transmit_queue_length{interface="eth0"} 1000
|
||||
# HELP node_network_up Valid operstate for interface.
|
||||
# TYPE node_network_up gauge
|
||||
node_network_up{address="01:01:01:01:01:01",broadcast="ff:ff:ff:ff:ff:ff",duplex="full",ifalias="",interface="eth0",operstate="up"} 1
|
||||
# HELP node_nf_conntrack_entries Number of currently allocated flow entries for connection tracking.
|
||||
# TYPE node_nf_conntrack_entries gauge
|
||||
node_nf_conntrack_entries 123
|
||||
|
|
@ -2165,6 +2219,7 @@ node_scrape_collector_success{collector="mdadm"} 1
|
|||
node_scrape_collector_success{collector="meminfo"} 1
|
||||
node_scrape_collector_success{collector="meminfo_numa"} 1
|
||||
node_scrape_collector_success{collector="mountstats"} 1
|
||||
node_scrape_collector_success{collector="netclass"} 1
|
||||
node_scrape_collector_success{collector="netdev"} 1
|
||||
node_scrape_collector_success{collector="netstat"} 1
|
||||
node_scrape_collector_success{collector="nfs"} 1
|
||||
|
|
|
|||
|
|
@ -1669,6 +1669,51 @@ 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_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{interface="eth0"} 3
|
||||
# HELP node_network_carrier carrier value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier gauge
|
||||
node_network_carrier{interface="eth0"} 1
|
||||
# HELP node_network_carrier_changes_total carrier_changes_total value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier_changes_total counter
|
||||
node_network_carrier_changes_total{interface="eth0"} 2
|
||||
# HELP node_network_carrier_down_changes_total carrier_down_changes_total value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier_down_changes_total counter
|
||||
node_network_carrier_down_changes_total{interface="eth0"} 1
|
||||
# HELP node_network_carrier_up_changes_total carrier_up_changes_total value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_carrier_up_changes_total counter
|
||||
node_network_carrier_up_changes_total{interface="eth0"} 1
|
||||
# HELP node_network_device_id device_id value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_device_id gauge
|
||||
node_network_device_id{interface="eth0"} 32
|
||||
# HELP node_network_dormant dormant value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_dormant gauge
|
||||
node_network_dormant{interface="eth0"} 1
|
||||
# HELP node_network_flags flags value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_flags gauge
|
||||
node_network_flags{interface="eth0"} 4867
|
||||
# HELP node_network_iface_id iface_id value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_iface_id gauge
|
||||
node_network_iface_id{interface="eth0"} 2
|
||||
# HELP node_network_iface_link iface_link value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_iface_link gauge
|
||||
node_network_iface_link{interface="eth0"} 2
|
||||
# HELP node_network_iface_link_mode iface_link_mode value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_iface_link_mode gauge
|
||||
node_network_iface_link_mode{interface="eth0"} 1
|
||||
# HELP node_network_mtu_bytes mtu_bytes value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_mtu_bytes gauge
|
||||
node_network_mtu_bytes{interface="eth0"} 1500
|
||||
# HELP node_network_name_assign_type name_assign_type value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_name_assign_type gauge
|
||||
node_network_name_assign_type{interface="eth0"} 2
|
||||
# HELP node_network_net_dev_group net_dev_group value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_net_dev_group gauge
|
||||
node_network_net_dev_group{interface="eth0"} 0
|
||||
# HELP node_network_protocol_type protocol_type value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_protocol_type gauge
|
||||
node_network_protocol_type{interface="eth0"} 1
|
||||
# HELP node_network_receive_bytes_total Network device statistic receive_bytes.
|
||||
# TYPE node_network_receive_bytes_total counter
|
||||
node_network_receive_bytes_total{device="docker0"} 6.4910168e+07
|
||||
|
|
@ -1765,6 +1810,9 @@ node_network_receive_packets_total{device="tun0"} 24
|
|||
node_network_receive_packets_total{device="veth4B09XN"} 8
|
||||
node_network_receive_packets_total{device="wlan0"} 1.3899359e+07
|
||||
node_network_receive_packets_total{device="💩0"} 105557
|
||||
# HELP node_network_speed_bytes speed_bytes value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_speed_bytes gauge
|
||||
node_network_speed_bytes{interface="eth0"} 1.25e+08
|
||||
# HELP node_network_transmit_bytes_total Network device statistic transmit_bytes.
|
||||
# TYPE node_network_transmit_bytes_total counter
|
||||
node_network_transmit_bytes_total{device="docker0"} 2.681662018e+09
|
||||
|
|
@ -1861,6 +1909,12 @@ node_network_transmit_packets_total{device="tun0"} 934
|
|||
node_network_transmit_packets_total{device="veth4B09XN"} 10640
|
||||
node_network_transmit_packets_total{device="wlan0"} 1.17262e+07
|
||||
node_network_transmit_packets_total{device="💩0"} 304261
|
||||
# HELP node_network_transmit_queue_length transmit_queue_length value of /sys/class/net/<iface>.
|
||||
# TYPE node_network_transmit_queue_length gauge
|
||||
node_network_transmit_queue_length{interface="eth0"} 1000
|
||||
# HELP node_network_up Valid operstate for interface.
|
||||
# TYPE node_network_up gauge
|
||||
node_network_up{address="01:01:01:01:01:01",broadcast="ff:ff:ff:ff:ff:ff",duplex="full",ifalias="",interface="eth0",operstate="up"} 1
|
||||
# HELP node_nf_conntrack_entries Number of currently allocated flow entries for connection tracking.
|
||||
# TYPE node_nf_conntrack_entries gauge
|
||||
node_nf_conntrack_entries 123
|
||||
|
|
@ -2165,6 +2219,7 @@ node_scrape_collector_success{collector="mdadm"} 1
|
|||
node_scrape_collector_success{collector="meminfo"} 1
|
||||
node_scrape_collector_success{collector="meminfo_numa"} 1
|
||||
node_scrape_collector_success{collector="mountstats"} 1
|
||||
node_scrape_collector_success{collector="netclass"} 1
|
||||
node_scrape_collector_success{collector="netdev"} 1
|
||||
node_scrape_collector_success{collector="netstat"} 1
|
||||
node_scrape_collector_success{collector="nfs"} 1
|
||||
|
|
|
|||
|
|
@ -299,6 +299,21 @@ Mode: 755
|
|||
Directory: sys/class/net/bond0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/class/net/bond0/bonding
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -306,6 +321,117 @@ Path: sys/class/net/bond0/bonding/slaves
|
|||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bond0/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/bonding_masters
|
||||
Lines: 1
|
||||
bond0 dmz int
|
||||
|
|
@ -314,6 +440,21 @@ Mode: 644
|
|||
Directory: sys/class/net/dmz
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/class/net/dmz/bonding
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -322,6 +463,102 @@ Lines: 1
|
|||
eth0 eth4
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/class/net/dmz/slave_eth0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -338,9 +575,42 @@ Lines: 1
|
|||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/dmz/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/eth0
|
||||
SymlinkTo: ../../devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/class/net/int
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/class/net/int/bonding
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -349,6 +619,102 @@ Lines: 1
|
|||
eth5 eth1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/class/net/int/slave_eth1
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -365,12 +731,165 @@ Lines: 1
|
|||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/class/net/int/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/pci0000:00
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/pci0000:00/0000:00:03.0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/addr_assign_type
|
||||
Lines: 1
|
||||
3
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/addr_len
|
||||
Lines: 1
|
||||
6
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/address
|
||||
Lines: 1
|
||||
01:01:01:01:01:01
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/broadcast
|
||||
Lines: 1
|
||||
ff:ff:ff:ff:ff:ff
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/carrier
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/carrier_changes
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/carrier_down_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/carrier_up_count
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/dev_id
|
||||
Lines: 1
|
||||
0x20
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/dormant
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/duplex
|
||||
Lines: 1
|
||||
full
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/flags
|
||||
Lines: 1
|
||||
0x1303
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/ifalias
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/ifindex
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/iflink
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/link_mode
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/mtu
|
||||
Lines: 1
|
||||
1500
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/name_assign_type
|
||||
Lines: 1
|
||||
2
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/netdev_group
|
||||
Lines: 1
|
||||
0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/operstate
|
||||
Lines: 1
|
||||
up
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/phys_port_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/phys_port_name
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/phys_switch_id
|
||||
Lines: 0
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/speed
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/tx_queue_len
|
||||
Lines: 1
|
||||
1000
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0/net/eth0/type
|
||||
Lines: 1
|
||||
1
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: sys/devices/pci0000:00/0000:00:0d.0
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
|||
173
collector/netclass_linux.go
Normal file
173
collector/netclass_linux.go
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
// Copyright 2018 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !nonetclass
|
||||
// +build linux
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/procfs/sysfs"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
var (
|
||||
netclassIgnoredDevices = kingpin.Flag("collector.netclass.ignored-devices", "Regexp of net devices to ignore for netclass collector.").Default("^$").String()
|
||||
)
|
||||
|
||||
type netClassCollector struct {
|
||||
subsystem string
|
||||
ignoredDevicesPattern *regexp.Regexp
|
||||
metricDescs map[string]*prometheus.Desc
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerCollector("netclass", defaultEnabled, NewNetClassCollector)
|
||||
}
|
||||
|
||||
// NewNetClassCollector returns a new Collector exposing network class stats.
|
||||
func NewNetClassCollector() (Collector, error) {
|
||||
pattern := regexp.MustCompile(*netclassIgnoredDevices)
|
||||
return &netClassCollector{
|
||||
subsystem: "network",
|
||||
ignoredDevicesPattern: pattern,
|
||||
metricDescs: map[string]*prometheus.Desc{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *netClassCollector) Update(ch chan<- prometheus.Metric) error {
|
||||
netClass, err := getNetClassInfo(c.ignoredDevicesPattern)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get net class info: %s", err)
|
||||
}
|
||||
for _, ifaceInfo := range netClass {
|
||||
upDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, c.subsystem, "up"),
|
||||
"Valid operstate for interface.",
|
||||
[]string{"interface", "address", "broadcast", "duplex", "operstate", "ifalias"},
|
||||
nil,
|
||||
)
|
||||
upValue := 0.0
|
||||
if ifaceInfo.OperState == "up" {
|
||||
upValue = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, upValue, ifaceInfo.Name, ifaceInfo.Address, ifaceInfo.Broadcast, ifaceInfo.Duplex, ifaceInfo.OperState, ifaceInfo.IfAlias)
|
||||
|
||||
if ifaceInfo.AddrAssignType != nil {
|
||||
pushMetric(ch, c.subsystem, "address_assign_type", *ifaceInfo.AddrAssignType, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.Carrier != nil {
|
||||
pushMetric(ch, c.subsystem, "carrier", *ifaceInfo.Carrier, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.CarrierChanges != nil {
|
||||
pushMetric(ch, c.subsystem, "carrier_changes_total", *ifaceInfo.CarrierChanges, ifaceInfo.Name, prometheus.CounterValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.CarrierUpCount != nil {
|
||||
pushMetric(ch, c.subsystem, "carrier_up_changes_total", *ifaceInfo.CarrierUpCount, ifaceInfo.Name, prometheus.CounterValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.CarrierDownCount != nil {
|
||||
pushMetric(ch, c.subsystem, "carrier_down_changes_total", *ifaceInfo.CarrierDownCount, ifaceInfo.Name, prometheus.CounterValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.DevID != nil {
|
||||
pushMetric(ch, c.subsystem, "device_id", *ifaceInfo.DevID, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.Dormant != nil {
|
||||
pushMetric(ch, c.subsystem, "dormant", *ifaceInfo.Dormant, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.Flags != nil {
|
||||
pushMetric(ch, c.subsystem, "flags", *ifaceInfo.Flags, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.IfIndex != nil {
|
||||
pushMetric(ch, c.subsystem, "iface_id", *ifaceInfo.IfIndex, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.IfLink != nil {
|
||||
pushMetric(ch, c.subsystem, "iface_link", *ifaceInfo.IfLink, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.LinkMode != nil {
|
||||
pushMetric(ch, c.subsystem, "iface_link_mode", *ifaceInfo.LinkMode, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.MTU != nil {
|
||||
pushMetric(ch, c.subsystem, "mtu_bytes", *ifaceInfo.MTU, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.NameAssignType != nil {
|
||||
pushMetric(ch, c.subsystem, "name_assign_type", *ifaceInfo.NameAssignType, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.NetDevGroup != nil {
|
||||
pushMetric(ch, c.subsystem, "net_dev_group", *ifaceInfo.NetDevGroup, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.Speed != nil {
|
||||
speedBytes := int64(*ifaceInfo.Speed / 8 * 1000 * 1000)
|
||||
pushMetric(ch, c.subsystem, "speed_bytes", speedBytes, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.TxQueueLen != nil {
|
||||
pushMetric(ch, c.subsystem, "transmit_queue_length", *ifaceInfo.TxQueueLen, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
|
||||
if ifaceInfo.Type != nil {
|
||||
pushMetric(ch, c.subsystem, "protocol_type", *ifaceInfo.Type, ifaceInfo.Name, prometheus.GaugeValue)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func pushMetric(ch chan<- prometheus.Metric, subsystem string, name string, value int64, ifaceName string, valueType prometheus.ValueType) {
|
||||
fieldDesc := prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, subsystem, name),
|
||||
fmt.Sprintf("%s value of /sys/class/net/<iface>.", name),
|
||||
[]string{"interface"},
|
||||
nil,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(fieldDesc, valueType, float64(value), ifaceName)
|
||||
}
|
||||
|
||||
func getNetClassInfo(ignore *regexp.Regexp) (sysfs.NetClass, error) {
|
||||
fs, err := sysfs.NewFS(*sysPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
netClass, err := fs.NewNetClass()
|
||||
|
||||
if err != nil {
|
||||
return netClass, fmt.Errorf("error obtaining net class info: %s", err)
|
||||
}
|
||||
|
||||
for device := range netClass {
|
||||
if ignore.MatchString(device) {
|
||||
delete(netClass, device)
|
||||
}
|
||||
}
|
||||
|
||||
return netClass, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue