#!/usr/local/bin/perl # get BGP routing tables from Cisco host router # # usage: getb.pl # crates output file "ASmap.{seconds}" $them = "route-views.oregon-ix.net"; $port = "23"; $pf_inet = 2; $sock_stream = 1; $tcp_proto = 6; $sockaddr = 'S n a4 x8'; chop($hostname = `hostname`); ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname); ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them); $this = pack($sockaddr, 2, 0, $thisaddr); $that = pack($sockaddr, 2, $port, $thataddr); socket(S, $pf_inet, $sock_stream, $tcp_proto) || die "socket: $!"; bind(S, $this) || die "bind: $!"; connect(S, $that) || die "connect: $!"; select(S); $| = 1; select(stdout); $| = 1; print S "\r\n"; print S "term len 0\r\n"; print S "show ip bgp\r\n"; $time = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime($time); $mon++; $fname=sprintf"ASmap.%.2d%.2d%.2d.$time",$year,$mon,$mday; open(O,">$fname") || die("cannot open output file"); while(){ printf O "$_"; } system("/var/Web/AS/Bin/bco.pl $fname"); system("/var/Web/AS/Bin/nnorg.pl $fname + "); system("/bin/gzip $fname");