Skip to content

Instantly share code, notes, and snippets.

@britcey
Created November 9, 2017 16:51
Show Gist options
  • Save britcey/1f185b1c56a7a10b4bbaf7cbcf4f3291 to your computer and use it in GitHub Desktop.
Save britcey/1f185b1c56a7a10b4bbaf7cbcf4f3291 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# use snmptranslate to lookup OID if there's no comment after an existing numeric OID
def translate_oid(oid)
@cache ||= {}
@cache[oid] ||= `snmptranslate -Os -mALL #{oid}`
end
file = 'generator.yml.j2'
File.open(file).each do |l|
if l =~ /^(\s+)([\d\.]+),*$/
print "#{$1}#{$2}, # #{translate_oid $2}"
else
print l
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment