-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretention.pl
More file actions
49 lines (44 loc) · 1.33 KB
/
retention.pl
File metadata and controls
49 lines (44 loc) · 1.33 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
#!/usr/bin/perl -w
use Date::Calc qw(Delta_Days Add_Delta_Days);
#($today, $thisMonth, $thisYear) = (localtime)[3, 4, 5];
%pools = &getPools("recycle.cfg");
foreach $pool (keys(%pools)) {
$offset = $pools{$pool};
chomp $pool;
@ssid = &getSsid($pool);
foreach (@ssid) {
chomp;
($y1, $m1, $d1) = getDate($_, 'savetime');
($y2, $m2, $d2) = getDate($_, 'ssretent');
chomp($y1, $m1, $d1, $y2, $m2, $d2);
$delta = Delta_Days($y1, $m1, $d1, $y2, $m2, $d2);
($year, $month, $day) = Add_Delta_Days($y1, $m1, $d1, $offset);
if ($delta > $offset) {
print "ssid: $_, ssretent:$m2-$d2-$y2, savetime: $m1-$d1-$y1, delta: $delta, shouldbe: $month-$day-$year\n";
system("/usr/sbin/nsrmm -S $ssid -w $month/$day/$year -e $month/$day/$year");
system("/usr/sbin/mminfo -q \"ssid=$ssid\" -r \"savetime,ssretent,ssbrowse,state,pool\"");
}
}
}
sub getDate {
$ssid = $_[0];
$infoType = $_[1];
$date = `/usr/sbin/mminfo -q \"ssid=$ssid\" -r $infoType | /bin/grep -v $infoType`;
return &splitDays($date);
}
sub splitDays {
$infoType = shift;
($m, $d, $y)=split(/\//, $infoType);
return($y, $m, $d);
}
sub getSsid {
$pool = shift;
return `/usr/sbin/mminfo -q \"pool=$pool\" -r ssid | /bin/grep -v ssid`;
}
sub getPools {
$POOLS=shift;
open(POOLS);
%pools=<POOLS>;
close(POOLS);
return %pools;
}