Index: /trunk/klask
===================================================================
--- /trunk/klask	(revision 48)
+++ /trunk/klask	(revision 49)
@@ -29,9 +29,9 @@
 my $KLASK_CFG = YAML::Syck::LoadFile("$KLASK_CFG_FILE");
 
-my %DEFAULT = %{$KLASK_CFG->{default}};
-my @SWITCH  = @{$KLASK_CFG->{switch}};
+my %DEFAULT = %{ $KLASK_CFG->{default} };
+my @SWITCH  = @{ $KLASK_CFG->{switch}  };
 
 my %switch_level = ();
-my %SWITCH_DB = ();
+my %SWITCH_DB    = ();
 LEVEL_OF_EACH_SWITCH:
 for my $sw (@SWITCH){
@@ -39,5 +39,5 @@
    $SWITCH_DB{$sw->{hostname}} = $sw;
    }
-@SWITCH = sort { $switch_level{$b->{hostname}} <=> $switch_level{$a->{hostname}} } @{$KLASK_CFG->{switch}};  
+@SWITCH = sort { $switch_level{$b->{hostname}} <=> $switch_level{$a->{hostname}} } @{$KLASK_CFG->{switch}};
 
 my %SWITCH_PORT_COUNT = ();
@@ -87,7 +87,7 @@
    BS350T => { model => 'BS350T',     match => 'BayStack 350T HW'                },
    );
- 
+
 my %OID_NUMBER = (
-   sysDescr    => '1.3.6.1.2.1.1.1.0',
+   sysDescription    => '1.3.6.1.2.1.1.1.0',
    sysName     => '1.3.6.1.2.1.1.5.0',
    sysContact  => '1.3.6.1.2.1.1.4.0',
@@ -163,7 +163,4 @@
    my ($arp, $ip, $timestamp, $host) = split /\s+/, $cmd_arpwatch;
 
-#print "OOO $cmd\n";
-#print "TTT arp $arp -> $ip pour host $host\n";
-
    $ret{ipv4_address} = $ip        if $ip;
    $ret{mac_address}  = $arp       if $arp;
@@ -177,5 +174,5 @@
       }
 
-  # resultat de la commande arp
+   # resultat de la commande arp
    # tech7meylan.hmg.inpg.fr (194.254.66.240) at 00:14:22:45:28:A9 [ether] on eth0
    # sw2-batF0-legi.hmg.priv (192.168.22.112) at 00:30:c1:76:9c:01 [ether] on eth0.37
@@ -186,26 +183,22 @@
    $ret{ipv4_address} = $2 if(defined($2));
    $ret{mac_address}  = $3 if(defined($3));
-#print "RET1 $ret{ipv4_address} -> $ret{mac_address} : $ret{hostname_fq}\n";
-
-#   if ($ret{ipv4_address} eq '0.0.0.0' and $ret{mac_address} eq 'unknow'and $ret{hostname_fq} eq 'unknow') {
-      # resultat de la commande host si le parametre est ip
-      # 250.66.254.194.in-addr.arpa domain name pointer legihp2100.hmg.inpg.fr.
-      my $cmd_host = `host $param_ip_or_host 2>/dev/null`;
-      chomp $cmd_host;
-      $cmd_host =~ m/domain\sname\spointer\s(\S+)\.$/;
-      $ret{hostname_fq} = $1 if defined $1;
-
-      # resultat de la commande host si parametre est hostname
-      # tech7meylan.hmg.inpg.fr has address 194.254.66.240
-      $cmd_host =~ m/(\S*)\shas\saddress\s([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/;
-      $ret{hostname_fq}  = $1 if defined $1;
-      $ret{ipv4_address} = $2 if defined $2;
-
-      $cmd_host =~ m/\b([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.in-addr\.arpa\s/;
-      $ret{ipv4_address} = "$4.$3.$2.$1"     if defined $1 and  defined $2 and  defined $3 and  defined $4;
-      $ret{hostname_fq}  = $param_ip_or_host if not defined $1 and $ret{hostname_fq} eq 'unknow';
-#      }
-
-#print "RET2 $ret{ipv4_address} -> $ret{mac_address} : $ret{hostname_fq}\n";
+
+   # resultat de la commande host si le parametre est ip
+   # 250.66.254.194.in-addr.arpa domain name pointer legihp2100.hmg.inpg.fr.
+   my $cmd_host = `host $param_ip_or_host 2>/dev/null`;
+   chomp $cmd_host;
+   $cmd_host =~ m/domain\sname\spointer\s(\S+)\.$/;
+   $ret{hostname_fq} = $1 if defined $1;
+
+   # resultat de la commande host si parametre est hostname
+   # tech7meylan.hmg.inpg.fr has address 194.254.66.240
+   $cmd_host =~ m/(\S*)\shas\saddress\s([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/;
+   $ret{hostname_fq}  = $1 if defined $1;
+   $ret{ipv4_address} = $2 if defined $2;
+
+   $cmd_host =~ m/\b([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.in-addr\.arpa\s/;
+   $ret{ipv4_address} = "$4.$3.$2.$1"     if defined $1 and  defined $2 and  defined $3 and  defined $4;
+   $ret{hostname_fq}  = $param_ip_or_host if not defined $1 and $ret{hostname_fq} eq 'unknow';
+
    unless ($ret{mac_address} eq 'unknow') {
       my @paquets = ();
@@ -217,5 +210,4 @@
       }
 
-#print "RET3 $ret{ipv4_address} -> $ret{mac_address} : $ret{hostname_fq}\n";
    return %ret;
    }
@@ -224,11 +216,11 @@
 sub get_switch_model {
    my $sw_snmp_description = shift || 'unknow';
-   
+
    for my $sw_kind (keys %SWITCH_KIND) {
       next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/;
-      
+
       return $SWITCH_KIND{$sw_kind}->{model};
       }
-      
+
    return $sw_snmp_description;
    }
@@ -238,5 +230,5 @@
 sub init_switch_names {
    my $verbose = shift;
-   
+
    printf "%-25s                %-25s %s\n",'Switch','Description','Type';
 #   print "Switch description\n" if $verbose;
@@ -262,5 +254,5 @@
       my $result = $session->get_request(
          -varbindlist => [
-            $OID_NUMBER{sysDescr},
+            $OID_NUMBER{sysDescription},
             $OID_NUMBER{sysName},
             $OID_NUMBER{sysContact},
@@ -269,12 +261,11 @@
          );
       $sw->{description} = $result->{$OID_NUMBER{sysName}} || $sw->{hostname};
-      $sw->{model} = get_switch_model( $result->{$OID_NUMBER{sysDescr}});
+      $sw->{model} = get_switch_model( $result->{$OID_NUMBER{sysDescription}});
       #$sw->{location} = $result->{"1.3.6.1.2.1.1.6.0"} || $sw->{hostname};
       #$sw->{contact} = $result->{"1.3.6.1.2.1.1.4.0"} || $sw->{hostname};
       $session->close;
 
-      # Ligne à virer car on récupère maintenant le modèle du switch 
+      # Ligne à virer car on récupère maintenant le modèle du switch
       my ($desc, $type) = split ':', $sw->{description}, 2;
-#      printf "%-25s 0--------->>>> %-25s %s\n", $sw->{hostname}, $desc, uc($type)."**" if $verbose;
       printf "%-25s 0--------->>>> %-25s %s\n", $sw->{hostname}, $desc, $sw->{model} if $verbose;
       }
@@ -292,8 +283,9 @@
    return '00' if $car eq '00UNKNOW';
    my %table = (
-      "0"=>"0",  "1"=>"1",  "2"=>"2",  "3"=>"3",  "4"=>"4",  "5"=>"5", "6"=>"6", "7"=>"7", "8"=>"8", "9"=>"9",
+      "0"=>"0",  "1"=>"1",  "2"=>"2",  "3"=>"3",  "4"=>"4",
+      "5"=>"5",  "6"=>"6",  "7"=>"7",  "8"=>"8",  "9"=>"9",
       "A"=>"10", "B"=>"11", "C"=>"12", "D"=>"13", "E"=>"14", "F"=>"15"
       );
-   my @chars = split(//, $car);
+   my @chars = split //, $car;
    return $table{$chars[-2]}*16 + $table{$chars[-1]};
    }
@@ -316,7 +308,7 @@
 # va rechercher le port et le switch sur lequel est la machine
 sub find_switch_port {
-   my $arp = shift;
+   my $arp             = shift;
    my $switch_proposal = shift || '';
-   
+
    my %ret;
    $ret{switch_description} = "unknow";
@@ -335,5 +327,5 @@
 
    my $research = "1.3.6.1.2.1.17.4.3.1.2".arp_hex_to_dec($arp);
-   
+
    LOOP_ON_SWITCH:
    for my $sw (@switch_search) {
@@ -353,5 +345,5 @@
 
          # IMPORTANT !!
-         # ceci empeche la detection sur certains port ... 
+         # ceci empeche la detection sur certains port ...
          # en effet les switch sont relies entre eux par un cable reseau et du coup
          # tous les arp de toutes les machines sont presentes sur ces ports (ceux choisis ici sont les miens)
@@ -369,5 +361,5 @@
             $ret{switch_description} = $sw->{description};
             $ret{switch_port}        = get_human_readable_port($sw->{model}, $swport); # $swport;
-            
+
             last LOOP_ON_SWITCH;
 #            }
@@ -427,5 +419,5 @@
    return $KLASK_CFG->{network}{$network}{interface};
    }
-  
+
 ###
 # liste l'ensemble des adresses ip d'un réseau
@@ -473,7 +465,7 @@
    my $sw_model = shift;
    my $sw_port  = shift;
-   
+
    return $sw_port if not $sw_model eq 'HP8000M';
-   
+
    my $reste = (($sw_port - 1) % 8) + 1;
    my $major = int( ($sw_port - 1) / 8 );
@@ -485,13 +477,13 @@
    my $sw_model = shift;
    my $sw_port  = shift;
-   
+
    return $sw_port if not $sw_model eq 'HP8000';
 
    my $letter = substr($sw_port, 0, 1);
-   
+
 #   return $port if $letter =~ m/\d/;
-   
+
    my $reste =  substr($sw_port, 1);
-   
+
    return $INTERNAL_PORT_MAP_REV{$letter} * 8 + $reste;
    }
@@ -537,5 +529,5 @@
 sub cmd_search {
    my @computer = @_;
-   
+
    init_switch_names();    #nomme les switchs
    fastping(@computer);
@@ -554,12 +546,12 @@
    fastping(@computer);
    my $computerdb = YAML::Syck::LoadFile("$KLASK_DB_FILE");
-   
+
    LOOP_ON_COMPUTER:
    for my $clientname (@computer) {
       my %resol_arp = resolve_ip_arp_host($clientname);      #resolution arp
       my $ip = $resol_arp{ipv4_address};
-      
+
       next LOOP_ON_COMPUTER unless exists $computerdb->{$ip};
-      
+
       my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($computerdb->{$ip}{timestamp});
       $year += 1900;
@@ -604,5 +596,5 @@
    my %db_switch_connected_on_port = %{$switch_connection->{connected_on_port}};
    my %db_switch_chained_port = ();
-   for my $swport (keys %db_switch_connected_on_port) {        
+   for my $swport (keys %db_switch_connected_on_port) {
       my ($sw_connect,$port_connect) = split ':', $swport;
       $db_switch_chained_port{$sw_connect} .= "$port_connect:";
@@ -637,5 +629,5 @@
       for my $one_computer (@computer) {
          $i++;
-         
+
          my $total_percent = int(($i*100)/$number_of_computer);
 
@@ -655,5 +647,5 @@
 
          my %resol_arp = resolve_ip_arp_host($one_computer,$current_interface);
-         
+
          # do not search on router connection (why ?)
          if ( exists $router_mac_ip{$resol_arp{mac_address}}) {
@@ -725,17 +717,12 @@
          # mise a jour du nom de la machine si modification dans le dns
          $computerdb->{$resol_arp{ipv4_address}}{hostname_fq} = $resol_arp{hostname_fq};
-       
+
          # mise à jour de la date de détection si détection plus récente par arpwatch
          $computerdb->{$resol_arp{ipv4_address}}{timestamp}   = $resol_arp{timestamp} if exists $resol_arp{timestamp} and $computerdb->{$resol_arp{ipv4_address}}{timestamp} < $resol_arp{timestamp};
 
-         # provisoire car changement de nom des attributs
-#         $computerdb->{$resol_arp{ipv4_address}}{mac_address}        = $computerdb->{$resol_arp{ipv4_address}}{arp};
-#         $computerdb->{$resol_arp{ipv4_address}}{switch_description} = $computerdb->{$resol_arp{ipv4_address}}{switch};
-#         $computerdb->{$resol_arp{ipv4_address}}{switch_port}        = $computerdb->{$resol_arp{ipv4_address}}{port};
-       
          # relance un arping sur la machine si celle-ci n'a pas été détectée depuis plus d'une semaine
 #         push @computer_not_detected, $resol_arp{ipv4_address} if $computerdb->{$resol_arp{ipv4_address}}{timestamp} < $timestamp_last_week;
          $computer_not_detected{$resol_arp{ipv4_address}} = $current_interface if $computerdb->{$resol_arp{ipv4_address}}{timestamp} < $timestamp_last_week;
-       
+
          }
       }
@@ -794,5 +781,5 @@
 
    $format = 'txt' if not defined $possible_format{$format};
-   
+
    $possible_format{$format}->(@ARGV);
    return;
@@ -809,5 +796,5 @@
    LOOP_ON_IP_ADDRESS:
    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %$computerdb)) {
-   
+
 #      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq 'unknow';
 
@@ -817,5 +804,5 @@
 # dans le futur
 #      next if $computerdb->{$ip}{hostname_fq} eq 'unknow';
-      
+
       my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($computerdb->{$ip}{timestamp});
       $year += 1900;
@@ -873,8 +860,8 @@
    LOOP_ON_IP_ADDRESS:
    foreach my $ip (keys %$computerdb) {
-   
+
       # to be improve in the future
       next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
-      
+
       $mac_count{$computerdb->{$ip}{mac_address}}++;
       }
@@ -884,5 +871,5 @@
    LOOP_ON_IP_ADDRESS:
    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %$computerdb)) {
-   
+
       # to be improve in the future
       next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
@@ -895,5 +882,5 @@
 #      $odd_or_even++;
 #      my $typerow = $odd_or_even % 2 ? 'odd' : 'even';
-      $typerow = $typerow eq 'even' ? 'odd' : 'even'; 
+      $typerow = $typerow eq 'even' ? 'odd' : 'even';
 
       my $switch_hostname = $computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description} || 'unkown';
@@ -932,5 +919,5 @@
       my $switch_hostname_sort = sprintf "%s %3s" ,$sw, $db_switch_output_port{$sw};
 
-      $typerow = $typerow eq 'even' ? 'odd' : 'even'; 
+      $typerow = $typerow eq 'even' ? 'odd' : 'even';
 
       if (exists $db_switch_parent{$sw}) {
@@ -949,8 +936,7 @@
       my $mac_sort = sprintf "%04i-%s", 9999, $mac_address;
 
-
-         my ( $host_short ) = sprintf "%s %3s" , split(/\./, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port};
-
-print <<"END_HTML";
+      my ( $host_short ) = sprintf "%s %3s" , split(/\./, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port};
+
+      print <<"END_HTML";
   <tr class="$typerow">
    <td sorttable_customkey="$switch_hostname_sort">$sw</td>
@@ -965,6 +951,5 @@
          }
       else {
-#         printf "%-25s  %2s  +-->  router\n", $sw, $db_switch_output_port{$sw};
-print <<"END_HTML";
+         print <<"END_HTML";
   <tr class="$typerow">
    <td sorttable_customkey="$switch_hostname_sort">$sw</td>
@@ -999,11 +984,11 @@
       my $mac_sort = sprintf "%04i-%s", 9999, $mac_address;
 
-      $typerow = $typerow eq 'even' ? 'odd' : 'even'; 
+      $typerow = $typerow eq 'even' ? 'odd' : 'even';
 
          if (exists $db_switch_output_port{$sw}) {
 
-             my ( $host_short ) = sprintf "%s %3s" , split(/\./, $sw, 1), $db_switch_output_port{$sw};
-
-print <<"END_HTML";
+            my ( $host_short ) = sprintf "%s %3s" , split(/\./, $sw, 1), $db_switch_output_port{$sw};
+
+            print <<"END_HTML";
   <tr class="$typerow">
    <td sorttable_customkey="$switch_hostname_sort">$sw_connect</td>
@@ -1018,5 +1003,5 @@
             }
          else {
-print <<"END_HTML";
+            print <<"END_HTML";
   <tr class="$typerow">
    <td sorttable_customkey="$switch_hostname_sort">$sw_connect</td>
@@ -1033,5 +1018,4 @@
       }
 
-
    print <<'END_HTML';
  </tbody>
@@ -1051,5 +1035,5 @@
       my $sw_hostname = $computerdb->{$ip}{switch_hostname} || '';
       next if $sw_hostname eq 'unknow';
-  
+
       my $sw_location = '';
       for my $sw (@SWITCH) {
@@ -1067,7 +1051,7 @@
    my $switch = shift;
    my $port   = shift;
-   
-   #snmpset -v 1 -c community X.X.X.X 1.3.6.1.2.1.2.2.1.7.NoPort = 1 (up) 
-   #snmpset -v 1 -c community X.X.X.X 1.3.6.1.2.1.2.2.1.7.NoPort = 2 (down) 
+
+   #snmpset -v 1 -c community X.X.X.X 1.3.6.1.2.1.2.2.1.7.NoPort = 1 (up)
+   #snmpset -v 1 -c community X.X.X.X 1.3.6.1.2.1.2.2.1.7.NoPort = 2 (down)
    system "snmpset -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port = 1";
    return;
@@ -1077,5 +1061,5 @@
    my $switch = shift;
    my $port   = shift;
-   
+
    system "snmpset -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port = 2";
    return;
@@ -1085,5 +1069,5 @@
    my $switch = shift;
    my $port   = shift;
-   
+
    system "snmpget -v 1 -c public $switch 1.3.6.1.2.1.2.2.1.7.$port";
    return;
@@ -1093,5 +1077,5 @@
    my $switch_name = shift || '';
    my $mac_address = shift || '';
-   
+
    if ($switch_name eq '' or $mac_address eq '') {
       die "Usage: klask search-mac-on-switch SWITCH_NAME MAC_ADDRESS\n";
@@ -1099,5 +1083,5 @@
 
    if (not defined $SWITCH_DB{$switch_name}) {
-      die "Switch $switch_name must be defined in klask configuration file\n"; 
+      die "Switch $switch_name must be defined in klask configuration file\n";
       }
 
@@ -1122,5 +1106,5 @@
       -varbindlist => [$research]
       );
-   
+
    if (not defined($result) or $result->{$research} eq 'noSuchInstance') {
       print "Klask do not find MAC $mac_address on switch $switch_name\n";
@@ -1147,8 +1131,6 @@
 #   for my $one_computer ('194.254.66.254') {
    for my $one_router ( get_list_main_router(get_list_network()) ) {
-#print "TT$one_router\n";      
       my %resol_arp = resolve_ip_arp_host($one_router,'*','low');            # resolution arp
       next DETECT_ALL_ROUTER if $resol_arp{mac_address} eq 'unknow';
-#print "$one_router\n";      
       $where{$resol_arp{ipv4_address}} = find_all_switch_port($resol_arp{mac_address}); # retrouve les emplacements des routeurs
       }
@@ -1156,5 +1138,5 @@
    ALL_ROUTER_IP_ADDRESS:
    for my $ip (Net::Netmask::sort_by_ip_address(keys %where)) { # '194.254.66.254')) {
-   
+
       next ALL_ROUTER_IP_ADDRESS if not exists $where{$ip}; # /a priori/ idiot car ne sers à rien...
 
@@ -1165,16 +1147,8 @@
 
          next ALL_SWITCH_CONNECTED if $switch->{port} eq '0';
-         
+
          $db_switch_output_port{$switch->{hostname}} = $switch->{port};
          }
-      }   
-
-#   print "Switch output port\n";  
-#   print "------------------\n";
-#   for my $sw (sort keys %db_switch_output_port) {
-#      printf "%-25s %2s\n", $sw, $db_switch_output_port{$sw};
-#      }
-#   print "\n";
-
+      }
 
    my %db_switch_link_with = ();
@@ -1192,7 +1166,7 @@
       my %resol_arp = resolve_ip_arp_host($one_computer,'*','low'); # arp resolution
       next ALL_SWITCH if $resol_arp{mac_address} eq 'unknow';
-      
+
       push @list_switch_ipv4,$resol_arp{ipv4_address};
-      
+
       $where{$resol_arp{ipv4_address}} = find_all_switch_port($resol_arp{mac_address}); # find port on all switch
 
@@ -1203,8 +1177,8 @@
       $SWITCH_DB{$one_computer}->{timestamp}    = $timestamp;
       }
-      
+
    ALL_SWITCH_IP_ADDRESS:
    for my $ip (Net::Netmask::sort_by_ip_address(@list_switch_ipv4)) {
-   
+
       next ALL_SWITCH_IP_ADDRESS if not exists $where{$ip};
 
@@ -1225,14 +1199,14 @@
 
       }
-   
+
    my %db_switch_connected_on_port = ();
    my $maybe_more_than_one_switch_connected = 'yes';
-   
+
    while ($maybe_more_than_one_switch_connected eq 'yes') {
       for my $sw (keys %db_switch_link_with) {
          for my $connect (keys %{$db_switch_link_with{$sw}}) {
-         
+
             my $port = $db_switch_link_with{$sw}->{$connect};
-         
+
             $db_switch_connected_on_port{"$connect:$port"} ||= {};
             $db_switch_connected_on_port{"$connect:$port"}->{$sw}++; # Just to define the key
@@ -1244,7 +1218,7 @@
       SWITCH_AND_PORT:
       for my $swport (keys %db_switch_connected_on_port) {
-         
+
          next if keys %{$db_switch_connected_on_port{$swport}} == 1;
-         
+
          $maybe_more_than_one_switch_connected = 'yes';
 
@@ -1254,15 +1228,15 @@
          CONNECTED:
          for my $sw_connected (@sw_on_same_port) {
-            
+
             next CONNECTED if not keys %{$db_switch_link_with{$sw_connected}} == 1;
-            
+
             $db_switch_connected_on_port{$swport} = {$sw_connected => 1};
-            
+
             for my $other_sw (@sw_on_same_port) {
                next if $other_sw eq $sw_connected;
-               
+
                delete $db_switch_link_with{$other_sw}->{$sw_connect};
                }
-            
+
             # We can not do better for this switch for this loop
             next SWITCH_AND_PORT;
@@ -1275,15 +1249,15 @@
    for my $sw (keys %db_switch_link_with) {
       for my $connect (keys %{$db_switch_link_with{$sw}}) {
-      
+
          my $port = $db_switch_link_with{$sw}->{$connect};
-      
+
          $db_switch_connected_on_port{"$connect:$port"} ||= {};
          $db_switch_connected_on_port{"$connect:$port"}->{$sw} = $port;
-        
+
          $db_switch_parent{$sw} = {switch => $connect, port => $port};
          }
       }
 
-   print "Switch output port and parent port connection\n";  
+   print "Switch output port and parent port connection\n";
    print "---------------------------------------------\n";
    for my $sw (sort keys %db_switch_output_port) {
@@ -1299,5 +1273,5 @@
    print "Switch parent and children port inter-connection\n";
    print "------------------------------------------------\n";
-   for my $swport (sort keys %db_switch_connected_on_port) {        
+   for my $swport (sort keys %db_switch_connected_on_port) {
       my ($sw_connect,$port_connect) = split ':', $swport;
       for my $sw (keys %{$db_switch_connected_on_port{$swport}}) {
@@ -1318,5 +1292,5 @@
       switch_db         => \%SWITCH_DB,
       };
-      
+
    YAML::Syck::DumpFile("$KLASK_SW_FILE", $switch_connection);
    return;
@@ -1340,5 +1314,5 @@
 
    $format = 'txt' if not defined $possible_format{$format};
-   
+
    $possible_format{$format}->(@ARGV);
    return;
@@ -1353,5 +1327,5 @@
    my %db_switch_connected_on_port = %{$switch_connection->{connected_on_port}};
 
-   print "Switch output port and parent port connection\n";  
+   print "Switch output port and parent port connection\n";
    print "---------------------------------------------\n";
    for my $sw (sort keys %db_switch_output_port) {
@@ -1367,5 +1341,5 @@
    print "Switch parent and children port inter-connection\n";
    print "------------------------------------------------\n";
-   for my $swport (sort keys %db_switch_connected_on_port) {        
+   for my $swport (sort keys %db_switch_connected_on_port) {
       my ($sw_connect,$port_connect) = split ':', $swport;
       for my $sw (keys %{$db_switch_connected_on_port{$swport}}) {
@@ -1384,5 +1358,5 @@
 
    my $switch_connection = YAML::Syck::LoadFile("$KLASK_SW_FILE");
-   
+
    my %db_switch_output_port       = %{$switch_connection->{output_port}};
    my %db_switch_parent            = %{$switch_connection->{parent}};
@@ -1398,6 +1372,6 @@
       $db_building{$building}->{$location}{ $sw->{hostname} } = 'y';
       }
- 
- 
+
+
    print "digraph G {\n";
 
@@ -1408,5 +1382,5 @@
    for my $building (keys %db_building) {
       $b++;
-      
+
       print "\"building$b\" [label = \"$building\", color = black, fillcolor = gold, style = filled];\n";
       print "site -> \"building$b\" [len = 2, color = firebrick];\n";
@@ -1415,5 +1389,5 @@
       for my $loc (keys %{$db_building{$building}}) {
          $l++;
- 
+
          print "\"location$b-$l\" [label = \"$building".'/'.join('\n',split("/",$loc))."\", color = black, fillcolor = orange, style = filled];\n";
 #         print "\"location$b-$l\" [label = \"$building / $loc\", color = black, fillcolor = orange, style = filled];\n";
@@ -1442,5 +1416,5 @@
       }
 
-#   print "Switch output port and parent port connection\n";  
+#   print "Switch output port and parent port connection\n";
 #   print "---------------------------------------------\n";
    for my $sw (sort keys %db_switch_output_port) {
@@ -1456,5 +1430,5 @@
 #   print "Switch parent and children port inter-connection\n";
 #   print "------------------------------------------------\n";
-   for my $swport (sort keys %db_switch_connected_on_port) {        
+   for my $swport (sort keys %db_switch_connected_on_port) {
       my ($sw_connect,$port_connect) = split ':', $swport;
       for my $sw (keys %{$db_switch_connected_on_port{$swport}}) {
@@ -1615,6 +1589,6 @@
 
 =head1 COPYRIGHT
-       
-Copyright (C) 2005-2008 Gabriel Moreau.
+
+Copyright (C) 2005-2009 Gabriel Moreau.
 
 
