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