Update on "panicanal": now "traceanal" w/improvements 
Author Message
 Update on "panicanal": now "traceanal" w/improvements

This is an improvement on the Perl program I sent a few days ago called
"panicanal"; it has been improved since then, and its name has been
changed to better reflect its function: "traceanal".  It looks for
traceback messages in the named file, /var/adm/messages, by default
(stdin is given with a file arg of '-'), and passes the addresses to
"adb" for symbolic decoding against the kernel (/vmunix).  You should
even be able to do: "dmesg | trace{*filter*}-"

It now supports a "summary" option (-s or -summary), which provides a
summary of the tracebacks found in the file.

As you might guess, the motivation for this script to help diagnose an
apparent kernel bug that we are currently experiencing, in the form of
spurious or random faults on one of our sparc1stations.  Not
incidentally, we are running it as a relatively loaded NFS fileserver
with four 1.7GB SCSI drives.  We've totally eliminated the hardware as
being the fault.

Enjoy.


     Center for Computational Sciences and Engineering (CCSE)
          University of California, Santa Barbara (UCSB)
           3111 Engineering I, Santa Barbara, CA 93106

============================= cut here ===================================
#!/bin/perl -s
# trace{*filter*}[-a] [-s] [file]
#
# $Revision: 1.3 $ $Date: 1992/09/03 18:44:57 $
# Alan K. Stebbens, CCSE, UCSB
#
# Do analysis of vmunix tracebacks as written in file (default is
# /var/adm/messages).
#
# If -a given, do all dumps, otherwise, interact with the user
# If STDOUT is not a tty, assume -a.
#
# If -s given, do a summary of the dumps.
#
$all = $a     unless $all;
$summary = $s unless $summary;

$dumpfile = '/var/adm/messages' unless $dumpfile = shift;
die "$dumpfile doesn't exist" unless ($dumpfile eq '-') || -f $dumpfile;

$KEEP_LINES = 6;

$interact = !($all || $summary) && -t && $dumpfile ne '-';      # set interaction flag

open(DUMP,$dumpfile) || die "Can't read $dumpfile because $!\n";
$defans = 'n';                          # initial default answer is 'no'
select(STDOUT);
$| = 1;                                 # flush all STDOUT
while (<DUMP>) {


    next if !/Begin traceback\.\.\./;   # loop until the traceback starts
    $header = $1 if /^(.*)Begin traceback\.\.\./;


    $what = '';
    $pidinfo = '';

        if (!$what) {
            $what = $1 if /^panic:\s*(\S.*)/ ||
                          /^([A-Z -]+)/ ||
                          /^syncing file systems\.+[ \d]*([A-Z -]+)/;
        }
        if (!$pidinfo) {
            $pidinfo = $1 if /^(pid \d+,.*)/;
        }
        last if $what && $pidinfo;      # quit when both found
    }
    $mon = '';
    ($mon, $day, $time, $host, $proc) = split(' ',$header) if $header;


    while (<DUMP>) {
        chop;
        last unless s/$header//;        # strip header

        last if /End traceback\.\.\./;
    }
    printf "\n" unless $summary;
    printf "Traceback";
    printf " on $mon $day at $time" if $mon;
    printf " on $host" if $host;
    $pidinfo =~ s/: $what//;            # avoid duplicate stuff
    printf " : $what, $pidinfo" if $summary || $interact;
    printf "\n";
    if ($interact) {
        printf "Analyze (ynq)? [$defans]";
        exit unless $ans = <STDIN>;
        chop($ans);
        $ans = $defans unless $ans;
        $defans = $ans;                 # new default
        exit     if !index('quit',$ans);
        next unless !index('yes',$ans);
    }
    &analyze unless $summary;

Quote:
}

close DUMP;
exit;

sub analyze {
    local($_);

    $addr = '';
    $tmp = "/tmp/$$.anal";
    open(TMP,">$tmp") || die "Can't open $tmp because $!\n";


        printf "%s\n",$_;
        next unless /Called from ([0-9a-f]+),/ || /pc=0x([0-9a-f]+),/;
        $addr = $1;
        print TMP "$addr?i\n";

    }
    close TMP;
    $| = 1;                     # flush STDOUT
    open(ADB,"adb /vmunix < $tmp|") || die "Can't open pipe from adb because $!\n";
    while (<ADB>) {
        chop;
        next if /^\s*$/;

        if (!/text address not found/) {
            ($symaddr,$instr) = ($1,$2) if /^([^:]+:)\s+(.*)/;
            printf "%s: %-30s %s\n",$addr,$symaddr,$instr;
        }
    }
    close ADB;
    unlink $tmp;

Quote:
}



Tue, 21 Feb 1995 03:33:15 GMT  
 Update on "panicanal": now "traceanal" w/improvements
: We've totally eliminated the hardware as being the fault.

Then it's definitely the cables.  :-)

Larry



Wed, 22 Feb 1995 01:33:08 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. "panicanal": vmunix panic analyzer

2. "character class ""bug""

3. system(("cp", "-Rf", "/tmp/a/*", "/tmp/b")); doesnt wrk

4. how to parse a "this", "that", "and the ", "other" file

5. s"\n+$"" s"\n*$""

6. how to safely substitute a "(", ")" or "["

7. "perlfreak", "i love perl", "perllover" or...???

8. how to parse "this", "that", "other"

9. split line like "a","b","c"

10. Looking for a Solaris "quot" replacement

11. Utility to update "group", "passwd" files, (in spite of) NIS

12. How to "$block_of_text<<"EOT" while "use strict"?

 

 
Powered by phpBB® Forum Software