From e430daf4a724445f16e583a69c27bfb454d71f5e Mon Sep 17 00:00:00 2001 From: Stephan Kleber Date: Sat, 14 Sep 2024 14:37:44 +0200 Subject: [PATCH] fix division by zero error on empty cache data. Change category to match amavis_multi. --- plugins/amavis/amavis_ | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/amavis/amavis_ b/plugins/amavis/amavis_ index 2287f4a4..d095a97f 100755 --- a/plugins/amavis/amavis_ +++ b/plugins/amavis/amavis_ @@ -68,7 +68,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") { if ($stats_type eq "cache") { print "graph_title Amavis cache hit / miss ratio\n"; print "graph_args --lower-limit 0 --upper-limit 100 --rigid\n"; - print "graph_category antivirus\n"; + print "graph_category spamfilter\n"; print "graph_info The ratio of cache hits and misses for AMaViSd-new.\n"; print "graph_order hits misses\n"; print "graph_scale no\n"; @@ -83,7 +83,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") { print "misses.min 0\n"; } elsif ($stats_type eq "content") { print "graph_title Amavis scanned mails\n"; - print "graph_category antivirus\n"; + print "graph_category spamfilter\n"; print "graph_period minute\n"; print "graph_vlabel msgs / \${graph_period}\n"; foreach my $type (qw(total clean spam spammy virus)) { @@ -99,7 +99,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") { } elsif ($stats_type eq "time") { print "graph_title Amavis average scan time\n"; print "graph_info Average time spent in each phase of the mail scanning process, per mail.\n"; - print "graph_category antivirus\n"; + print "graph_category spamfilter\n"; print "graph_vlabel sec / mail\n"; print "graph_scale no\n"; @@ -163,9 +163,12 @@ for my $k (sort keys %values) { if ($stats_type eq "cache") { my $hits = $values{'CacheHits'}; my $misses = $values{'CacheMisses'}; - my $misses_ratio = $misses * 100.00 / ($hits + $misses); - my $hits_ratio = $hits * 100.00 / ($hits + $misses); - + my $misses_ratio = 0; + my $hits_ratio = 0; + if ($hits + $misses > 0) { + $misses_ratio = $misses * 100.00 / ($hits + $misses); + $hits_ratio = $hits * 100.00 / ($hits + $misses); + } printf("hits.value %.1f\n", $hits_ratio); printf("misses.value %.1f\n", $misses_ratio); } elsif ($stats_type eq "content") {