Last active
January 5, 2016 03:11
-
-
Save feuerrot/a6a37e568ce5354eb938 to your computer and use it in GitHub Desktop.
It may be useful, if you're using dn42 on linux with suitable named interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
echo ' IPv4' | |
ip r | cut -d' ' -f 5 | grep dn42 |perl -MList::Util=sum -E 'my %cnt; $fmt = "%3d %s\n"; while (<>) { chomp; $cnt{$_}++ }; for my $k (reverse sort { $cnt{$a} <=> $cnt{$b} || -($a cmp $b) } keys %cnt) { printf($fmt, $cnt{$k}, $k) } printf($fmt, sum(values %cnt), "total"); printf($fmt, scalar keys %cnt, "peerings")' | |
echo | |
echo ' IPv6' | |
ip -6 r | cut -d' ' -f 5 | grep dn42 |perl -MList::Util=sum -E 'my %cnt; $fmt = "%3d %s\n"; while (<>) { chomp; $cnt{$_}++ }; for my $k (reverse sort { $cnt{$a} <=> $cnt{$b} || -($a cmp $b) } keys %cnt) { printf($fmt, $cnt{$k}, $k) } printf($fmt, sum(values %cnt), "total"); printf($fmt, scalar keys %cnt, "peerings")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an counterpart for someone like me who is using FreeBSD and can't really use named interfaces: