Merged in combined_graph branch (include link to graph in mail)
This commit is contained in:
parent
cadf194099
commit
c831f707f9
|
@ -1,16 +1,22 @@
|
||||||
#!@@@perl@@@
|
#!@@@perl@@@ -w
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
|
my $time=time;
|
||||||
|
my @time=localtime($time);
|
||||||
|
my $hostname;
|
||||||
|
|
||||||
sub warnmsg {
|
sub warnmsg {
|
||||||
my ($mount, $usage, $soft, $hard, $grace, $unit) = @_;
|
my ($mount, $usage, $soft, $hard, $grace, $unit, $user) = @_;
|
||||||
%dosdrv = (
|
my %dosdrv = (
|
||||||
'/wifosv/dosprogs' => 'H:',
|
'/wifosv/dosprogs' => 'H:',
|
||||||
'/wsrdb/users' => 'J:',
|
'/wsrdb/users' => 'J:',
|
||||||
'/wifosv/users' => 'K:',
|
'/wifosv/users' => 'K:',
|
||||||
'/usr/local/www' => 'W:',
|
'/usr/local/www' => 'W:',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $wo;
|
||||||
if ($dosdrv{$mount}) {
|
if ($dosdrv{$mount}) {
|
||||||
$wo = 'Netzplatte ' . $dosdrv{$mount};
|
$wo = 'Netzplatte ' . $dosdrv{$mount};
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +25,7 @@ sub warnmsg {
|
||||||
|
|
||||||
|
|
||||||
my $msg = "Sie haben auf $wo Ihr in Disk Quotas gesetztes Limit\n" .
|
my $msg = "Sie haben auf $wo Ihr in Disk Quotas gesetztes Limit\n" .
|
||||||
"überschritten. ";
|
"überschritten. \n";
|
||||||
|
|
||||||
if ($grace eq "EXPIRED" or $usage >= $hard-2) {
|
if ($grace eq "EXPIRED" or $usage >= $hard-2) {
|
||||||
$msg .= "Sie können dort KEINE Files mehr anlegen.\n" ;
|
$msg .= "Sie können dort KEINE Files mehr anlegen.\n" ;
|
||||||
|
@ -29,10 +35,19 @@ sub warnmsg {
|
||||||
$msg .= "Sie können noch " .
|
$msg .= "Sie können noch " .
|
||||||
(int (($hard - $usage) * 10 + 0.5) / 10) . " $unit anlegen.\n" ;
|
(int (($hard - $usage) * 10 + 0.5) / 10) . " $unit anlegen.\n" ;
|
||||||
}
|
}
|
||||||
|
my $mount_t = $mount;
|
||||||
|
$mount_t =~ s|/|_|g;
|
||||||
|
|
||||||
$msg .= "\nBei dringendem Bedarf können Sie sofort zusätzlichen Platz schaffen,\n" .
|
$msg .= "\nBei dringendem Bedarf können Sie sofort zusätzlichen Platz schaffen,\n" .
|
||||||
"indem Sie auf $wo Files löschen, komprimieren oder auf eine\n" .
|
"indem Sie auf $wo Files löschen, komprimieren oder auf eine\n" .
|
||||||
"andere Netzplatte verschieben.\n" .
|
"andere Netzplatte verschieben.\n" .
|
||||||
"\n" .
|
"\n" .
|
||||||
|
"Sie können sich Ihre Verbrauchsgraphen unter\n" .
|
||||||
|
"http://sww.wsr.ac.at/intranet/quotas/$user$mount_t.gif ansehen. \n" .
|
||||||
|
"Die Quotas die Sie verwendet haben werden rot angezeigt. Außerdem zeigen\n" .
|
||||||
|
"die Softquotas, die Grenze an, die Sie überschritten haben und die Hardquotas\n" .
|
||||||
|
"die Obergrenze, die Sie nicht überschreiten können. \n" .
|
||||||
|
"\n" .
|
||||||
"Lassen Sie sich bei Gelegenheit auch von einem der zuständigen\n" .
|
"Lassen Sie sich bei Gelegenheit auch von einem der zuständigen\n" .
|
||||||
"Systemadministratoren unterstützen:\n" .
|
"Systemadministratoren unterstützen:\n" .
|
||||||
"Peter Holzer, hjp\@wsr.ac.at, Kl. 786\n" .
|
"Peter Holzer, hjp\@wsr.ac.at, Kl. 786\n" .
|
||||||
|
@ -40,61 +55,23 @@ sub warnmsg {
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
getopts('ad', \%opts);
|
my %opts;
|
||||||
|
|
||||||
$hostname=`hostname`;
|
sub sendmail
|
||||||
chomp($hostname);
|
{
|
||||||
open (DF, "@@@df@@@ |") or die "cannot call @@@df@@@: $!";
|
my ($user, $msg, $mount) = @_;
|
||||||
|
|
||||||
$fs = $/;
|
my @startgraph=
|
||||||
undef ($/);
|
("/usr/local/dfstat/quotagraph",
|
||||||
$df = <DF>;
|
"--fs=$mount",
|
||||||
close(DF);
|
"--user=$user",
|
||||||
$/ = $fs;
|
"--data=b",
|
||||||
|
glob("/usr/local/dfstat/quota.stat.????-??")
|
||||||
$df =~ s/\n[ \t]+/ /mg;
|
);
|
||||||
@df = split(/\n/, $df);
|
if (system (@startgraph) != 0) {
|
||||||
for $ln (@df) {
|
die "cannot execute @startgraph";
|
||||||
($fs, $total, $used, $free, $pct, $mount) = split(/\s+/, $ln);
|
|
||||||
if ($fs =~ m|^/dev/|) {
|
|
||||||
open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!";
|
|
||||||
while (<REPQUOTA>) {
|
|
||||||
$msg = "";
|
|
||||||
if (/(\w+) \s+ -- \s*
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)\s+
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)
|
|
||||||
/x) {
|
|
||||||
#print "ok: $1\n";
|
|
||||||
} elsif (/(\w+) \s+ \+- \s*
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)
|
|
||||||
/x) {
|
|
||||||
print "block limit: $1: $2 > ($3 $4) $5\n";
|
|
||||||
$user = $1;
|
|
||||||
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5/1024, "MB");
|
|
||||||
|
|
||||||
} elsif (/(\w+) \s+ -\+ \s*
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)\s+
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
|
||||||
/x) {
|
|
||||||
print "file limit: $1: $5 > ($6 $7) $8\n";
|
|
||||||
$user = $1;
|
|
||||||
$msg = warnmsg($mount, $5, $6, $7, $8, "Files");
|
|
||||||
} elsif (/(\w+) \s+ \+\+ \s*
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
|
||||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
|
||||||
/x) {
|
|
||||||
print "block limit: $1: $2 > ($3 $4) $5\n";
|
|
||||||
$user = $1;
|
|
||||||
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5/1024, "MB");
|
|
||||||
print "file limit: $1: $6 > ($7 $8) $9\n";
|
|
||||||
$msg .= "\n\n" . warnmsg($mount, $6, $7, $8, $9, "Files");
|
|
||||||
} else {
|
|
||||||
if ($. > 2) { # ignore header lines
|
|
||||||
print "$mount: $.: unparseable: $_";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($msg) {
|
|
||||||
if ($opts{'d'}) {
|
if ($opts{'d'}) {
|
||||||
open (SENDMAIL, ">&1");
|
open (SENDMAIL, ">&1");
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,12 +84,93 @@ for $ln (@df) {
|
||||||
print SENDMAIL "To: <$user\@wsr.ac.at>\r\n";
|
print SENDMAIL "To: <$user\@wsr.ac.at>\r\n";
|
||||||
print SENDMAIL "Cc: <system\@wsr.ac.at>\r\n";
|
print SENDMAIL "Cc: <system\@wsr.ac.at>\r\n";
|
||||||
print SENDMAIL "Subject: Disk Quotas überschritten\r\n";
|
print SENDMAIL "Subject: Disk Quotas überschritten\r\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
print SENDMAIL "Reply-To: <system\@wsr.ac.at>\r\n";
|
print SENDMAIL "Reply-To: <system\@wsr.ac.at>\r\n";
|
||||||
print SENDMAIL "\r\n";
|
print SENDMAIL "\r\n";
|
||||||
print SENDMAIL "$msg\r\n";
|
print SENDMAIL "$msg\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getopts('ad', \%opts);
|
||||||
|
|
||||||
|
$hostname=`hostname`;
|
||||||
|
chomp($hostname);
|
||||||
|
open (DF, "@@@df@@@ |") or die "cannot call @@@df@@@: $!";
|
||||||
|
|
||||||
|
my $fs = $/;
|
||||||
|
undef ($/);
|
||||||
|
my $df = <DF>;
|
||||||
|
close(DF);
|
||||||
|
$/ = $fs;
|
||||||
|
|
||||||
|
$df =~ s/\n[ \t]+/ /mg;
|
||||||
|
my @df = split(/\n/, $df);
|
||||||
|
for my $ln (@df) {
|
||||||
|
my ($fs, $total, $used, $free, $pct, $mount) = split(/\s+/, $ln);
|
||||||
|
if ($fs =~ m|^/dev/|) {
|
||||||
|
open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!";
|
||||||
|
while (<REPQUOTA>) {
|
||||||
|
my $msg = "";
|
||||||
|
my $user;
|
||||||
|
if (/(\w+) \s+ -- \s*
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)\s+
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)
|
||||||
|
/x) {
|
||||||
|
#print "ok: $1\n";
|
||||||
|
} elsif (/(\w+) \s+ \+- \s*
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)
|
||||||
|
/x) {
|
||||||
|
print "block limit: $1: $2 > ($3 $4) $5\n";
|
||||||
|
$user = $1;
|
||||||
|
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5, "MB", $user);
|
||||||
|
|
||||||
|
} elsif (/(\w+) \s+ -\+ \s*
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)\s+
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
||||||
|
/x) {
|
||||||
|
print "file limit: $1: $5 > ($6 $7) $8\n";
|
||||||
|
$user = $1;
|
||||||
|
$msg = warnmsg($mount, $5, $6, $7, $8, "Files", $user);
|
||||||
|
} elsif (/(\w+) \s+ \+\+ \s*
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
||||||
|
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
||||||
|
/x) {
|
||||||
|
print "block limit: $1: $2 > ($3 $4) $5\n";
|
||||||
|
$user = $1;
|
||||||
|
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5, "MB", $user);
|
||||||
|
print "file limit: $1: $6 > ($7 $8) $9\n";
|
||||||
|
$msg .= "\n\n" . warnmsg($mount, $6, $7, $8, $9, "Files", $user);
|
||||||
|
} else {
|
||||||
|
if ($. > 2) { # ignore header lines
|
||||||
|
print "$mount: $.: unparseable: $_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($msg) {
|
||||||
|
my $timestamp = "/usr/local/dfstat/quotacheck-timestamps/$user";
|
||||||
|
|
||||||
|
if (!-e $timestamp) {
|
||||||
|
sendmail($user, $msg, $mount);
|
||||||
|
open (PMSG, ">$timestamp")
|
||||||
|
or die "cannot open $timestamp: $!";
|
||||||
|
print PMSG (@time);
|
||||||
|
close (PMSG);
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
my $comp = -A $timestamp;
|
||||||
|
print STDERR "comp = $comp\n";
|
||||||
|
if ($comp > 5)
|
||||||
|
{
|
||||||
|
sendmail($user, $msg, $mount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
my $user;
|
||||||
|
my @deletemsg = ("/usr/local/dfstat/quotacheck-timestamps/$user");
|
||||||
|
unlink (@deletemsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close (REPQUOTA);
|
close (REPQUOTA);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use Time::Local;
|
use Time::Local;
|
||||||
|
@ -8,12 +10,16 @@ GetOptions(\%opts, "fs=s", "data=s", "user=s");
|
||||||
|
|
||||||
my $lastdate = "";
|
my $lastdate = "";
|
||||||
my @data = ();
|
my @data = ();
|
||||||
my $ld;
|
|
||||||
|
|
||||||
print STDERR "fs = ", $opts{"fs"}, "\n";
|
print STDERR "fs = ", $opts{"fs"}, "\n";
|
||||||
print STDERR "user = ", $opts{"user"}, "\n";
|
print STDERR "user = ", $opts{"user"}, "\n";
|
||||||
print STDERR "data = ", $opts{"data"}, "\n";
|
print STDERR "data = ", $opts{"data"}, "\n";
|
||||||
|
|
||||||
|
sub usage {
|
||||||
|
print STDERR "Usage: $0 --fs=<filesystem> --user=<username> --data=[bi]\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
while(<>) {
|
while(<>) {
|
||||||
my ($date, $fs, $user, $bused, $bsoft, $bhard, $iused, $isoft, $ihard) = split(/\t/);
|
my ($date, $fs, $user, $bused, $bsoft, $bhard, $iused, $isoft, $ihard) = split(/\t/);
|
||||||
if (
|
if (
|
||||||
|
@ -22,6 +28,7 @@ while(<>) {
|
||||||
|
|
||||||
) {
|
) {
|
||||||
if ($date ne $lastdate) {
|
if ($date ne $lastdate) {
|
||||||
|
my $time;
|
||||||
if ($date =~ /(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})/) {
|
if ($date =~ /(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})/) {
|
||||||
$time = timelocal($6, $5, $4, $3, $2-1, $1-1900);
|
$time = timelocal($6, $5, $4, $3, $2-1, $1-1900);
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,36 +36,34 @@ while(<>) {
|
||||||
}
|
}
|
||||||
print "$date $time\n";
|
print "$date $time\n";
|
||||||
|
|
||||||
$ld = {};
|
my $ld;
|
||||||
|
if ($opts{data} eq "b") {
|
||||||
|
$ld = [ $bused, $bsoft, $bhard ];
|
||||||
|
} elsif ($opts{data} eq "i") {
|
||||||
|
$ld = [ $iused, $isoft, $ihard ];
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
push(@data, [ $time, $ld ]);
|
push(@data, [ $time, $ld ]);
|
||||||
$lastdate = $date;
|
$lastdate = $date;
|
||||||
}
|
}
|
||||||
$ld->{$user . $fs} = $bused if ($opts{"data"} eq "bused");
|
|
||||||
$ld->{$user . $fs} = $bsoft if ($opts{"data"} eq "bsoft");
|
|
||||||
$ld->{$user . $fs} = $bhard if ($opts{"data"} eq "bhard");
|
|
||||||
$ld->{$user . $fs} = $iused if ($opts{"data"} eq "iused");
|
|
||||||
$ld->{$user . $fs} = $isoft if ($opts{"data"} eq "isoft");
|
|
||||||
$ld->{$user . $fs} = $ihard if ($opts{"data"} eq "ihard");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my @top = (sort { ($ld->{$b} <=> $ld->{$a}) } (keys %$ld))[0..9];
|
|
||||||
|
|
||||||
print "@top\n";
|
|
||||||
open (DATA, ">quotastat.data") or die "cannot open quotastat.data for output: $!";
|
open (DATA, ">quotastat.data") or die "cannot open quotastat.data for output: $!";
|
||||||
for (my $i = 0; $i <= $#data; $i++) {
|
for (my $i = 0; $i <= $#data; $i++) {
|
||||||
my $time = ($data[$i])->[0];
|
my $time = ($data[$i])->[0];
|
||||||
my $data = ($data[$i])->[1];
|
my $data = ($data[$i])->[1];
|
||||||
|
|
||||||
print DATA $time;
|
print DATA $time;
|
||||||
for $j (@top) {
|
for my $j (@$data) {
|
||||||
print DATA "\t", $data->{$j} + 0;
|
print DATA "\t", $j + 0;
|
||||||
}
|
}
|
||||||
print DATA "\n";
|
print DATA "\n";
|
||||||
}
|
}
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
||||||
open (CTL, ">quotastat.ctl") or die "cannot open quotastat.ctl for output: $!";
|
open (CTL, ">quotacheck.ctl") or die "cannot open quotacheck.ctl for output: $!";
|
||||||
|
|
||||||
# generic settings
|
# generic settings
|
||||||
|
|
||||||
|
@ -73,12 +78,13 @@ my $firsttime = ($data[0])->[0];
|
||||||
my $lasttime = ($data[$#data])->[0];
|
my $lasttime = ($data[$#data])->[0];
|
||||||
|
|
||||||
if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||||
$sec = $min = $hour = 0;
|
$sec = $min = $hour = 0;
|
||||||
$mday = 1;
|
$mday = 1;
|
||||||
$firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
$firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||||
print CTL "set xtics rotate (";
|
print CTL "set xtics rotate (";
|
||||||
$comma = 0;
|
my $comma = 0;
|
||||||
|
my $time;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
$time = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
$time = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||||
if ($comma) {
|
if ($comma) {
|
||||||
|
@ -95,14 +101,14 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||||
$lasttime = $time;
|
$lasttime = $time;
|
||||||
print CTL ")\n";
|
print CTL ")\n";
|
||||||
} elsif ($lasttime - $firsttime > 30 * 24 * 3600) {
|
} elsif ($lasttime - $firsttime > 30 * 24 * 3600) {
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||||
$firsttime -= 86400 * $wday;
|
$firsttime -= 86400 * $wday;
|
||||||
|
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||||
$sec = $min = $hour = 0;
|
$sec = $min = $hour = 0;
|
||||||
$time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
my $time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||||
print CTL "set xtics rotate (";
|
print CTL "set xtics rotate (";
|
||||||
$comma = 0;
|
my $comma = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||||
if ($comma) {
|
if ($comma) {
|
||||||
|
@ -115,7 +121,7 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||||
|
|
||||||
$time += 7 * 24 * 3600;
|
$time += 7 * 24 * 3600;
|
||||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||||
$toff = $hour * 3600 + $min * 60 * $sec;
|
my $toff = $hour * 3600 + $min * 60 * $sec;
|
||||||
if ($toff != 0) {
|
if ($toff != 0) {
|
||||||
if ($toff > 12*3600) {
|
if ($toff > 12*3600) {
|
||||||
$toff = 24 * 3600 - $toff;
|
$toff = 24 * 3600 - $toff;
|
||||||
|
@ -132,11 +138,11 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||||
$lasttime = $time;
|
$lasttime = $time;
|
||||||
print CTL ")\n";
|
print CTL ")\n";
|
||||||
} else {
|
} else {
|
||||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||||
$sec = $min = $hour = 0;
|
$sec = $min = $hour = 0;
|
||||||
$time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
my $time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||||
print CTL "set xtics rotate (";
|
print CTL "set xtics rotate (";
|
||||||
$comma = 0;
|
my $comma = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||||
if ($comma) {
|
if ($comma) {
|
||||||
|
@ -149,7 +155,7 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||||
|
|
||||||
$time += 24 * 3600;
|
$time += 24 * 3600;
|
||||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||||
$toff = $hour * 3600 + $min * 60 * $sec;
|
my $toff = $hour * 3600 + $min * 60 * $sec;
|
||||||
if ($toff != 0) {
|
if ($toff != 0) {
|
||||||
if ($toff > 12*3600) {
|
if ($toff > 12*3600) {
|
||||||
$toff = 24 * 3600 - $toff;
|
$toff = 24 * 3600 - $toff;
|
||||||
|
@ -169,28 +175,20 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||||
|
|
||||||
# what to plot
|
# what to plot
|
||||||
|
|
||||||
print CTL "plot ";
|
print CTL qq{plot "quotastat.data" using 1:2 title "used", "quotastat.data" using 1:3 title "soft", "quotastat.data" using 1:4 title "hard"\n};
|
||||||
$comma = 0;
|
|
||||||
$col = 2;
|
|
||||||
|
|
||||||
for $i (@top) {
|
|
||||||
if ($comma) {
|
|
||||||
print CTL ", ";
|
|
||||||
} else {
|
|
||||||
$comma = 1;
|
|
||||||
}
|
|
||||||
print CTL "'quotastat.data' using 1:", $col++, " title '$i'";
|
|
||||||
}
|
|
||||||
|
|
||||||
print CTL "\n";
|
|
||||||
close (CTL);
|
close (CTL);
|
||||||
|
|
||||||
|
|
||||||
my $rc = system("gnuplot", "quotastat.ctl");
|
my $rc = system("gnuplot", "quotacheck.ctl");
|
||||||
print "system returned $rc\n";
|
print "system returned $rc\n";
|
||||||
|
|
||||||
|
my $fs = $opts{fs};
|
||||||
|
$fs =~ s|/|_|g;
|
||||||
|
|
||||||
system("gs -sDEVICE=ppmraw -r150 -dBATCH -sOutputFile=- -q - < quotastat.ps |" .
|
system("gs -sDEVICE=ppmraw -r150 -dBATCH -sOutputFile=- -q - < quotastat.ps |" .
|
||||||
"pnmscale 0.5 |" .
|
"pnmscale 0.5 |" .
|
||||||
"pnmflip -cw |" .
|
"pnmflip -cw |" .
|
||||||
"pnmcrop |" .
|
"pnmcrop |" .
|
||||||
"ppmquant 256 |" .
|
"ppmquant 256 |" .
|
||||||
"ppmtogif > quotastat.gif");
|
"ppmtogif >/usr/local/www/wsr/intranet/quotas/$opts{user}$fs.gif");
|
||||||
|
|
Loading…
Reference in New Issue