Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

FSInfo

by bpoag (Monk)
on Jun 29, 2006 at 17:40 UTC ( [id://558398]=sourcecode: print w/replies, xml ) Need Help??
Category: AIX
Author/Contact Info Bowie J. Poag (bpoag@comcast.net)
Description: FSInfo will dump useful information about the LVM structure of a given filesystem in AIX. It's a simple script that prevents you from having to do the legwork involved in discovering which logical volume and corresponding volume group a given filesystem belongs to.

#!/usr/bin/perl
#
# FSInfo v0.1 written 061306:1135 by BJP
#
# FSInfo will dump useful information about LVM structure of a given f
+ilesystem.
#
# Usage: fsinfo <mountpoint>
# Example: fsinfo /tmp
#

main();

sub usage()
{
  print "\n   Usage: fsinfo <mountpoint>\n";
  print " Example: fsinfo /tmp\n\n";
  exit();
}

sub sanityCheck()
{
  if($#ARGV<0 || $#ARGV>0) ## Hee haw! 
  {
    usage();
  }

  else
  {
    $targetFS=$ARGV[0];
  }

  ## OS level check..

  @unameDump=split(/\s+/,`uname -a`);

  if ($unameDump[3]<5)
  {
    print "fsinfo only works in AIX 5L or later.\n";
    usage();
  }

  ## Check to see if the filesystem actually exists...

  @dfContents=split(/\s+/,`df -m | grep " $targetFS\$"`);

  if(length($targetFS)==length($dfContents[6]))
  {
    print "\nFSInfo: Starting up..\nFSInfo:\n";
  }


  else
  {
    print "\nFSInfo: Ack! Can't find the filesystem you specified ($ta
+rgetFS)..!  Exiting.\n\n";
    exit();
  }
}


sub main()
{
  sanityCheck();

  ## So far so good. Pull up the VG info for this filesystem..

  $dfContents[0]=~/\/dev\//;

  $targetLV=$';

  @lslvContents=split(/\s+/,`lslv $targetLV|head -n1` );

  $targetVG=$lslvContents[5];

  print "FSInfo: Filesystem \"$targetFS\" belongs to logical volume $t
+argetLV which sits inside $targetVG. Details shown below.\n";

  @vgdump=`lsvg -L $targetVG`;
  @lvdump=`lslv -L $targetLV`;

  ## Dump it all out...

  print "FSInfo:\nFSInfo: Volume Group information for $targetFS..\n";
  print "FSInfo:\n";

  foreach $line (@vgdump)
  {
    print "FSInfo: $line";
  }

  print "FSInfo:\nFSInfo: Logical Volume information for $targetFS..\n
+";
  print "FSInfo:\n";

  foreach $line (@lvdump)
  {
    print "FSInfo: $line";
  }

  print "FSInfo:\nFSInfo: Spinning down..\n\n";

}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://558398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2025-11-10 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (66 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.