Mailing List Archive

real query patch for looking glass
Dear All,
I made a patch against the rancid 2.2b8 for looking glass for display the
real command not only the Cisco command.

Would you like to integrate into the next version?
Regards,
Janos Mohacsi


Additional section for the configuration file (lg.conf) to enable real command:

#
# $LG_REALCMD enable displaying the real router command also
#
$LG_REALCMD=1;


Here is the patch:

*** lg.cgi.save Fri Nov 9 15:27:53 2001
--- lg.cgi Fri Nov 9 19:45:36 2001
***************
*** 169,174 ****
--- 169,177 ----
# 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",
$ENV{REMOTE_HOST}, $ENV{REMOTE_ADDR}, $ENV{REMOTE_USER},
***************
*** 181,186 ****
--- 184,196 ----
# 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,198 ****
<center>
<b>Date:</b> $timestr
<p>
! <b>Query:</b> $cmdDisp{$type}
! <br>
HEAD

if ($arg) { print "<b>Argument(s):</b> $arg\n"; }
print "</center>\n";
--- 200,209 ----
<center>
<b>Date:</b> $timestr
<p>
! <b>Query:</b> $cmdDisp{$type}
HEAD
+ if ($LG_REALCMD) { print "<b>Real Query:</b> $cmd"; }
+ print "<br>";

if ($arg) { print "<b>Argument(s):</b> $arg\n"; }
print "</center>\n";
***************
*** 267,273 ****
($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;
}

# conversion of command "type" passed from lgform.cgi to the vendor's
syntax.
--- 278,284 ----
($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($mfg);
}

# conversion of command "type" passed from lgform.cgi to the vendor's
syntax.
***************
*** 361,373 ****
if ($mfg =~ /juniper/) {
if (! defined($juniperCmd{$type})) {
$results[0] = "$cmdDisp{$type} not implemented for junipers. sorry.\n";
! &print_results;
}
$cmd = $juniperCmd{$type};
} elsif ($mfg =~ /foundry/) {
if(! defined($foundryCmd{$type})) {
$results[0] = "$cmdDisp{$type} not implemented for foundrys. sorry.\n";
! &print_results;
}
$cmd = $foundryCmd{$type};
} else {
--- 372,384 ----
if ($mfg =~ /juniper/) {
if (! defined($juniperCmd{$type})) {
$results[0] = "$cmdDisp{$type} not implemented for junipers. sorry.\n";
! &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($mfg);
}
$cmd = $foundryCmd{$type};
} else {
***************
*** 378,387 ****
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;
} elsif (defined($arg[1]) && $arg[1] !~ /^\d+\.\d+\.\d+\.\d+$/) {
$results[0] = "The IP netmask \"$arg[1]\" is not valid.\n";
! &print_results;
}
if ($mfg =~ /juniper/i && defined($arg[1])) {
$arg = $arg[0] . "/" . mask2len($arg[1]);
--- 389,398 ----
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($mfg);
} elsif (defined($arg[1]) && $arg[1] !~ /^\d+\.\d+\.\d+\.\d+$/) {
$results[0] = "The IP netmask \"$arg[1]\" is not valid.\n";
! &print_results($mfg);
}
if ($mfg =~ /juniper/i && defined($arg[1])) {
$arg = $arg[0] . "/" . mask2len($arg[1]);
***************
*** 390,396 ****
if ($mfg =~ /juniper/) {
$results[0] = "Juniper does not have a show frame-relay pvc command. ".
"Use show interface.\n";
! &print_results;
}
if ($arg[0] > 15 && $arg[0] < 1024) {
$arg = $arg[0];
--- 401,407 ----
if ($mfg =~ /juniper/) {
$results[0] = "Juniper does not have a show frame-relay pvc command. ".
"Use show interface.\n";
! &print_results($mfg);
}
if ($arg[0] > 15 && $arg[0] < 1024) {
$arg = $arg[0];
***************
*** 428,456 ****
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;
}
}
$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;
}
$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;
}
$arg = $arg[0];
# don't show the jewels
! &print_results 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;
}
$arg = $arg[0];
} elsif ($type eq "regex") {
--- 439,467 ----
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($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($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($mfg);
}
$arg = $arg[0];
# don't show the jewels
! &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($mfg);
}
$arg = $arg[0];
} elsif ($type eq "regex") {
***************
*** 462,474 ****
$arg =~ s/^\s*//; $arg =~ s/\s*$//;
if ($arg !~ /^[0-9_ ^.*+?[\])\(-]*\$?$/ || $arg =~ /^\s*$/) {
$results[0] = "That argument ($arg[0]) is not valid.\n";
! &print_results;
}
# 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;
}
if ($mfg =~ /juniper/) {
$arg =~ s/_/ /g;
--- 473,485 ----
$arg =~ s/^\s*//; $arg =~ s/\s*$//;
if ($arg !~ /^[0-9_ ^.*+?[\])\(-]*\$?$/ || $arg =~ /^\s*$/) {
$results[0] = "That argument ($arg[0]) is not valid.\n";
! &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($mfg);
}
if ($mfg =~ /juniper/) {
$arg =~ s/_/ /g;
***************
*** 486,492 ****
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;
}
}
$arg = $arg[0];
--- 497,503 ----
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($mfg);
}
}
$arg = $arg[0];
***************
*** 523,529 ****
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;
}
}
$arg = $arg[0];
--- 534,540 ----
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($mfg);
}
}
$arg = $arg[0];
***************
*** 576,582 ****
while (<CACHE>) { push(@results, $_); }
close CACHE ;
$seconds = $dtime;
! &print_results ;
}
}

--- 587,593 ----
while (<CACHE>) { push(@results, $_); }
close CACHE ;
$seconds = $dtime;
! &print_results($mfg) ;
}
}

***************
*** 590,599 ****
} else {
@results = &DoRsh($router, $mfg, $cmd, $arg);
}
! &print_results ;
} # end dampened-paths/flap-statistics

@results = &DoRsh($router, $mfg, $cmd, $arg);
! &print_results ;

exit ;
--- 601,610 ----
} else {
@results = &DoRsh($router, $mfg, $cmd, $arg);
}
! &print_results($mfg) ;
} # end dampened-paths/flap-statistics

@results = &DoRsh($router, $mfg, $cmd, $arg);
! &print_results($mfg) ;

exit ;
real query patch for looking glass [ In reply to ]
Fri, Nov 09, 2001 at 08:07:20PM +0000, Janos Mohacsi:
> Dear All,
> I made a patch against the rancid 2.2b8 for looking glass for display the
> real command not only the Cisco command.
>
> Would you like to integrate into the next version?
> Regards,
> Janos Mohacsi
>
>
> Additional section for the configuration file (lg.conf) to enable real command:
>
> #
> # $LG_REALCMD enable displaying the real router command also
> #
> $LG_REALCMD=1;
>

merged. it seemed like a better format than the generic command,
so i didnt merge the LG_REALCMD switch. thanks.