hey, maybe i should have bothered to test this... =)
this works =) 
open (FILE, "<file");
my (@linenums, $seq, $pseq, $line);
$pseq=0; $line=1;
while (<FILE>) {
    ($seq) = $_ =~ /^.*?icmp_seq\=(\d+)\s/;
    if (($seq-1) != $pseq && $pseq != 0) {
        push(@linenums, $line);
    }
    $pseq = $seq;
    $line++;
}
close(FILE);
if (scalar(@linenums) > 0) {
    print "non-sequential lines:\n\t";
    foreach $line (@linenums) {
        print "$line ";
    }
}


tom carlile ([EMAIL PROTECTED]) wrote:
> whoops, that should be 
> my (@linenums, $seq, $pseq, $line);
> $pseq=0; $line=1;
> 
> tom carlile ([EMAIL PROTECTED]) wrote:
> > jim, meet perl.  perl, meet jim:
> > 
> > 
> > #!/usr/local/bin/perl
> > open (FILE, "<file");
> > my @linenums, $seq, $pseq=0, $line=1;
> > while (<FILE>) {
> >     ($seq) =~ /^.*?icmp_seq\=(\d+)\s/;
> >     if (($seq-1) != $pseq && $pseq != 0) {
> >         push(@linenums, $line);
> >     }
> >     $line++;
> > }
> > close(FILE);
> > if (scalar(@linenums) > 0) {
> >     print "non-sequential lines:\n\t";
> >     foreach $line (@linenums) {
> >         print "$line ";
> >     }
> > }
> > 
> > 
> > Jim Westbrook ([EMAIL PROTECTED]) wrote:
> > > I am trying to troubleshoot a router that occasionally "drops out" for several
> > > minutes at a time.  I'm using a cron call to "ping -i 60 -c 1440
> > > 66.xx.31.17" which is redirected to a file.  Here's a clip from the file
> > > showing a dropout which shows up as a break in the sequence numbers.
> > > 
> > > 64 bytes from 66.xx.31.17: icmp_seq=560 ttl=251 time=64.345 ms
> > > 64 bytes from 66.xx.31.17: icmp_seq=561 ttl=251 time=66.814 ms
> > > 64 bytes from 66.xx.31.17: icmp_seq=571 ttl=251 time=42.825 ms
> > > 64 bytes from 66.xx.31.17: icmp_seq=572 ttl=251 time=21.539 ms
> > > 
> > > What I need now is a quick way to locate these non-sequential entries in the
> > > files captured over several days.  Is there a way to get awk (or something
> > > else) to detect the non-sequential entries?
> > > 
> > > Thanks,
> > > JimW
> > > ---------------------------------------------------------------------------
> > > Send administrative requests to [EMAIL PROTECTED]
> > 
> > -- 
> > tom carlile                 [EMAIL PROTECTED]
> > "There are two major products that came out of Berkeley:
> >  LSD and BSD. We don't believe this to be a coincidence."
> >  --Jeremy S. Anderson
> > ---------------------------------------------------------------------------
> > Send administrative requests to [EMAIL PROTECTED]
> 
> -- 
> tom carlile                   [EMAIL PROTECTED]
> "There are two major products that came out of Berkeley:
>  LSD and BSD. We don't believe this to be a coincidence."
>  --Jeremy S. Anderson
> ---------------------------------------------------------------------------
> Send administrative requests to [EMAIL PROTECTED]

-- 
tom carlile                     [EMAIL PROTECTED]
"There are two major products that came out of Berkeley:
 LSD and BSD. We don't believe this to be a coincidence."
 --Jeremy S. Anderson
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to