diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 236064b4e3..041c5ed98a 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.764-220927 +Version: 7.0NG.764-220928 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 9f086f5251..357f109d1b 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.764-220927" +pandora_version="7.0NG.764-220928" 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 a0e473063e..62e785b74e 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -165,9 +165,15 @@ remote_config 0 # should consider changing the temporal directory, since /tmp is world writable. xml_buffer 1 -# Minimum available bytes in the temporal directory to enable the XML buffer +# Minimum available megabytes in the temporal directory to enable the XML buffer temporal_min_size 1024 +# Maximum size (in megabytes) allowed for the XML buffer. +temporal_max_size 1024 + +# Maximum number of files allowed for the XML buffer. +temporal_max_files 1024 + # Agent mode: Learn (default), No-learn, Autodisable # agent_mode autodisable diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 87cfd2c8cf..6e878f0d73 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.764'; -use constant AGENT_BUILD => '220927'; +use constant AGENT_BUILD => '220928'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -1145,7 +1145,9 @@ my %DefaultConf = ( 'secondary_server_opts' => '', 'secondary_temporal' => '/var/spool/pandora', 'autotime' => 0, - 'temporal_min_size' => 1, + 'temporal_min_size' => 1024, + 'temporal_max_files' => 1024, + 'temporal_max_size' => 1024, 'timezone_offset' => 0, 'pandora_exec' => 'pandora_agent_exec', 'agent_threads' => 1, @@ -2110,13 +2112,13 @@ sub send_xml_file ($) { swap_servers(); # Secondary buffer. - if ($rc_sec != 0 && $Conf{'xml_buffer'} == 1 && temporal_freedisk () > $Conf{'temporal_min_size'}) { + if ($rc_sec != 0 && write_to_buffer($Conf{'secondary_temporal'}) == 1) { copy($file, $Conf{'secondary_temporal'}) || die("Error copying file $file to " . $Conf{'secondary_temporal'} . ": $!"); } } # Primary buffer. - if ($rc == 0 || $Conf{'xml_buffer'} == 0 || temporal_freedisk () <= $Conf{'temporal_min_size'}) { + if ($rc == 0 || write_to_buffer($Conf{'temporal'}) == 0) { if ($Conf{'debug'} eq '1') { rename($file, $file . "sent"); } else { @@ -3761,20 +3763,45 @@ sub kill_signal_handler (){ } ################################################################################ -# Get the free disk space in the temporal directory (in bytes). +# Get the free disk space in the temporal directory (in megabytes). ################################################################################ -sub temporal_freedisk () { +sub temporal_freedisk { + my ($temporal) = @_; # Call df return 0 unless defined (DF_CMDS->{$OS}); - my $cmd = DF_CMDS->{$OS} . ' ' . $Conf{'temporal'} . ' | awk \'NR > 1 {print $4}\''; + my $cmd = DF_CMDS->{$OS} . ' ' . $temporal . ' | awk \'NR > 1 {print $4}\''; my $temporal_freedisk = `$cmd`; # Check for errors return 0 unless ($? eq 0); - # Convert to bytes - return 1024 * int ($temporal_freedisk); + # Convert from KB to MB. + return $temporal_freedisk / 1024; +} + +################################################################################ +# Return the number of data files in the temporal directory and their total +# size (in megabytes). +################################################################################ +sub temporal_stats { + my ($temporal) = @_; + + my $file_count = 0; + my $file_size = 0; + opendir(my $dir, $temporal) or die($!); + while (my $f = readdir($dir)) { + if ($f =~ m/.data$/ || $f =~ m/.datasent$/) { + $file_count += 1; + $file_size += (stat $temporal . '/' . $f)[7]; + } + } + closedir($dir); + + # Convert from B to MB. + $file_size /= 1048576; + + return ($file_count, $file_size); } ################################################################################ @@ -3960,6 +3987,27 @@ sub get_ehkey { return ''; } +################################################################################ +# Return 1 if XML files should be written to the buffer. 0 otherwise. +################################################################################ +sub write_to_buffer { + my ($temporal) = @_; + + # The XML buffer is disabled. + return 0 if ($Conf{'xml_buffer'} == 0); + + # Check available disk space. + return 0 if ($Conf{'temporal_min_size'} != 0 && temporal_freedisk($temporal) < $Conf{'temporal_min_size'}); + + # Check buffer file count and size limits. + my ($file_count, $file_size) = temporal_stats($temporal); + return 0 if ($Conf{'temporal_max_files'} != 0 && $file_count > $Conf{'temporal_max_files'}); + return 0 if ($Conf{'temporal_max_size'} != 0 && $file_size > $Conf{'temporal_max_size'}); + + # It's OK to write to the buffer. + return 1; +} + ################################################################################ # Main. ################################################################################ diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 97bcbf4a2d..791d552104 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.764 -%define release 220927 +%define release 220928 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index e0096d54cc..42c0fa606d 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.764 -%define release 220927 +%define release 220928 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 0c07e243f0..5e2fb23f0e 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.764" -PI_BUILD="220927" +PI_BUILD="220928" 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 549b0e7ac9..200a31d57d 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -55,9 +55,15 @@ address auto # or setting a fixed IP address, like for example: #address 192.168.36.73 -# This limits operation if temporal dir has not enough free disk. +# This limits operation if temporal dir has not enough free disk (in megabytes). #temporal_min_size 1024 +# Maximum size (in megabytes) allowed for the XML buffer. +temporal_max_size 1024 + +# Maximum number of files allowed for the XML buffer. +temporal_max_files 1024 + # Delay start execution X second before start to monitoring nothing #startup_delay 30 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index ebcb1fe62d..acd552c566 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220927} +{220928} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index a2cc6c75fc..f79828bb02 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.764 Build 220927") +#define PANDORA_VERSION ("7.0NG.764 Build 220928") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index f047eb17ff..f369935aac 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -1696,7 +1696,7 @@ Pandora_Windows_Service::checkConfig (string file) { int Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) { - int rc = 0, rc_sec = 0, xml_buffer; + int rc = 0, rc_sec = 0, xml_buffer; string data_xml; string xml_filename, random_integer; string tmp_filename, tmp_filepath; @@ -1705,12 +1705,10 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* string ehorus_conf, eh_key; static HANDLE mutex = 0; ULARGE_INTEGER free_bytes; - double min_free_bytes = 0; Pandora_Agent_Conf *conf = NULL; FILE *conf_fh = NULL; conf = this->getConf (); - min_free_bytes = 1024 * atoi (conf->getValue ("temporal_min_size").c_str ()); xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ()); if (mutex == 0) { @@ -1814,14 +1812,14 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* rc_sec = this->copyToSecondary (tmp_filename, false); /* Secondary buffer. */ - if (rc_sec != 0 && xml_buffer == 1 && (GetDiskFreeSpaceEx (conf->getValue ("secondary_temporal").c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart >= min_free_bytes)) { + if (rc_sec != 0 && this->writeToBuffer(conf->getValue ("secondary_temporal").c_str ())) { secondary_filepath = conf->getValue ("secondary_temporal") + "\\" + tmp_filename; CopyFile (tmp_filepath.c_str(), secondary_filepath.c_str(), false); } } /* Primary buffer. Delete the file if successfully copied, buffer disabled or not enough space available. */ - if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) { + if (rc == 0 || !writeToBuffer(conf->getValue ("temporal").c_str ())) { /* Rename the file if debug mode is enabled*/ if (getPandoraDebug ()) { string tmp_filepath_sent = tmp_filepath; @@ -2218,3 +2216,60 @@ Pandora_Windows_Service::generateAgentName () { sha256(data.str().c_str(), digest); return std::string(digest); } + +bool +Pandora_Windows_Service::writeToBuffer (string temporal) { + int xml_buffer; + long int temporal_max_files; + double temporal_min_size, temporal_max_size; + string dir, file_name; + ULARGE_INTEGER free_bytes; + Pandora_Agent_Conf *conf = NULL; + + conf = this->getConf (); + + dir = temporal; + if (dir[dir.length () - 1] != '\\') { + dir += "\\"; + } + file_name = dir + "*.data"; + + // Is the XML buffer disabled? + xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ()); + if (xml_buffer == 0) { + return false; + } + + // Check available disk space. + temporal_min_size = atoi (conf->getValue ("temporal_min_size").c_str ()); + if (GetDiskFreeSpaceEx (dir.c_str (), &free_bytes, NULL, NULL) && (free_bytes.QuadPart / 1048576) < temporal_min_size) { // Convert free_bytes.QuadPart from B to MB. + pandoraLog ("[writeToBuffer] Disk full."); + return false; + } + + // Check buffer file count and size limits. + temporal_max_size = atoi (conf->getValue ("temporal_max_size").c_str ()); + temporal_max_files = atol (conf->getValue ("temporal_max_files").c_str ()); + if (temporal_max_size != 0 || temporal_max_files != 0) { + long int file_count = 0; + ULONGLONG file_size = 0; + HANDLE hFind; + WIN32_FIND_DATA FindFileData; + if ((hFind = FindFirstFile(file_name.c_str(), &FindFileData)) != INVALID_HANDLE_VALUE) { + do { + file_count += 1; + file_size += (FindFileData.nFileSizeHigh * (MAXDWORD + 1)) + FindFileData.nFileSizeLow; + } while (FindNextFile(hFind, &FindFileData)); + FindClose(hFind); + } + + file_size /= 1048576; // Convert from B to MB. + if ((temporal_max_size != 0 && file_size > temporal_max_size) || + (temporal_max_files != 0 && file_count > temporal_max_files)) { + pandoraLog ("[writeToBuffer] Too many files or buffer full."); + return false; + } + } + + return true; +} diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index 39ad2e8e44..f863ae2c27 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -124,6 +124,7 @@ namespace Pandora { long getInterval (); long getIntensiveInterval (); string generateAgentName (); + bool writeToBuffer (string temporal); }; } diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 6aaaf1203f..e59fef9655 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.764(Build 220927))" + VALUE "ProductVersion", "(7.0NG.764(Build 220928))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d45bd6a8f5..7f85b72cfb 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.764-220927 +Version: 7.0NG.764-220928 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 1e4f6092e6..834fb47321 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.764-220927" +pandora_version="7.0NG.764-220928" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/57.sql b/pandora_console/extras/mr/57.sql index 131a02ce89..5b3f4d9648 100644 --- a/pandora_console/extras/mr/57.sql +++ b/pandora_console/extras/mr/57.sql @@ -9,6 +9,16 @@ ALTER TABLE `tusuario` ADD COLUMN `allowed_ip_list` TEXT; SET @id_config := (SELECT id_config FROM tconfig WHERE `token` = 'metaconsole_node_id' AND `value` IS NOT NULL ORDER BY id_config DESC LIMIT 1); DELETE FROM tconfig WHERE `token` = 'metaconsole_node_id' AND (id_config < @id_config OR `value` IS NULL); +ALTER TABLE `tpolicies` ADD COLUMN `apply_to_secondary_groups` TINYINT NOT NULL DEFAULT 0; + +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Send report by e-mail','Internal type','This command allows you to send a report by email.',1,'[\"Report\",\"e-mail address\",\"Subject\",\"Text\",\"Report type\",\"\",\"\",\"\",\"\",\"\"]','[\"_reports_\",\"\",\"\",\"_html_editor_\",\"xml,XML;pdf,PDF;json,JSON;csv,CSV\",\"\",\"\",\"\",\"\",\"\"]'); +SET @send_report_command_id := LAST_INSERT_ID(); +INSERT INTO `talert_actions` (`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 ('Send Report by e-mail',@send_report_command_id,'','yourmail@domain.es','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"><table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"><thead><tr><td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td><td style="padding: 0px 0px 5px;"><p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p></td></tr><tr><td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td></tr></thead><tbody><tr><td colspan="2"><img onerror="this.style.display="none";" src="_statusimage_" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td></tr><tr><td colspan="2"><p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have bad news for you, something is on <span style="text-transform: uppercase; font-weight: 800;">_modulestatus_</span> status!</p><div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div></td></tr><tr><td colspan="2"><div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"><p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p></div></td></tr><tr><td style="padding: 20px 0px;" colspan="2"><p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated: <span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date: <span style="font-weight: 400!important;">_report_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description: <span style="font-weight: 400!important;">_report_description_</span></p></td></tr></tbody></table><div style="text-align: center; margin-top: 10px;"><p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p></div></div>','','','','','','',0,0,'','','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"> <table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"> <thead> <tr> <td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td> <td style="padding: 0px 0px 5px;"> <p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p> </td> </tr> <tr> <td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td> </tr> </thead> <tbody> <tr> <td colspan="2"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Good-news.png" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td> </tr> <tr> <td colspan="2"> <p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have good news for you, alert has been <span style="text-transform: uppercase; font-weight: 800;">recovered</span></p> <div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div> </td> </tr> <tr> <td colspan="2"> <div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p> </div> </td> </tr> <tr> <td style="padding: 20px 0px;" colspan="2"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated: <span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date: <span style="font-weight: 400!important;">_report_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description: <span style="font-weight: 400!important;">_report_description_</span></p> </td> </tr> </tbody> </table> <div style="text-align: center; margin-top: 10px;"> <p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p> </div> </div>','','','','','',''); + +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Send report by e-mail (from template)','Internal type','This command allows you to send a report generated from a template by email.',1,'[\"Template\",\"Regexp agent filter\",\"e-mail address\",\"Subject\",\"Text\",\"Report type\",\"\",\"\",\"\",\"\"]','[\"_report_templates_\",\"\",\"\",\"\",\"_html_editor_\",\"xml,XML;pdf,PDF;json,JSON;csv,CSV\",\"\",\"\",\"\",\"\"]'); +SET @send_report_by_temp_command_id := LAST_INSERT_ID(); +INSERT INTO `talert_actions` (`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 ('Send Report by e-mail (from template)',@send_report_by_temp_command_id,'','','yourmail@domain.es','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"><table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"><thead><tr><td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td><td style="padding: 0px 0px 5px;"><p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p></td></tr><tr><td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td></tr></thead><tbody><tr><td colspan="2"><img onerror="this.style.display="none";" src="_statusimage_" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td></tr><tr><td colspan="2"><p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have bad news for you, something is on <span style="text-transform: uppercase; font-weight: 800;">_modulestatus_</span> status!</p><div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div></td></tr><tr><td colspan="2"><div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"><p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p></div></td></tr><tr><td style="padding: 20px 0px;" colspan="2"><p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated: <span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date: <span style="font-weight: 400!important;">_report_date_<em><br></em></span></p><p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description: <span style="font-weight: 400!important;">_report_description_</span></p></td></tr></tbody></table><div style="text-align: center; margin-top: 10px;"><p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p></div></div>','','','','','',0,0,'','','','','<div style="background-color: #eaf0f6; font-family: Arial, Helvetica, sans-serif; padding: 30px; margin: 0;"> <table style="max-width: 560px; background-color: white; border-radius: 10px; padding: 10px 20px 40px;" cellspacing="0" cellpadding="0" align="center"> <thead> <tr> <td style="padding: 0px 0px 5px;"><a href="https://pandorafms.com/en/" target="_blank"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Pandora-FMS.png" width="206px"></a></td> <td style="padding: 0px 0px 5px;"> <p style="text-align: right; color: #223549; font-weight: bold; line-height: 36px; padding: 0px; font-size: 12px;">Automatic alert system</p> </td> </tr> <tr> <td style="padding: 0px 0px 5px;" colspan="2"><hr style="border: 1px solid #f5f5f5; width: 100%; margin: 0px;"></td> </tr> </thead> <tbody> <tr> <td colspan="2"><img src="https://pandorafms.com/wp-content/uploads/2022/03/System-email-Good-news.png" style="display: block; margin-left: auto; margin-right: auto; width: 105px; margin-top: 20px; padding: 0px;" width="105px"></td> </tr> <tr> <td colspan="2"> <p style="font-size: 24px; text-align: center; color: #223549; padding: 0px 10%; line-height: 34px; margin: 20px 0px;">We have good news for you, alert has been <span style="text-transform: uppercase; font-weight: 800;">recovered</span></p> <div><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"><w:anchorlock/><center><![endif]--><a style="background-color: #223549; border: none; color: white; padding: 15px 30px; text-align: center; text-decoration: none; display: block; font-size: 16px; margin-left: auto; margin-right: auto; border-radius: 100px; max-width: 50%; margin-top: 0px; font-weight: bold;" href="_homeurl_">Go to Pandora FMS Console</a><!--[if mso]></center></v:rect><![endif]--></div> </td> </tr> <tr> <td colspan="2"> <div style="background-color: #f6f6f6; border-radius: 10px; padding: 10px 20px; margin-top: 40px;"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Monitoring details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Data: <span style="font-weight: 400!important;">_data_ <em>(_modulestatus_)</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Agent: <span style="font-weight: 400!important;">_agent_ <em>_address_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Module: <span style="font-weight: 400!important;">_module_ <em>_moduledescription_</em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Timestamp: <span style="font-weight: 400!important;">_timestamp_</span></p> </div> </td> </tr> <tr> <td style="padding: 20px 0px;" colspan="2"> <p style="font-size: 18px; line-height: 30px; color: #223549;">Report details</p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Generated: <span style="font-weight: 400!important;">_report_generated_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Report date: <span style="font-weight: 400!important;">_report_date_<em><br></em></span></p> <p style="font-size: 15px; color: #333333; font-weight: 800; line-height: 15px;">Description: <span style="font-weight: 400!important;">_report_description_</span></p> </td> </tr> </tbody> </table> <div style="text-align: center; margin-top: 10px;"> <p style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;"><a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/en/contact/">Contact Us</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/community/forums/forum/english/">Support</a> | <a style="font-size: 12px; text-decoration: none; font-weight: 400; color: #777;" href="https://pandorafms.com/manual/en/start">Docs</a></p> </div> </div>','','','','',''); + ALTER TABLE `tmodule_group` MODIFY COLUMN `id_mg` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT; -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/extras/mr/58.sql b/pandora_console/extras/mr/58.sql new file mode 100644 index 0000000000..395f30f861 --- /dev/null +++ b/pandora_console/extras/mr/58.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + + + +COMMIT; diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index a10e32aeff..26dc279cb9 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -15,6 +15,7 @@ global $config; require_once $config['homedir'].'/include/functions_alerts.php'; +require_once $config['homedir'].'/include/functions_reports.php'; enterprise_include_once('meta/include/functions_alerts_meta.php'); check_login(); @@ -284,13 +285,13 @@ if (is_ajax()) { $ffield .= '