Class: NEWhubWifiApi_1
- Inherits:
-
Object
- Object
- NEWhubWifiApi_1
- Defined in:
- lib/freewifi/mikrotik/newhub_mtik_api.rb
Instance Attribute Summary collapse
-
#mtik_control_ips_get ⇒ Object
Returns the value of attribute mtik_control_ips_get.
-
#mtik_password ⇒ Object
Returns the value of attribute mtik_password.
-
#mtik_user ⇒ Object
Returns the value of attribute mtik_user.
Instance Method Summary collapse
- #get_info_subs_from_mik_1(subs_mac, controllers_ip) ⇒ Object
- #get_info_subs_from_mik_ssh(subs_mac, controllers_ip) ⇒ Object
-
#initialize(mtik_control_ips_get, mtik_user, mtik_password) ⇒ NEWhubWifiApi_1
constructor
A new instance of NEWhubWifiApi_1.
Constructor Details
#initialize(mtik_control_ips_get, mtik_user, mtik_password) ⇒ NEWhubWifiApi_1
Returns a new instance of NEWhubWifiApi_1.
8 9 10 11 12 |
# File 'lib/freewifi/mikrotik/newhub_mtik_api.rb', line 8 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 |
Instance Attribute Details
#mtik_control_ips_get ⇒ Object
Returns the value of attribute mtik_control_ips_get.
6 7 8 |
# File 'lib/freewifi/mikrotik/newhub_mtik_api.rb', line 6 def mtik_control_ips_get @mtik_control_ips_get end |
#mtik_password ⇒ Object
Returns the value of attribute mtik_password.
6 7 8 |
# File 'lib/freewifi/mikrotik/newhub_mtik_api.rb', line 6 def mtik_password @mtik_password end |
#mtik_user ⇒ Object
Returns the value of attribute mtik_user.
6 7 8 |
# File 'lib/freewifi/mikrotik/newhub_mtik_api.rb', line 6 def mtik_user @mtik_user end |
Instance Method Details
#get_info_subs_from_mik_1(subs_mac, controllers_ip) ⇒ 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/freewifi/mikrotik/newhub_mtik_api.rb', line 15 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 subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes end |
#get_info_subs_from_mik_ssh(subs_mac, controllers_ip) ⇒ Object
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/freewifi/mikrotik/newhub_mtik_api.rb', line 99 def get_info_subs_from_mik_ssh(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 = "" begin Net::SSH.start(controllers_ip, mtik_user, :password => mtik_password) do |ssh| #result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}") #p result result = ssh.exec!("/caps-man registration-table print detail value-list where mac-address=#{subs_mac}") p result access_point_reg = /interface:\s(.+)\r\n/ access_point = result.scan(access_point_reg)[0][0] ssid_reg = /ssid:\s(.+)\r\n/ ssid_ap = result.scan(ssid_reg)[0][0] tx_rate_set = "unknown" tx_rate = "0" rx_rate = "0" rx_signal = "0" uptime = "0" packets = "0" bytes = "0" p access_point p ssid_ap #regimsi = /\s+name="(.+)"\s+/ #m1 = regimsi.match(result)[1] #result2 = ssh.exec!("interface bridge port add bridge=#{bridge_name} interface=#{tunnel_name}") end #Net::SSH.stop rescue nil end p "1111111111111111111" 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=='' access_point= "unknown" end if ssid_ap==nil || ssid_ap=='' ssid_ap= "unknown" end if tx_rate_set==nil || tx_rate_set=='' tx_rate_set= "unknown" end if tx_rate==nil || tx_rate=='' tx_rate= "unknown" end if rx_rate==nil || rx_rate=='' rx_rate= "unknown" end if rx_signal==nil || rx_signal=='' rx_signal= "unknown" end if uptime==nil || uptime=='' uptime= "unknown" end if packets==nil || packets=='' packets= "unknown" end if bytes==nil || bytes=='' bytes= "unknown" end #endregion subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes end |