diff options
author | Tar Committer <tar@ocjtech.us> | 2002-01-04 21:31:49 +0000 |
---|---|---|
committer | Tar Committer <tar@ocjtech.us> | 2002-01-04 21:31:49 +0000 |
commit | 9f2402b0d86333f5f7e9d50437036cd3124bde47 (patch) | |
tree | 163861dc0a0052447f838d3674a35870a80026f5 /util/lg | |
parent | b0d71377c1854271b4511488422427f73d9473d1 (diff) | |
download | rancid-9f2402b0d86333f5f7e9d50437036cd3124bde47.tar.gz rancid-9f2402b0d86333f5f7e9d50437036cd3124bde47.tar.xz rancid-9f2402b0d86333f5f7e9d50437036cd3124bde47.zip |
Imported from rancid-2.2.tar.gz.rancid-2.2
Diffstat (limited to 'util/lg')
-rw-r--r-- | util/lg/Makefile.in | 2 | ||||
-rw-r--r-- | util/lg/README | 2 | ||||
-rwxr-xr-x | util/lg/lg.cgi.in | 87 | ||||
-rw-r--r-- | util/lg/lg.conf.in | 11 | ||||
-rwxr-xr-x | util/lg/lgform.cgi.in | 3 |
5 files changed, 73 insertions, 32 deletions
diff --git a/util/lg/Makefile.in b/util/lg/Makefile.in index 274fa5a..54b42a6 100644 --- a/util/lg/Makefile.in +++ b/util/lg/Makefile.in @@ -25,9 +25,9 @@ install: all done clean: - rm -f Makefile $(UTIL_LG_PROGS) lg.conf distclean: clean + rm -f Makefile $(UTIL_LG_PROGS) lg.conf rm -f config.log config.status distdir: diff --git a/util/lg/README b/util/lg/README index 183dd15..4546487 100644 --- a/util/lg/README +++ b/util/lg/README @@ -1,6 +1,6 @@ This is a looking glass based on Ed Kern's which can be found on http://nitrous.digex.net/. This version supports cisco, juniper, and -foundry, useing rancid's [cfj]login to login (so rcmd is not necessary, +foundry, using rancid's [cfj]login to login (so rcmd is not necessary, it can use telnet, ssh, or rsh), and has some additional commands implemented. There are a few cisco commands where either no juniper or foundry equivalent exists or we have not had time to implement yet. diff --git a/util/lg/lg.cgi.in b/util/lg/lg.cgi.in index cf4caa8..714c6cc 100755 --- a/util/lg/lg.cgi.in +++ b/util/lg/lg.cgi.in @@ -34,6 +34,9 @@ my($pingcmd) = "@LG_PING_CMD@"; my($query, $max_time_diff, $cache_dir, $cloginrc, @results); my($type, $router_param, $remote_user, $arg, $router, $mfg); +my($LG_CACHE_DIR, $LG_CLOGINRC, $LG_IMAGE, $LG_LOG, $LG_ROUTERDB, $LG_AS_REG); +my($LG_BGP_RT, $LG_CACHE_TIME, $LG_SINGLE, $LG_STRIP); + if (!defined($ENV{HOME})) { $ENV{HOME} = "."; } # read LG configuration file @@ -43,6 +46,8 @@ sub readconf local(*CONF); if (defined($env{LG_CONF})) { $conffile = $env{LG_CONF}; + } elsif (-e "lg.conf") { + $conffile = "lg.conf"; } else { $conffile = "$BASEDIR/util/lg/lg.conf"; } @@ -119,14 +124,14 @@ sub DoCmd local(*CMD); if ($mfg =~ /foundry/i) { - open(CMD, "sh -c \"flogin -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); $cmd = $foundryCmd{$type}; + open(CMD, "sh -c \"flogin -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); } elsif ($mfg =~ /juniper/i) { - open(CMD, "sh -c \"jlogin -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); $cmd = $juniperCmd{$type}; + open(CMD, "sh -c \"jlogin -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); } else { - open(CMD, "sh -c \"clogin -noenable -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); $cmd = $ciscoCmd{$type}; + open(CMD, "sh -c \"clogin -noenable -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); } while (<CMD>) { tr/\015//d; @@ -168,6 +173,8 @@ sub mask2len { } # create the page and log the transaction... sub print_results { + my($mfg) = @_; + my($cmd); my($timestr) = strftime("%a %b %e %H:%M:%S %Y %Z", gmtime); dolog(LOG_INFO, sprintf("%s %s %s %s\n", @@ -181,6 +188,14 @@ sub print_results { # add the company image, LG_IMAGE print $LG_IMAGE; + if ($mfg =~ /foundry/i) { + $cmd = $foundryCmd{$type}; + } elsif ($mfg =~ /juniper/i) { + $cmd = $juniperCmd{$type}; + } else { + $cmd = $ciscoCmd{$type}; + } + print <<HEAD ; </b></font> <font size=+3><b><h1>Looking Glass Results - $router @@ -190,7 +205,7 @@ sub print_results { <center> <b>Date:</b> $timestr <p> - <b>Query:</b> $cmdDisp{$type} + <b>Query:</b> $cmd <br> HEAD @@ -267,7 +282,7 @@ $arg = ($query->param('args'))[0]; ($router, $mfg) = split(':', $router_param); if (!defined($type) || !defined($router)) { $results[0] = "You must at least choose a Query and a router. Try buying a clue.\n"; - &print_results; + &print_results($mfg); } # conversion of command "type" passed from lgform.cgi to the vendor's syntax. @@ -278,7 +293,7 @@ if (!defined($type) || !defined($router)) { damp => "show ip bgp dampened-paths", framerelay => "show frame-relay pvc", interface => "show interface", - intbrief => "show ip interface", + intbrief => "show ip interface", # switch in {interface} log => "show logging", mbgp => "show ip mbgp", mbgpsum => "show ip mbgp summary", @@ -361,13 +376,13 @@ if (!defined($type) || !defined($router)) { if ($mfg =~ /juniper/) { if (! defined($juniperCmd{$type})) { $results[0] = "$cmdDisp{$type} not implemented for junipers. sorry.\n"; - &print_results; + &print_results($mfg); } $cmd = $juniperCmd{$type}; } elsif ($mfg =~ /foundry/) { if(! defined($foundryCmd{$type})) { $results[0] = "$cmdDisp{$type} not implemented for foundrys. sorry.\n"; - &print_results; + &print_results($mfg); } $cmd = $foundryCmd{$type}; } else { @@ -378,10 +393,10 @@ if ($mfg =~ /juniper/) { if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) { $results[0] = "The IP address \"$arg[0]\" is not valid and lacking an address would over-burden our router.\n"; - &print_results; + &print_results($mfg); } elsif (defined($arg[1]) && $arg[1] !~ /^\d+\.\d+\.\d+\.\d+$/) { $results[0] = "The IP netmask \"$arg[1]\" is not valid.\n"; - &print_results; + &print_results($mfg); } if ($mfg =~ /juniper/i && defined($arg[1])) { $arg = $arg[0] . "/" . mask2len($arg[1]); @@ -390,7 +405,7 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { if ($mfg =~ /juniper/) { $results[0] = "Juniper does not have a show frame-relay pvc command. ". "Use show interface.\n"; - &print_results; + &print_results($mfg); } if ($arg[0] > 15 && $arg[0] < 1024) { $arg = $arg[0]; @@ -398,15 +413,31 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { undef($arg); } } elsif ($type eq "interface") { - if ($arg[1] =~ /[-\/0-9:.]+/) { - $arg = $arg[0] . " " . $arg[1]; - } else { - if ($arg[0] !~ /^b[^ ]+[0-9]/i && $arg[0] =~ /^b/i && $mfg =~ /(cisco|foundry)/i) { + if ($mfg =~ /(cisco|foundry)/) { + if ($arg[0] !~ /^b[^ ]+[0-9]/i && $arg[0] =~ /^b/i) { $type = "intbrief"; $arg = "brief"; } else { $arg = $arg[0]; } + } elsif ($mfg =~ /juniper/) { + my($optind) = 0; + # arg 0 may be an intf name or a display option, but there can + # only be 2 args + $arg = ""; + while ($optind <= $#arg && $optind < 2) { + $arg[$optind] =~ s/brief/terse/; + if ($arg[$optind] =~ /^([a-z0-9]{2}\-\d+\/\d+\/\d+(:\d+)?)/i) { + $arg .= " $1"; + } elsif ($arg[$optind] =~ /^det/i) { + $arg .= " detail"; + } elsif ($arg[$optind] =~ /^ter/i) { + $arg .= " terse"; + } elsif ($arg[$optind] =~ /^ext/i) { + $arg .= " extensive"; + } + $optind += 1; + } } } elsif ($type eq "log") { if ($arg[0] =~ /^\s*\|?$/) { @@ -428,29 +459,29 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) { if ($arg[0] !~ /([A-Za-z0-9-]*.)*[A-Za-z0-9-]*.(com|edu|net|org)/) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } } $arg = $arg[0]; } elsif ($type eq "aspath" || $type eq "communitylist") { if ($arg[0] !~ /^\d+$/ || ($arg[0] < 1 && $arg[0] > 199)) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } $arg = $arg[0]; } elsif ($type eq "acl") { if ($arg[0] !~ /^\d+$/ || ($arg[0] < 100 && $arg[0] > 199) || ($arg[0] < 1300 && $arg[0] > 2699)) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } $arg = $arg[0]; # don't show the jewels - &print_results if ($arg == 98 || $arg == 99); + &print_results($mfg) if ($arg == 98 || $arg == 99); } elsif ($type eq "prefixlist" || $type eq "routemap") { if ($arg[0] !~ /^[0-9A-Za-z][^\s\"]*$/) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } $arg = $arg[0]; } elsif ($type eq "regex") { @@ -462,13 +493,13 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { $arg =~ s/^\s*//; $arg =~ s/\s*$//; if ($arg !~ /^[0-9_ ^.*+?[\])\(-]*\$?$/ || $arg =~ /^\s*$/) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } # pathetic excuses for lookups if ($arg =~ /^[_.* ^]*(\*|1|701|1239|1280|1740|3561|5462|10303)+[_\$]*$/ || $arg =~ /^[_.* ^]*(1|701|1239|1280|1740|3561|5462|10303)+[_ .]*[\[*.]/) { $results[0] = "Get real. Such a query has potential to over-burden our router.\nLook that up on your own router.\n"; - &print_results; + &print_results($mfg); } if ($mfg =~ /juniper/) { $arg =~ s/_/ /g; @@ -486,7 +517,7 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) { if ($arg[0] !~ /([A-Za-z0-9-]*.)*[A-Za-z0-9-]*.(com|edu|net|org)/) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } } $arg = $arg[0]; @@ -523,7 +554,7 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) { if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) { if ($arg[0] !~ /([A-Za-z0-9-]*.)*[A-Za-z0-9-]*.(com|edu|net|org)/) { $results[0] = "That argument ($arg[0]) is not valid.\n"; - &print_results; + &print_results($mfg); } } $arg = $arg[0]; @@ -576,7 +607,7 @@ if ($type eq "summary" || $type eq "mbgpsu" || $type eq "damp" || $type eq "log" while (<CACHE>) { push(@results, $_); } close CACHE ; $seconds = $dtime; - &print_results ; + &print_results($mfg); } } @@ -590,10 +621,10 @@ if ($type eq "summary" || $type eq "mbgpsu" || $type eq "damp" || $type eq "log" } else { @results = &DoRsh($router, $mfg, $cmd, $arg); } - &print_results ; + &print_results($mfg); } # end dampened-paths/flap-statistics @results = &DoRsh($router, $mfg, $cmd, $arg); -&print_results ; +&print_results($mfg); -exit ; +exit; diff --git a/util/lg/lg.conf.in b/util/lg/lg.conf.in index 7b78c3f..d13d9fd 100644 --- a/util/lg/lg.conf.in +++ b/util/lg/lg.conf.in @@ -35,7 +35,14 @@ $ENV{PATH}="@prefix@/bin:@ENV_PATH@"; #$LG_IMAGE="<img src=rancid.gif hspace=0>\n"; # # -# LG_LOG is either a FQPN (fully qualified path name) the syslog +# LG_INFO is info in html format to output at the bottom of main form. +# it might be local contact information, disclaimer, etc. this +# is just handed to print, so \n and the like will work. +# +#$LG_INFO="For support, contact <a href=\"mailto:webmaster\@localhost\">webmaster</a>"; +# +# +# LG_LOG is either a FQPN (fully qualified path name) or the syslog # facility to use for logging. if not defined, the LG # will log to LG_CACHE_DIR/lg.log. possible syslog facility # values are from the facility codes in /usr/include/syslog.h @@ -56,7 +63,7 @@ $ENV{PATH}="@prefix@/bin:@ENV_PATH@"; # option; the group directories and router.db files' modes may # have to be changed, depending upon the UID/GID of the user # your server (httpd) runs under, since rancid's default mask -# is 007 (see bin/env). routers marked 'down' are skipped. +# is 007 (see bin/env). routers not marked 'up' are skipped. # #$LG_ROUTERDB="@prefix@/util/lg/router.db"; # diff --git a/util/lg/lgform.cgi.in b/util/lg/lgform.cgi.in index 7fa7d0f..3ea6856 100755 --- a/util/lg/lgform.cgi.in +++ b/util/lg/lgform.cgi.in @@ -28,6 +28,8 @@ sub readconf local(*CONF); if (defined($env{LG_CONF})) { $conffile = $env{LG_CONF}; + } elsif (-e "lg.conf") { + $conffile = "lg.conf"; } else { $conffile = "$BASEDIR/util/lg/lg.conf"; } @@ -199,6 +201,7 @@ TAIL print <<TAIL ; <p> +$LG_INFO </body> TAIL |