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