require 'net-telnet' class HuaWifi_1 attr_accessor :hua_wlc_1_ip, :hua_wlc_2_ip, :hua_wlc_login, :hua_wlc_password def initialize(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password) @hua_wlc_1_ip = hua_wlc_1_ip @hua_wlc_2_ip = hua_wlc_2_ip @hua_wlc_login = hua_wlc_login @hua_wlc_password = hua_wlc_password end def get_sub_info_1(mac) subscribers_mac =mac access_point = "unknown" ssid_ap = "unknown" tx_rate_set = "unknown" tx_rate = "unknown" rx_rate = "unknown" rx_signal = "unknown" uptime = "unknown" packets = "unknown" bytes = "unknown" begin p macaddr1 = mac.downcase p macaddr2 = macaddr1[0]+macaddr1[1]+macaddr1[3]+macaddr1[4]+"-"+macaddr1[6]+macaddr1[7]+macaddr1[9]+macaddr1[10]+"-"+macaddr1[12]+macaddr1[13]+macaddr1[15]+macaddr1[16] dump = "" connection = Net::Telnet.new( "Host" => hua_wlc_1_ip, "Timeout" => 10, "Prompt" => /.*>/ ) { |str| print str } connection.login({ "Name" => hua_wlc_login, "Password" => hua_wlc_password, "LoginPrompt" => /Username:/ }) { |str| } connection.cmd("system-view\n display station sta-mac #{macaddr2}\n quit \n") { |c| dump << c } connection.close iter1 = dump.split("\n") ssid_ap = iter1[7].split(" ")[3] temmmm="" temmmm1="1" i=0 while i < iter1.length if iter1[i].include? "AP Name" temmmm = iter1[i] elsif iter1[i].include? "Station's Channel Band-width" && "20MHz" temmmm1="0" end i+=1 end if temmmm1=="0" access_point = temmmm.gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-1" else access_point = temmmm.gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-2" end tx_rate_set = iter1[11].split(" ")[4] rx_signal = iter1[10].split(" ")[6] uptime = iter1[8].split(" ")[4] # p iter1 = dump.split("----------------------------------------------------------------------------------------------------") # p iter2 = iter1[2] # p iter3 = iter2.split("\n") # i = 1 # while i hua_wlc_2_ip, "Timeout" => 10, "Prompt" => /.*>/ ) { |str| print str } connection.login({ "Name" => hua_wlc_login, "Password" => hua_wlc_password, "LoginPrompt" => /Username:/ }) { |str| } connection.cmd("system-view\n display station sta-mac #{macaddr2}\n quit \n") { |c| dump << c } connection.close iter1 = dump.split("\n") ssid_ap = iter1[7].split(" ")[3] if iter1[41].gsub!(" ","").split(":")[1]=="20MHz" access_point = iter1[35].gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-1" else access_point = iter1[35].gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-2" end tx_rate_set = iter1[11].split(" ")[4] rx_signal = iter1[10].split(" ")[6] uptime = iter1[8].split(" ")[4] # p iter1 = dump.split("----------------------------------------------------------------------------------------------------") # p iter2 = iter1[2] # p iter3 = iter2.split("\n") # i = 1 # while i