Changeset 250


Ignore:
Timestamp:
Sep 8, 2017, 4:53:06 PM (3 years ago)
Author:
g7moreau
Message:
  • Better html and .dot export
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r249 r250  
    467467
    468468#---------------------------------------------------------------
     469sub format_aggregator4html {
     470   my $port_hr = shift;
     471   $port_hr =~ s/($SEP_AGGREGATOR_PORT)/: /; # First occurence
     472   $port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
     473   return $port_hr;
     474   }
     475
     476#---------------------------------------------------------------
     477sub format_aggregator4dot {
     478   my $port_hr = shift;
     479   $port_hr =~ s/($SEP_AGGREGATOR_PORT)/ - /; # First occurence
     480   $port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
     481   return $port_hr;
     482   }
     483
     484#---------------------------------------------------------------
    469485# return the port and the switch where the computer is connected
    470486sub find_switch_port {
     
    14831499      $vlan = $computerdb->{$ip}{network}.' ('.get_current_vlan_id($computerdb->{$ip}{network}).')' if $computerdb->{$ip}{network};
    14841500
    1485       my $switch_port_hr = $computerdb->{$ip}{switch_port_hr} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
    1486       $switch_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
    1487 
    14881501      print <<"END_HTML";
    14891502  <tr class="$typerow">
    14901503   <td sorttable_customkey="$switch_hostname_sort">$switch_hostname</td>
    1491    <td class="bklask-port">$switch_port_hr</td>
     1504   <td class="bklask-port">format_aggregator4html($computerdb->{$ip}{switch_port_hr})</td>
    14921505   <td colspan="2">$arrow</td>
    14931506   <td sorttable_customkey="$host_short">$computerdb->{$ip}{hostname_fq}</td>
     
    15321545         my ( $host_short ) = sprintf '%s %3s' , split(m/ \. /xms, $db_switch_parent{$sw}->{'switch'}, 1), $db_switch_parent{$sw}->{port_hr};
    15331546
    1534          my $switch_port_hr = $db_switch_output_port{$sw} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
    1535          $switch_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
    1536 
    1537          my $switch_connected_port_hr = $db_switch_parent{$sw}->{port_hr} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
    1538          $switch_connected_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
    1539 
    15401547         print <<"END_HTML";
    15411548  <tr class="$typerow">
    15421549   <td sorttable_customkey="$switch_hostname_sort">$sw</td>
    1543    <td class="bklask-port">$switch_port_hr</td>
    1544    <td>$arrow</td><td>$switch_connected_port_hr</td>
     1550   <td class="bklask-port">format_aggregator4html($db_switch_output_port{$sw})</td>
     1551   <td>$arrow</td><td>format_aggregator4html($db_switch_parent{$sw}->{port_hr})</td>
    15451552   <td sorttable_customkey="$host_short">$db_switch_parent{$sw}->{'switch'}</td>
    15461553   <td sorttable_customkey="$ip_sort">$ipv4_address</td>
     
    15521559         }
    15531560      else {
    1554          my $switch_port_hr = $db_switch_output_port{$sw} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
    1555          $switch_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
    1556 
    15571561         print <<"END_HTML";
    15581562  <tr class="$typerow">
    15591563   <td sorttable_customkey="$switch_hostname_sort">$sw</td>
    1560    <td class="bklask-port">$switch_port_hr</td>
     1564   <td class="bklask-port">format_aggregator4html($db_switch_output_port{$sw})</td>
    15611565   <td>$arrow</td><td></td>
    15621566   <td sorttable_customkey="router">router</td>
     
    16011605  <tr class="$typerow">
    16021606   <td sorttable_customkey="$switch_hostname_sort">$sw_connect</td>
    1603    <td class="bklask-port">$port_connect</td>
    1604    <td>$arrow</td><td>$db_switch_output_port{$sw}</td>
     1607   <td class="bklask-port">format_aggregator4html($port_connect)</td>
     1608   <td>$arrow</td><td>format_aggregator4html($db_switch_output_port{$sw})</td>
    16051609   <td sorttable_customkey="$host_short">$sw</td>
    16061610   <td sorttable_customkey="$ip_sort">$ipv4_address</td>
     
    16151619  <tr class="$typerow">
    16161620   <td sorttable_customkey="$switch_hostname_sort">$sw_connect</td>
    1617    <td class="bklask-port">$port_connect</td>
     1621   <td class="bklask-port">format_aggregator4html($port_connect)</td>
    16181622   <td>$arrow</td><td></td>
    16191623   <td sorttable_customkey="$sw">$sw</td>
     
    27522756         for my $sw (keys %{$db_building{$building}->{$loc}}) {
    27532757
    2754             print "\"$sw:$db_switch_output_port{$sw}\" [label = \"$db_switch_output_port{$sw}\", color = black, fillcolor = lightblue,  peripheries = 2, style = filled];\n";
     2758            print "\"$sw:$db_switch_output_port{$sw}\" [label = \"".format_aggregator4dot($db_switch_output_port{$sw})"\", color = black, fillcolor = lightblue,  peripheries = 2, style = filled];\n";
    27552759
    27562760            my $swname  = $sw;
     
    27652769               next if not $sw_connect eq $sw;
    27662770               next if $port_connect eq $db_switch_output_port{$sw};
    2767                print "\"$sw:$port_connect\" [label = \"$port_connect\", color = black, fillcolor = plum,  peripheries = 1, style = filled];\n";
     2771               print "\"$sw:$port_connect\" [label = \"".format_aggregator4dot($port_connect)."\", color = black, fillcolor = plum,  peripheries = 1, style = filled];\n";
    27682772               print "\"$sw:$port_connect\" -> \"$sw\" [len=2, style=bold, arrowhead= normal, arrowtail = inv]\n";
    27692773              }
Note: See TracChangeset for help on using the changeset viewer.