`host.meta.interfaces` is null when use `ifconfig`
Overview
The metric host.meta.interfaces are always null on the particular host.
This problem seems to occur on the hosts satisfy the following conditions.
- not installed
ipcommand - installed
ifconfigcommand - a newer version of Linux (maybe)
Output of mackerel-agent
The following log shows mackerel-agent outputs the metrics without proper .host.meta.interfaces.
It is expected .host.meta.interfaces have valid information of the NICs of host, but it always be null.
ruins@vm-ubnt1804-Frigg:~$ cat /etc/issue
Ubuntu 18.04.3 LTS \n \l
ruins@vm-ubnt1804-Frigg:~$ uname -r
5.0.0-25-generic
ruins@vm-ubnt1804-Frigg:~$ docker run --rm -it mackerel/mackerel-agent mackerel-agent once -apikey=dummy | jq .host.meta.interfaces
null
Consideration
It seems caused by mismatched Regexp on here (https://github.com/mackerelio/mackerel-agent/blob/master/spec/linux/interface.go#L97-L100).
This Regexp expects the section of IP addresses begins with inet addr but it seems to begin with inet in the newer version of Linux.
On Debian Jessie, the section of IP address begins with inet addr.
But on Debian Stretch, it begins with inet.
ruins@thor:~$ docker run --rm -it debian:jessie-slim sh -c "apt update;apt install net-tools;ifconfig -a"
(omit apt logs)
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02
inet addr:172.17.0.2 Bcast:172.17.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:817 errors:0 dropped:0 overruns:0 frame:0
TX packets:364 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:10517296 (10.0 MiB) TX bytes:25479 (24.8 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ruins@thor:~$ docker run --rm -it debian:stretch-slim sh -c "apt update;apt install net-tools;ifconfig -a"
(omit apt logs)
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)
RX packets 508 bytes 8413071 (8.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 256 bytes 18348 (17.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Thank you for your report! We will check this issue.
We plan to implement this using netlink. It will be independent of the command execution result.
A corrected version will be in the next release.