From d41157029dbc0b5923450c98698dbcb0415bc091 Mon Sep 17 00:00:00 2001 From: hjp Date: Mon, 14 Aug 2006 08:14:42 +0000 Subject: [PATCH] Send mail only if change (only moderately successful). --- quotacheck/quotacheck.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/quotacheck/quotacheck.pl b/quotacheck/quotacheck.pl index e0d4b15..e4d0211 100644 --- a/quotacheck/quotacheck.pl +++ b/quotacheck/quotacheck.pl @@ -3,6 +3,8 @@ use strict; use Getopt::Std; +use Digest::MD5 qw(md5_hex); + my $time=time; my @time=localtime($time); my $hostname; @@ -69,7 +71,15 @@ sub warnmsg { my $comp = -A $timestamp; #print STDERR "comp = $comp\n"; if ($comp > 5) { - sendmail($user, $msg, $mount); + my $msg1 = $msg; + $msg1 =~ s/( noch \d)([.\d]*)( MB )/$1 . "x" x length($2) . $3/e; + my $digest = md5_hex($msg1); + unless (-f "/var/tmp/quotacheck/$digest") { + sendmail($user, $msg, $mount); + mkdir("/var/tmp/quotacheck"); + my $f; + open ($f, ">", "/var/tmp/quotacheck/$digest") && print $f "x"; + } } } }