]> andersk Git - moira.git/blame - incremental/afs/afs_quota.pl
No old scary perl interpreter.
[moira.git] / incremental / afs / afs_quota.pl
CommitLineData
601b067e 1#!/usr/athena/bin/perl
6231b320 2# Usage: afs_quota path quota
3
e2666aac 4require "/moira/bin/afs_utils.pl";
6231b320 5
6die "Usage: $0 path quota\n" unless (@ARGV==2);
7
8($path,$newq) = @ARGV;
9$path =~ s:^/afs/([^.]):/afs/.\1:;
10
11system("$fs checkb >/dev/null");
12
13open(PROG,"$fs lv $path|");
14chop(@fs=<PROG>);
15close(PROG);
16die "Unable to get information about $path\n" if ($?);
17
601b067e 18shift(@fs);
6231b320 19@tmp = split(/\s+/, shift(@fs));
20$vname = pop(@tmp);
21@tmp = split(/\s+/, shift(@fs));
22$oldq = pop(@tmp);
601b067e 23print "$vname $oldq $newq\n";
6231b320 24
25open(PROG,"$fs whichcell $path|");
26chop($_=<PROG>);
27close(PROG);
28die "Unable to get information about $path\n" if ($?);
29
30@tmp=split(/\s+/,$_);
31($cell=pop(@tmp)) =~ s/^'(.*)'$/\1/;
32$cell =~ tr/a-z/A-Z/;
33
34open(PROG,"$vos ex $vname -cell $cell|");
35chop(@tmp=<PROG>);
36close(PROG);
37die "Unable to get volume information about $vname ($path)\n" if ($?);
38
564ed5a8 39$_ = shift(@tmp);
40($vusage, $vusage, $vusage, $vusage) = split(/\s+/,$_);
41$_ = shift(@tmp);
6231b320 42($asrv,$asrv,$apart) = split(/\s+/,$_);
43
564ed5a8 44open(PROG,"$vos partinfo $asrv $apart -cell $cell|");
45chop($_ = <PROG>);
46close(PROG);
47die "Unable to get partition information about $asrv $apart\n" if ($?);
48
49@tmp = split(/\s+/,$_);
50$dtotal = $tmp[11];
51$dusage = $dtotal - $tmp[5];
52
6231b320 53system("$fs","sq",$path,$newq);
54die "Unable to change quota on $path\n" if ($?);
39e0b5bb 55
9205b505 56&afs_quota_adj($cell,$asrv,$apart,$newq-$oldq,$dusage);
119f209e 57
564ed5a8 58if ($dusage > (0.9 * $dtotal)) {
7a4e84fa 59 system("$zwrite","-q","-n","-c","afsadm","-i","moira","-m",
564ed5a8 60 "WARNING: Disk usage on $asrv:$apart is greater than 90%
61Used $dusage K out of $dtotal K");
62}
63elsif (($dusage + ($newq-$vusage)) > (0.9 * $dtotal)) {
7a4e84fa 64 system("$zwrite","-q","-n","-c","afsadm","-i","moira","-m",
564ed5a8 65 "Quota change on volume $vname, if used completely will cause
66$asrv:$apart to be over 90% used.
67
68Current volume usage: $vusage, old quota $oldq, new quota $newq");
69}
b818680b 70elsif ($newq-$oldq > 3999999) {
7a4e84fa 71 system("$zwrite","-q","-n","-c","afsadm","-i","moira","-m",
564ed5a8 72 "Increased quota on volume $vname ($asrv:$apart) from $oldq to $newq");
73}
This page took 0.095644 seconds and 5 git commands to generate.