Looking for script to map storage

Looking for script to map storage

Post by Dennis Pinckar » Fri, 07 May 1999 04:00:00



Has anyone seen a script (perl/ksh) that will map out the storage of an AIX
server?

I currently use a perl script I picked up from the net to generate a text
listing showing VG/PV/LV/FS relationships, but would like to do it
graphically.  Preferably a web-page.

I'd like to be able to go all the way from the adapter to the file system
showing what lives where and how much is unallocated/unused.

Not a very good description.

I'll be happy to post the current script if anyone is interested.

BTW: Are there any great archives of AIX admin specific scripts out there?

TIA

 
 
 

Looking for script to map storage

Post by Bruce Spence » Fri, 07 May 1999 04:00:00


Try "xlvm"

>Has anyone seen a script (perl/ksh) that will map out the storage of an AIX
>server?

>I currently use a perl script I picked up from the net to generate a text
>listing showing VG/PV/LV/FS relationships, but would like to do it
>graphically.  Preferably a web-page.

>I'd like to be able to go all the way from the adapter to the file system
>showing what lives where and how much is unallocated/unused.

>Not a very good description.

>I'll be happy to post the current script if anyone is interested.

>BTW: Are there any great archives of AIX admin specific scripts out there?

>TIA


 
 
 

Looking for script to map storage

Post by Dennis Pinckar » Tue, 11 May 1999 04:00:00


I've had several people ask for the script that I currently use, so here it
is.

I did NOT write this script.  I pulled it from one of the perl archives, but
don't remember where.

xlvm is close to what I'm looking for, but I can't print the entire
configuration.  Again, I don't have it clearly defined in my head what I'm
looking for, but if anyone has anything they use, I'd appreciate hearing
about it.

Thanks for the replies.

==============================================

#! /usr/local/bin/perl
#
#   volinfo - display AIX volume group & logical volume info
#
sub usage { die "\nUsage: $0\n\n$0 - display AIX volume group & logical
volume info\n" }

$Unit = 1e6;   # some may prefer 1024*1024 for megabyte

$host =`hostname`;
chomp($host);
$currenttime = localtime;

print("Volume Info for $host      $currenttime\n\n");

printf("%-24s  %-6s  %-6s    %-30s\n", 'Vg|Lv-----------', 'MBytes',
       'Free--', 'Pv/Mount/Type----------');

open(LsPv, "lspv |") or die("Error: Unable to lspv\n");
while(<LsPv>) {
   chop;
   ($pv, $id, $vg) = split;
   $Pv{$vg} = ($Pv{$vg}) ? "$Pv{$vg},$pv" : $pv;
   }

for $vg(keys(%Pv)) {
   open(LsVg, "lsvg $vg|") or die("Error: Unable to lsvg $vg\n");
   while(<LsVg>) {
      if (/\sPP SIZE:\s*(\d+)\s/) {
  $Sz{$vg} = $1*1024*1024;
  }
      elsif (/\s+TOTAL PPs:\s*(\d+)\s/) {
  $Total{$vg} = $1 * $Sz{$vg};
  $TotalMB += $Total{$vg};
  }
      elsif (/\s+FREE PPs:\s*(\d+)\s/) {
  $Free{$vg} = $1 * $Sz{$vg};
  $TotalFree += $Free{$vg};
  }
      }
   }

open(Df, "df -k 2>/dev/null |") or die("Error: Unable to df\n");
while(<Df>) {
   next unless m|^/|;
   chop;
   ($fs, $total, $free, $pctu, $iused, $pctiu, $mount) = split;
   ($x,$x,$lv) = split(m|/|, $fs);
   $Free{$lv} = $free * 1024;
   $TotalFree += $Free{$lv};
   }

for $vg(keys(%Pv)) {
   open(LsVg, "lsvg -l $vg|") or die("Error: Unable to lsvg -l $vg\n");

   <LsVg>; <LsVg>;
   while(<LsVg>) {
      chop;
      ($lv,$type,$lp,$pp,$pv,$state,$mount) = split;

      $Vg{$lv} = $vg;
      $Mount{$lv} = ($type eq 'jfs') ? $mount : $type;
      $Mb{$lv} = $pp * $Sz{$vg};
      }

   }

for $vg(sort(keys(%Pv))) {
   printf("%-24s  %6.0f  %6.0f    %-30s\n",
          $vg, $Total{$vg}/$Unit, $Free{$vg}/$Unit, "<$Pv{$vg}>");
   for $lv(sort(split(/\s/, $Lvs{$vg}))) {
      printf(" | %-21s  %6.0f  %6.0f    %-30s\n",
             $lv, $Mb{$lv}/$Unit, $Free{$lv}/$Unit, $Mount{$lv});
      }
   printf("%s\n", '_'x79);
   }
printf("%-24s  %6.0f  %6.0f\n", 'Total', $TotalMB/$Unit, $TotalFree/$Unit);