Class: HuaWifi_1
- Inherits:
-
Object
- Object
- HuaWifi_1
- Defined in:
- lib/freewifi/huawei/hua_controller_class.rb
Instance Attribute Summary collapse
-
#hua_wlc_1_ip ⇒ Object
Returns the value of attribute hua_wlc_1_ip.
-
#hua_wlc_2_ip ⇒ Object
Returns the value of attribute hua_wlc_2_ip.
-
#hua_wlc_login ⇒ Object
Returns the value of attribute hua_wlc_login.
-
#hua_wlc_password ⇒ Object
Returns the value of attribute hua_wlc_password.
Instance Method Summary collapse
- #get_sub_info2_1(mac) ⇒ Object
- #get_sub_info_1(mac) ⇒ Object
-
#initialize(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password) ⇒ HuaWifi_1
constructor
A new instance of HuaWifi_1.
Constructor Details
#initialize(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password) ⇒ HuaWifi_1
Returns a new instance of HuaWifi_1.
7 8 9 10 11 12 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 7 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 |
Instance Attribute Details
#hua_wlc_1_ip ⇒ Object
Returns the value of attribute hua_wlc_1_ip.
5 6 7 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 5 def hua_wlc_1_ip @hua_wlc_1_ip end |
#hua_wlc_2_ip ⇒ Object
Returns the value of attribute hua_wlc_2_ip.
5 6 7 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 5 def hua_wlc_2_ip @hua_wlc_2_ip end |
#hua_wlc_login ⇒ Object
Returns the value of attribute hua_wlc_login.
5 6 7 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 5 def hua_wlc_login @hua_wlc_login end |
#hua_wlc_password ⇒ Object
Returns the value of attribute hua_wlc_password.
5 6 7 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 5 def hua_wlc_password @hua_wlc_password end |
Instance Method Details
#get_sub_info2_1(mac) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 85 def get_sub_info2_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 macaddr1 = mac.downcase 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_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<iter3.length # p iter4 = iter3[i].split(" ") # i+=1 # end rescue p "failed to get info from huawei controller1" end return subscribers_mac+ ",,," + access_point + ",,," + ssid_ap + ",,," + tx_rate_set + ",,,"+ tx_rate + ",,,"+ rx_rate + ",,,"+ rx_signal + ",,,"+ uptime + ",,,"+ packets + ",,,"+ bytes end |
#get_sub_info_1(mac) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/freewifi/huawei/hua_controller_class.rb', line 15 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<iter3.length # p iter4 = iter3[i].split(" ") # i+=1 # end rescue p "failed to get info from huawei controller1" end return subscribers_mac+ ",,," + access_point + ",,," + ssid_ap + ",,," + tx_rate_set + ",,,"+ tx_rate + ",,,"+ rx_rate + ",,,"+ rx_signal + ",,,"+ uptime + ",,,"+ packets + ",,,"+ bytes end |