-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremovePool.pl
More file actions
93 lines (89 loc) · 2.89 KB
/
removePool.pl
File metadata and controls
93 lines (89 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/perl -w
%poolList=(
"Olympus DWH Clone1y",0,
"Olympus DWH Clone7y",0,
"Olympus Monthly DWH",0,
"Olympus DWH Clone2m",0,
"Olympus Weekly DWH",0,
"Olympus Weekly",0,
"Olympus Monthly",0,
"Olympus Clone2m",0,
"Olympus Clone1y",0,
"Olympus Clone7y",0,
"Olympus Yearly",0,
"Olympus Yearly DWH",0,
"Atlantis Monthly",0,
"Atlantis Weekly",0,
"Atlantis Daily",0,
"Atlantis Yearly",0,
"Atlantis Clone1y",0,
"Atlantis Clone2m",0,
"Atlantis Clone2w",0,
"Atlantis Clone7y",0,
"Clone1y",0,
"Clone2m",0,
"Clone7y",0,
"Work Daily",0,
"Work Monthly",0,
"Work Weekly",0,
"work Eternity",0,
"Work Yearly",0,
"Clone2m",0,
);
foreach $pool (keys(%poolList)) {
print "P o o l: $pool\n";
$msg .= "P o o l: $pool\n";
print "================================\n";
$msg .= "==============================\n";
open(MM, "mminfo -s atlas -q 'pool=$pool' -r volume,state 2>/dev/null|") or die "$!\n";
while(<MM>) {
chomp;
next if $_ =~ /volume/;
if ($_ =~ /U0|X/) {
print "$_\n";
$msg .= "$_\n";
if ($_ =~ /E/) {
$poolList{$pool} = 1;
}
else {
$poolList{$pool} = 2;
}
}
}
close MM;
print "P o o l $pool S u m m a r y\n\r";
print "================================\n";
if ($poolList{$pool} == 0) {
print "Pool $pool may be removed from poolList\n";
$msg .= "Pool $pool may be removed from poolList\n";
}
elsif ($poolList{$pool} == 1) {
print "Pool $pool may be removed from poolList, but need to delete all eraseable volumes first\n";
$msg .= "Pool $pool may be removed from poolList, but need to delete all eraseable volumes first\n";
}
elsif ($poolList{$pool} == 2) {
print "Pool $pool is active\n";
$msg .= "Pool $pool is active\n";
}
print "\n\n\n";
$msg .= "\n\n\n";
}
if ($msg) {
&MailError($msg);
} else {
exit 0;
}
sub MailError {
my $message = shift;
my $sendmail = "/usr/lib/sendmail -t";
my $subject = "Check for unused Networker pools";
my @rcpts = qw(doron.dollev@dbs.co.il ori.michaeli@dbs.co.il);
for ($i=0;$i<=$#rcpts;$i++) {
open (SENDMAIL, "|$sendmail");
print SENDMAIL "Subject: $subject\n";
print SENDMAIL "From: doron\@atlantis.dbs.co.il\n";
print SENDMAIL "To: $rcpts[$i]\n\n";
print SENDMAIL "$message\n";
close(SENDMAIL);
}
}