Changeset 20


Ignore:
Timestamp:
Feb 1, 2008, 9:49:07 PM (13 years ago)
Author:
g7moreau
Message:
  • Model of the switch are now search on the switch by SNMP 10 models are actually defined in Klask
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r19 r20  
    6060my %INTERNAL_PORT_MAP_REV = reverse %INTERNAL_PORT_MAP;
    6161
    62 my %SWITCH_CODE = (
    63    J4120A   => 'HP J4120A ProCurve Switch 1600M',
    64    J4093A   => 'HP J4093A ProCurve Switch 2424M',
    65    J4813A   => 'HP J4813A ProCurve Switch 2524',
    66    J4900A   => 'HP J4900A ProCurve Switch 2626',
    67    J9021A   => 'ProCurve J9021A Switch 2810-24G',
    68    J4903A   => 'HP J4903A ProCurve Switch 2824',
    69    J4110A   => 'HP J4110A ProCurve Switch 8000M',
     62my %SWITCH_KIND = (
     63   J3299A => { model => 'HP224M',     match => 'HP J3299A ProCurve Switch 224M'  },
     64   J4120A => { model => 'HP1600M',    match => 'HP J4120A ProCurve Switch 1600M' },
     65   J4093A => { model => 'HP2424M',    match => 'HP J4093A ProCurve Switch 2424M' },
     66   J4813A => { model => 'HP2524',     match => 'HP J4813A ProCurve Switch 2524'  },
     67   J4900A => { model => 'HP2626',     match => 'HP J4900[A|B] ProCurve Switch 2626'  },
     68   J9021A => { model => 'HP2810-24G', match => 'ProCurve J9021A Switch 2810-24G' },
     69   J4903A => { model => 'HP2824',     match => 'J4903A.+?Switch 2824,'           },
     70   J4110A => { model => 'HP8000M',    match => 'HP J4110A ProCurve Switch 8000M' },
     71   BS350T => { model => 'BS350T',     match => 'BayStack 350T HW'                },
    7072   );
    71 
    72 my %SWITCH_TYPE = (
    73    J4120A   => 'HP1600M  ',
    74    J4093A   => 'HP2424M  ',
    75    J4813A   => 'HP2524   ',
    76    J4900A   => 'HP2626   ',
    77    J9021A   => 'HP2810-24',
    78    J4903A   => 'HP2824   ',
    79    J4110A   => 'HP8000M  ',
    80    );
    81 
     73 
    8274my %OID_NUMBER = (
    8375   sysDescr    => '1.3.6.1.2.1.1.1.0',
     
    186178   }
    187179
     180# Find Surname of a switch
     181sub get_switch_model {
     182   my $sw_description = shift || '?';
     183   
     184   for my $sw_kind (keys %SWITCH_KIND) {
     185      next if not $sw_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/;
     186     
     187      return $SWITCH_KIND{$sw_kind}->{model};
     188      }
     189     
     190   return $sw_description;
     191   }
     192
    188193###
    189194# va rechercher le nom des switchs pour savoir qui est qui
     
    221226         );
    222227      $sw->{description} = $result->{$OID_NUMBER{sysName}} || $sw->{hostname};
     228      $sw->{model} = get_switch_model( $result->{$OID_NUMBER{sysDescr}});
    223229      #$sw->{location} = $result->{"1.3.6.1.2.1.1.6.0"} || $sw->{hostname};
    224230      #$sw->{contact} = $result->{"1.3.6.1.2.1.1.4.0"} || $sw->{hostname};
     
    226232 
    227233      my ($desc, $type) = split ':', $sw->{description}, 2;
    228       printf "%-25s 0--------->>>> %-25s %s\n", $sw->{hostname}, $desc, uc($type) if $verbose;
     234#      printf "%-25s 0--------->>>> %-25s %s\n", $sw->{hostname}, $desc, uc($type)."**" if $verbose;
     235      printf "%-25s 0--------->>>> %-25s %s\n", $sw->{hostname}, $desc, $sw->{model} if $verbose;
    229236      }
    230237
Note: See TracChangeset for help on using the changeset viewer.