Removed actual creation of graph from quotacheck.

Graph is now created/updated in a separate job.
Removed some debugging output.
Changed output from gif to png.
This commit is contained in:
hjp 2005-12-05 08:46:40 +00:00
parent 09751207a7
commit 3808d97c6d
4 changed files with 22 additions and 28 deletions

View File

@ -4,7 +4,7 @@ CONFDIR=../../configure
CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok) CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok)
TARGETS = quotacheck quotastat quotasanitycheck quotagraph TARGETS = quotacheck quotastat quotasanitycheck quotagraph do_cron
all: $(TARGETS) all: $(TARGETS)
clean: clean:
@ -17,7 +17,8 @@ install: $(SBINDIR) $(SBINDIR)/quotacheck $(SBINDIR)/quotastat \
$(SBINDIR)/dfree \ $(SBINDIR)/dfree \
$(SBINDIR)/quotasanitycheck $(MAN8DIR)/quotasanitycheck.8 \ $(SBINDIR)/quotasanitycheck $(MAN8DIR)/quotasanitycheck.8 \
/usr/local/dfstat/ \ /usr/local/dfstat/ \
/usr/local/dfstat/quotagraph /usr/local/dfstat/quotagraph \
/usr/local/dfstat/do_cron \
%: %.pl customize %: %.pl customize
sh ./customize < $< > $@ sh ./customize < $< > $@

11
quotacheck/do_cron.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
/usr/local/sbin/quotastat
/usr/local/sbin/quotacheck
find /usr/local/dfstat/quotacheck-timestamps -type f -name '*:*' -print | sed -e 's/.*\///' -e 's/:/ /' |
while read user mount_t
do
mount=`echo $mount_t | sed -e 's/_/\//'`
"/usr/local/dfstat/quotagraph" "--fs=$mount" "--user=$user" "--data=b" /usr/local/dfstat/quota.stat.????-??
@@@scp@@@ /usr/local/www//wsr/intranet/quotas/$user$mount_t.gif "intra.wsr.ac.at:/usr/local/www/intra/informationssysteme/quotas/$user$mount_t.gif"
done

View File

@ -43,10 +43,10 @@ sub warnmsg {
"andere Netzplatte verschieben.\n" . "andere Netzplatte verschieben.\n" .
"\n" . "\n" .
"Sie können sich Ihre Verbrauchsgraphen unter\n" . "Sie können sich Ihre Verbrauchsgraphen unter\n" .
"http://intra.wsr.ac.at/informationssysteme/quotas/$user$mount_t.gif ansehen. \n" . "http://intra.wsr.ac.at/informationssysteme/quotas/$user$mount_t.png ansehen. \n" .
"Der Graph zeigten den verbrauchten Platz ('used') sowie die beiden\n" . "Der Graph zeigten den verbrauchten Platz ('used') sowie die beiden\n" .
"Quotas ('soft' und 'hard')\n" . "Quotas ('soft' und 'hard')\n" .
"Die Softquota können Sie kurzfristig (bis zu einer Woche) überschreiten,\n" . "Die Softquota können Sie kurzfristig (noch $grace) überschreiten,\n" .
"die Hardquota nicht.\n" . "die Hardquota nicht.\n" .
"\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" .
@ -157,25 +157,11 @@ for my $ln (@df) {
my $mount_t = $mount; my $mount_t = $mount;
$mount_t =~ s|/|_|g; $mount_t =~ s|/|_|g;
open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!"; open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!";
my $hpuxtime = '(?:NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))';
my $linuxtime = '(?:none|\d+\:\d+|\d+days)';
while (<REPQUOTA>) { while (<REPQUOTA>) {
next unless (/\b\d+\b/); # ignore header lines next unless (/\b\d+\b/); # ignore header lines
my ($user, $msg) = parseline($mount, $_); my ($user, $msg) = parseline($mount, $_);
if ($msg) { if ($msg) {
my $timestamp = "/usr/local/dfstat/quotacheck-timestamps/$user$mount_t"; my $timestamp = "/usr/local/dfstat/quotacheck-timestamps/$user:$mount_t";
my @startgraph=
("/usr/local/dfstat/quotagraph",
"--fs=$mount",
"--user=$user",
"--data=b",
glob("/usr/local/dfstat/quota.stat.????-??")
);
if (system (@startgraph) != 0) {
die "cannot execute @startgraph";
}
system("@@@scp@@@", "/usr/local/www//wsr/intranet/quotas/$user$mount_t.gif", "intra.wsr.ac.at:/usr/local/www/intra/informationssysteme/quotas/$user$mount_t.gif");
if (!-e $timestamp) { if (!-e $timestamp) {
sendmail($user, $msg, $mount); sendmail($user, $msg, $mount);
@ -186,14 +172,11 @@ for my $ln (@df) {
} else { } else {
my $comp = -A $timestamp; my $comp = -A $timestamp;
print STDERR "comp = $comp\n"; #print STDERR "comp = $comp\n";
if ($comp > 5) { if ($comp > 5) {
sendmail($user, $msg, $mount); sendmail($user, $msg, $mount);
} }
} }
} else{
my @deletemsg = ("/usr/local/dfstat/quotacheck-timestamps/$user$mount_t");
unlink (@deletemsg);
} }
} }
close (REPQUOTA); close (REPQUOTA);

View File

@ -11,9 +11,9 @@ GetOptions(\%opts, "fs=s", "data=s", "user=s");
my $lastdate = ""; my $lastdate = "";
my @data = (); my @data = ();
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 { sub usage {
print STDERR "Usage: $0 --fs=<filesystem> --user=<username> --data=[bi]\n"; print STDERR "Usage: $0 --fs=<filesystem> --user=<username> --data=[bi]\n";
@ -195,5 +195,4 @@ system("gs -sDEVICE=ppmraw -r150 -dBATCH -sOutputFile=- -q - < quotastat.ps |" .
"pnmscale 0.5 |" . "pnmscale 0.5 |" .
"pnmflip -cw |" . "pnmflip -cw |" .
"pnmcrop |" . "pnmcrop |" .
"ppmquant 256 |" . "pnmtopng >/usr/local/www/wsr/intranet/quotas/$opts{user}$fs.png");
"ppmtogif >/usr/local/www/wsr/intranet/quotas/$opts{user}$fs.gif");