diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 816fcc4244..4d64634349 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -770,3 +770,33 @@ netflowserver 0 # Number of threads for the Pandora FMS Netflow Server (PANDORA FMS ENTERPRISE ONLY). netflowserver_threads 1 +# Enable (1) or disable (0) the Monitoring Anomaly Detection Engine (PANDORA FMS ENTERPRISE ONLY). +madeserver 0 + +# Directory where models will be stored (PANDORA FMS ENTERPRISE ONLY). +madeserver_path /var/spool/pandora/data_in/models + +# Number of server threads for MADE (PANDORA FMS ENTERPRISE ONLY). +madeserver_threads 2 + +# Model backend: 'prophet' or 'iforest' (PANDORA FMS ENTERPRISE ONLY). +# 'prophet' is better suited for temporal series and supports forecasting. +# 'iforest' is faster and more efficient (cpu, memory...). +madeserver_backend prophet + +# MADE will query the Pandora FMS database every madeserver_interval seconds +# to look for new data (PANDORA FMS ENTERPRISE ONLY). +madeserver_interval 60 + +# Minimum number of data required to train a model (e.g., '7d' for seven days) (PANDORA FMS ENTERPRISE ONLY). +madeserver_min_train 7d + +# Maximum number of data kept to train models (e.g., '90d' for 90 days) (PANDORA FMS ENTERPRISE ONLY). +madeserver_max_history 90d + +# Model automatic retraining period (e.g., '7d' for seven days) (PANDORA FMS ENTERPRISE ONLY). +madeserver_autofit 7d + +# Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY). +madeserver_sensitivity 0.1 + diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 86c4c3a4a5..be4c3c7154 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -579,6 +579,8 @@ sub pandora_load_config { $pa_config->{"repl_dbuser"} = undef; # 7.0.770 $pa_config->{"repl_dbpass"} = undef; # 7.0.770 + $pa_config->{"madeserver"} = 0; # 774. + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1387,6 +1389,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^repl_dbpass\s(.*)/i) { $pa_config->{'repl_dbpass'} = clean_blank($1); } + elsif ($parametro =~ m/^madeserver\s+([0-1])/i){ + $pa_config->{'madeserver'}= clean_blank($1); + } } # end of loop for parameter # # The DB host was overridden by pandora_ha. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index e7ac485a1d..b796b651ea 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -317,6 +317,8 @@ our @ServerTypes = qw ( correlationserver ncmserver netflowserver + logserver + madeserver ); our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not execute the alert, but increment its internal counter', 'Cease the alert', 'Recover the alert', 'Reset internal counter'); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 326e4692ad..70164e84dd 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -79,6 +79,8 @@ our @EXPORT = qw( MIGRATIONSERVER NCMSERVER NETFLOWSERVER + LOGSERVER + MADESERVER METACONSOLE_LICENSE OFFLINE_LICENSE DISCOVERY_HOSTDEVICES @@ -201,9 +203,11 @@ use constant SYSLOGSERVER => 18; use constant PROVISIONINGSERVER => 19; use constant MIGRATIONSERVER => 20; use constant ALERTSERVER => 21; -use constant CORRELATIONSERVER => 22; +use constant CORRELATIONSERVER => 22; # Deprecated. use constant NCMSERVER => 23; use constant NETFLOWSERVER => 24; +use constant LOGSERVER => 25; +use constant MADESERVER => 26; # Module status use constant MODULE_NORMAL => 0; @@ -2855,6 +2859,8 @@ sub get_server_name { return "CORRELATIONSERVER" if ($server_type eq CORRELATIONSERVER); return "NCMSERVER" if ($server_type eq NCMSERVER); return "NETFLOWSERVER" if ($server_type eq NETFLOWSERVER); + return "LOGSERVER" if ($server_type eq LOGSERVER); + return "MADESERVER" if ($server_type eq MADESERVER); return "UNKNOWN"; } diff --git a/pandora_server/util/pandora_ha.pl b/pandora_server/util/pandora_ha.pl index 941b6dc854..23bc79189a 100755 --- a/pandora_server/util/pandora_ha.pl +++ b/pandora_server/util/pandora_ha.pl @@ -168,6 +168,7 @@ sub ha_load_pandora_conf($) { $conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'}); $conf->{'tentacle_service_cmd'} = 'service tentacle_serverd' unless defined ($conf->{'tentacle_service_cmd'}); $conf->{'tentacle_service_watchdog'} = 1 unless defined ($conf->{'tentacle_service_watchdog'}); + $conf->{'made_service_cmd'} = 'service pandora_made' unless defined($conf->{'made_service_cmd'}); } ############################################################################## @@ -257,6 +258,31 @@ sub ha_keep_pandora_running($$) { } } +############################################################################## +# Keep MADE running +############################################################################## +sub ha_keep_made_running($$) { + my ($conf, $dbh) = @_; + + # Is MADE enabled? + return unless (defined($conf->{'madeserver'}) && $conf->{'madeserver'} == 1); + + # Is MADE installed? + `$conf->{'made_service_cmd'} status 2>/dev/null`; + if (($? >> 8) == 4) { + log_message($conf, 'LOG', "Pandora FMS MADE is not installed."); + return; + } + + # Try to get the PID of the service. + my $pid = `systemctl show --property MainPID pandora_made | cut -d= -f2`; + chomp($pid); + if ($pid eq "0") { + log_message($conf, 'LOG', 'MADE service not running.'); + `$conf->{'made_service_cmd'} start 2>/dev/null`; + } +} + ############################################################################## # Keep the Tentacle server running ############################################################################## @@ -535,6 +561,9 @@ sub ha_main_pacemaker($) { # Keep Tentacle running ha_keep_tentacle_running($conf, $dbh); + # Keep MADE running + ha_keep_made_running($conf, $dbh); + # Are we the master? pandora_set_master($conf, $dbh); if (!pandora_is_master($conf)) { @@ -627,6 +656,9 @@ sub ha_main_pandora($) { # Keep Tentacle running ha_keep_tentacle_running($conf, $dbh); + # Keep MADE running + ha_keep_made_running($conf, $dbh); + # Are we the master? pandora_set_master($conf, $dbh); if (!pandora_is_master($conf)) {