Skip to content

Commit

Permalink
[snmp] Support new profiles without throwing errors in translate-prof…
Browse files Browse the repository at this point in the history
…iles (#10648)

* [snmp] support new profiles without throwing errors

* [snmp] support profiles with no metrics
  • Loading branch information
pducolin authored Dec 6, 2021
1 parent 2772ad2 commit 5be5bfb
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,24 @@ def translate_profile(ctx, profile_path, mib_source_url):
data = yaml.safe_load(f.read())

output = []
for metric in data['metrics']:
metrics = data.get('metrics', [])
for metric in metrics:
mib = metric['MIB']
try:
mib_view_controller.mibBuilder.loadModule(mib)
except MibNotFoundError:
fetch_mib(mib, source_url=mib_source_url)
if 'table' in metric:
table = metric['table']
if not isinstance(table, str):
continue
node = mib_view_controller.mibBuilder.importSymbols(mib, table)[0]
value = '.'.join([str(i) for i in node.getName()])
table = {'name': table, 'OID': value}
symbols = []
for symbol in metric['symbols']:
if not isinstance(symbol, str):
continue
node = mib_view_controller.mibBuilder.importSymbols(mib, symbol)[0]
value = '.'.join([str(i) for i in node.getName()])
symbols.append({'name': symbol, 'OID': value})
Expand All @@ -85,6 +90,8 @@ def translate_profile(ctx, profile_path, mib_source_url):
if 'column' in tag:
tag_mib = tag.get('MIB', mib)
key = tag['column']
if not isinstance(key, str):
continue
node = mib_view_controller.mibBuilder.importSymbols(tag_mib, key)[0]
value = '.'.join([str(i) for i in node.getName()])
tag = tag.copy()
Expand Down

0 comments on commit 5be5bfb

Please sign in to comment.