sentrysoftware / metricshub-community-connectors

MetricsHub Community Connectors Repository
https://sentrysoftware.org/metricshub-community-connectors
GNU Affero General Public License v3.0
5 stars 0 forks source link

LinuxIPNetwork connector fails to monitor some Ethernet interfaces #111

Open bertysentry opened 2 months ago

bertysentry commented 2 months ago

Problem

Currently, the connectors takes into account only network cards whose name match with this regular expression: /^eth[0-9][0-9]*:?|^vmnic[0-9][0-9]*:?|^em[0-9]*:?|^[Pp][0-9][0-9]*[Pp][0-9][0-9]*:?|^en[os][0-9]*:?|^enp[0-9]*s[0-9]*:?/

But as a network card can be named arbitrarily by the system admin, filtering with a regular expression will fail to list the physical Ethernet interfaces.

Specifications

Instead of using a regular expression, try listing the symbolic links in /sys/class/net.

All entries that link to something in /sys/devices/ that is not virtual should be considered physical.

Examples:

ls -l /sys/class/net
total 0
lrwxrwxrwx 1 root root 0 Aug 14 01:46 eth0 -> ../../devices/pci0000:00/0000:00:05.0/0000:05:00.2/0000:07:08.0/net/eth0
lrwxrwxrwx 1 root root 0 Aug 26 16:33 eth1 -> ../../devices/pci0000:00/0000:00:05.0/0000:05:00.0/0000:06:07.0/net/eth1
lrwxrwxrwx 1 root root 0 Aug 26 16:33 lo -> ../../devices/virtual/net/lo
ls -l
total 0
lrwxrwxrwx 1 root root    0 Aug 26 16:31 bond0 -> ../../devices/virtual/net/bond0
-rw-r--r-- 1 root root 4096 Aug 26 16:31 bonding_masters
lrwxrwxrwx 1 root root    0 Aug 26 16:31 dummy0 -> ../../devices/virtual/net/dummy0
lrwxrwxrwx 1 root root    0 Aug 20 12:50 eth0 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0004:00/VMBUS:00/a03b81eb-5f29-44f5-ad95-e6a8b4993c17/net/eth0
lrwxrwxrwx 1 root root    0 Aug 20 12:50 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root    0 Aug 20 12:50 sit0 -> ../../devices/virtual/net/sit0
lrwxrwxrwx 1 root root    0 Aug 26 16:31 tunl0 -> ../../devices/virtual/net/tunl0