############################################################################# # # nawk script to read the output of oncheck -pe and summarize it. # # IDS Version # # Copyright (c) 1999 Jack Parker. # Permission is granted to copy, distribute and/or modify this document # under the terms of the GNU Free Documentation License, Version 1.1 # or any later version published by the Free Software Foundation; # # syntax: oncheck -pe | nawk -f onchk.awk > wherever. # # Version 9.21.UC4 - Linux # ############################################################################# BEGIN { # array of database names to track prod_db["my_database1"]=1 prod_db["my_database2"]=1 skip["FREE"]=1 # array of names to skip skip["TBLSPACE"]=1 skip["CHUNK"]=1 skip["DATABASE"]=1 skip["OTHER"]=1 skip["EXT"]=1 skip["ROOT"]=1 page_sz=2048 # set according to your $ONCONFIG PAGESIZE low=.2 # Less than this percent free generates a flag high=.8 # over this percent free generates a flag ext=4 # More than this number of extents generates a flag idx=0 # dbspace index } function fmt(nbr) { return (nbr*page_sz/(1024*1024)) } { if (csw==1) { # This is the actual chunk line chknumber=$1 chknm=$2 cksz=$3 ckusd=$4 ckfree=$5 csw=0 if (chknumber != oldchknumber && oldchknumber != "") { # Lets summarize by chunk/dbspace while we're here idx++ dbsp[idx]=dbspc dbck[idx]=chknm dbsz[idx]=cksz dbus[idx]=ckusd dbfr[idx]=ckfree tsw=0 # if its the same as the last one you printed, dont print it if (olderdbsp != olddbsp) printf("\nDBSpace: %s\n",olddbsp) # Print Chunk info printf("\n Chunk: %-9s Size: %7.2f Used: %7.2f Ckfree: %7.2f PctFree: %3.2f\n", oldchknm, fmt(oldcksz), fmt(oldckusd), fmt(oldckfree), (oldckfree/oldcksz)*100) if (oldckfree/oldckszhigh) {printf("\t\t\t\t\t\t*** OVER %2.0f%% FREE SPACE ***\n",high*100)} # Loop through table array for (i in tb) { if (tb[i] > 0 && substr(tb[i],1,3) != " " && tb[i]!=3) { printf(" %-39s %8.2f Extents %3d", i, fmt(tb[i]), tbct[i]) if (tbct[i] > ext) { printf(" *****\n") } else {printf("\n") } } # Clear it tot+=tb[i] tb[i]=000 tbct[i]=0 } # Add to total gtot+=ckusd tot=0 } # Set up the next one oldchknumber=chknumber oldchknm=chknm oldcksz=cksz oldckusd=ckusd oldckfree=ckfree olderdbsp=olddbsp # last one printed olddbsp=dbspc # current one we are reading } # Must be a table if (tsw==1) { if ( $1 in skip ) { # Ignore these } else { if ($1 == "LOGICAL") { tbnm=sprintf("Logical %s %s %s",$3,$4,$5) } else if ($1 == "PHYSICAL") { tbnm="Physical log" } else { n=split($1,x,":") if (n>1) { if (x[1] in prod_db) { n=split(x[2],y,".") tbnm=sprintf("%s:%s",x[1],x[2]) } # else { tbnm=x[1] } } else { tbnm="" tb[tbnm]=" " } } tb[tbnm]+=substr($0,72) tbct[tbnm]+=1 } } } /DBspace/ { dbspc=$4 } /Chunk/ { csw=1 } /----------------------/ {tsw=1} END { # Print Chunk info printf("\n Chunk: %-9s Size: %7.2f Used: %7.2f Ckfree: %7.2f PctFree: %3.2f\n", oldchknm, fmt(oldcksz), fmt(oldckusd), fmt(oldckfree), (oldckfree/oldcksz)*100) if (oldckfree/oldckszhigh) {printf("\t\t\t\t\t\t*** OVER %2.0f%% FREE SPACE ***\n",high*100)} # Loop through table array for (i in tb) { if (tb[i] > 0 && substr(tb[i],1,3) != " " && tb[i]!=3) { printf(" %-39s %8.2f Extents %3d", i, fmt(tb[i]), tbct[i]) if (tbct[i] > ext) { printf(" *****\n") } else {printf("\n") } } # Clear it tot+=tb[i] tb[i]=000 tbct[i]=0 } # Add to total gtot+=ckusd tot=0 printf("\n\n\nSummary\n\n") printf("DBSpace Chunk Size Used Free\n") # need to skip dbspc if already printed for (i=1;i<=idx;i++) { dbspc=dbsp[i] if (odbspc != dbspc) printf ("%-20s %-20s %7.2f %7.2f %7.2f\n", dbspc, dbck[i], fmt(dbsz[i]), fmt(dbus[i]), fmt(dbfr[i])) else printf ("%-20s %-20s %7.2f %7.2f %7.2f\n", "", dbck[i], fmt(dbsz[i]), fmt(dbus[i]), fmt(dbfr[i])) odbspc=dbspc totsz+=dbsz[i] totus+=dbus[i] totfr+=dbfr[i] } printf(" ------ ------ ------\n") printf ("%-50s %7.2f %7.2f %7.2f\n", "Grand Total Data Space", fmt(totsz), fmt(totus), fmt(totfr)) printf("%-59s %9.2f\n", "Grand Total Disk Used (MB)", fmt(gtot)) }