]> andersk Git - moira.git/blame - incremental/afs_nightly.pl
Initial revision
[moira.git] / incremental / afs_nightly.pl
CommitLineData
6231b320 1#!/afs/athena/contrib/perl/perl
2
3require "/moira/bin/afs_utils.pl";
08afe93f 4
5#
6# Nightly reaper - Recompute all usages/allocations.
7#
8
9local ($key, @vos, %used,%alloc,%total, %a);
10local ($c,$as,$ap,$total,$used,$alloc);
11
ea0d6880 12if (open(TMP,"/afs/athena.mit.edu/service/afs_data")) {
e9993d7d 13 @new_data = <TMP>;
08afe93f 14 close(TMP);
15}
16
e9993d7d 17chop(@new_data);
18for (@new_data) {
08afe93f 19 $as = $ap = 0;
20 if ($_ !~ /^\#/) {
e9993d7d 21 ($c,$as,$ap,$type) = split(/\s+/,$_);
08afe93f 22 ($as) = gethostbyname($as);
23 $c =~ tr/a-z/A-Z/;
24 $as =~ tr/a-z/A-Z/;
25 $ap =~ s:^([^/]):/vicep\1:;
26 }
e9993d7d 27 next unless ($as && $ap);
08afe93f 28
e9993d7d 29 &afs_lock;
30 truncate(SRV, 0);
31 for (@afs_data) {
32 ($c2,$as2,$ap2) = split(/\s+/,$_);
33 print SRV $_ unless ($c eq $c2 && $as eq $as2 && $ap eq $ap2);
34 }
35 &afs_unlock;
08afe93f 36
37 open(VOS,"$vos partinfo $as $ap -cell $c -noauth|");
38 chop(@vos = <VOS>);
39 close(VOS);
40 next if ($?);
41 @vos = split(/\s+/,$vos[0]);
e9993d7d 42 $total = pop(@vos);
43 $used = $total-$vos[5];
44 $alloc = 0;
08afe93f 45
46 open(VOS,"$vos listvol $as $ap -cell $c -long -noauth|");
47 @vos = <VOS>;
48 close(VOS);
49 next if ($?);
50
51 while ($_ = shift(@vos)) {
52 next unless /On-line/;
53 local($vn,$id) = split(/\s+/, $_);
54 shift(@vos);
55 local($p,$p,$p) = split(/\s+/, shift(@vos));
56 local($q,$q,$q) = split(/\s+/, shift(@vos));
57 if ($id==$p || !$a{$p}) {
58 $a{$p} = $q;
59 }
60 }
e9993d7d 61 for $p (keys %a) { $alloc += $a{$p}; delete $a{$p}; }
08afe93f 62
e9993d7d 63 &afs_lock;
64 seek(SRV, 0, 2);
65 print SRV "$c $as $ap $type $total $used $alloc\n";
66 &afs_unlock;
08afe93f 67}
This page took 0.125299 seconds and 5 git commands to generate.