require 'mtik' class NEWhubWifiApi_1 attr_accessor :mtik_control_ips_get, :mtik_user, :mtik_password def initialize(mtik_control_ips_get, mtik_user, mtik_password) @mtik_control_ips_get = mtik_control_ips_get @mtik_user = mtik_user @mtik_password = mtik_password end def get_info_subs_from_mik_1(subs_mac, controllers_ip) input_parameters = {:subs_mac => subs_mac, :controllers_ip => controllers_ip} #region get additional information subscribers_mac = subs_mac access_point ="" ssid_ap ="" tx_rate_set = "" tx_rate = "" rx_rate = "" rx_signal = "" uptime = "" packets = "" bytes = "" MTik::verbose = false mikrot_connection1 = MTik::Connection.new :host => controllers_ip, :user => mtik_user, :pass => mtik_password, :conn_timeout => 7, :cmd_timeout => 7 mikrot_connection1.get_reply('/caps-man/registration-table/getall') do |req, sentence| req.reply.each do |reply| if reply.key?('mac-address') #p reply if reply['mac-address'] == subscribers_mac access_point = reply['interface'] ssid_ap = reply['ssid'] tx_rate = reply['tx-rate'] rx_rate = reply['rx-rate'] rx_signal = reply['rx-signal'] uptime = reply['uptime'] packets = reply['packets'] bytes = reply['bytes'] tx_rate_set = reply['tx-rate-set'] end end end end if access_point=="" || ssid_ap=="" || packets=="" access_point = "not on mikrotik controller" ssid_ap = "unknown" tx_rate_set = "unknown" tx_rate = "0" rx_rate = "0" rx_signal = "0" uptime = "0" packets = "0" bytes = "0" end if access_point==nil access_point= "unknown" end if ssid_ap==nil ssid_ap= "unknown" end if tx_rate_set==nil tx_rate_set= "unknown" end if tx_rate==nil tx_rate= "unknown" end if rx_rate==nil rx_rate= "unknown" end if rx_signal==nil rx_signal= "unknown" end if uptime==nil uptime= "unknown" end if packets==nil packets= "unknown" end if bytes==nil bytes= "unknown" end #endregion answ = subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes answ end end