snmp: make snmptranslate not required (#2008)

This commit is contained in:
Patrick Hemmer
2016-12-12 08:30:07 -05:00
committed by Cameron Sparr
parent efb64a049f
commit 91143dda1a
3 changed files with 62 additions and 0 deletions

View File

@@ -848,6 +848,11 @@ func snmpTranslate(oid string) (mibName string, oidNum string, oidText string, c
out, err = execCmd("snmptranslate", "-Td", "-Ob", oid)
} else {
out, err = execCmd("snmptranslate", "-Td", "-Ob", "-m", "all", oid)
if err, ok := err.(*exec.Error); ok && err.Err == exec.ErrNotFound {
// Silently discard error if snmptranslate not found and we have a numeric OID.
// Meaning we can get by without the lookup.
return "", oid, oid, "", nil
}
}
if err != nil {
return "", "", "", "", err