From: Dirk Koopman Date: Mon, 7 Sep 2020 22:02:06 +0000 (+0100) Subject: Watchdbg, grepdbg args change, fix pc92c for rbn X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?p=spider.git;a=commitdiff_plain;h=d235b0d777f1a90c65d5dcf8cd6adaeb9f2b7e99 Watchdbg, grepdbg args change, fix pc92c for rbn As Changes says: 1, Change interface to watchdbg & grepdbg slightly so that multiple search regexes are ANDed rather than ORed together. ORing is easily achieved already by the usual regex pattern 'PATT..|PATT..|..' whereas ANDing could not be done as easily without resorting lots of 'PATT.*PATH' things which would not necessarily get what was wanted. 2. Make sure that the pc92 C record only contains nodes and users and not other extranoeus things like skimmers... --- diff --git a/Changes b/Changes index 25d70ce6..9e81881b 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,11 @@ +07Sep20======================================================================= +1, Change interface to watchdbg & grepdbg slightly so that multiple search + regexes are ANDed rather than ORed together. ORing is easily achieved + already by the usual regex pattern 'PATT..|PATT..|..' whereas ANDing could + not be done as easily without resorting lots of 'PATT.*PATH' things which + would not necessarily get what was wanted. +2. Make sure that the pc92 C record only contains nodes and users and not + other extranoeus things like skimmers... 15Aug20======================================================================= 1. Simplify the skimmer scoring mechanism. 13Aug20======================================================================= diff --git a/perl/DXProt.pm b/perl/DXProt.pm index b5606eff..6cc0eea4 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -928,7 +928,7 @@ sub gen_my_pc92_config clear_pc92_changes(); # remove any slugged data, we are generating it as now my @dxchan = grep { $_->call ne $main::mycall && !$_->{isolate} } DXChannel::get_all(); dbg("ROUTE: all dxchan: " . join(',', map{$_->{call}} @dxchan)) if isdbg('routelow'); - my @localnodes = map { my $r = Route::get($_->{call}); $r ? $r : () } @dxchan; + my @localnodes = map { my $r = Route::get($_->{call});($_->is_node || $_->is_user) && $r ? $r : () } @dxchan; dbg("ROUTE: localnodes: " . join(',', map{$_->{call}} @localnodes)) if isdbg('routelow'); return pc92c($node, @localnodes); } else { diff --git a/perl/Route.pm b/perl/Route.pm index 3f264846..304b9c68 100644 --- a/perl/Route.pm +++ b/perl/Route.pm @@ -224,12 +224,14 @@ sub config my $c; if ($uref) { $c = $uref->user_call; - } else { + } + else { $c = "$ucall?"; } if ((length $line) + (length $c) + 1 < $width) { $line .= $c . ' '; - } else { + } + else { $line =~ s/\s+$//; push @out, $line; $line = ' ' x ($level*2) . "$pcall->$c "; @@ -240,7 +242,8 @@ sub config $line =~ s/->$//g; $line =~ s/\s+$//; push @out, $line if length $line; - } else { + } + else { # recursion detector if ((DXChannel::get($call) && $level > 1) || $seen->{$call} || $level > $maxlevel) { return @out; diff --git a/perl/grepdbg b/perl/grepdbg index 80a918a0..06f7df63 100755 --- a/perl/grepdbg +++ b/perl/grepdbg @@ -12,7 +12,9 @@ # ten lines including the line matching the regular expression. # # is the regular expression you are searching for, -# a caseless search is done +# a caseless search is done. There can be more than one +# a preceeded by a '!' is treated as NOT . Each +# is implcitly ANDed together. # # If you specify something that likes a filename and that filename # has a .pm on the end of it and it exists then rather than doing @@ -47,8 +49,9 @@ $fp = DXLog::new('debug', 'dat', 'd'); $today = $fp->unixtoj(time()); my $nolines = 1; my @prev; +my @patt; -for my $arg (@ARGV) { +foreach my $arg (@ARGV) { if ($arg =~ /^-/) { $arg =~ s/^-//o; if ($arg =~ /^\s*\-+(?:[h\?]e?l?p?)/) { @@ -68,12 +71,11 @@ for my $arg (@ARGV) { die "$arg not found"; } } else { - $string = $arg; - last; + push @patt, $arg; } } -$string ||= '.*'; +push @patt, '.*' unless @patt; push @list, "0" unless @list; for my $entry (@list) { @@ -104,7 +106,17 @@ sub process chomp $line; push @prev, $line; shift @prev while @prev > $nolines; - if ($line =~ m{$string}io) { + my $flag = 0; + foreach my $p (@patt) { + if ($p =~ /^!/) { + my $r = substr $p, 1; + last if $line =~ m{$r}i; + } else { + last unless $line =~ m{$p}i; + } + ++$flag; + } + if ($flag == @patt) { for (@prev) { s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg; my ($t, $l) = split /\^/, $_, 2; @@ -117,6 +129,6 @@ sub process sub usage { - die "usage: grepdbg [nn days before] [-nnn lines before] [|]\n"; + die "usage: grepdbg [nn days before] [-nnn lines before] [] [|!]...\n"; } exit(0); diff --git a/perl/watchdbg b/perl/watchdbg index 8d9551d3..a497eff9 100755 --- a/perl/watchdbg +++ b/perl/watchdbg @@ -3,6 +3,10 @@ # watch the end of the current debug file (like tail -f) applying # any regexes supplied on the command line. # +# There can be more than one . a preceeded by a '!' is +# treated as NOT . Each is implcitly ANDed together. +# All are caseless. +# # examples:- # # watchdbg g1tlh # watch everything g1tlh does @@ -35,7 +39,7 @@ my $fh = $fp->open($today) or die $!; my $nolines = 1; $nolines = shift if $ARGV[0] =~ /^-?\d+$/; $nolines = abs $nolines if $nolines < 0; -my $exp = join '|', @ARGV; +my @patt = @ARGV; my @prev; # seek to end of file @@ -43,10 +47,20 @@ $fh->seek(0, 2); for (;;) { my $line = $fh->getline; if ($line) { - if ($exp) { + if (@patt) { push @prev, $line; shift @prev while @prev > $nolines; - if ($line =~ m{(?:$exp)}oi) { + my $flag = 0; + foreach my $p (@patt) { + if ($p =~ /^!/) { + my $r = substr $p, 1; + last if $line =~ m{$r}i; + } else { + last unless $line =~ m{$p}i; + } + ++$flag; + } + if ($flag == @patt) { printit(@prev); @prev = (); } @@ -80,7 +94,7 @@ sub printit $line =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\x%02X", ord($1))/eg; my ($t, $l) = split /\^/, $line, 2; $t = time unless defined $t; - printf "%02d:%02d:%02d %s\n", (gmtime($t))[2,1,0], $l; + printf "%02d:%02d:%02d %s\n", (gmtime($t))[2,1,0], $l; } } exit(0);