Changeset 348
- Timestamp:
- Nov 1, 2017, 2:47:11 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r344 r348 501 501 502 502 #--------------------------------------------------------------- 503 # port can be switch index or human readable 504 sub format_switchport4sort { 505 my ($switch_name, $port) = @_; 506 507 # numeric port 508 return sprintf '%s %09i', $switch_name, $port if $port =~ m{^\d+$}; 509 510 # Gi3/0/14 type port 511 if ($port =~ m{^(\w+?)(\d+)/(\d+)/(\d+)$}) { 512 return sprintf '%s %03i%03i%03i', $switch_name, $2, $3, $4; 513 } 514 515 # Gi3/14 type port 516 if ($port =~ m{^(\w+?)(\d+)/(\d+)$}) { 517 return sprintf '%s %06i%03i', $switch_name, $2, $3; 518 } 519 520 # Po14 or A3 type port 521 if ($port =~ m{^(\w+?)(\d+)(.*)$}) { 522 return sprintf '%s %s%04i%s', $switch_name, $1, $2, $3; 523 } 524 525 # otherwise 526 return sprintf '%s %s', $switch_name, $port; 527 } 528 529 #--------------------------------------------------------------- 503 530 # fqdn_html_breakable change it's parameter, use it like chomp perl function 504 531 … … 1791 1818 my $switch_hostname = $computerdb->{$ip}{'switch_hostname'} || $computerdb->{$ip}{'switch_description'} || 'unkown'; 1792 1819 chomp $switch_hostname; 1793 my $switch_hostname_sort = sprintf '%s %06i' ,$switch_hostname, $computerdb->{$ip}{'switch_port_id'}; # Take switch index1820 my $switch_hostname_sort = format_switchport4sort($switch_hostname, $computerdb->{$ip}{'switch_port_hr'}); 1794 1821 1795 1822 my $ip_sort = sprintf '%03i%03i%03i%03i', split m/ \. /xms, $ip; … … 1833 1860 for my $sw (sort keys %db_switch_output_port) { 1834 1861 1835 my $switch_hostname_sort = sprintf '%s %3s' ,$sw, $db_switch_output_port{$sw};1862 my $switch_hostname_sort = format_switchport4sort($sw, $db_switch_output_port{$sw}); 1836 1863 1837 1864 $typerow = $typerow eq 'even' ? 'odd' : 'even'; … … 1860 1887 my $mac_sort = sprintf '%04i-%s', 9999, $mac_address; 1861 1888 1862 my ( $host_short ) = sprintf '%s %3s' , split(m/ \. /xms, $db_switch_parent{$sw}->{'switch'}, 1), $db_switch_parent{$sw}->{'port_hr'};1889 my $host_short = format_switchport4sort(split(m/ \. /xms, $db_switch_parent{$sw}->{'switch'}, 1), $db_switch_parent{$sw}->{'port_hr'}); 1863 1890 1864 1891 my $vlan = $db_switch{$db_switch_parent{$sw}->{'switch'}}->{'network'}; … … 1888 1915 my $parent_port_hr = format_aggregator4html($db_switch_output_port{$sw}); 1889 1916 1890 my $host_short = sprintf '%s %3s' ,$sw, $db_switch_output_port{$sw};1917 my $host_short = format_switchport4sort($sw, $db_switch_output_port{$sw}); 1891 1918 1892 1919 my $mac_address = $db_switch{$sw}->{'mac_address'}; … … 1932 1959 for my $sw (keys %{$db_switch_connected_on_port{$swport}}) { 1933 1960 1934 my $switch_hostname_sort = sprintf '%s %3s' ,$sw_connect, $port_connect;1961 my $switch_hostname_sort = format_switchport4sort($sw_connect, $port_connect); 1935 1962 1936 1963 my $mac_address = $db_switch{$sw}->{'mac_address'}; … … 1959 1986 if (exists $db_switch_output_port{$sw}) { 1960 1987 1961 my ( $host_short ) = sprintf '%s %3s' , split( m/\./xms, $sw, 1), $db_switch_output_port{$sw};1988 my $host_short = format_switchport4sort(split( m/\./xms, $sw, 1), $db_switch_output_port{$sw}); 1962 1989 1963 1990 my $parent_port_hr = format_aggregator4html($port_connect); … … 2209 2236 $typerow = $typerow eq 'even' ? 'odd' : 'even'; 2210 2237 2211 my $switch_hostname_sort = sprintf '%s %3s' ,$item->{'switch'}, $item->{'port_hr'};2238 my $switch_hostname_sort = format_switchport4sort($item->{'switch'}, $item->{'port_hr'}); 2212 2239 my ( $host_short ) = split m/ \. /xms, $item->{'hostname_fq'}; 2213 2240
Note: See TracChangeset
for help on using the changeset viewer.