From 3808d97c6d25e81a0d0bf6b4a612d158274f3d3b Mon Sep 17 00:00:00 2001 From: hjp Date: Mon, 5 Dec 2005 08:46:40 +0000 Subject: [PATCH] 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. --- quotacheck/GNUmakefile | 5 +++-- quotacheck/do_cron.sh | 11 +++++++++++ quotacheck/quotacheck.pl | 25 ++++--------------------- quotacheck/quotagraph | 9 ++++----- 4 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 quotacheck/do_cron.sh diff --git a/quotacheck/GNUmakefile b/quotacheck/GNUmakefile index 0c94b99..fed026e 100644 --- a/quotacheck/GNUmakefile +++ b/quotacheck/GNUmakefile @@ -4,7 +4,7 @@ CONFDIR=../../configure CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok) -TARGETS = quotacheck quotastat quotasanitycheck quotagraph +TARGETS = quotacheck quotastat quotasanitycheck quotagraph do_cron all: $(TARGETS) clean: @@ -17,7 +17,8 @@ install: $(SBINDIR) $(SBINDIR)/quotacheck $(SBINDIR)/quotastat \ $(SBINDIR)/dfree \ $(SBINDIR)/quotasanitycheck $(MAN8DIR)/quotasanitycheck.8 \ /usr/local/dfstat/ \ - /usr/local/dfstat/quotagraph + /usr/local/dfstat/quotagraph \ + /usr/local/dfstat/do_cron \ %: %.pl customize sh ./customize < $< > $@ diff --git a/quotacheck/do_cron.sh b/quotacheck/do_cron.sh new file mode 100644 index 0000000..a88bd74 --- /dev/null +++ b/quotacheck/do_cron.sh @@ -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 diff --git a/quotacheck/quotacheck.pl b/quotacheck/quotacheck.pl index cc36d6d..64ec21c 100644 --- a/quotacheck/quotacheck.pl +++ b/quotacheck/quotacheck.pl @@ -43,10 +43,10 @@ sub warnmsg { "andere Netzplatte verschieben.\n" . "\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" . "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" . "\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; $mount_t =~ s|/|_|g; 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 () { next unless (/\b\d+\b/); # ignore header lines my ($user, $msg) = parseline($mount, $_); if ($msg) { - 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"); + my $timestamp = "/usr/local/dfstat/quotacheck-timestamps/$user:$mount_t"; if (!-e $timestamp) { sendmail($user, $msg, $mount); @@ -186,14 +172,11 @@ for my $ln (@df) { } else { my $comp = -A $timestamp; - print STDERR "comp = $comp\n"; + #print STDERR "comp = $comp\n"; if ($comp > 5) { sendmail($user, $msg, $mount); } } - } else{ - my @deletemsg = ("/usr/local/dfstat/quotacheck-timestamps/$user$mount_t"); - unlink (@deletemsg); } } close (REPQUOTA); diff --git a/quotacheck/quotagraph b/quotacheck/quotagraph index 255fad2..96ee445 100755 --- a/quotacheck/quotagraph +++ b/quotacheck/quotagraph @@ -11,9 +11,9 @@ GetOptions(\%opts, "fs=s", "data=s", "user=s"); my $lastdate = ""; my @data = (); -print STDERR "fs = ", $opts{"fs"}, "\n"; -print STDERR "user = ", $opts{"user"}, "\n"; -print STDERR "data = ", $opts{"data"}, "\n"; +#print STDERR "fs = ", $opts{"fs"}, "\n"; +#print STDERR "user = ", $opts{"user"}, "\n"; +#print STDERR "data = ", $opts{"data"}, "\n"; sub usage { print STDERR "Usage: $0 --fs= --user= --data=[bi]\n"; @@ -195,5 +195,4 @@ system("gs -sDEVICE=ppmraw -r150 -dBATCH -sOutputFile=- -q - < quotastat.ps |" . "pnmscale 0.5 |" . "pnmflip -cw |" . "pnmcrop |" . - "ppmquant 256 |" . - "ppmtogif >/usr/local/www/wsr/intranet/quotas/$opts{user}$fs.gif"); + "pnmtopng >/usr/local/www/wsr/intranet/quotas/$opts{user}$fs.png");