sensu-extensions-snmp-trap 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c593de31023cd607a14e7df9a9b43378684a41
4
- data.tar.gz: 94ac44c50553cdf049a0c0aced15c5a2f340b99e
3
+ metadata.gz: 9f0973bb3ae00e0a0ce2cb2c73f791647e1c0cc6
4
+ data.tar.gz: dfb3cddff9fdd957baebc60eb66f98ca0abc5122
5
5
  SHA512:
6
- metadata.gz: 2000c69d0fb8bcd358c623e92ff0d27fb064821905a77aafbc086aabce910dc5b047752ac3b5dd9028d627dc64381e6bba5f849d4dd0bdefc042bc875046ee29
7
- data.tar.gz: 3cfe7fa539c732e6bb99c11c057bfe692230e1aacd99be9bc25df15366c4f1844fec4ade394c8e30f67209cffd39dc43094c9228558f637fe02d31bd96fbebcc
6
+ metadata.gz: 9821e8c84870558c58d524457e7755cc03d64ed0bf4669bf0b8278de07588d96cd602531a998fe7c8a99ac7a35112b58cbebc6f302a723c067804afd126bb28f
7
+ data.tar.gz: c16dff9fa82c6a204858921c49449bd0ef4881e1ac441cc93236322dc1032d86cc29087bf2c99826a76586b3baad2c64d0bcf48dc6d4789c63843809f8ae0fbd
@@ -71,10 +71,12 @@ module Sensu
71
71
  :mibs_dir => options[:mibs_dir],
72
72
  :imported_dir => options[:imported_dir]
73
73
  })
74
- Dir.glob(File.join(options[:mibs_dir], "*")) do |mib_file|
74
+ mib_files = Dir.glob(File.join(options[:mibs_dir], "*"))
75
+ mib_files.each do |mib_file|
75
76
  @logger.debug("snmp trap check extension importing mib", :mib_file => mib_file)
76
77
  begin
77
- SNMP::MIB.import_module(mib_file, options[:imported_dir])
78
+ preload = mib_files - [mib_file]
79
+ SNMP::MIB.import_module(mib_file, options[:imported_dir], preload)
78
80
  rescue StandardError, SyntaxError => error
79
81
  @logger.debug("snmp trap check extension failed to import mib", {
80
82
  :mib_file => mib_file,
@@ -13,11 +13,13 @@ module SNMP
13
13
  @sensu_logger.warn("snmp trap check extension mib warning", :warning => message.downcase)
14
14
  end
15
15
 
16
- def import_module(module_file, mib_dir=DEFAULT_MIB_PATH)
16
+ def import_module(module_file, mib_dir=DEFAULT_MIB_PATH, mib_preload=[])
17
17
  raise "smidump tool must be installed" unless import_supported?
18
18
  FileUtils.makedirs mib_dir
19
+ # PATCH: add preload support
20
+ preload = mib_preload.map {|mib_file| " -p #{mib_file}"}.join("")
19
21
  # PATCH: redirect STDERR to /dev/null
20
- mib_hash = `smidump -k -f python #{module_file} 2>/dev/null`
22
+ mib_hash = `smidump#{preload} -k -f python #{module_file} 2>/dev/null`
21
23
  mib = eval_mib_data(mib_hash)
22
24
  if mib
23
25
  module_name = mib["moduleName"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-extensions-snmp-trap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Extensions and contributors