diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index aa8208f5d0..67e603b225 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -54,7 +54,6 @@ if (!$@) { use constant AGENT_VERSION => '4.0.1'; use constant AGENT_BUILD => '111213'; - # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { linux => 'cat /proc/meminfo | grep MemTotal: | awk \'{ print $2 }\'', @@ -117,7 +116,6 @@ my $ConfDir = ''; # Pandora FMS agent configuration file my $ConfFile = 'pandora_agent.conf'; - # Broker agent configuration files my @BrokerPid; @@ -264,7 +262,6 @@ sub valid_regexp ($) { sub rmrf { my $path = shift; local *DIR; - if (-d $path) { opendir (DIR, $path) || return; while (defined (my $file_name = readdir(DIR))) { @@ -348,7 +345,6 @@ sub log_message ($$;$) { } } } - ################################################################################ # Add the given directory to the PATH. ################################################################################ @@ -582,7 +578,6 @@ sub write_broker_conf($){ } while (my $line = ){ - # Skip broker definitions if ($line =~ m/^\s*broker_agent/) { next; @@ -1810,7 +1805,6 @@ sub exec_plugin ($) { $Sem->down () if (defined ($Sem)); $Xml .= $output; $Sem->up () if (defined ($Sem)); - $ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1); } @@ -2287,4 +2281,4 @@ This is released under the GNU Lesser General Public License. Copyright (c) 2005-2023 Pandora FMS -=cut +=cut \ No newline at end of file diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 6d673eaefa..a70887de92 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.773.3-231026 +Version: 7.0NG.773.3-231031 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 716132f5a2..93fe95d24c 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.773.3-231026" +pandora_version="7.0NG.773.3-231031" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 179f98dac8..2e1186ff6a 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -316,3 +316,12 @@ module_plugin autodiscover --default #module_plugin /usr/share/pandora_agent/plugins/pandora_sca -t 150 #module_absoluteinterval 7d #module_end + +# Logs extraction +#module_begin +#module_name Syslog +#module_description Logs extraction module +#module_type log +#module_regexp /var/log/logfile.log +#module_pattern .* +#module_end \ No newline at end of file diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 46eed564d4..49599efa4d 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -39,6 +39,14 @@ BEGIN { use File::Copy; use Scalar::Util qw(looks_like_number); + use File::Basename; + + BEGIN { + eval { + require MIME::Base64; + }; + } + BEGIN { push @INC, '/usr/lib/perl5'; } ################################################################################ @@ -1031,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.773.3'; -use constant AGENT_BUILD => '231026'; +use constant AGENT_BUILD => '231031'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -1562,6 +1570,9 @@ sub parse_conf_modules($) { } elsif ($line =~ /^\s*module_occupiedpercentdisk\s+(.*)$/) { $module->{'func'} = \&module_occupiedpercentdisk; $module->{'params'} = $1; + }elsif ($line =~ /^\s*module_regexp\s+(.*)$/) { + $module->{'func'} = \&module_logger; + $module->{'params'} = $1; } elsif ($line =~ /^\s*module_max\s+(.*)\s*$/) { $module->{'max'} = $1; } elsif ($line =~ /^\s*module_min\s+(.*)\s*$/) { @@ -1817,7 +1828,11 @@ sub parse_conf_modules($) { # Macros } elsif ($line =~ /^\s*module_macro(\S+)\s+(.*)\s*$/) { $module->{'macros'}{$1} = $2; + # Regexp } + elsif ($line =~ /^\s*module_pattern(\S+)\s+(.*)\s*$/) { + $module->{'filter'} = $1; + } } return; } @@ -3663,6 +3678,11 @@ sub write_module_xml ($@) { return; } + if ($module->{'func'} == \&module_logger) { + $Xml .= $data[0]; + return + } + # Critical section $Sem->down () if (defined ($Sem)); @@ -3860,6 +3880,237 @@ sub module_plugin ($) { return ($output); } +################################################################################ +# Read the logs +################################################################################ +sub module_logger ($) { + my $module = shift; + + my $status = grep_logs( + $module->{'name'}, + $module->{'params'}, + $module->{'filter'} + ); + + return $status; +} + +my $encode_sub = defined(&MIME::Base64::encode_base64) ? \&MIME::Base64::encode_base64 : sub { + my ($str, $endl) = @_; + + my @ALPHABET = ('A'..'Z', 'a'..'z', 0..9, '+', '/'); + my $str_len = length($str); + my $str_base64 = ''; + + for (my $i = 0; $i < $str_len; $i += 3) { + my $chunk = substr($str, $i, 3); + my $chunk_len = length($chunk); + + my $num = 0; + $num |= ord(substr($chunk, 0, 1)) << 16 if ($chunk_len >= 1); + $num |= ord(substr($chunk, 1, 1)) << 8 if ($chunk_len >= 2); + $num |= ord(substr($chunk, 2, 1)) if ($chunk_len == 3); + + my $enc_1 = ($num & 0xfc0000) >> 18; + my $enc_2 = ($num & 0x03f000) >> 12; + my $enc_3 = ($num & 0x000fc0) >> 6; + my $enc_4 = ($num & 0x00003f); + + $str_base64 .= $ALPHABET[$enc_1]; + $str_base64 .= $ALPHABET[$enc_2]; + $str_base64 .= $chunk_len >= 2 ? $ALPHABET[$enc_3] : '='; + $str_base64 .= $chunk_len == 3 ? $ALPHABET[$enc_4] : '='; + } + + return $str_base64; +}; + +sub grep_logs { + my ($str_name, $str_file, $str_regex) = @_; + + if(!$str_name){ + log_message("module_logger", "Missing module name"); + return; + } + + if(!$str_file){ + log_message("module_logger", "Missing file name"); + return; + } + + if(!$str_regex){ + $str_regex = '.*'; + } + + my $idx_dir = '/tmp/'; + my $idx_file = ''; + my $idx_pos = 0; + my $idx_size = 0; + my $idx_ino = ''; + my $module_name = $str_name; + my $log_file = $str_file; + my $reg_exp = $str_regex; + + # Check that log file exists + if (! -e $log_file) { + log_message("module_logger", "File $log_file does not exist"); + return; + } + + # Create index file storage directory + if (! -d $idx_dir) { + if (!mkdir($idx_dir)){ + log_message("module_logger", "Error creating directory $idx_dir: " . $!); + return; + } + } + + # Create index file if it does not exist + $idx_file = $idx_dir.$module_name."_".basename($log_file).".idx"; + if (! -e $idx_file) { + return if create_idx(\$idx_pos, \$idx_ino, \$idx_file, \$log_file, \$idx_size) == 1; + return + } else{ + + return if load_idx(\$idx_pos, \$idx_ino, \$idx_file, \$idx_size) == 1; + my @data = parse_log(\$idx_pos, \$idx_ino, \$idx_file, \$log_file, \$module_name, \$reg_exp, \$idx_size); + + my $output = create_log($module_name, @data); + + return $output; + } + + # Start the function definition + + sub create_idx { + my ($idx_pos_ref, $idx_ino_ref, $idx_file_ref, $log_file_ref, $idx_size_ref) = @_; + my $first_line; + + log_message("module_logger", "Creating index file $$idx_file_ref"); + + if (!open(LOGFILE, $$log_file_ref)){ + log_message("module_logger", "Error opening file $$log_file_ref: ".$!); + return 1; + } + + # Go to EOF and save the position + seek(LOGFILE, 0, 2); + $$idx_pos_ref = tell(LOGFILE); + + close(LOGFILE); + + # Save the file inode number + $$idx_ino_ref = (stat($$log_file_ref))[1]; + + return 1 if save_idx($idx_pos_ref, $idx_ino_ref, $idx_file_ref, $idx_size_ref) == 1; + + return 0; + } + + sub save_idx { + my ($idx_pos_ref, $idx_ino_ref, $idx_file_ref, $idx_size_ref) = @_; + + log_message("module_logger", "Saving index file $$idx_file_ref"); + + if (!open(IDXFILE, "> $$idx_file_ref")){ + log_message("module_logger", "Error opening file $$idx_file_ref: ". $!); + return 1; + } + + print (IDXFILE $$idx_pos_ref . " " . $$idx_ino_ref . " " . $$idx_size_ref); + close(IDXFILE); + + return 0; + } + + sub load_idx { + my ($idx_pos_ref, $idx_ino_ref, $idx_file_ref, $idx_size_ref) = @_; + my $line; + my $current_ino; + my $current_size; + + log_message("module_logger", "Loading index file $$idx_file_ref"); + + if (!open(IDXFILE, $$idx_file_ref)){ + log_message("module_logger", "Error opening file $$idx_file_ref: " .$!); + return 1; + } + + # Read position and date + $line = ; + ($$idx_pos_ref, $$idx_ino_ref, $$idx_size_ref) = split(' ', $line); + + close(IDXFILE); + + # Reset the file index if the file has changed + $current_ino = (stat($$idx_file_ref))[1]; + $current_size = -s "$$idx_file_ref"; + if ($current_ino != $$idx_ino_ref || $current_size < $$idx_size_ref) { + log_message("module_logger", "File changed, resetting index"); + + $$idx_pos_ref = 0; + $$idx_ino_ref = $current_ino; + } + $$idx_size_ref = $current_size; + + return 0; + } + + sub parse_log { + my ($idx_pos_ref, $idx_ino_ref, $idx_file_ref, $log_file_ref, $module_name_ref, $reg_exp_ref, $idx_size_ref) = @_; + + my $line; + + log_message("module_logger", "Parsing log file $$log_file_ref"); + + # Open log file for reading + if (!open(LOGFILE, $$log_file_ref)){ + log_message("module_logger", "Error opening file $$log_file_ref: " . $!); + return 1; + } + + # Go to starting position. + seek(LOGFILE, $$idx_pos_ref, 0); + + # Parse log file + my @data; + while ($line = ) { + if ($line =~ m/$$reg_exp_ref/i) { + push (@data, $line); + } + } + + $$idx_pos_ref = tell(LOGFILE); + close(LOGFILE); + + # Save the index file + return 1 if save_idx($idx_pos_ref, $idx_ino_ref, $idx_file_ref, $idx_size_ref) == 1; + + return @data; + } + + sub create_log($$){ + my ($module_name, @data) = @_; + + # No data + if ($#data < 0) { + return; + } + + # Log module + my $output = "\n"; + $output .= "\n"; + $output .= "base64\n"; + $output .= "\n"; + $output .= "\n"; + + return $output; + } + +} + ################################################################################ # TERM Handler ################################################################################ @@ -4030,6 +4281,7 @@ sub init_module ($) { $module->{'module_ff_interval'} = undef; $module->{'macros'} = {}; $module->{'alert_template'} = undef; + $module->{'filter'} = undef; } ################################################################################ diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 536059c848..9c81eadedd 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.773.3 -%define release 231026 +%define release 231031 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index 400ddccc6a..68966f1a94 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.773.3 -%define release 231026 +%define release 231031 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index d62a9d45ca..3086bd4102 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.773.3 -%define release 231026 +%define release 231031 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 88579ca477..888a2ab4fa 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.773.3" -PI_BUILD="231026" +PI_BUILD="231031" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index cd64fa670b..2cbf7c4749 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -530,3 +530,11 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default #module_absoluteinterval 7d #module_end +# Logs extraction +#module_begin +#module_name X_Server_log +#module_description Logs extraction module +#module_type log +#module_regexp C:\server\logs\xserver.log +#module_pattern .* +#module_end diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c1ee50b183..ae71b2bf45 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{231026} +{231031} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index eb1897b531..b9ab0f5d2e 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.773.3 Build 231026") +#define PANDORA_VERSION ("7.0NG.773.3 Build 231031") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index c9af1ee5b0..b57a00dfbc 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.773.3(Build 231026))" + VALUE "ProductVersion", "(7.0NG.773.3(Build 231031))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 6acf4f9204..db922b6538 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.773.3-231026 +Version: 7.0NG.773.3-231031 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 2aa7db42ef..ec26a38525 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.773.3-231026" +pandora_version="7.0NG.773.3-231031" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql index 2036b46601..0fbd22863e 100644 --- a/pandora_console/extras/mr/66.sql +++ b/pandora_console/extras/mr/66.sql @@ -160,6 +160,9 @@ UPDATE tagente_modulo SET `tcp_send` = '2c' WHERE `tcp_send` = '2'; UPDATE tpolicy_modules SET `tcp_send` = '2c' WHERE `tcp_send` = '2'; UPDATE tnetwork_component SET `tcp_send` = '2c' WHERE `tcp_send` = '2'; +ALTER TABLE tagente_modulo ADD COLUMN `made_enabled` TINYINT UNSIGNED DEFAULT 0; +ALTER TABLE tpolicy_modules ADD COLUMN `made_enabled` TINYINT UNSIGNED DEFAULT 0; + ALTER TABLE talert_templates ADD COLUMN `time_window` ENUM ('thirty_days','this_month','seven_days','this_week','one_day','today'), ADD COLUMN `math_function` ENUM ('avg', 'min', 'max', 'sum'), @@ -164214,10 +164217,87 @@ UPDATE `tevent_alert` ea INNER JOIN `tevent_rule` er ON ea.id = er.id_event_aler ALTER TABLE `tnetwork_explorer_filter` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT; +-- Add messaging alerts + +SET @command_name = 'Pandora Google chat'; +SET @action_name = 'Pandora Google chat'; + +-- Get command ID in case it exists +SET @id_command = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +INSERT IGNORE INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@id_command, @command_name, '/usr/share/pandora_server/util/plugin/pandora-gchat-cli -u "_field1_" -d "_field2_" -t "_field3_" -D "_field4_"', 'Send messages using Google chat API', 0, '["Google chat webhook URL","Data in coma separate keypairs","Title","Description"]', '["","","",""]'); + +-- Get command ID again in case it has been created +SET @id_command = NULL; +SET @id_action = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +SELECT @id_action := `id` FROM `talert_actions` WHERE `name` = @action_name; +INSERT IGNORE INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (@id_action, @action_name, @id_command, "", "data=_data_", "[PANDORA] Alert FIRED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", "", 0, 0, "", "data=_data_", "[PANDORA] Alert RECOVERED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", ""); + +SET @command_name = 'Pandora Slack'; +SET @action_name = 'Pandora Slack'; + +-- Get command ID in case it exists +SET @id_command = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +INSERT IGNORE INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@id_command, @command_name, '/usr/share/pandora_server/util/plugin/pandora-slack-cli -t "TOKEN" -d "_field1_" -c "_field2_" -e "_field3_" -T "_field4_" -D "_field5_"', 'Send messages using Slack API', 0, '["Data in coma separate keypairs","Slack channel id/name","Title emoji","Title","Description"]', '["","",":red_circle:,Red circle;:green_circle:,Green circle","",""]'); + +-- Get command ID again in case it has been created +SET @id_command = NULL; +SET @id_action = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +SELECT @id_action := `id` FROM `talert_actions` WHERE `name` = @action_name; +INSERT IGNORE INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (@id_action, @action_name, @id_command, "data=_data_", "", ":red_circle:", "[PANDORA] Alert FIRED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", 0, 0, "data=_data_", "", ":green_circle:", "[PANDORA] Alert RECOVERED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", ""); + +SET @command_name = 'Pandora Telegram'; +SET @action_name = 'Pandora Telegram'; + +-- Get command ID in case it exists +SET @id_command = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +INSERT IGNORE INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@id_command, @command_name, '/usr/share/pandora_server/util/plugin/pandora-telegram-cli -t "TOKEN" -c "_field1_" -m "_field2_"', 'Send messages using Telegram API', 0, '["Chat ID","Message"]', '["",""]'); + +-- Get command ID again in case it has been created +SET @id_command = NULL; +SET @id_action = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +SELECT @id_action := `id` FROM `talert_actions` WHERE `name` = @action_name; +INSERT IGNORE INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (@id_action, @action_name, @id_command, "", "[PANDORA] Alert FIRED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", "", 0, 0, "", "[PANDORA] Alert RECOVERED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", ""); + +SET @command_name = 'Pandora ilert'; +SET @action_name = 'Pandora ilert'; + +-- Get command ID in case it exists +SET @id_command = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +INSERT IGNORE INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@id_command, @command_name, '/usr/share/pandora_server/util/plugin/pandora_ilert -a "API_KEY" -t "_field1_" -k "_field2_" -T "_field3_" -d "_field4_" -A "_agentname_" -m "_module_" -p "_alert_text_severity_" -D "_data_" -C "_timestamp_"', 'Send SMS using ilert API: https://docs.ilert.com/integrations/pandorafms/', 0, '["Event type","Event title","Title","Description"]', '["alert,Alert;resolved,Resolved","","",""]'); + +-- Get command ID again in case it has been created +SET @id_command = NULL; +SET @id_action = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +SELECT @id_action := `id` FROM `talert_actions` WHERE `name` = @action_name; +INSERT IGNORE INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (@id_action, @action_name, @id_command, "alert", "", "[PANDORA] Alert FIRED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", "", 0, 0, "resolved", "", "[PANDORA] Alert RECOVERED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", ""); + +SET @command_name = 'Pandora Vonage'; +SET @action_name = 'Pandora Vonage'; + +-- Get command ID in case it exists +SET @id_command = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +INSERT IGNORE INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (@id_command, @command_name, '/usr/share/pandora_server/util/plugin/pandora_vonage -a "API_KEY" -s "SECRET" -f "FROM_ALIAS" -n "_field1_" -m "_field2_"', 'Send SMS using Vonage API: https://www.vonage.com/communications-apis/sms/', 0, '["Phone number","Message"]', '["",""]'); + +-- Get command ID again in case it has been created +SET @id_command = NULL; +SET @id_action = NULL; +SELECT @id_command := `id` FROM `talert_commands` WHERE `name` = @command_name; +SELECT @id_action := `id` FROM `talert_actions` WHERE `name` = @action_name; +INSERT IGNORE INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (@id_action, @action_name, @id_command, "", "[PANDORA] Alert FIRED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", "", 0, 0, "", "[PANDORA] Alert RECOVERED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", ""); + -- Insert new Pandora vulscan APP SET @short_name = 'pandorafms.vulnscan'; SET @name = 'Vulnerability Scanner'; -SET @section = 'cloud'; +SET @section = 'app'; SET @description = 'Pandora FMS Vulnerability Scanner. Scans the network looking for known software vulnerabilities.'; SET @version = '1.0'; @@ -164225,7 +164305,7 @@ INSERT IGNORE INTO tdiscovery_apps (id_app, short_name, name, section, descripti SELECT @id_app := id_app FROM tdiscovery_apps WHERE short_name = @short_name; -- Insert into tdiscovery_apps_scripts -INSERT IGNORE INTO tdiscovery_apps_scripts (id_app, macro, value) VALUES (@id_app, '_exec1_', 'pandora_vulnscan.py'); +INSERT IGNORE INTO tdiscovery_apps_scripts (id_app, macro, value) VALUES (@id_app, '_exec1_', 'bin/pandora_vulnscan'); -- Insert into tdiscovery_apps_executions INSERT IGNORE INTO tdiscovery_apps_executions (id_app, execution) VALUES (@id_app, ''_exec1_' '__pandoraServerConf__' '_agentGroups_' -t _numThreads_'); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 5ab4ed9e9c..09ca22062e 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1339,6 +1339,12 @@ if ($update_module === true || $create_module === true) { */ $post_process = (string) get_parameter('post_process', 0.0); + if (modules_made_compatible($id_module_type) === true) { + $made_enabled = (bool) get_parameter_checkbox('made_enabled', 0); + } else { + $made_enabled = false; + } + $prediction_module = (int) get_parameter('prediction_module'); $max_timeout = (int) get_parameter('max_timeout'); $max_retries = (int) get_parameter('max_retries'); @@ -1733,6 +1739,7 @@ if ($update_module) { 'plugin_parameter' => $plugin_parameter, 'id_plugin' => $id_plugin, 'post_process' => $post_process, + 'made_enabled' => $made_enabled, 'prediction_module' => $prediction_module, 'max_timeout' => $max_timeout, 'max_retries' => $max_retries, @@ -1931,6 +1938,7 @@ if ($create_module) { 'plugin_parameter' => $plugin_parameter, 'id_plugin' => $id_plugin, 'post_process' => $post_process, + 'made_enabled' => $made_enabled, 'prediction_module' => $prediction_module, 'max_timeout' => $max_timeout, 'max_retries' => $max_retries, diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 452d2a498a..a52813fbf3 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -294,6 +294,7 @@ if ($id_agent_module) { $plugin_parameter = $module['plugin_parameter']; $id_plugin = $module['id_plugin']; $post_process = $module['post_process']; + $made_enabled = $module['made_enabled']; $prediction_module = $module['prediction_module']; $custom_integer_1 = $module['custom_integer_1']; $custom_integer_2 = $module['custom_integer_2']; @@ -408,6 +409,7 @@ if ($id_agent_module) { $id_module_group = 1; $id_module_type = 1; $post_process = ''; + $made_enabled = false; $max_timeout = 0; $max_retries = 0; $min = ''; diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index d9a0d3ba22..ca74b7d171 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1,4 +1,5 @@ data['switch_warning_threshold'][0] .= html_print_switch_ html_print_radio_button_extended('warning_thresholds_checks', 'warning_inverse', __('Inverse interval'), ($warning_inverse) ? 'warning_inverse' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-warning_inverse'), html_print_radio_button_extended('warning_thresholds_checks', 'percentage_warning', __('Percentage'), ($percentage_warning) ? 'percentage_warning' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_warning'), ], - [ 'class' => 'margin-top-10' ], + ['class' => 'margin-top-10'], true ); @@ -565,7 +566,7 @@ $tableBasicThresholds->data['switch_critical_threshold'][0] .= html_print_switch html_print_radio_button_extended('critical_thresholds_checks', 'critical_inverse', __('Inverse interval'), ($critical_inverse) ? 'critical_inverse' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-critical_inverse'), html_print_radio_button_extended('critical_thresholds_checks', 'percentage_critical', __('Percentage'), ($percentage_critical) ? 'percentage_critical' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_critical'), ], - [ 'class' => 'margin-top-10' ], + ['class' => 'margin-top-10'], true ); @@ -722,14 +723,14 @@ if ($cps_module > 0) { ob_start(); ?> data['ff_main_thresholds'][0] = html_print_switch_radio_butto html_print_radio_button_extended('each_ff', 0, __('All state changing'), $each_ff, false, 'ffStateChange(0)', '', true, false, '', 'ff_all_state'), html_print_radio_button_extended('each_ff', 1, __('Each state changing'), $each_ff, false, 'ffStateChange(1)', '', true, false, '', 'ff_each_state'), ], - [ 'add_content' => $ffThresholdsScript ], + ['add_content' => $ffThresholdsScript], true ); @@ -1376,6 +1377,24 @@ $table_advanced->data['process_unit'][1] = html_print_extended_select_for_post_p $disabledBecauseInPolicy ); +$table_advanced->rowclass['caption_made_enabled'] = 'w50p'; +$table_advanced->rowclass['made_enabled'] = 'w50p'; +$table_advanced->data['caption_made_enabled'][0] = __('MADE enabled').ui_print_help_tip( + __('By activating this option, the module data will be processed by the MADE engine (if active), and events will be generated automatically by the IA engine'), + true +); +$table_advanced->data['made_enabled'][0] = html_print_checkbox_switch( + 'made_enabled', + 1, + (bool) $made_enabled, + false, + false, + '', + false, + false, + 'wp100 static' +); + $table_advanced->data['title_5'] = html_print_subtitle_table(__('Notifications and alerts')); $table_advanced->data['caption_export_target'][0] = __('Export target'); @@ -1666,47 +1685,48 @@ ui_require_jquery_file('json'); ?> + /* ]]> */ + \ No newline at end of file diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index fbb63c49d3..156ca507d8 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -916,7 +916,24 @@ $table->data[17][0] = html_print_label_input_block( ) ); -$table->data[17][1] = html_print_label_input_block( +$table->data['made_enabled'][1] = html_print_label_input_block( + __('MADE enabled').ui_print_help_tip( + __('By activating this option, the module data will be processed by the MADE engine (if active), and events will be generated automatically by the IA engine'), + true + ), + html_print_checkbox_switch( + 'made_enabled', + 1, + false, + true, + false, + '', + false, + 'wp100 static' + ) +); + +$table->data[17][2] = html_print_label_input_block( __('SNMP community'), html_print_input_text( 'snmp_community', @@ -1653,7 +1670,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").hide(); var params = { @@ -1728,7 +1746,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").show (); switch($('#module_type').val()) { @@ -1838,7 +1857,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").hide (); $('input[type=checkbox]').attr('checked', false); $('input[type=checkbox]').attr('disabled', true); @@ -1877,7 +1897,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").show(); } else { @@ -1908,7 +1929,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").hide(); } } @@ -1932,6 +1954,9 @@ $(document).ready (function () { else if (this.id == "checkbox-dynamic_two_tailed") { return; //Do none } + else if (this.id == "checkbox-made_enabled") { + return; //Do none + } else { if (this.id == "checkbox-force_group") { $("#checkbox-recursion").prop("checked", false); @@ -1964,7 +1989,7 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + "tr#delete_table-40").show (); } else { @@ -1995,7 +2020,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").hide(); } } @@ -2085,7 +2111,8 @@ $(document).ready (function () { "tr#delete_table-36, " + "tr#delete_table-37, " + "tr#delete_table-38, " + - "tr#delete_table-39, " + + "tr#delete_table-39, " + + "tr#delete_table-made_enabled, " + "tr#delete_table-40").hide(); jQuery.post ("ajax.php", @@ -2315,6 +2342,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' 'module_interval', 'disabled', 'post_process', + 'made_enabled', 'unit_select', 'snmp_community', 'snmp_oid', @@ -2626,6 +2654,10 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' $values['macros'] = json_encode($module_macros); } + if (modules_made_compatible($module['id_tipo_modulo']) === false) { + $values['made_enabled'] = 0; + } + $result = modules_update_agent_module( $module['id_agente_modulo'], $values, diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index e6032de2f6..bb06d3a800 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1932,33 +1932,8 @@ if (is_metaconsole() === true) { $a) { - if ($index == 0) { - $sql_log .= ' AND (id_agente = '.$key; - } else { - $sql_log .= ' OR id_agente = '.$key; - } - - $index++; - } - - $sql_log .= ')'; - } - - html_print_select_from_sql( - $sql_log, + html_print_select( + [], 'source', $source, 'onselect=source_change_agents();', @@ -1966,7 +1941,7 @@ if (is_metaconsole() === true) { '', false, false, - false + false, ); ?> @@ -6702,68 +6677,41 @@ function loadGeneralAgents(agent_group) { function loadLogAgents() { var params = []; - params.push("get_log_agents=1"); - params.push("source="); - params.push('id_agents='); - params.push("page=include/ajax/reporting.ajax"); + let source = ''; + let agent = ''; + agent = JSON.parse(agent); - $('#id_agents3') - .find('option') - .remove(); + var params = {}; + params["get_agent_source"] = 1; + params["log_alert"] = 1; + params["page"] = "enterprise/include/ajax/log_viewer.ajax"; - $('#id_agents3') - .append(''); - - jQuery.ajax ({ - data: params.join ("&"), - type: 'POST', - url: action= - - + "/ajax.php", - timeout: 300000, - dataType: 'json', - success: function (data) { - if (data['correct']) { - $('#id_agents3') - .find('option') - .remove(); - - var selectElements = []; - var selectedStr = 'selected="selected"'; - - if (data['select_agents'] === null) { - return; - } - - if (Array.isArray(data['select_agents'])) { - data['select_agents'].forEach(function(agentAlias, agentID) { - var optionAttr = ''; - if (typeof data['agents_selected'][agentID] !== 'undefined') { - optionAttr = ' selected="selected"'; - } - - $('#id_agents3') - .append(''); - }); + jQuery.ajax({ + data: params, + dataType: "json", + type: "POST", + url: "ajax.php", + async: true, + success: function(data) { + $('#id_agents3') + .find('option') + .remove(); + $.each(data['source'],function(key,value) { + if (value === source) { + $('#source').append( ``); } else { - for (const [agentID, agentAlias] of Object.entries(data['select_agents'])) { - var optionAttr = ''; - if (typeof data['agents_selected'][agentID] !== 'undefined') { - optionAttr = ' selected="selected"'; - } - - $('#id_agents3') - .append(''); - } + $('#source').append( ``); } - } + }); + + $.each(data['agent'],function(key,value) { + const result = agent.includes(key); + if (result === true) { + $('#id_agents3').append( ``); + } else { + $('#id_agents3').append( ``); + } + }); } }); } @@ -7948,23 +7896,46 @@ function set_last_value_period() { } function source_change_agents() { - $("#id_agents3").empty(); - $("#spinner_hack").show(); - jQuery.post ("ajax.php", - {"page" : "operation/agentes/ver_agente", - "get_agents_source_json" : 1, - "source" : $("#source").val() - }, - function (data, status) { - for (var clave in data) { - $("#id_agents3").append( - '' - ); + const source = $("#source").val(); + if (source === '') { + $("#id_agents3 option[value!=0]").attr("style","display:"); + } else { + $("#spinner_hack").show(); + $("#id_agents3 option").attr("style","display:none"); + + var params = {}; + params["get_agent_source"] = 1; + params["page"] = "enterprise/include/ajax/log_viewer.ajax"; + + jQuery.ajax({ + data: params, + dataType: "json", + type: "POST", + url: "ajax.php", + async: true, + success: function(data) { + let source_array = []; + $.each(data['source'],function(key,value) { + if (value === source) { + const split = key.split('-'); + source_array.push(split[1]); + } + }); + + $.each(data['agent'],function(key,value) { + const result = source_array.includes(key); + if (result === true) { + $(`#id_agents3 option[value*='${key}']`).attr("style","display:"); + } + }); + + $("#spinner_hack").hide(); + }, + error: function(error){ + $("#spinner_hack").hide(); } - $("#spinner_hack").hide(); - }, - "json" - ); + }); + } } function dialog_message(message_id) { diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 4b3f26606a..c51c0476d3 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -151,6 +151,10 @@ if (isset($_GET['server']) === true) { $title .= __('Netflow server').' ID: '.$id_server; break; + case SERVER_TYPE_MADE: + $title .= __('MADE server').' ID: '.$id_server; + break; + default: $title = __('Update server').' ID: '.$id_server; break; diff --git a/pandora_console/images/Anomaly-detection.png b/pandora_console/images/Anomaly-detection.png new file mode 100644 index 0000000000..cf3c346138 Binary files /dev/null and b/pandora_console/images/Anomaly-detection.png differ diff --git a/pandora_console/images/Anomaly-detection@2x.png b/pandora_console/images/Anomaly-detection@2x.png new file mode 100644 index 0000000000..ba2352fbf1 Binary files /dev/null and b/pandora_console/images/Anomaly-detection@2x.png differ diff --git a/pandora_console/images/Anomaly-detection@svg.svg b/pandora_console/images/Anomaly-detection@svg.svg new file mode 100644 index 0000000000..45abb1db7a --- /dev/null +++ b/pandora_console/images/Anomaly-detection@svg.svg @@ -0,0 +1,14 @@ + + + Anomaly detection@svg + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 92ab21b1bc..3d77c7ba30 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -483,6 +483,13 @@ if (check_login()) { 'tagente_modulo', ['id_agente_modulo' => $module_id] ); + + $made_enabled = db_get_value_filter( + 'made_enabled', + 'tagente_modulo', + ['id_agente_modulo' => $module_id] + ); + $unit = db_get_value_filter( 'unit', 'tagente_modulo', diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ebb9da98fa..8ffdc71c33 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC231026'; +$build_version = 'PC231031'; $pandora_version = 'v7.0NG.773.3'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 2dba4790e3..4f020e61de 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -442,6 +442,7 @@ define('SERVER_TYPE_CORRELATION', 22); define('SERVER_TYPE_NCM', 23); define('SERVER_TYPE_NETFLOW', 24); define('SERVER_TYPE_LOG', 25); +define('SERVER_TYPE_MADE', 26); // REPORTS. define('REPORT_TOP_N_MAX', 1); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index e82fca400b..de618605c8 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4762,3 +4762,31 @@ function export_agents_module_csv($filters) return $result; } + + +/** + * Check if modules are compatible with MADE server. + * + * @param integer $id_tipo_modulo + * @retur boolean True if compatible, false otherwise. + */ +function modules_made_compatible($id_tipo_modulo) +{ + $compatible_types = [ + 1, + 4, + 5, + 8, + 15, + 16, + 22, + 30, + 34, + ]; + + if (array_search($id_tipo_modulo, $compatible_types) === false) { + return false; + } else { + return true; + } +} diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 845a57a77b..75e034ce3c 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -992,6 +992,19 @@ function servers_get_info($id_server=-1, $sql_limit=-1) $id_modulo = 0; break; + case SERVER_TYPE_MADE: + $server['img'] = html_print_image( + 'images/Anomaly-detection@svg.svg', + true, + [ + 'title' => __('MADE server'), + 'class' => 'main_menu_icon invert_filter', + ] + ); + $server['type'] = 'made'; + $id_modulo = 0; + break; + default: $server['img'] = ''; $server['type'] = 'unknown'; diff --git a/pandora_console/install.php b/pandora_console/install.php index f0cf6d8b6a..fb0b661943 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
+ // No click enabled when user not logged. + $( "a" ).on( "click", function( event ) { + event.preventDefault(); + $('#visual-console-container').removeClass('is-updating'); + $('.div-visual-console-spinner').remove(); + }); + {"ssl_verify"} = 0; # 7.0 774 + $pa_config->{"madeserver"} = 0; # 774. + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1403,6 +1405,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^ssl_verify\s+([0-1])/i) { $pa_config->{'ssl_verify'} = 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 7cd108376e..e830c90837 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -325,6 +325,7 @@ our @ServerTypes = qw ( 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'); @@ -6739,24 +6740,23 @@ sub pandora_installation_monitoring($$) { my $data_size = get_db_value($dbh, 'SELECT SUM(data_length)/(1024*1024) FROM information_schema.TABLES'); my $index_size = get_db_value($dbh, 'SELECT SUM(index_length)/(1024*1024) FROM information_schema.TABLES'); my $writes = $insert->{'Value'} + $update->{'Value'} + $replace->{'Value'} + $delete->{'Value'} ; - + my $reads = $select->{'Value'}; + # Mysql Questions - Reads $module->{'name'} = "mysql_questions_reads"; $module->{'description'} = 'MySQL: Questions - Reads (#): Number of read questions'; - $module->{'data'} = $select->{'Value'}; - $module->{'unit'} = 'qu'; + $module->{'data'} = $reads; + $module->{'unit'} = 'qu/s'; + $module->{'type'} = 'generic_data_inc'; push(@modules, $module); undef $module; # Mysql Questions - Writes - my $question_writes = 0; - if(($writes + $select) > 0) { - $question_writes = (($writes * 10000) / ($select + $writes)) / 100; - } $module->{'name'} = "mysql_questions_writes"; $module->{'description'} = 'MySQL: Questions - Writes (#): Number of writed questions'; - $module->{'data'} = $question_writes; - $module->{'unit'} = 'qu'; + $module->{'data'} = $writes; + $module->{'unit'} = 'qu/s'; + $module->{'type'} = 'generic_data_inc'; push(@modules, $module); undef $module; @@ -6896,7 +6896,7 @@ sub pandora_installation_monitoring($$) { $dbh, 'SELECT COUNT(id_evento) FROM tevento - WHERE timestamp >=UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY)' + WHERE utimestamp >=UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY)' ); $module->{'name'} = "last_events_24h"; $module->{'description'} = 'Last 24h events'; diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 3c188efa46..836bc8209a 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.773.3"; -my $pandora_build = "231026"; +my $pandora_build = "231031"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 4af9292467..70d697dab4 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -79,6 +79,7 @@ our @EXPORT = qw( NCMSERVER NETFLOWSERVER LOGSERVER + MADESERVER METACONSOLE_LICENSE OFFLINE_LICENSE DISCOVERY_HOSTDEVICES @@ -209,6 +210,7 @@ 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; @@ -2976,6 +2978,7 @@ sub get_server_name { 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/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index f26dda1f90..0936210692 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.773.3 -%define release 231026 +%define release 231031 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 5971f2f9d7..8e48063d08 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.773.3 -%define release 231026 +%define release 231031 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index b15547900d..b3d6c4d8bf 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.773.3" -PI_BUILD="231026" +PI_BUILD="231031" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 493f1a89f4..383422d602 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.773.3 Build 231026"; +my $version = "7.0NG.773.3 Build 231031"; # Pandora server configuration my %conf; 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)) { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 6f65473ecf..6ad0c4b85b 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.773.3 Build 231026"; +my $version = "7.0NG.773.3 Build 231031"; # save program name for logging my $progname = basename($0);