#!/usr/bin/perl # # FSInfo v0.1 written 061306:1135 by BJP # # FSInfo will dump useful information about LVM structure of a given filesystem. # # Usage: fsinfo # Example: fsinfo /tmp # main(); sub usage() { print "\n Usage: fsinfo \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 ($targetFS)..! 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 $targetLV 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"; }