Integrate MADE with Pandora FMS.

This commit is contained in:
Ramon Novoa 2023-10-10 11:04:25 +02:00 committed by Ramon Novoa
parent 086835765d
commit 35db83647a
5 changed files with 76 additions and 1 deletions

View File

@ -770,3 +770,33 @@ netflowserver 0
# Number of threads for the Pandora FMS Netflow Server (PANDORA FMS ENTERPRISE ONLY). # Number of threads for the Pandora FMS Netflow Server (PANDORA FMS ENTERPRISE ONLY).
netflowserver_threads 1 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

View File

@ -579,6 +579,8 @@ sub pandora_load_config {
$pa_config->{"repl_dbuser"} = undef; # 7.0.770 $pa_config->{"repl_dbuser"} = undef; # 7.0.770
$pa_config->{"repl_dbpass"} = undef; # 7.0.770 $pa_config->{"repl_dbpass"} = undef; # 7.0.770
$pa_config->{"madeserver"} = 0; # 774.
# Check for UID0 # Check for UID0
if ($pa_config->{"quiet"} != 0){ if ($pa_config->{"quiet"} != 0){
if ($> == 0){ if ($> == 0){
@ -1387,6 +1389,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^repl_dbpass\s(.*)/i) { elsif ($parametro =~ m/^repl_dbpass\s(.*)/i) {
$pa_config->{'repl_dbpass'} = clean_blank($1); $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 # } # end of loop for parameter #
# The DB host was overridden by pandora_ha. # The DB host was overridden by pandora_ha.

View File

@ -317,6 +317,8 @@ our @ServerTypes = qw (
correlationserver correlationserver
ncmserver ncmserver
netflowserver 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'); 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');

View File

@ -79,6 +79,8 @@ our @EXPORT = qw(
MIGRATIONSERVER MIGRATIONSERVER
NCMSERVER NCMSERVER
NETFLOWSERVER NETFLOWSERVER
LOGSERVER
MADESERVER
METACONSOLE_LICENSE METACONSOLE_LICENSE
OFFLINE_LICENSE OFFLINE_LICENSE
DISCOVERY_HOSTDEVICES DISCOVERY_HOSTDEVICES
@ -201,9 +203,11 @@ use constant SYSLOGSERVER => 18;
use constant PROVISIONINGSERVER => 19; use constant PROVISIONINGSERVER => 19;
use constant MIGRATIONSERVER => 20; use constant MIGRATIONSERVER => 20;
use constant ALERTSERVER => 21; use constant ALERTSERVER => 21;
use constant CORRELATIONSERVER => 22; use constant CORRELATIONSERVER => 22; # Deprecated.
use constant NCMSERVER => 23; use constant NCMSERVER => 23;
use constant NETFLOWSERVER => 24; use constant NETFLOWSERVER => 24;
use constant LOGSERVER => 25;
use constant MADESERVER => 26;
# Module status # Module status
use constant MODULE_NORMAL => 0; use constant MODULE_NORMAL => 0;
@ -2855,6 +2859,8 @@ sub get_server_name {
return "CORRELATIONSERVER" if ($server_type eq CORRELATIONSERVER); return "CORRELATIONSERVER" if ($server_type eq CORRELATIONSERVER);
return "NCMSERVER" if ($server_type eq NCMSERVER); return "NCMSERVER" if ($server_type eq NCMSERVER);
return "NETFLOWSERVER" if ($server_type eq NETFLOWSERVER); return "NETFLOWSERVER" if ($server_type eq NETFLOWSERVER);
return "LOGSERVER" if ($server_type eq LOGSERVER);
return "MADESERVER" if ($server_type eq MADESERVER);
return "UNKNOWN"; return "UNKNOWN";
} }

View File

@ -168,6 +168,7 @@ sub ha_load_pandora_conf($) {
$conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'}); $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_cmd'} = 'service tentacle_serverd' unless defined ($conf->{'tentacle_service_cmd'});
$conf->{'tentacle_service_watchdog'} = 1 unless defined ($conf->{'tentacle_service_watchdog'}); $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 # Keep the Tentacle server running
############################################################################## ##############################################################################
@ -535,6 +561,9 @@ sub ha_main_pacemaker($) {
# Keep Tentacle running # Keep Tentacle running
ha_keep_tentacle_running($conf, $dbh); ha_keep_tentacle_running($conf, $dbh);
# Keep MADE running
ha_keep_made_running($conf, $dbh);
# Are we the master? # Are we the master?
pandora_set_master($conf, $dbh); pandora_set_master($conf, $dbh);
if (!pandora_is_master($conf)) { if (!pandora_is_master($conf)) {
@ -627,6 +656,9 @@ sub ha_main_pandora($) {
# Keep Tentacle running # Keep Tentacle running
ha_keep_tentacle_running($conf, $dbh); ha_keep_tentacle_running($conf, $dbh);
# Keep MADE running
ha_keep_made_running($conf, $dbh);
# Are we the master? # Are we the master?
pandora_set_master($conf, $dbh); pandora_set_master($conf, $dbh);
if (!pandora_is_master($conf)) { if (!pandora_is_master($conf)) {