]>
Commit | Line | Data |
---|---|---|
6231b320 | 1 | #!/afs/athena/contrib/perl/perl |
2 | ||
3 | require "/moira/bin/afs_utils.pl"; | |
08afe93f | 4 | |
5 | # | |
6 | # Nightly reaper - Recompute all usages/allocations. | |
7 | # | |
8 | ||
9 | local ($key, @vos, %used,%alloc,%total, %a); | |
10 | local ($c,$as,$ap,$total,$used,$alloc); | |
11 | ||
12 | &afs_lock; | |
13 | truncate(SRV, 0); | |
14 | ||
15 | if (open(TMP,"/afs/athena/service/afs_data")) { | |
16 | @afs_data = <TMP>; | |
17 | close(TMP); | |
18 | } | |
19 | ||
20 | chop(@afs_data); | |
21 | for (@afs_data) { | |
22 | $as = $ap = 0; | |
23 | if ($_ !~ /^\#/) { | |
24 | ($c,$as,$ap,$t,$total,$used,$alloc) = split(/\s+/,$_); | |
25 | ($as) = gethostbyname($as); | |
26 | $c =~ tr/a-z/A-Z/; | |
27 | $as =~ tr/a-z/A-Z/; | |
28 | $ap =~ s:^([^/]):/vicep\1:; | |
29 | } | |
30 | if (!$as || !$ap) { | |
31 | print SRV "$_\n"; next; | |
32 | } | |
33 | ||
34 | $key = "$c $as $ap"; | |
35 | $total{$key} = $used{$key} = $alloc{$key} = 0; | |
36 | $type{$key} = $t; | |
37 | ||
38 | open(VOS,"$vos partinfo $as $ap -cell $c -noauth|"); | |
39 | chop(@vos = <VOS>); | |
40 | close(VOS); | |
41 | next if ($?); | |
42 | @vos = split(/\s+/,$vos[0]); | |
43 | $total{$key} = pop(@vos); | |
44 | $used{$key} = $total{$key}-$vos[5]; | |
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 | } | |
61 | for $p (keys %a) { $alloc{$key} += $a{$p}; delete $a{$p}; } | |
62 | } | |
63 | ||
64 | for (sort keys %total) { | |
65 | print SRV "$_ $type{$_} $total{$_} $used{$_} $alloc{$_}\n"; | |
66 | delete $type{$_}; | |
67 | delete $total{$_}; | |
68 | delete $used{$_}; | |
69 | delete $alloc{$_}; | |
70 | } | |
71 | ||
72 | &afs_unlock; |