]> git.proxmox.com Git - pmg-api.git/commitdiff
filter: skip warning about max_filters on low-memory if manually set
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Feb 2024 14:00:05 +0000 (15:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Feb 2024 14:00:08 +0000 (15:00 +0100)
The get_max_filters method gets called on module load to fill the
default value used, at that stage we cannot know if the admin set
max_filters manually or not, so the warning might be bogus and thus
annoying.

Move it over to the smtp-filter executable's startup code, as there we
can check the config if it's max_filters is set or not.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/Config.pm
src/bin/pmg-smtp-filter

index 061396e4d6da1025c7ca4c5bfde2968f29a5f79b..c9c5ad53d248fe1a6ef513de3a1a6ada5ffdb88e 100644 (file)
@@ -462,8 +462,7 @@ sub get_max_filters {
     my $base;
     my $memory = physical_memory();
     if ($memory < 3840) {
-       warn "low amount of system memory installed, recommended is 4+ GB\n"
-           ."to prevent OOM kills, it is better to set max_filters manually\n";
+       warn "low amount of system memory installed, recommended is 4+ GB\n";
        $base = $memory > 1536 ? 1024 : 512;
     } else {
        $base = 2816;
index 7da3de8708d602c490764214c9bc7d6d317b6bb0..779ac9425f405c3a239cc84d0c42cbde05333a45 100755 (executable)
@@ -96,6 +96,12 @@ if (!$opt_testmode) {
        exit (0);
     }
 
+    my $memory = PMG::Config::Mail::physical_memory();
+    if ($memory < 3840) {
+       warn "total memory below 4 GiB, consider setting 'max_filters' manually to avoid OOM-kills\n"
+           if !defined($pmg_cfg->get('mail', 'max_filters', 1));
+    }
+
     $max_servers = $pmg_cfg->get('mail', 'max_filters') + 2;
     $min_servers = 2;
     $min_spare_servers = 1;