[Orca-users] VXFS fragmentation

Shaw, Richard K richard_k_shaw at groton.pfizer.com
Fri Jan 24 08:47:39 PST 2003


Liston,

Here is a Perl script I wrote to report vxfs fragmentation, you could base
your defragmentation
on the output of a query and run defrag passes until it clears.
One important point we discovered - don't run defrags on Oracle data space.
I don't proclaim to be even a good Perl programmer so minimal flames please.
You could use these commands to generate a defined data set which could then
be graphed.

Regards,
Rich



#!/net/{someserver}/scripts/prod/perl -w
########################################################
#  Check out vxfs directories and filesystems for fragmentation
#  Richard Shaw, Pfizer Inc, CIT Groton UNIX Engineering
# $Id: vxfsck.pl,v 1.1 2002/09/10 15:38:11 shawr Exp shawr $
########################################################
$|=1;

$i=0;
$j1=0;
$OSrev=0;
$buf0="";
$buf1="";
$mailbuf="";

# 0 = filesystem
$FileSystem   = 0;
# 1 = DirsToReduce
$DirsToReduce = 1;
# 2 = Extents free < 64k  : < 5% = Unfragmented : > 50% = Badly Fragmented
$ExtFree64k   = 2;
# 3 = Extents free < 8k   : < 1% = Unfragmented : > 5% = Badly Fragmented
$ExtFree8k    = 3;
# 4 = Extents > 64 blocks : > 5% = Unfragmented : < 5% = Badly Fragmented
$ExtGT64      = 4;
# 5 = Problem flag
$Pflag        = 5;


@vxfs_table = ( [ 0,0,0,0,0,0 ] );

$dumpmail = 1;
$sendmail = 1;

$fsadm = "/usr/lib/fs/vxfs/fsadm";
$OSrev = `uname -r | cut -c1-3`;
$Host  = `uname -n`;


open FILE1, "df -F vxfs -n |";
while ( <FILE1> ) {
	chop;
        ( $mnt[$i],$j1 ) =split /:/;
        $vxfs_table[$i][$FileSystem]=$mnt[$i];
        # print("check: $vxfs_table[$i][0] \n");
	$i++;
}

$j=0;
$i=0;
$k=0;

for $j ( 0 .. $#mnt ) {

 $vxfs_table[$j][$Pflag]=0;

 open FILE2,"$fsadm -D $mnt[$j]|grep total|tr -s '[:space:]'|cut -f 7 -d ' '
|";

  while ( <FILE2> ) {
	chop;
        ( $vxfs_table[$i][$DirsToReduce] ) =split / /;
	$i++
  }

 open FILE3,"$fsadm -E $mnt[$j] |grep % |";

 while ( <FILE3> ) {
	chop;
        ( $j1,$percent[$k] ) =split /:/;
	  if ( $k == 0 ) {

            $vxfs_table[$j][$ExtFree64k]=$percent[$k];

	  } elsif ( $k == 1 ) {

            $vxfs_table[$j][$ExtFree8k]=$percent[$k];

	  } elsif ( $k == 2 ) {

            $vxfs_table[$j][$ExtGT64]=$percent[$k];

          }

	$k++
 }
#print(".");
$k=0;
}

for $k ( 0 .. $#vxfs_table ) {

	for $l ( 1 .. 4 ){
	       $buf0 = "\n$vxfs_table[$k][0]\n";
		    $ntest = ($vxfs_table[$k][$l]);
	   if ($l == 1 ) {
               if ( $ntest > 5 ) {
		    # $DirsToReduce - Need to defrag dirs
                    $dumpmail = 0;
$buf1 = $buf1."Dirs to Reduce:$ntest indicates fragmentation.\n";
$buf1 = $buf1 . "This number should be < 4\n";
               }
	   } elsif ($l == 2 ) {
               if ( $ntest > 5 && $vxfs_table[$k][$l] < 50 ) {
		    # $ExtFree64k - Need to defrag Extents 
                    $dumpmail = 0;
$buf1 = $buf1."% Free blocks in extents smaller than  64 blks: $ntest\n";
$buf1 = $buf1 . "This number should be < 5%\n";
               }
               if ( $ntest >= 50 ) {
		    # $ExtFree64k - Badly fragmented filesystem 
                    $dumpmail = 0;
$buf1 = $buf1."% Free blocks in extents smaller than  64 blks: $ntest\n";
$buf1 = $buf1 . "This number should be < 5%\n";
$buf1 = $buf1 . "This filesystem is badly fragmented:\n";
               }

	   } elsif ($l == 3 ) {
               if ( ($ntest > 1.00 ) && ($ntest < 5.1) ) {
		    # $ExtFree8k - Need to defrag Extents
                    $dumpmail = 0;
$buf1 = $buf1."% Free blocks in extents smaller than 8 blks: $ntest\n";
$buf1 = $buf1 . "This number should be < 1%\n";
               }
               if ( $ntest > 5 ) {
		    # $ExtFree8k - Badly fragmented filesystem
                    $dumpmail = 0;
$buf1 = $buf1."% Free blocks in extents smaller than 8 blks: $ntest\n";
$buf1 = $buf1 . "This number should be < 1%\n";
$buf1 = $buf1 . "This filesystem is badly fragmented:";
               }
	   } elsif ($l == 4 ) {
               if ( $ntest < 5 && $ntest != 0.00 ) {
		    # $ExtGT64 - Badly fragmented filesystem
                    $dumpmail = 0;
$buf1 = $buf1."% blks allocated to extents 64 blks or larger: $ntest\n";
$buf1 = $buf1 . "This number should be > 5%";
$buf1 = $buf1 . "This filesystem is badly fragmented!";
               }

	   } else { # handle an error 
		  }

	}
	if ( $dumpmail == 0 ) {
	     $sendmail = 0;
	     $mailbuf = $mailbuf.$buf0.$buf1."\n";
	     #$print("$mailbuf\n");
	     $dumpmail = 1;
	     $buf0 = "";
	     $buf1 = "";
	} 
}

if ( $sendmail == 0 ) {

  open ( MAIL, "|mailx -ruser\@someplace.com ")
       || die "can't open email program\n";
     print MAIL <<EOM;
     
VXFS Fragmentation Report for: $Host

$mailbuf

Please escalate to UNIX Support @ Low.

Thanks,
{some id)

EOM

}

-----Original Message-----
From: Liston Bias [mailto:bias at pobox.com]
Sent: Thursday, January 23, 2003 5:46 PM
To: orca-users at orcaware.com
Subject: [Orca-users] VXFS fragmentation


We have identified a bug in VXFS 3.4 that is not allowing us to reaname a
file if it happens to exist in directory with fragmented directory inode.
We are working that issue with Veritas... but it got us thinking.

We don't ever run vxfs fsadm on our systems unless problem identified.

In reasearching docs, there is recommendations ranging from daily to
monthly cron of this function on systems.  I know it is I/O intensive to
run these functions, so am looking to "display" the fragmentation that
actually exist to justify runs.

Has anyone taking a shot at graphing fragmentation with orca?

Thanks,
Liston

============================================================================
- Liston Bias                       Love is the only gold.
  Alumnus of Oklahoma State Univ            -- Alfred, Lord Tennyson
  Alumnus of Florida State Univ

  bias at pobox.com
  http://www.pobox.com/~bias
============================================================================

_______________________________________________
Orca-users mailing list
Orca-users at orcaware.com
http://www.orcaware.com/mailman/listinfo/orca-users


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.


More information about the Orca-users mailing list