| 63 | | |
|---|
| 64 | | end |
|---|
| 65 | | |
|---|
| 66 | | |
|---|
| 67 | | # Display a list of entities on a device that the user may manage. |
|---|
| 68 | | |
|---|
| 69 | | def device |
|---|
| 70 | | |
|---|
| 71 | | |
|---|
| 72 | | # Trap the case where an invalid device ID has been specified and throw |
|---|
| 73 | | # an error. We don't differentiate between 'device does not exist' and |
|---|
| 74 | | # 'you are not authorised to manage' - it gives away less information. |
|---|
| 75 | | |
|---|
| 76 | | begin |
|---|
| 77 | | @device = Device.find(params[:device_id]) |
|---|
| 78 | | rescue |
|---|
| 79 | | flash[:notice] = "You are not authorised to manage the device with id=#{params[:device_id]}" |
|---|
| 80 | | redirect_to :action => "index", :params => {} and return |
|---|
| 81 | | end |
|---|
| 82 | | |
|---|
| 83 | | if @device |
|---|
| 84 | | @l2_interfaces = L2Interface.find(:all, :conditions => ["l2_interfaces.device_id = ?", @device.id.to_s], |
|---|
| 85 | | :include => ['l3_interfaces']) |
|---|
| 86 | | end |
|---|
| 87 | | |
|---|
| 88 | | respond_to do |format| |
|---|
| 89 | | format.html |
|---|
| 90 | | format.xml |
|---|
| 91 | | end |
|---|
| 92 | | |
|---|
| 93 | | end |
|---|
| 94 | | |
|---|
| 95 | | |
|---|
| 96 | | # Display a list of entities on an interface that the user may manage. |
|---|
| 97 | | |
|---|
| 98 | | def interface |
|---|
| 99 | | |
|---|
| 100 | | |
|---|
| 101 | | # Look up the device and interface |
|---|
| 102 | | |
|---|
| 103 | | logger.debug "Looking up interface details for device_id=#{params[:device_id]} and l2_interface_id=#{params[:interface_id]}" |
|---|
| 104 | | |
|---|
| 105 | | @device = Device.find(:first, :conditions => { :id => params[:device_id] }) |
|---|
| 106 | | |
|---|
| 107 | | if @device.nil? |
|---|
| 108 | | flash[:notice] = "Could not find this device. This may mean the device does not exist, or that you do not have access to this device." |
|---|
| 109 | | logger.debug "Failed to retrieve device id=#{params[:device_id]}" |
|---|
| 110 | | redirect_to :back |
|---|
| 111 | | else |
|---|
| 112 | | logger.debug "Retrieved device id=#{@device.id}, hostname=#{@device.hostname}" |
|---|
| 113 | | end |
|---|
| 114 | | |
|---|
| 115 | | |
|---|
| 116 | | @interface = @device.l2_interfaces.find(:first, :conditions => { :id => params[:interface_id] }) |
|---|
| 117 | | |
|---|
| 118 | | if @interface.nil? |
|---|
| 119 | | flash[:notice] = "Could not find this interface. This may mean that the interface does not exist, or you do not have access to this device." |
|---|
| 120 | | logger.debug "Failed to retrieve interface id=#{params[:interface_id]}" |
|---|
| 121 | | redirect_to :back |
|---|
| 122 | | else |
|---|
| 123 | | logger.debug "Retrieved interface id=#{@interface.id}, ifdescr_short=#{@interface.ifdescr_short}" |
|---|
| 124 | | end |
|---|
| 125 | | |
|---|
| 126 | | |
|---|
| 127 | | |
|---|
| 128 | | if @interface.iftype == "adsl" && @interface.connector_present? != :true |
|---|
| 129 | | |
|---|
| 130 | | begin |
|---|
| 131 | | @adsl_line_table = @device.get_table('ADSL-LINE-MIB::adslLineTable') |
|---|
| 132 | | @adsl_atuc_physical_table = @device.get_table('ADSL-LINE-MIB::adslAtucPhysTable') |
|---|
| 133 | | @adsl_atur_physical_table = @device.get_table('ADSL-LINE-MIB::adslAturPhysTable') |
|---|
| 134 | | @adsl_atuc_channel_table = @device.get_table('ADSL-LINE-MIB::adslAtucChanTable') |
|---|
| 135 | | @adsl_atur_channel_table = @device.get_table('ADSL-LINE-MIB::adslAturChanTable') |
|---|
| 136 | | @adsl_atuc_performance_data_table = @device.get_table('ADSL-LINE-MIB::adslAtucPerfDataTable') |
|---|
| 137 | | @adsl_atur_performance_data_table = @device.get_table('ADSL-LINE-MIB::adslAturPerfDataTable') |
|---|
| 138 | | @adsl_atuc_channel_performance_data_table = @device.get_table('ADSL-LINE-MIB::adslAtucChanPerfDataTable') |
|---|
| 139 | | @adsl_atur_channel_performance_data_table = @device.get_table('ADSL-LINE-MIB::adslAturChanPerfDataTable') |
|---|
| 140 | | rescue Device::SNMPProxyConnectFailure |
|---|
| 141 | | end |
|---|
| 142 | | |
|---|
| 143 | | @interface_specific_partial = "adsl_interface" |
|---|
| 144 | | |
|---|
| 145 | | elsif @interface.iftype == "ethernetCsmacd" |
|---|
| 146 | | |
|---|
| 147 | | # Read the duplex status for this interface, but return nothing if the |
|---|
| 148 | | # SNMP proxy isn't available (e.g. offline usage) |
|---|
| 149 | | |
|---|
| 150 | | dot3stats_oids = [ ['dot3StatsAlignmentErrors', @interface.ifindex ], ['dot3StatsFCSErrors', @interface.ifindex ], ['dot3StatsSingleCollisionFrames', @interface.ifindex ], ['dot3StatsMultipleCollisionFrames', @interface.ifindex ], ['dot3StatsDeferredTransmissions', @interface.ifindex ], ['dot3StatsLateCollisions', @interface.ifindex ], ['dot3StatsExcessiveCollisions', @interface.ifindex ], ['dot3StatsInternalMacTransmitErrors', @interface.ifindex ], ['dot3StatsCarrierSenseErrors', @interface.ifindex ], ['dot3StatsFrameTooLongs', @interface.ifindex ], ['dot3StatsInternalMacReceiveErrors', @interface.ifindex ], ['dot3StatsSymbolErrors', @interface.ifindex ], ['dot3StatsDuplexStatus', @interface.ifindex ], ['dot3StatsRateControlAbility', @interface.ifindex ], ['dot3StatsRateControlStatus', @interface.ifindex ] ] |
|---|
| 151 | | |
|---|
| 152 | | begin |
|---|
| 153 | | @dot3stats_values = @device.get_oid(dot3stats_oids, :format => :yes) |
|---|
| 154 | | rescue Device::SNMPProxyConnectFailure |
|---|
| 155 | | end |
|---|
| 156 | | |
|---|
| 157 | | @interface_specific_partial = "ethernet_interface" |
|---|
| 158 | | |
|---|
| 159 | | elsif @interface.iftype == "ds1" |
|---|
| 160 | | |
|---|
| 161 | | # Read the DS1 stats for this interface |
|---|
| 162 | | |
|---|
| 163 | | begin |
|---|
| 164 | | dsx1_config_table = @device.get_table('DS1-MIB::dsx1ConfigTable') |
|---|
| 165 | | rescue Device::SNMPProxyConnectFailure |
|---|
| 166 | | end |
|---|
| 167 | | |
|---|
| 168 | | |
|---|
| 169 | | dsx1_config_table.each do |ds1_row| |
|---|
| 170 | | |
|---|
| 171 | | if ds1_row[1]['dsx1IfIndex'] == @interface.ifindex |
|---|
| 172 | | |
|---|
| 173 | | logger.debug "Found a ds1_interface=#{ds1_row[1]['dsx1LineIndex']} for ifindex=#{@interface.ifindex}" |
|---|
| 174 | | @ds1_interface = ds1_row[1] |
|---|
| 175 | | |
|---|
| 176 | | end |
|---|
| 177 | | |
|---|
| 178 | | end |
|---|
| 179 | | |
|---|
| 180 | | |
|---|
| 181 | | # Translate the dsx1LineType in to human-readable descriptions |
|---|
| 182 | | |
|---|
| 183 | | @ds1_line_type = Hash.new |
|---|
| 184 | | @ds1_line_type['other'] = "undefined" |
|---|
| 185 | | @ds1_line_type['dsx1ESF'] = "Extended Superframe DS1 (T1.107)" |
|---|
| 186 | | @ds1_line_type['dsx1D4'] = "AT&T D4 format DS1 (T1.107)" |
|---|
| 187 | | @ds1_line_type['dsx1E1'] = "ITU-T G.704 (Table 5A)" |
|---|
| 188 | | @ds1_line_type['dsx1E1CRC'] = "ITU-T G.704 (Table 5B)" |
|---|
| 189 | | @ds1_line_type['dsx1E1MF'] = "ITU-T G.704 (Table 5A) with TS16 multiframing" |
|---|
| 190 | | @ds1_line_type['dsx1E1CRCMF'] = "ITU-T G.704 (Table 5B) with TS16 multiframing" |
|---|
| 191 | | @ds1_line_type['dsx1Unframed'] = "Unframed DS1" |
|---|
| 192 | | @ds1_line_type['dsx1E1Unframed'] = "Unframed E1 (G.703)" |
|---|
| 193 | | @ds1_line_type['dsx1DS2M12'] = "DS2 frame format (T1.107)" |
|---|
| 194 | | @ds1_line_type['dsx1E2'] = "E2 frame format (G.704)" |
|---|
| 195 | | @ds1_line_type['dsx1E1Q50'] = "E1Q50" |
|---|
| 196 | | @ds1_line_type['dsx1E1Q50CRC'] = "E1Q50 with CRC" |
|---|
| 197 | | @ds1_line_type['dsx1J1ESF'] = "J1 according to JT-G704, JT-G706 and JT-I431" |
|---|
| 198 | | @ds1_line_type['dsx1J1Unframed'] = "Unframed J1" |
|---|
| 199 | | |
|---|
| 200 | | |
|---|
| 201 | | # Translate the dsx1LineEncoding in to human-readable descriptions |
|---|
| 202 | | |
|---|
| 203 | | @ds1_line_coding = Hash.new |
|---|
| 204 | | @ds1_line_coding['dsx1JBZS'] = "Jammed Bit Zero Suppression (JBZS)" |
|---|
| 205 | | @ds1_line_coding['dsx1B8ZS'] = "Biploar with 8 Zeros Substitution (B8ZS)" |
|---|
| 206 | | @ds1_line_coding['dsx1HDB3'] = "High-Density Bipoloar Order of 3 (HDB3)" |
|---|
| 207 | | @ds1_line_coding['dsx1ZBTSI'] = "ZBTSI" |
|---|
| 208 | | @ds1_line_coding['dsx1AMI'] = "No Zero Code Suppression (AMI)" |
|---|
| 209 | | @ds1_line_coding['other'] = "Other" |
|---|
| 210 | | @ds1_line_coding['dsx1B6ZS'] = "Bipolar with 6 Zeros Substitution (B6ZS)" |
|---|
| 211 | | |
|---|
| 212 | | |
|---|
| 213 | | # Translate the dsx1SignalMode in to human-readable descriptions |
|---|
| 214 | | |
|---|
| 215 | | @ds1_signal_mode = Hash.new |
|---|
| 216 | | @ds1_signal_mode['none'] = "No signalling" |
|---|
| 217 | | @ds1_signal_mode['robbedBit'] = "Robbed Bit Signalling (RBS)" |
|---|
| 218 | | @ds1_signal_mode['bitOriented'] = "Channel Associated Signalling (CAS)" |
|---|
| 219 | | @ds1_signal_mode['messageOriented'] = "Common Channel Signalling (CCS)" |
|---|
| 220 | | |
|---|
| 221 | | |
|---|
| 222 | | # Translate the dsx1SendCode in to human-readable descriptions |
|---|
| 223 | | |
|---|
| 224 | | @ds1_send_code = Hash.new |
|---|
| 225 | | @ds1_send_code['dsx1SendNoCode'] = "Normal" |
|---|
| 226 | | @ds1_send_code['dsx1SendLineCode'] = "Requesting line loopback" |
|---|
| 227 | | @ds1_send_code['dsx1SendPayloadCode'] = "Requesting payload loopback" |
|---|
| 228 | | @ds1_send_code['dsx1SendResetCode'] = "Requesting loop termination" |
|---|
| 229 | | @ds1_send_code['dsx1SendQRS'] = "Sending quasi-random signal (QRS)" |
|---|
| 230 | | @ds1_send_code['dsx1Send511Pattern'] = "Sending 511-bit fixed test pattern" |
|---|
| 231 | | @ds1_send_code['dsx1Send3in24Pattern'] = "Sending 3-in-24-bits-set test pattern" |
|---|
| 232 | | @ds1_send_code['dsx1SendOtherTestPattern'] = "Sending other test pattern" |
|---|
| 233 | | |
|---|
| 234 | | |
|---|
| 235 | | # Translate the dsx1TransmitClockSource in to individual states |
|---|
| 236 | | |
|---|
| 237 | | @ds1_transmit_clock_source = Hash.new |
|---|
| 238 | | @ds1_transmit_clock_source['loopTiming'] = "Line clock" |
|---|
| 239 | | @ds1_transmit_clock_source['localTiming'] = "Local clock" |
|---|
| 240 | | @ds1_transmit_clock_source['throughTiming'] = "Line clock from another circuit" |
|---|
| 241 | | |
|---|
| 242 | | |
|---|
| 243 | | # Translate the dsx1LoopbackStatus in to individual states |
|---|
| 244 | | |
|---|
| 245 | | @ds1_loopback_status = Array.new |
|---|
| 246 | | @ds1_loopback_status.push "Near-end payload loopback" if (@ds1_interface['dsx1LoopbackStatus'] & 2 == 2) |
|---|
| 247 | | @ds1_loopback_status.push "Near-end line loopback" if (@ds1_interface['dsx1LoopbackStatus'] & 4 == 4) |
|---|
| 248 | | @ds1_loopback_status.push "Near-end other loopback" if (@ds1_interface['dsx1LoopbackStatus'] & 8 == 8) |
|---|
| 249 | | @ds1_loopback_status.push "Near-end inward loopback" if (@ds1_interface['dsx1LoopbackStatus'] & 16 == 16) |
|---|
| 250 | | @ds1_loopback_status.push "Far-end payload loopback" if (@ds1_interface['dsx1LoopbackStatus'] & 32 == 32) |
|---|
| 251 | | @ds1_loopback_status.push "Far-end line loopback" if (@ds1_interface['dsx1LoopbackStatus'] & 64 == 64) |
|---|
| 252 | | |
|---|
| 253 | | |
|---|
| 254 | | # Translate the dsx1LineStatus value in to individual states |
|---|
| 255 | | |
|---|
| 256 | | @ds1_line_status = Array.new |
|---|
| 257 | | @ds1_line_status.push "Yellow Alarm: Far end Loss of Framing (LOF)" if (@ds1_interface['dsx1LineStatus'] & 2 == 2) |
|---|
| 258 | | @ds1_line_status.push "Near end sending Loss of Framing (LOF)" if (@ds1_interface['dsx1LineStatus'] & 4 == 4) |
|---|
| 259 | | @ds1_line_status.push "Far end sending Alarm Indication Signal (AIS)" if (@ds1_interface['dsx1LineStatus'] & 8 == 8) |
|---|
| 260 | | @ds1_line_status.push "Near end sending Alarm Indication Signal (AIS)" if (@ds1_interface['dsx1LineStatus'] & 16 == 16) |
|---|
| 261 | | @ds1_line_status.push "Red Alarm: Near end Loss of Framing (LOF)" if (@ds1_interface['dsx1LineStatus'] & 32 == 32) |
|---|
| 262 | | @ds1_line_status.push "Near end Loss of Signal (LOS)" if (@ds1_interface['dsx1LineStatus'] & 64 == 64) |
|---|
| 263 | | @ds1_line_status.push "Near end looped" if (@ds1_interface['dsx1LineStatus'] & 128 == 128) |
|---|
| 264 | | @ds1_line_status.push "E1 Timeslot 16 Alarm Indication Signal (AIS)" if (@ds1_interface['dsx1LineStatus'] & 256 == 256) |
|---|
| 265 | | @ds1_line_status.push "Far end sending Timeslot 16 Loss of Signalling Multiframe (LOMF) alarm" if (@ds1_interface['dsx1LineStatus'] & 512 == 512) |
|---|
| 266 | | @ds1_line_status.push "Near end sending Timeslot 16 Loss of Signalling Multiframe (LOMF) alarm" if (@ds1_interface['dsx1LineStatus'] & 1024 == 1024) |
|---|
| 267 | | @ds1_line_status.push "Near end detected a test code" if (@ds1_interface['dsx1LineStatus'] & 2048 == 2048) |
|---|
| 268 | | @ds1_line_status.push "Unknown line status - failure?" if (@ds1_interface['dsx1LineStatus'] & 4096 == 4096) |
|---|
| 269 | | @ds1_line_status.push "Near end in Unavailable Signal State" if (@ds1_interface['dsx1LineStatus'] & 8192 == 8192) |
|---|
| 270 | | @ds1_line_status.push "Carrier equipment Out Of Service (OOS)" if (@ds1_interface['dsx1LineStatus'] & 16384 == 16384) |
|---|
| 271 | | @ds1_line_status.push "DS2 Payload Alarm Indication Signal (AIS)" if (@ds1_interface['dsx1LineStatus'] & 32768 == 32768) |
|---|
| 272 | | @ds1_line_status.push "DS2 Performance Threshold Exceeded" if (@ds1_interface['dsx1LineStatus'] & 65536 == 65536) |
|---|
| 273 | | |
|---|
| 274 | | |
|---|
| 275 | | # Translate the dsx1LoopbackConfig value in to individual states |
|---|
| 276 | | |
|---|
| 277 | | @ds1_loopback_config = Hash.new |
|---|
| 278 | | @ds1_loopback_config['dsx1NoLoop'] = "No loopback set" |
|---|
| 279 | | @ds1_loopback_config['dsx1PayloadLoop'] = "Local loop through device" |
|---|
| 280 | | @ds1_loopback_config['dsx1LineLoop'] = "Local loop set" |
|---|
| 281 | | @ds1_loopback_config['dsx1OtherLoop'] = "Undefined loopback set" |
|---|
| 282 | | @ds1_loopback_config['dsx1InwardLoop'] = "Remote loop set" |
|---|
| 283 | | @ds1_loopback_config['dsx1DualLoop'] = "Local and remote loops set" |
|---|
| 284 | | |
|---|
| 285 | | |
|---|
| 286 | | # Retrieve the dsx1CurrentTable for this interface |
|---|
| 287 | | |
|---|
| 288 | | ds1_current_table_oids = [ ['dsx1TimeElapsed', @interface.ifindex], ['dsx1CurrentESs', @interface.ifindex], ['dsx1CurrentSESs', @interface.ifindex], ['dsx1CurrentSEFSs', @interface.ifindex], ['dsx1CurrentUASs', @interface.ifindex], ['dsx1CurrentCSSs', @interface.ifindex], ['dsx1CurrentPCVs', @interface.ifindex], ['dsx1CurrentLESs', @interface.ifindex], ['dsx1CurrentBESs', @interface.ifindex], ['dsx1CurrentDMs', @interface.ifindex], ['dsx1CurrentLCVs', @interface.ifindex] ] |
|---|
| 289 | | ds1_total_table_oids = [ ['dsx1TotalESs', @interface.ifindex], ['dsx1TotalSESs', @interface.ifindex], ['dsx1TotalSEFSs', @interface.ifindex], ['dsx1TotalUASs', @interface.ifindex], ['dsx1TotalCSSs', @interface.ifindex], ['dsx1TotalPCVs', @interface.ifindex], ['dsx1TotalLESs', @interface.ifindex], ['dsx1TotalBESs', @interface.ifindex], ['dsx1TotalDMs', @interface.ifindex], ['dsx1TotalLCVs', @interface.ifindex] ] |
|---|
| 290 | | |
|---|
| 291 | | |
|---|
| 292 | | # Gather the current interval statistics table |
|---|
| 293 | | |
|---|
| 294 | | begin |
|---|
| 295 | | @ds1_current_table = @device.get_oid(ds1_current_table_oids, :format => :yes) |
|---|
| 296 | | rescue Device::SNMPProxyConnectFailure |
|---|
| 297 | | end |
|---|
| 298 | | |
|---|
| 299 | | |
|---|
| 300 | | # Gather the last 24 hours statistics table |
|---|
| 301 | | |
|---|
| 302 | | begin |
|---|
| 303 | | @ds1_total_table = @device.get_oid(ds1_total_table_oids, :format => :yes) |
|---|
| 304 | | rescue Device::SNMPProxyConnectFailure |
|---|
| 305 | | end |
|---|
| 306 | | |
|---|
| 307 | | |
|---|
| 308 | | # Render the gathered data |
|---|
| 309 | | |
|---|
| 310 | | @interface_specific_partial = "ds1_interface" |
|---|
| 311 | | |
|---|
| 312 | | end |
|---|
| 313 | | |
|---|
| 314 | | if @interface_specific_partial |
|---|
| 315 | | |
|---|
| 316 | | logger.debug "Will render interface-specific partial=#{@interface_specific_partial}" |
|---|
| 317 | | |
|---|
| 318 | | else |
|---|
| 319 | | |
|---|
| 320 | | logger.debug "No interface-specific partials for an interface of type=#{@interface.iftype}" |
|---|
| 321 | | |
|---|
| 322 | | end |
|---|
| 323 | | |
|---|
| 324 | | respond_to do |format| |
|---|
| 325 | | format.html |
|---|
| 326 | | format.xml |
|---|
| 327 | | end |
|---|
| 328 | | |
|---|
| 329 | | end |
|---|
| 330 | | |
|---|
| 331 | | |
|---|
| 332 | | # Return a fragment of HTML with the values of ifInOctets, ifOutOctets, |
|---|
| 333 | | # ifOperStatus and ifAdminStatus for a specified :device_id and |
|---|
| 334 | | # :interface_id. This is typically called in a view. |
|---|
| 335 | | |
|---|
| 336 | | def traffic_monitor |
|---|
| 337 | | |
|---|
| 338 | | @device = Device.find(params[:device_id]) |
|---|
| 339 | | @interface = L2Interface.find(:first, :conditions => "device_id = #{params[:device_id]} AND ifindex = #{params[:interface_id]}") |
|---|
| 340 | | |
|---|
| 341 | | manager = SNMP::Manager.new(:Host => @device.ipv4_address, :Community => @device.snmp_community) |
|---|
| 342 | | |
|---|
| 343 | | ifTable_columns = ['ifInOctets.' + @interface.ifindex.to_s, 'ifOutOctets.' + @interface.ifindex.to_s, 'ifOperStatus.' + @interface.ifindex.to_s, 'ifAdminStatus.' + @interface.ifindex.to_s ] |
|---|
| 344 | | |
|---|
| 345 | | ifTable_row = manager.get(ifTable_columns) |
|---|
| 346 | | |
|---|
| 347 | | row_id = 0 |
|---|
| 348 | | @row = Hash.new |
|---|
| 349 | | |
|---|
| 350 | | ifTable_row.each_varbind do |vb| |
|---|
| 351 | | column = ifTable_columns[row_id].chomp.split(/\./)[0] |
|---|
| 352 | | @row[column] = vb.value |
|---|
| 353 | | row_id = row_id + 1 |
|---|
| 354 | | end |
|---|
| 355 | | |
|---|
| 356 | | respond_to do |format| |
|---|
| 357 | | format.html { |
|---|
| 358 | | render :partial => 'manage/traffic_monitor', :locals => { :data => @row } } |
|---|
| 359 | | format.xml |
|---|
| 360 | | end |
|---|
| 361 | | |
|---|
| 362 | | end |
|---|
| 363 | | |
|---|
| 364 | | |
|---|
| 365 | | # Return a fragment of HTML with all interface data. This is typically |
|---|
| 366 | | # called in a view. |
|---|
| 367 | | |
|---|
| 368 | | def all_interfaces |
|---|
| 369 | | |
|---|
| 370 | | @device = Device.find(params[:device_id]) |
|---|
| 371 | | |
|---|
| 372 | | @interfaces = L2Interface.find(:all, :conditions => "device_id = " + @device.id.to_s) |
|---|
| 373 | | |
|---|
| 374 | | respond_to do |format| |
|---|
| 375 | | format.html { |
|---|
| 376 | | render :partial => 'common/all_interfaces', :interfaces => @interfaces } |
|---|
| 377 | | format.xml |
|---|
| 378 | | end |
|---|