]> git.proxmox.com Git - pmg-api.git/blobdiff - src/PMG/Config.pm
config: adjust max_filters calculation to reflect current memory usage
[pmg-api.git] / src / PMG / Config.pm
index 20afd71f901ee9db3f9cadbc9a8867298fbd45dc..061396e4d6da1025c7ca4c5bfde2968f29a5f79b 100644 (file)
@@ -72,7 +72,7 @@ If this is enabled, the receiver statistic are limited to active ones
 statistic will not contain these active receivers.
 EODESC
            type => 'boolean',
-           default => 1,
+           default => 0,
        },
        dailyreport => {
            description => "Send daily reports.",
@@ -177,12 +177,12 @@ sub properties {
        use_bayes => {
            description => "Whether to use the naive-Bayesian-style classifier.",
            type => 'boolean',
-           default => 1,
+           default => 0,
        },
        use_awl => {
            description => "Use the Auto-Whitelist plugin.",
            type => 'boolean',
-           default => 1,
+           default => 0,
        },
        use_razor => {
            description => "Whether to use Razor2, if it is available.",
@@ -459,8 +459,17 @@ sub get_max_filters {
 
     my $max_servers = 5;
     my $servermem = 120;
+    my $base;
     my $memory = physical_memory();
-    my $add_servers = int(($memory - 512)/$servermem);
+    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";
+       $base = $memory > 1536 ? 1024 : 512;
+    } else {
+       $base = 2816;
+       $servermem = 150;
+    }
+    my $add_servers = int(($memory - $base)/$servermem);
     $max_servers += $add_servers if $add_servers > 0;
     $max_servers = 40 if  $max_servers > 40;
 
@@ -939,10 +948,8 @@ sub get_config {
 sub read_pmg_conf {
     my ($filename, $fh) = @_;
 
-    local $/ = undef; # slurp mode
-
     my $raw;
-    $raw = <$fh> if defined($fh);
+    $raw = do { local $/ = undef; <$fh> } if defined($fh);
 
     return  PMG::Config::Base->parse_config($filename, $raw);
 }