Here we have two VGs, vg00 and vg01: first with 9 LVs and second with 4. One caveat, HP-UX does not support the -F mode in versions previous to 11.31 so a different approach has to be taken. At least in versions 11.11 and 11.23 I have tried. And second, I use dd if=/dev/zero of=dummy bs=1024k count=2*PE to create the file, which perhaps one might want to do it other way. One last thing to add is that the program is not checking for the free available space in advance, it just goes and creates the file whenever it can so perhaps some filesystems may become full. The Perl code follows. It does not contain comments, I apologize in advance.vg_name=/dev/vg00:vg_write_access=read,write:vg_status=available:max_l +v=255:cur_lv=9:open_lv=9:max_pv=16:cur_pv=1:act_pv=1:max_pe_per_pv=29 +53:vgda=2:pe_size=16:total_pe=2055:alloc_pe=1984:free_pe=71:total_pvg +=0:total_spare_pvs=0:total_spare_pvs_in_use=0:vg_version=1.0.0 lv_name=/dev/vg00/lvol1:lv_status=available,syncd:lv_size=1024:current +_le=64:allocated_pe=64:used_pv=1 lv_name=/dev/vg00/lvol2:lv_status=available,syncd:lv_size=4096:current +_le=256:allocated_pe=256:used_pv=1 lv_name=/dev/vg00/lvol3:lv_status=available,syncd:lv_size=1024:current +_le=64:allocated_pe=64:used_pv=1 lv_name=/dev/vg00/lvol4:lv_status=available,syncd:lv_size=1024:current +_le=64:allocated_pe=64:used_pv=1 lv_name=/dev/vg00/lvol5:lv_status=available,syncd:lv_size=2048:current +_le=128:allocated_pe=128:used_pv=1 lv_name=/dev/vg00/lvol6:lv_status=available,syncd:lv_size=8192:current +_le=512:allocated_pe=512:used_pv=1 lv_name=/dev/vg00/lvol7:lv_status=available,syncd:lv_size=4096:current +_le=256:allocated_pe=256:used_pv=1 lv_name=/dev/vg00/lvol8:lv_status=available,syncd:lv_size=8192:current +_le=512:allocated_pe=512:used_pv=1 lv_name=/dev/vg00/lvol9:lv_status=available,syncd:lv_size=2048:current +_le=128:allocated_pe=128:used_pv=1 pv_name=/dev/disk/disk2_p2:pv_status=available:total_pe=2055:free_pe=7 +1:autoswitch=On:proactive_polling=On pv_name=/dev/disk/disk2_p3:pv_status=available:total_pe=2055:free_pe=7 +1:autoswitch=On:proactive_polling=On pv_name=/dev/disk/disk2_p4:pv_status=available:total_pe=2055:free_pe=7 +1:autoswitch=On:proactive_polling=On vg_name=/dev/vg01:vg_write_access=read,write:vg_status=available:max_l +v=255:cur_lv=4:open_lv=4:max_pv=16:cur_pv=1:act_pv=1:max_pe_per_pv=43 +51:vgda=2:pe_size=4:total_pe=4351:alloc_pe=2646:free_pe=1705:total_pv +g=0:total_spare_pvs=0:total_spare_pvs_in_use=0:vg_version=1.0.0 lv_name=/dev/vg01/lvol1:lv_status=available,syncd:lv_size=7000:current +_le=1750:allocated_pe=1750:used_pv=1 lv_name=/dev/vg01/lvol2:lv_status=available,syncd:lv_size=512:current_ +le=128:allocated_pe=128:used_pv=1 lv_name=/dev/vg01/lvol3:lv_status=available,syncd:lv_size=2048:current +_le=512:allocated_pe=512:used_pv=1 lv_name=/dev/vg01/lvol4:lv_status=available,syncd:lv_size=1024:current +_le=256:allocated_pe=256:used_pv=1 pv_name=/dev/dsk/c0t1d0:pv_status=available:total_pe=4351:free_pe=1705 +:autoswitch=On:proactive_polling=On
#!/usr/bin/env perl $FILE="/etc/mnttab"; open FILE or die "Can't open $FILE: $!"; while (<FILE>) { chomp; ($lv, $fs) = split; push @mnttab, ($lv, $fs) } %mnttab = @mnttab; open(LVM, "vgdisplay -Fv |") || die "Can't fork vgdisplay: $!"; while (<LVM>) { chomp; $h_ref = {}; %{ $h_ref } = split(/[=:]/); if ( $h_ref->{vg_name} && $a_ref->[0]->{vg_name} ) { push @vgdisplay, $a_ref; $a_ref = () } delete $a_ref->[0] unless ( %{ $a_ref->[0] } ); push @{ $a_ref }, $h_ref } push @vgdisplay, $a_ref if ref($a_ref); for $i ( @vgdisplay ) { print "Detected VG: $i->[0]->{vg_name}\n"; print "The PE size is: $i->[0]->{pe_size}\n"; $count = 2*$i->[0]->{pe_size}; for ( $j = 1; $i->[$j]->{lv_name}; $j++ ) { next unless defined $mnttab{$i->[$j]->{lv_name}}; print "Detected LV: $i->[$j]->{lv_name}\t"; print "The LV is mounted on: $mnttab{$i->[$j]->{lv_nam +e}}\n"; print "Changing directory to the $mnttab{$i->[$j]->{lv +_name}}/lost+found\n"; chdir "$mnttab{$i->[$j]->{lv_name}}/lost+found" or war +n "Can't cd to $mnttab{$i->[$j]->{lv_name}}/lost+found: $!\n" and nex +t; print "Creating the dummy file: dummy\n"; !system "dd if=/dev/zero of=dummy bs=1024k count=$coun +t" or warn "Can't dd to file dummy\n"; } # for ( ; $i->[$j]->{pv_name}; $j++ ) { # print "Detected PV: $i->[$j]->{pv_name}\n"; # } print "########################################\n"; } close(LVM) || die "Can't close vgdisplay: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HP-UX best practices
by toolic (Bishop) on May 24, 2012 at 15:04 UTC | |
by rustic (Monk) on May 25, 2012 at 07:18 UTC |