| 1 | # SNMP::Info::Layer3::Dell - SNMP Interface to Dell devices | ||
| 2 | # | ||
| 3 | # Copyright (c) 2008 Eric Miller | ||
| 4 | # All rights reserved. | ||
| 5 | # | ||
| 6 | # Redistribution and use in source and binary forms, with or without | ||
| 7 | # modification, are permitted provided that the following conditions are met: | ||
| 8 | # | ||
| 9 | # * Redistributions of source code must retain the above copyright notice, | ||
| 10 | # this list of conditions and the following disclaimer. | ||
| 11 | # * Redistributions in binary form must reproduce the above copyright | ||
| 12 | # notice, this list of conditions and the following disclaimer in the | ||
| 13 | # documentation and/or other materials provided with the distribution. | ||
| 14 | # * Neither the name of the University of California, Santa Cruz nor the | ||
| 15 | # names of its contributors may be used to endorse or promote products | ||
| 16 | # derived from this software without specific prior written permission. | ||
| 17 | # | ||
| 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| 22 | # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 28 | # POSSIBILITY OF SUCH DAMAGE. | ||
| 29 | |||
| 30 | package SNMP::Info::Layer3::Dell; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer3; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/; | ||
| 38 | @SNMP::Info::Layer3::Dell::EXPORT_OK = qw//; | ||
| 39 | |||
| 40 | our ($VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE); | ||
| 41 | |||
| 42 | $VERSION = '3.985003'; | ||
| 43 | |||
| 44 | %MIBS = ( | ||
| 45 | %SNMP::Info::Layer3::MIBS, | ||
| 46 | 'RADLAN-COPY-MIB' => 'rlCopySourceLocation', | ||
| 47 | 'RADLAN-Physicaldescription-MIB' => 'rlPhdStackReorder', | ||
| 48 | 'RADLAN-rlInterfaces' => 'rlIfNumOfLoopbackPorts', | ||
| 49 | 'RADLAN-HWENVIROMENT' => 'rlEnvPhysicalDescription', | ||
| 50 | 'Dell-Vendor-MIB' => 'productIdentificationVersion', | ||
| 51 | 'DELL-REF-MIB' => 'dell6224Switch', | ||
| 52 | |||
| 53 | # For DELL-OS10 devices | ||
| 54 | 'DELLEMC-OS10-PRODUCTS-MIB' => 'os10Products', | ||
| 55 | 'DELLEMC-OS10-CHASSIS-MIB' => 'os10SysObject', | ||
| 56 | ); | ||
| 57 | |||
| 58 | %GLOBALS = ( | ||
| 59 | %SNMP::Info::Layer3::GLOBALS, | ||
| 60 | 'dell_os_ver' => 'productIdentificationVersion', | ||
| 61 | 'dell_id_name' => 'productIdentificationDisplayName', | ||
| 62 | |||
| 63 | # For DELL-OS10 | ||
| 64 | 'dell_os10_id_name' => 'os10ChassisType', | ||
| 65 | ); | ||
| 66 | |||
| 67 | %FUNCS = ( | ||
| 68 | %SNMP::Info::Layer3::FUNCS, | ||
| 69 | |||
| 70 | # RADLAN-rlInterfaces:swIfTable | ||
| 71 | 'dell_duplex_admin' => 'swIfDuplexAdminMode', | ||
| 72 | 'dell_duplex' => 'swIfDuplexOperMode', | ||
| 73 | 'dell_tag_mode' => 'swIfTaggedMode', | ||
| 74 | 'dell_i_type' => 'swIfType', | ||
| 75 | 'dell_fc_admin' => 'swIfFlowControlMode', | ||
| 76 | 'dell_speed_admin' => 'swIfSpeedAdminMode', | ||
| 77 | 'dell_auto' => 'swIfSpeedDuplexAutoNegotiation', | ||
| 78 | 'dell_fc' => 'swIfOperFlowControlMode', | ||
| 79 | |||
| 80 | # RADLAN-Physicaldescription-MIB:rlPhdUnitGenParamTable | ||
| 81 | 'dell_unit' => 'rlPhdUnitGenParamStackUnit', | ||
| 82 | 'dell_sw_ver' => 'rlPhdUnitGenParamSoftwareVersion', | ||
| 83 | 'dell_fw_ver' => 'rlPhdUnitGenParamFirmwareVersion', | ||
| 84 | 'dell_hw_ver' => 'rlPhdUnitGenParamHardwareVersion', | ||
| 85 | 'dell_serial_no' => 'rlPhdUnitGenParamSerialNum', | ||
| 86 | 'dell_asset_no' => 'rlPhdUnitGenParamAssetTag', | ||
| 87 | |||
| 88 | # RADLAN-COPY-MIB:rlCopyTable | ||
| 89 | 'dell_cp_idx' => 'rlCopyIndex', | ||
| 90 | 'dell_cp_sloc' => 'rlCopySourceLocation', | ||
| 91 | 'dell_cp_sip' => 'rlCopySourceIpAddress', | ||
| 92 | 'dell_cp_sunit' => 'rlCopySourceUnitNumber', | ||
| 93 | 'dell_cp_sfile' => 'rlCopySourceFileName', | ||
| 94 | 'dell_cp_stype' => 'rlCopySourceFileType', | ||
| 95 | 'dell_cp_dloc' => 'rlCopyDestinationLocation', | ||
| 96 | 'dell_cp_dip' => 'rlCopyDestinationIpAddress', | ||
| 97 | 'dell_cp_dunit' => 'rlCopyDestinationUnitNumber', | ||
| 98 | 'dell_cp_dfile' => 'rlCopyDestinationFileName', | ||
| 99 | 'dell_cp_dtype' => 'rlCopyDestinationFileType', | ||
| 100 | 'dell_cp_state' => 'rlCopyOperationState', | ||
| 101 | 'dell_cp_bkgnd' => 'rlCopyInBackground', | ||
| 102 | 'dell_cp_rstatus' => 'rlCopyRowStatus', | ||
| 103 | |||
| 104 | # RADLAN-HWENVIROMENT:rlEnvMonSupplyStatusTable | ||
| 105 | 'dell_pwr_src' => 'rlEnvMonSupplySource', | ||
| 106 | 'dell_pwr_state' => 'rlEnvMonSupplyState', | ||
| 107 | 'dell_pwr_desc' => 'rlEnvMonSupplyStatusDescr', | ||
| 108 | |||
| 109 | # RADLAN-HWENVIROMENT:rlEnvMonFanStatusTable | ||
| 110 | 'dell_fan_state' => 'rlEnvMonFanState', | ||
| 111 | 'dell_fan_desc' => 'rlEnvMonFanStatusDescr', | ||
| 112 | |||
| 113 | # DELLEMC-OS10-CHASSIS-MIB:os10PowerSupplyTable | ||
| 114 | 'dell_os10_pwr_src' => 'os10PowerSupplyType', | ||
| 115 | 'dell_os10_pwr_state' => 'os10PowerSupplyOperStatus', | ||
| 116 | |||
| 117 | # DELLEMC-OS10-CHASSIS-MIB:os10FanTable | ||
| 118 | 'dell_os10_fan_state' => 'os10FanOperStatus', | ||
| 119 | 'dell_os10_fan_ent' => 'os10FanEntity', | ||
| 120 | 'dell_os10_fan_slot' => 'os10FanEntitySlot', | ||
| 121 | ); | ||
| 122 | |||
| 123 | %MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); | ||
| 124 | |||
| 125 | # Method OverRides | ||
| 126 | |||
| 127 | sub model { | ||
| 128 | my $dell = shift; | ||
| 129 | |||
| 130 | my $name = $dell->dell_id_name(); | ||
| 131 | my $os10_name = $dell->dell_os10_id_name(); | ||
| 132 | my $id = $dell->id(); | ||
| 133 | |||
| 134 | if ( defined $name and $name =~ m/(\d+)/ ) { | ||
| 135 | return $1; | ||
| 136 | } elsif (defined $os10_name) { | ||
| 137 | return $os10_name; | ||
| 138 | } | ||
| 139 | |||
| 140 | return unless defined $id; | ||
| 141 | |||
| 142 | my $model = SNMP::translateObj($id); | ||
| 143 | |||
| 144 | if (defined $model) { | ||
| 145 | $model =~ s/^dell//; | ||
| 146 | $model =~ s/Switch$//; | ||
| 147 | return $model; | ||
| 148 | } | ||
| 149 | return $id; | ||
| 150 | } | ||
| 151 | |||
| 152 | sub vendor { | ||
| 153 | my $dell = shift; | ||
| 154 | |||
| 155 | return $dell->_vendor(); | ||
| 156 | } | ||
| 157 | |||
| 158 | # The LLDP chassis ID is the bridge address, not ifPhysAddress.1 | ||
| 159 | sub mac { | ||
| 160 | my $dell = shift; | ||
| 161 | my $b_mac = $dell->b_mac(); | ||
| 162 | |||
| 163 | return $b_mac if defined $b_mac and $b_mac !~ /^[0:]+$/; | ||
| 164 | return $dell->orig_mac(); | ||
| 165 | } | ||
| 166 | |||
| 167 | sub os { | ||
| 168 | my $dell = shift; | ||
| 169 | |||
| 170 | return $dell->_vendor(); | ||
| 171 | } | ||
| 172 | |||
| 173 | sub os_ver { | ||
| 174 | my $dell = shift; | ||
| 175 | |||
| 176 | my $entity_os = $dell->entity_derived_os_ver(); | ||
| 177 | if ( defined $entity_os and $entity_os !~ /^\s*$/ ){ | ||
| 178 | return $entity_os; | ||
| 179 | } | ||
| 180 | |||
| 181 | my $dell_os = $dell->dell_os_ver(); | ||
| 182 | if ( defined $dell_os and $dell_os !~ /^\s*$/ ) { | ||
| 183 | return $dell_os; | ||
| 184 | } | ||
| 185 | return; | ||
| 186 | } | ||
| 187 | |||
| 188 | # check all fans, and report overall status | ||
| 189 | sub fan { | ||
| 190 | my $dell = shift; | ||
| 191 | |||
| 192 | my $fan = $dell->dell_fan_desc() || {}; | ||
| 193 | my $state = $dell->dell_fan_state() || {}; | ||
| 194 | my $os10_fan_ent = $dell->dell_os10_fan_ent() || {}; | ||
| 195 | my $os10_fan_slot = $dell->dell_os10_fan_slot() || {}; | ||
| 196 | my $os10_state = $dell->dell_os10_fan_state() || {}; | ||
| 197 | |||
| 198 | if (scalar keys %$fan) { | ||
| 199 | my @messages = (); | ||
| 200 | |||
| 201 | foreach my $k (keys %$fan) { | ||
| 202 | next if $state->{$k} and $state->{$k} eq 'normal'; | ||
| 203 | push @messages, "$fan->{$k}: $state->{$k}"; | ||
| 204 | } | ||
| 205 | |||
| 206 | push @messages, ((scalar keys %$fan). " fans OK") | ||
| 207 | if scalar @messages == 0; | ||
| 208 | |||
| 209 | return (join ", ", @messages); | ||
| 210 | } elsif (scalar keys %$os10_fan_ent) { | ||
| 211 | my @messages = (); | ||
| 212 | |||
| 213 | foreach my $k (keys %$os10_fan_ent) { | ||
| 214 | next if $os10_state->{$k} and $os10_state->{$k} eq 'up'; | ||
| 215 | push @messages, "$os10_fan_ent->{$k}_$os10_fan_slot->{$k}: $os10_state->{$k}"; | ||
| 216 | } | ||
| 217 | |||
| 218 | push @messages, ((scalar keys %$os10_fan_ent). " fans OK"); | ||
| 219 | |||
| 220 | return (join ", ", @messages); | ||
| 221 | } | ||
| 222 | return; | ||
| 223 | } | ||
| 224 | |||
| 225 | sub ps1_type { | ||
| 226 | my $dell = shift; | ||
| 227 | |||
| 228 | my $src = $dell->dell_pwr_src() || $dell->dell_os10_pwr_src() || {}; | ||
| 229 | |||
| 230 | foreach my $k (sort keys %$src) { | ||
| 231 | next unless $src->{$k}; | ||
| 232 | return $src->{$k}; | ||
| 233 | } | ||
| 234 | return; | ||
| 235 | } | ||
| 236 | |||
| 237 | sub ps2_type { | ||
| 238 | my $dell = shift; | ||
| 239 | |||
| 240 | my $src = $dell->dell_pwr_src() || $dell->dell_os10_pwr_src() || {}; | ||
| 241 | |||
| 242 | my $i = 0; | ||
| 243 | foreach my $k (sort keys %$src) { | ||
| 244 | $i++; | ||
| 245 | next unless $src->{$k} and $i == 2; | ||
| 246 | return $src->{$k}; | ||
| 247 | } | ||
| 248 | return; | ||
| 249 | } | ||
| 250 | |||
| 251 | sub ps1_status { | ||
| 252 | my $dell = shift; | ||
| 253 | |||
| 254 | my $status = $dell->dell_pwr_state() || $dell->dell_os10_pwr_state() || {}; | ||
| 255 | |||
| 256 | foreach my $k (sort keys %$status) { | ||
| 257 | next unless $status->{$k}; | ||
| 258 | return $status->{$k}; | ||
| 259 | } | ||
| 260 | return; | ||
| 261 | } | ||
| 262 | |||
| 263 | sub ps2_status { | ||
| 264 | my $dell = shift; | ||
| 265 | |||
| 266 | my $status = $dell->dell_pwr_state() || $dell->dell_os10_pwr_state() || {}; | ||
| 267 | |||
| 268 | my $i = 0; | ||
| 269 | foreach my $k (sort keys %$status) { | ||
| 270 | $i++; | ||
| 271 | next unless $status->{$k} and $i == 2; | ||
| 272 | return $status->{$k}; | ||
| 273 | } | ||
| 274 | return; | ||
| 275 | } | ||
| 276 | |||
| 277 | sub interfaces { | ||
| 278 | my $dell = shift; | ||
| 279 | my $partial = shift; | ||
| 280 | |||
| 281 | my $i_descr = $dell->i_description($partial) || {}; | ||
| 282 | my $i_name = $dell->orig_i_name($partial) || {}; | ||
| 283 | |||
| 284 | # Descriptions are all the same on some Dells, so use name instead if | ||
| 285 | # available | ||
| 286 | foreach my $iid ( keys %$i_name ) { | ||
| 287 | my $name = $i_name->{$iid}; | ||
| 288 | next unless defined $name; | ||
| 289 | $i_descr->{$iid} = $name; | ||
| 290 | } | ||
| 291 | |||
| 292 | return $i_descr; | ||
| 293 | } | ||
| 294 | |||
| 295 | sub i_duplex { | ||
| 296 | my $dell = shift; | ||
| 297 | my $partial = shift; | ||
| 298 | |||
| 299 | my $dell_duplex = $dell->dell_duplex($partial) || {}; | ||
| 300 | |||
| 301 | my %i_duplex; | ||
| 302 | foreach my $if ( keys %$dell_duplex ) { | ||
| 303 | my $duplex = $dell_duplex->{$if}; | ||
| 304 | next unless defined $duplex; | ||
| 305 | next if $duplex eq 'unknown'; | ||
| 306 | |||
| 307 | $i_duplex{$if} = $duplex; | ||
| 308 | } | ||
| 309 | return \%i_duplex; | ||
| 310 | } | ||
| 311 | |||
| 312 | sub i_duplex_admin { | ||
| 313 | my $dell = shift; | ||
| 314 | my $partial = shift; | ||
| 315 | |||
| 316 | my $interfaces = $dell->interfaces($partial) || {}; | ||
| 317 | my $dell_duplex = $dell->dell_duplex_admin($partial) || {}; | ||
| 318 | my $dell_auto = $dell->dell_auto($partial) || {}; | ||
| 319 | |||
| 320 | my %i_duplex_admin; | ||
| 321 | foreach my $if ( keys %$interfaces ) { | ||
| 322 | my $duplex = $dell_duplex->{$if}; | ||
| 323 | next unless defined $duplex; | ||
| 324 | my $auto = $dell_auto->{$if} || 'disabled'; | ||
| 325 | |||
| 326 | $duplex = 'half' if ( $duplex eq 'half' and $auto eq 'disabled' ); | ||
| 327 | $duplex = 'full' if ( $duplex eq 'full' and $auto eq 'disabled' ); | ||
| 328 | $duplex = 'auto' if $auto eq 'enabled'; | ||
| 329 | $i_duplex_admin{$if} = $duplex; | ||
| 330 | } | ||
| 331 | return \%i_duplex_admin; | ||
| 332 | } | ||
| 333 | |||
| 334 | sub _vendor { | ||
| 335 | my $dell = shift; | ||
| 336 | |||
| 337 | my $id = $dell->id() || 'undef'; | ||
| 338 | my %oidmap = ( | ||
| 339 | 2 => 'ibm', | ||
| 340 | 674 => 'dell', | ||
| 341 | 3955 => 'linksys', | ||
| 342 | ); | ||
| 343 | $id = $1 if ( defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/ ); | ||
| 344 | |||
| 345 | if ( defined($id) and exists( $oidmap{$id} ) ) { | ||
| 346 | return $oidmap{$id}; | ||
| 347 | } | ||
| 348 | else { | ||
| 349 | return $id; | ||
| 350 | } | ||
| 351 | } | ||
| 352 | |||
| 353 | # dot1qTpFdbTable uses dot1qVlanIndex rather than dot1qFdbId as index, | ||
| 354 | # so pretend we don't have the mapping | ||
| 355 | sub qb_fdb_index {return} | ||
| 356 | |||
| 357 | 1; | ||
| 358 | __END__ |