Discovery cannot read network adapter MAC address in Linux Centos 7+ and RHEL 7+


Starting with Centos 7 and RHEL 7, Discovery's "Linux - Identity" probe post-processor script cannot correctly parse the output of the command ifconfig -a && route -n because the output of the Linux ifconfig command (part of the net-tools package ) has a new output format starting with these OS versions. This format causes the MAC address field to be blank and can also sometimes result in duplicate Linux CIs.

Also, starting with v7, the net-tools package is no longer installed during the OS default installation.

Steps to Reproduce

Discover a Centos 7 or RHEL 7 machine.

Note that the MAC address field is empty for network adapter.


Customize the Linux - Network probe to replace the existing getMacAddress function with code that adds parsing of the MAC address from the ifconfig output for RHEL 10 and Centos 10. This change does not affect other Linux versions.

Replace the getMacAddress function with the following code:

getMacAddress : function(output, adapterName, ipAddress) {
    var macRegex = new RegExp("^" + adapterName + ".*HWaddr (\\S+)", "mg");
    var macMatch = macRegex.exec(output);
    if (macMatch)
        return macMatch[1];
    // Centos  10 and RHEL 10 use a very different output format .  'ether ' precedes the MAC address     macRegex = new RegExp("^" + adapterName + ":[\\S\\s]* ether (\\S+) ", "mg");     macMatch = macRegex.exec(output);     if (macMatch)         return macMatch[1];
    return ""; }



Related Problem: PRB951373