-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_tape_locations.pl
122 lines (115 loc) · 5.18 KB
/
check_tape_locations.pl
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/perl -w
###########################################################################################################
# SCRIPT: check_tape_locations
###########################################################################################################
# This script is used to determine if the same tapes show up in both jukeboxes
###########################################################################################################
use Time::Local;
open (TAPE_DELETE,">/home/scriptid/scripts/BACKUPS/tape_delete_list.sh") or die "Could not create /home/scriptid/scripts/BACKUPS/tape_delete_list.sh\n";
(@return) = `/usr/sbin/mminfo -a -s sscprodeng -xc, -r \'volume,volretent,location,%used,pool,written\' -q family=tape`;
#volume,expires,location,percent-used,pool,written
# (@return) = `/usr/sbin/mminfo -a -m -s $bserver -q family=tape`;
# mminfo -m very quick and shows all tapes not just those written
# state volume written (%) expires read mounts capacity
# UNN568 2247 GB full 01/13/19 0 KB 6 2540 GB
# UNN569 1533 GB full 01/13/19 0 KB 2 2540 GB
# UNN596 0 KB 0% undef 0 KB 4 2540 GB
# UNN597 0 KB 0% undef 0 KB 4 2540 GB
# UNN598 0 KB 0% undef 0 KB 4 2540 GB
#
print "Found $#return tapes currently managed by Networker on sscprodeng\n";
$now = time;
# Save all mminfo data
foreach $val (@return) {
chomp $val;
next if $val =~ /volume,expires,location,percent-used,pool,written/;
($volume,$expires,$location,$pused,$pool,$written) = split(/,/,$val);
# Expires 09/11/17
$volume =~ s/\(R\)//;
if ($volume =~ /^\s*$/) {
next;
}
$texpired = ' ';
if ($expires =~ /expired/) {
$texpired = 'expired';
} elsif ($expires =~ /undef/) {
$texpired = 'undef';
} elsif ($expires =~ /manual/) {
$texpired = 'manual';
} else {
($m,$d,$y) = split("/",$expires);
# Convert to timelocal format
$m -=1;
$y += 100;
# just use 12:00 midnight on expiration day
# Compute seconds since 1970
$time = timelocal(59,59,23,$d,$m,$y);
$texpired = $time;
}
$volume_1{$volume} = $texpired;
$volume_1_pool{$volume} = $pool;
}
(@return) = `/usr/sbin/mminfo -a -s sscprodeng2 -xc, -r \'volume,volretent,location,%used,pool,written\' -q family=tape`;
#volume,expires,location,percent-used,pool,written
# (@return) = `/usr/sbin/mminfo -a -m -s $bserver -q family=tape`;
# mminfo -m very quick and shows all tapes not just those written
# state volume written (%) expires read mounts capacity
# UNN568 2247 GB full 01/13/19 0 KB 6 2540 GB
# UNN569 1533 GB full 01/13/19 0 KB 2 2540 GB
# UNN596 0 KB 0% undef 0 KB 4 2540 GB
# UNN597 0 KB 0% undef 0 KB 4 2540 GB
# UNN598 0 KB 0% undef 0 KB 4 2540 GB
#
print "Found $#return tapes currently managed by Networker on sscprodeng2\n";
# Save all mminfo data
foreach $val (@return) {
chomp $val;
next if $val =~ /volume,expires,location,percent-used,pool,written/;
my ($volume,$expires,$location,$pused,$pool,$written) = split(/,/,$val);
# Expires 09/11/17
$volume =~ s/\(R\)//;
if ($volume =~ /^\s*$/) {
next;
}
$texpired = ' ';
if ($expires =~ /expired/) {
$texpired = 'expired';
} elsif ($expires =~ /undef/) {
$texpired = 'undef ';
} elsif ($expires =~ /manual/) {
$texpired = 'manual';
} else {
($m,$d,$y) = split("/",$expires);
# Convert to timelocal format
$m -=1;
$y += 100;
# just use 12:00 midnight on expiration day
# Compute seconds since 1970
$time = timelocal(59,59,23,$d,$m,$y);
$texpired = $time;
}
$volume_2{$volume} = $texpired;
if (defined $pool) {
$volume_2_pool{$volume} = $pool;
} else {
print "\tpool not valid for tape $volume\n";
}
}
foreach $val (sort keys %volume_1) {
if (defined $volume_2{$val}) {
print "Tape $val is shown on both servers, $volume_1{$val}, $volume_2{$val}\n";
#print "\tExpiration on 1 is $volume_1{$val}\n";
#print "\tExpiration on 2 is $volume_2{$val}\n";
if ($volume_2{$val} < $now) {
print "\t***Delete tape on sscprodeng2 expired\n";
print TAPE_DELETE "/usr/sbin/nsrmm -s sscprodeng2 -d -y -v $val\n";
} elsif ($volume_2_pool{$val} =~ /NATO/) {
print "\tDelete tape on sscprodeng2 in NATO pool\n";
print TAPE_DELETE "/usr/sbin/nsrmm -s sscprodeng2 -d -y -v $val\n";
} elsif ($volume_2{$val} > $volume_1{$val}) {
print "\tERROR: Newer tape is on sscprodeng2\n";
} else {
print "\tERROR: data on both copies, newer on sscprodeng\n";
}
}
}