#!@PERLV_PATH@ # lgform.cgi - Looking glass front-end # produces html form for calling lg.cgi use CGI qw/:standard/; my(@rtrlist, %rtrlabels); my($BASEDIR) = "@prefix@"; # read LG configuration file sub readconf { my($conffile, $cmds); local(*CONF); if (defined($env{LG_CONF})) { $conffile = $env{LG_CONF}; } else { $conffile = "$BASEDIR/util/lg/lg.conf"; } if (! -f $conffile) { return; } if (open(CONF, "< $conffile")) { while () { next if (/^\s*(#|$)/); $cmds .= $_; } close(CONF); eval $cmds; } else { printf(STDERR "ERROR: couldn\'t open the configuration file: $conffile: $!\n"); exit(255); } return; } # read router.db file sub readrouters { my($rtrdb); local(*RTR); if (defined($LG_ROUTERDB)) { $rtrdb = $LG_ROUTERDB; } else { $rtrdb = "$BASEDIR/util/lg/router.db"; } if (! -f $rtrdb) { my(@dirs, $dir); # if the router.db file does not exist, try to compile from # the rancid group's router.db files. local(*DIR); if (! opendir(DIR, $BASEDIR)) { printf(STDERR "ERROR: couldn\'t read $BASEDIR: $!\n"); } else { while ($dir = readdir(DIR)) { next if ($dir =~ /^(\.|\.\.|CVS|bin|logs|util)$/); push(@dirs, $dir) if (-d "$BASEDIR/$dir"); } closedir(DIR); foreach $dir (@dirs) { if (! opendir(DIR, "$BASEDIR/$dir")) { printf(STDERR "ERROR: couldn\'t read $BASEDIR/$dir: $!\n"); next; } closedir(DIR); next if (! -f "$BASEDIR/$dir/router.db"); if (open(RTR, "< $BASEDIR/$dir/router.db")) { while () { next if (/^\s*(#|$)/); # fqdn:mfg:state @record = split('\:', $_); next if ($record[2] !~ /up/i || $record[1] !~ /(cisco|juniper)/); push(@rtrlist, join(':', ($record[0], $record[1]))); $rtrlabels{join(':', ($record[0], $record[1]))} = $record[0]; } close(RTR); } else { printf(STDERR "ERROR: couldn\'t open the router.db file: $BASEDIR/$dir/router.db: $!\n"); } } } } else { if (open(RTR, "< $rtrdb")) { while () { next if (/^\s*(#|$)/); # fqdn:mfg:state @record = split('\:', $_); next if ($record[2] !~ /up/i || $record[1] !~ /(cisco|juniper)/); push(@rtrlist, join(':', ($record[0], $record[1]))); $rtrlabels{join(':', ($record[0], $record[1]))} = $record[0]; } close(RTR); } else { printf(STDERR "ERROR: couldn\'t open the router.db file: $rtrdb: $!\n"); exit(255); } } return; } # read the configuration file if it exists. readconf(); $query = new CGI; print $query->header; print $query->start_html("LookingGlass form"); print ""; # add the company image, LG_IMAGE print $LG_IMAGE; print < Looking Glass

HEAD # start table, etc here print <
DOTABLE # available query types here print <
Query:
show frame-relay pvc [DLCI]
show interface <interface>
show ip bgp <prefix> [netmask]
show ip bgp regex <reg_exp>
show ip bgp summary
show ip bgp dampened-paths
show ip prefix-list <list_name>
show ip route <prefix> [netmask]
show ip mbgp <prefix> [netmask]
show ip mbgp summary
show logging [| <match_string>]
ping <IP_addr | FQDN>
traceroute <IP_addr | FQDN>

Argument(s):

Router:
QTYPES # unimplemented/disabled/removed query types. # #
show ip bgp neighbor <IP_addr>
#
show ip bgp neighbor <IP_addr> advertised routes
#
show ip bgp neighbor <IP_addr> flap statistics
#
show ip bgp neighbor <IP_addr> received
#
show ip bgp neighbor <IP_addr> routes
# #
sh ip as-path-access-list <list_number>
#
sh access-list <list_number>
#
sh ip community-list <list_number>
#
sh ip route-map <map_name>
# read routers table and create the scrolling list readrouters(); print $query->scrolling_list(-name => 'router', -values => \@rtrlist, -size => 20, -labels => \%rtrlabels); # end print <


Looking Glass notes TAIL print < TAIL print $query->end_html; exit 0;