Sha256: 8c16912948c11374ec8f8bf73d9b6fdd6895ceaefca271bf43a6905cdaa68be6

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'wlc_snmp'

require 'wifidiag/adapters/base'

require 'wifidiag/ap_data'
require 'wifidiag/client_data'

module Wifidiag
  module Adapters
    class CiscoWlc
      def initialize(host:, port: 161, community:)
        @host = host
        @port = port
        @community = community
      end

      def collect
        aps = {}
        wlc.clients.map do |client|
          if client.ap
            ap = aps.fetch(client.ap_mac) do
              aps[client.ap_mac] = ApData.new(
                name: client.ap.name,
                mac_address: client.ap.mac_address,
                location: client.ap.location,
                model: client.ap.model,
              )
            end
          end
          ClientData.new(
            mac_address: client.mac_address,
            ip_address: client.ip_address,
            ap: ap,
            wlan_profile: client.wlan_profile,
            protocol: client.protocol,
            ap_mac: client.ap_mac,
            uptime: client.uptime,
            current_rate: client.current_rate,
            supported_data_rates: client.supported_data_rates,
            user: client.user,
            ssid: client.ssid,
          )
        end
      end

      def wlc
        @snmp ||= WlcSnmp::Client.new(host: @host, port: @port, community: @community)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wifidiag-0.1.0 lib/wifidiag/adapters/cisco_wlc.rb