Sha256: 97549a03b2916265ef91912326317204c8df9559bc280ab24b33750609369ae1

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'telemetry/snmp/version'
require 'telemetry/logger'
require 'telemetry/metrics/parser'
require 'telemetry/snmp/data'
require 'telemetry/snmp/client'
require 'telemetry/snmp/publisher'
require 'telemetry/snmp/collector'
require 'telemetry/snmp/device_collector'

module Telemetry
  module Snmp
    class << self
      def bootstrap
        Telemetry::Logger.setup(level: 'info')
        Telemetry::Logger.info "Starting Telemetry::Snmp v#{Telemetry::Snmp::VERSION}"
        Telemetry::Snmp::Data.start!
        Telemetry::Snmp::Client.load_mibs
        Telemetry::Snmp::Publisher.start!
        Telemetry::Logger.info 'Telemetry::Snmp bootstrapped!'
        start_expire_devices
        start_collection
      end

      def start_expire_devices
        @expire_devices_task = Concurrent::TimerTask.new(execution_interval: 300, timeout_interval: 10) do
          Telemetry::Snmp::Collector.unlock_expired_devices
        end
        @expire_devices_task.execute
      end

      def stop_expire_devices
        @expire_devices_task.stop
      end

      def start_collection
        @collection_task = Concurrent::TimerTask.new(execution_interval: 10, timeout_interval: 300) do
          Telemetry::Snmp::Collector.loop_devices
        end
        @collection_task.execute
      end

      def stop_collection
        @collection_task.stop
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
telemetry-snmp-0.3.0 lib/telemetry/snmp.rb