Sha256: 96ac8cecb2a3e289445899ecd1363205acff976164273348fea43cb683c00d7b

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require "strada"
require "logger"

class Netdisco
  # 实例化配置对象
  CONFIG = Strada.new name: "netdisco", load: false

  # 设置默认参数
  CONFIG.default.use            = %w(LLDP CDP)
  CONFIG.default.poll           = %w[192.168.8.0/24]
  CONFIG.default.snmp.community = "cisco"
  CONFIG.default.snmp.timeout   = 15
  CONFIG.default.snmp.retries   = 1
  CONFIG.default.snmp.bulkrows  = 30 # 1500B packet should fit about 50 :cdpCacheAddress rows
  CONFIG.default.dot.bothlinks  = false # keep both a-b and b-a links
  CONFIG.default.dot.linklabels = true # label link with interface names
  CONFIG.default.dot.color      = [# regexp of host => color
    %w[cpe gold],
    %w[-sw blue],
    %w[-pe red],
    %w[-p yellow],
  ]
  CONFIG.default.dns.afi        = nil # could be 'ipv4' or 'ipv6'
  CONFIG.default.log            = "STDERR"
  CONFIG.default.debug          = true
  CONFIG.default.name_map       = [# regexp match+sub of hostname (needed for LLDP)
    ['-re\d+', ""],
    ["^KILLME(.*(?<!mojo.local)$)", '\1.mojo.local'], # adds missing domain name
  ]
  # 加载配置并设置对应常量
  CONFIG.load
  CFG = CONFIG.cfg
  # 设置项目日志参数
  log       = CFG.log
  log       = STDERR if log == "STDERR"
  log       = STDOUT if log == "STDOUT"
  Log       = Logger.new log
  Log.level = Logger::INFO
  Log.level = Logger::DEBUG if CFG.debug
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netdisco-0.0.4 lib/netdisco/config.rb
netdisco-0.0.3 lib/netdisco/config.rb
netdisco-0.0.2 lib/netdisco/config.rb