• 0

SNMP_Network_Interfaces fails when snmp returns MAC address in binary (SNMP STRING) format instead of the more typical HEX-STRING format


Question

I've discovered an issue with the new SNMP_Network_Interfaces DataSource if it finds that a device returns MAC addresses in STRING (binary) format instead of the more typical HEX-STRING ("xx:xx:xx:xx:xx:xx") format. You can see the issue if you walk .1.3.6.1.2.1.2.2.1.6 and see MAC addresses that look like "Lr 3a#". We found this was happening to only a very few Cisco switches out of hundreds but when it happens the interface instance doesn't show up in LogicMonitor. I was able to add some code to the DataSource AD script to account for the problem as shown below. We have not yet implemented across everything yet but looks good so far. I did provide this over to LM Support.

It appears the LM snmp calls in groovy doesn't support forcing a particular outputs like hex-string. Also if anyone knows why Cisco equipment might not use hex-string in snmp queries for some almost-random ports I would be interested to know. Thanks!

def extractInterfaces(host, options, timeout) {
 
    def ifTable = [:]
 
    // Extract interfaces
    Snmp.walkAsMap(host, "1.3.6.1.2.1.2.2.1.6", null, 160000).each { ifIndex, mac ->
        def entry = ifTable.get(ifIndex, ["ifIndex": ifIndex])
 
 
        //Check if we might have gotten the MAC in STRING (binary) format instead of HEX-STRING
        // and convert to hex format
        if (mac.length() == 6) {
            byte[] macByte = mac
            mac = macByte.encodeHex().toString()
        }
 
 
        entry.mac = mac
        ifTable[ifIndex] = entry
    }
 
    getSnmpField(host, ifTable, "type", "1.3.6.1.2.1.2.2.1.3")
    getSnmpField(host, ifTable, "mtu", "1.3.6.1.2.1.2.2.1.4")
    getSnmpField(host, ifTable, "highspeed", "1.3.6.1.2.1.31.1.1.1.15")
    getSnmpField(host, ifTable, "description", "1.3.6.1.2.1.2.2.1.2")
    getSnmpField(host, ifTable, "alias", "1.3.6.1.2.1.31.1.1.1.18")
    getSnmpField(host, ifTable, "name", "1.3.6.1.2.1.2.2.1.2")
 
    return ifTable
}

 

  • Like 1
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.