From 20cad3f629c1d2d49697ac124a7842fd1754daa7 Mon Sep 17 00:00:00 2001 From: hjp Date: Fri, 9 Jul 1999 18:06:17 +0000 Subject: [PATCH] Accumulated changes of past half year: configure: Use /usr/bin/bdf if exists quotacheck: round free space to 1 decimal place. quotastat: print to different file each month. --- quotacheck/configure | 3 ++- quotacheck/quotacheck.pl | 3 ++- quotacheck/quotastat.pl | 13 ++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/quotacheck/configure b/quotacheck/configure index 5ec0bd1..2ca8957 100755 --- a/quotacheck/configure +++ b/quotacheck/configure @@ -27,7 +27,7 @@ echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize ################################################################ # find a working df: # -for i in /bin/df /usr/bin/df /usr/sbin/df /usr/local/bin/df +for i in /bin/df /usr/bin/df /usr/bin/bdf /usr/sbin/df /usr/local/bin/df do a=`$i | awk 'NR == 1 {print $2}'` if [ "$a" = "kbytes" -o "$a" = "1024-blocks" ] @@ -51,6 +51,7 @@ then fi echo " -e 's,@@@df@@@,$df,g' \\" >> customize + ################################################################ # find repquota: # We don't try to check whether the output is useful, diff --git a/quotacheck/quotacheck.pl b/quotacheck/quotacheck.pl index d15671b..719c002 100644 --- a/quotacheck/quotacheck.pl +++ b/quotacheck/quotacheck.pl @@ -17,6 +17,7 @@ sub warnmsg { $wo = "$mount (Host $hostname)"; } + my $msg = "Sie haben auf $wo Ihr in Disk Quotas gesetztes Limit\n" . "überschritten. "; @@ -26,7 +27,7 @@ sub warnmsg { $grace =~ s/days/Tage/g; $grace =~ s/hours/Stunden/g; $msg .= "Sie können noch " . - ($hard - $usage) . " $unit anlegen.\n" ; + (int (($hard - $usage) * 10 + 0.5) / 10) . " $unit anlegen.\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" . diff --git a/quotacheck/quotastat.pl b/quotacheck/quotastat.pl index 1f45c82..5a08459 100644 --- a/quotacheck/quotastat.pl +++ b/quotacheck/quotastat.pl @@ -2,7 +2,14 @@ $hostname=`hostname`; chomp($hostname); -$date=`date '+%Y-%m-%dT%H:%M:%S'`; +($sec, $min, $hour, $day, $mon, $year) = localtime(time); +$year += 1900; +$mon += 1; + +$yearmon=sprintf("%4d-%02d", + $year, $mon); +$datetime=sprintf("%4d-%02d-%02dT%02d:%02d:%02d", + $year, $mon, $day, $hour, $min, $sec); chomp($date); open (DF, "@@@df@@@ |") or die "cannot call @@@df@@@: $!"; @@ -15,7 +22,7 @@ $/ = $fs; $df =~ s/\n[ \t]+/ /mg; @df = split(/\n/, $df); -open (STAT, ">>/usr/local/dfstat/quota.stat") or die "cannot append to quota.stat"; +open (STAT, ">>/usr/local/dfstat/quota.stat.$yearmon") or die "cannot append to quota.stat.$yearmon"; for $ln (@df) { ($fs, $total, $used, $free, $pct, $mount) = split(/\s+/, $ln); if ($fs =~ m|^/dev/| and -f "$mount/quotas") { @@ -28,7 +35,7 @@ for $ln (@df) { (\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 STAT "$date\t$mount\t$1\t$2\t$3\t$4\t$6\t$7\t$8\n"; + print STAT "$datetime\t$mount\t$1\t$2\t$3\t$4\t$6\t$7\t$8\n"; } else { print "unparseable: $_"; }