diff options
author | Tar Committer <tar@ocjtech.us> | 2000-11-24 22:14:14 +0000 |
---|---|---|
committer | Tar Committer <tar@ocjtech.us> | 2000-11-24 22:14:14 +0000 |
commit | 25c2b7c2c8a333b276c3499bcce004137d4b4fe0 (patch) | |
tree | baad136bdfcea88812dd658a682f126d1af4dfc3 /util/lg/lgform.cgi.in | |
parent | 1651adc35224e149715bd85af4ba108c5ee184bc (diff) | |
download | rancid-25c2b7c2c8a333b276c3499bcce004137d4b4fe0.tar.gz rancid-25c2b7c2c8a333b276c3499bcce004137d4b4fe0.tar.xz rancid-25c2b7c2c8a333b276c3499bcce004137d4b4fe0.zip |
Imported from rancid-2.1b.tar.gz.rancid-2.1b
Diffstat (limited to 'util/lg/lgform.cgi.in')
-rwxr-xr-x | util/lg/lgform.cgi.in | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/util/lg/lgform.cgi.in b/util/lg/lgform.cgi.in new file mode 100755 index 0000000..762c9d8 --- /dev/null +++ b/util/lg/lgform.cgi.in @@ -0,0 +1,200 @@ +#!@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 (<CONF>) { + 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 (<RTR>) { + 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 (<RTR>) { + 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 "<BODY>"; + +# add the company image, LG_IMAGE +print $LG_IMAGE; + +print <<HEAD ; +<br> +<B><FONT SIZE=+2>Looking Glass</FONT></B> +<br> +<hr> +HEAD + +# start table, etc here +print <<DOTABLE ; +<form action=lg.cgi method=GET> +<center> +<table border cellspacing=0 width=575 align=center> + +DOTABLE + +# available query types here +print <<QTYPES ; +<tr valign=top> + <TD><B>Query:</B> +<dd><input type=radio name="query" value="framerelay">show frame-relay pvc [DLCI]</DD> +<dd><input type=radio name="query" value="interface">show interface <interface></DD> +<dd><input type=radio name="query" value="prefix">show ip bgp <prefix> [netmask]</DD> +<dd><input type=radio name="query" value="regex">show ip bgp regex <reg_exp></DD> +<dd><input type=radio name="query" value="summary">show ip bgp summary</DD> +<dd><input type=radio name="query" value="damp">show ip bgp dampened-paths</DD> +<dd><input type=radio name="query" value="prefixlist">show ip prefix-list <list_name></DD> +<dd><input type=radio name="query" value="route">show ip route <prefix> [netmask]</DD> +<dd><input type=radio name="query" value="mbgp">show ip mbgp <prefix> [netmask]</dd> +<dd><input type=radio name="query" value="mbgpsum">show ip mbgp summary</dd> +<dd><input type=radio name="query" value="log">show logging [| <match_string>]</DD> +<dd><input type=radio name="query" value="ping">ping <IP_addr | FQDN></dd> +<dd><input type=radio name="query" value="trace">traceroute <IP_addr | FQDN></DD> + +<P><B>Argument(s):</B> <INPUT name="args" size=30></P> + </TD> + <td ALIGH=left VALIGN=top> + <b>Router:</B> + +<dd> +QTYPES + +# unimplemented/disabled/removed query types. +# +# <dd>show ip bgp neighbor <IP_addr></dd> +# <dd>show ip bgp neighbor <IP_addr> advertised routes</dd> +# <dd>show ip bgp neighbor <IP_addr> flap statistics</dd> +# <dd>show ip bgp neighbor <IP_addr> received</dd> +# <dd>show ip bgp neighbor <IP_addr> routes</dd> +# +# <dd><input type=radio name="query" value="aspath">sh ip as-path-access-list <list_number></DD> +# <dd><input type="radio" name="query" value="acl">sh access-list <list_number></dd> +# <dd><input type=radio name="query" value="communitylist">sh ip community-list <list_number><DD> +# <dd><input type=radio name="query" value="routemap">sh ip route-map <map_name></DD> + +# read routers table and create the scrolling list +readrouters(); +print $query->scrolling_list(-name => 'router', + -values => \@rtrlist, + -size => 20, + -labels => \%rtrlabels); + +# end +print <<TAIL ; +</dd> +</td> +</TABLE> +<p><input type=submit value=Submit> <INPUT type=reset value=Reset></FORM> +</center> +<br> +<a href=lgnotes.html>Looking Glass notes</a> +TAIL + +print <<TAIL ; +<p> +</body> +TAIL + +print $query->end_html; + +exit 0; |