从SAN map到vios的一些盘,由于种种原因,有时候并未assign到lpar,也未做其他用途,久之成为无用的盘,耗费
了storage的空间,需要把它们找出来,并删除。
这个是找出它们的脚本
- #! /usr/bin/perl
- my @lsdev_rs = `/usr/ios/cli/ioscli lsdev -type disk | grep -i mpio | awk -F " " '{print \$1}'`;
- my @lspv_rs = `lspv | awk -F " " '{print \$1}'`;
- my @lsmap_rs = `/usr/ios/cli/ioscli lsmap -all | grep -i "backing device" | awk -F " " '{print \$3}' | sed -n '/hdisk/p'`;
- #print @lsmap_rs;
- sub non_intersect{
- #my ($array_ref1, $aray_ref2) = @_;
- my $array_ref1 = shift;
- my $array_ref2 = shift;
- my %all_hash = ();
- my @non_intersec;
- foreach $em ( @$array_ref1, @$array_ref2 ) {
- $all_hash{$em}++;
- }
- foreach $em ( keys %all_hash ) {
- if ($all_hash{$em} == 1){
- push @non_intersec, $em;
- }
- }
- return \@non_intersec;
- }
- my $disklist_ref = non_intersect(\@lsdev_rs, \@lsmap_rs);
- my %disk_uid = ();
- foreach my $em ( @$disklist_ref ) {
- chomp $em;
- my $uid = `lsattr -El $em -a unique_id | awk -F " " '{print \$2}'`;
- $uid = substr( $uid, 5, 32 );
- $disk_uid{$em} = $uid;
- }
- foreach $k ( keys %disk_uid ){
- print "$k:$disk_uid{$k}\n";
- }
结果示例:
# ./detectUselessDisk.pl
hdisk5:600507680280838EC8000000000008E5
hdisk10:600507680280838EC80000000000089D
hdisk8:600507680280838EC80000000000089C
hdisk6:600507680280838EC800000000000899
hdisk3:600507680280838EC800000000000728
hdisk7:600507680280838EC80000000000089B
阅读(1747) | 评论(0) | 转发(0) |