Raid Manager / Vx tool

From: Seth Rothenberg (srothenb@montefiore.org)
Date: Fri Nov 15 2002 - 10:37:35 EST


This is to share a tool I wrote and ask if anyone has other ideas or a similar
tool.
This is a tool I wrote to extract and report the connection between Rm6 and
VxVM
in a concise way - so we can put it on the table and plan our next change.
(Now that it works, I'll try to format the output so volume/diskgroup/lun
sizes all line up)
(I like what I have so far, all on one page, but there is room to get more
info, eg mount points).

The perl script is attached below the output.
The name is vroom - and I can't remember where I got the name from
when I first wrote it 2 years ago. Something with Veritas Raid
Thanks
Seth

./vroom starting...Fri Nov 15 10:23:52 US/Eastern 2002

Running Raidutil -c c2t5d0
Running Raidutil -c c3t4d4
LUN info: (c2t5)d0 10000 MB
LUN info: (c2t5)d1 5000 MB
LUN info: (c2t5)d2 5000 MB
LUN info: (c2t5)d3 10000 MB
LUN info: (c3t4)d4 8597 MB
LUN info: (c3t4)d5 8597 MB
LUN info: (c3t4)d6 8597 MB
LUN info: (c3t4)d7 8597 MB
LUN info: (c2t5)d8 4389 MB
LUN info: (c3t4)d9 4900 MB
LUN info: (c3t4)d10 3690 MB
LUN info: (c2t5)d11 5000 MB
LUN info: (c2t5)d12 3597 MB

DG=rootdg
Volume dg fsgen size 1025 Meg
Volume dg1 fsgen size 2962 Meg
Volume opt fsgen size 1025 Meg
Volume rootvol root size 2045 Meg
Volume scratch_mpa2 fsgen size 4194 Meg
Volume swap2 fsgen size 512 Meg
Volume v_save fsgen size 5242 Meg
Volume var fsgen size 1025 Meg

DG=BATCH
Volume test1 fsgen size 3145 Meg
Volume v_batch fsgen size 3145 Meg

DG=HOME
  LUN 8 c2t5 size 4389 Meg c2t5d8s2
Volume vol01-home fsgen size 4487 Meg

DG=PROD1
  LUN 3 c2t5 size 10000 Meg c2t5d3s2
  LUN 9 c3t4 size 4900 Meg c3t4d9s2
Volume prod1-vol01 fsgen size 15245 Meg

DG=PROD2
  LUN 10 c3t4 size 3690 Meg c3t4d10s2
Volume prod2-vol01 fsgen size 12568 Meg

DG=PROD3
  LUN 11 c2t5 size 5000 Meg c2t5d11s2
Volume prod3-vol01 fsgen size 5112 Meg

=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-=-+-
#!/usr/bin/perl -w
# Note, code is not cleaned up yet. Use at your own risk

require "ctime.pl";

open(STDERR,">&STDOUT") || die "Could not open stderr\n";

$| = 1;

$Date = &ctime(time);
print "\n$0 starting...$Date\n";

open(LAD, "/usr/lib/osa/bin/lad |") || die "Could not lad\n";

while (<LAD>)
{
    @luns = split;

# print "Controller $luns[0]\n";
    push(@controllers, $luns[0]);
}

$maxlun = 0;
foreach $ctrl (@controllers)
{
    print "Running Raidutil -c $ctrl\n";
    $cmd = "/usr/lib/osa/bin/raidutil -c $ctrl | ";
    open(RU, $cmd) || die "Could not $cmd\n";
    while (<RU>)
    {
        next unless /^ LUN/;
        ($junk,$lun, $junk, $junk, $size, $units) = split;
        $lunsize[$lun] = $size;
        $lununit[$lun] = $units;
        $cname[$lun] = $ctrl;
        $cname[$lun] =~ s/d.//;
# print "Controller for $lun = $cname[$lun]\n";
        $vxgroup[$lun] = "";
        $maxlun = $lun if ($lun > $maxlun);
    }
}

for ($lno = 0; $lno <= $maxlun; $lno++)
{
    print "LUN info: ($cname[$lno])d$lno $lunsize[$lno] $lununit[$lno]\n";
    $lunname[$lno] = "$cname[$lno]d${lno}s2";
}

open(VXP, "/usr/sbin/vxprint | ") || die "Could not vxprint\n";
$currentgroup = "";

while (<VXP>)
{
    chop;
    next unless defined($_);
    $type=$len=$tutilo=$state=$ploffs=$kstate=$putil;
    ($type,$name,$assoc,$kstate,$len,$ploffs,$state,$tutilo,$putil) = split;

    if (/^dg/)
    {
        print "\n\n";
        print "DG=$name\n";
        $currentgroup=$name;
    }
    if (/^dm/)
    {
# print " DM = ";
# print "$name...$assoc\n";
        $thislun = $assoc;
        $thislun =~ s/c[0-9]*t[0-9][d]//;
        $thislun =~ s/s[0-9]*//;
        $thisctl = $assoc;
        $thisctl =~ s/d[0-9]*//;
        $thisctl =~ s/s[0-9]*//;
# print "Device $thisctl:$thislun\n";
        if (isanumber($thislun) && ($cname[$thislun] eq $thisctl))
        {
            print " LUN $thislun $cname[$thislun] size $lunsize[$thislun] Meg
$lunname[$thislun]\n";
            $vxgroup[$thislun] = $currentgroup;
# print "Compare lunname = $lunname[$thislun] $thislun vs $assoc\n";
        }
    }

    if (/^sd/)
    {
# print "SUB:$name\n";
# print " Subdisk ";
# print "$name Plex $assoc\n";
        next;
    }
    if (/^v/)
    {
# print "\n";
# print "CURRENT " if ($currentgroup);
        print "Volume ";
        $sizemeg = $len/2000;
        $sizemeg =~ s/\.[0-9]*$//;
        print "$name $assoc size $sizemeg Meg\n";
        next;
    }

    if (/^pl/)
    {
# print "CURRENT " if ($currentgroup);
# print " Plex = ";
# print "$name Volume $assoc\n";
        next;
    }

}
print "\n";

sub isanumber {
# "stolen" from someone named Robert @ http://perlmonks.thepen.com/72343.html

    my $var = $_[0];

    if (
        $var =~ /^([+-]?)(\d+\.|\.\d+|\d+)\d*([Ee]([+-]?\d+))?$/
        ) { return(1) }
    else { return(0) }
}
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:25:17 EDT