Xref: utzoo unix-pc.general:3173 comp.sys.att:6813 Path: utzoo!utgpu!attcan!uunet!shelby!rutgers!tut.cis.ohio-state.edu!n8emr!uncle!jbm From: jbm@uncle.UUCP (John B. Milton) Newsgroups: unix-pc.general,comp.sys.att Subject: Re: perl-based UNIXPC disk error message browser Keywords: UNIXPC, disk, errors Message-ID: <565@uncle.UUCP> Date: 27 Jun 89 01:42:57 GMT References: <19@taqwa.UUCP> Reply-To: jbm@uncle.UUCP (John B. Milton) Distribution: unix-pc Organization: U.N.C.L.E. Lines: 150 In article <19@taqwa.UUCP> mkp@taqwa.UUCP (Michael K. Peterson) writes: > >I suppose others have written awk scripts or whatever to glean clues from >the unix.log file, but I haven't seen anything posted, so here goes. > >I put some of the high points from John Milton's "Hardware Notes #13" >into a perl script, and it made deciphering the hard disk error messages >in my unix.log file much easier. John's discussion of the WD1010 error >register is included in the comment block at the beginning of the script. >Also, there are three variables, $HEADS, $BADLIST, and $SWAPSIZE, that you'll >want to change for your particular disk. (No provision as yet for >more than one drive.) Ooopss. I guess I should have posted my program when I got it working :) This program does the same thing. It is C, and check the VHB to get the sizes of the partitions, and heads. It prints out the offsets of the bad blocks found into each partition. Use post awk processing if you want to automate it's use, or just hack the code. I use the output of this with bf and ncheck to track down the file in which a bad spot appears. I have not yet integrated this into my nightly unix.log backup routine. John --- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'chs2blk.c' <<'END_OF_FILE' X/* vi:set ts=2 sw=2: */ X X#include X#include X#include X#include X Xextern int errno; Xextern int optind; Xextern char *optarg; X X#define LINESIZE 200 X#define SCTSPERTRK 4 /* shift factor */ X#define SCTPERBLK 2 X#define BLKPERTRK 8 /* 16 512 bytes sectors is 8 1024 bytes blocks */ X#define PART0 72 X#define PART1 5000 X Xchar *me,Debug=0; X Xstatic void show(dname,f) Xchar *dname; XFILE *f; X{ X int ST,EF,CL,CH,SN,SC,SDH; X int block,cyl,drive,head,i,sector,v; X char line[LINESIZE]; X struct vhbd vhb; X struct gdswprt dsk; X X if ((v=open(dname))==-1) X qperrorf("%s: open device \"%s\"",me,dname); X if ((v=read(v,&vhb,sizeof(struct vhbd))==-1)) X qperrorf("%s: read VHB from device \"%s\"",me,dname); X if (vhb.magic!=VHBMAGIC) { X fprintf(stderr,"%s: bad magic in VHB (slice zero!,%x!=%x)\n", X me,vhb.magic,VHBMAGIC); X exit(1); X } X while (fgets(line,LINESIZE,f)!=NULL) { X if (strncmp(line,"HDERR",5)==0) { X sscanf(line,"HDERR ST:%x EF:%x CL:%x CH:%x SN:%x SC:%x SDH:%x", X &ST,&EF,&CL,&CH,&SN,&SC,&SDH); X /* SDH: ESSDDHHH */ X drive=(SDH&0x18)>>3; X cyl=((CH&0xff)<<8)+(CL&0xff); X head=SDH&0x07; X sector=SN&0x1f; X if (Debug) { X *strchr(line,'\n')=='\0'; X fprintf(stderr,"Found: \"%s\"\n",line); X fprintf(stderr,"%x %x %x %x %x %x %x\n",ST,EF,CL,CH,SN,SC,SDH); X fprintf(stderr,"Drive: %d, Cylinder: %d, Head: %d, Sector: %d\n", X drive,cyl,head,sector); X } X block=((((cyl*vhb.dsk.heads)+head)<2) { X fprintf(stderr,usage,me); X exit(1); X } X if (argc-optind==1) X show(argv[optind],stdin); X else X if ((f=fopen(argv[optind+1],"r"))==NULL) X perrorf("%s: open %s",me,argv[optind+1]); X else { X show(argv[optind],f); X fclose(f); X } X} END_OF_FILE if test 2355 -ne `wc -c <'chs2blk.c'`; then echo shar: \"'chs2blk.c'\" unpacked with wrong size! fi # end of 'chs2blk.c' fi echo shar: End of shell archive. exit 0 -- John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu (614) h:294-4823, w:466-9324; N8KSN, AMPR: 44.70.0.52; Don't FLAME, inform!