diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 108d66feb0..f20c19f638 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.759-220207 +Version: 7.0NG.759-220208 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 9a1db3dffa..211e8823ab 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.759-220207" +pandora_version="7.0NG.759-220208" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 6b3e1b0877..930dacc92e 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.759'; -use constant AGENT_BUILD => '220207'; +use constant AGENT_BUILD => '220208'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index ce70f1ccf1..0defa2e7a1 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.759 -%define release 220207 +%define release 220208 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 4f85f078f1..df3752d389 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.759 -%define release 220207 +%define release 220208 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 5587f32540..d6728736c7 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.759" -PI_BUILD="220207" +PI_BUILD="220208" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index d76d4e21c3..c7d18e7a59 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220207} +{220208} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 72730f66c9..8be0160919 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.759 Build 220207") +#define PANDORA_VERSION ("7.0NG.759 Build 220208") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 96b9992601..04c0697f07 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.759(Build 220207))" + VALUE "ProductVersion", "(7.0NG.759(Build 220208))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 46de6e0d89..e7a7e565e8 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.759-220207 +Version: 7.0NG.759-220208 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 554eda9839..d4d8a64c51 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.759-220207" +pandora_version="7.0NG.759-220208" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 2c3bdb9408..1c611f5c5d 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 = 'PC220207'; +$build_version = 'PC220208'; $pandora_version = 'v7.0NG.759'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index c5ea1bc92e..a6bfb043f5 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1080,14 +1080,23 @@ function modules_get_agentmodule($id_agentmodule) } -function modules_get_table_data($id_agent_module) +/** + * Gets data table for agent module + * + * @param integer|null $id_agent_module Id agentmodule. + * @param integer|null $id_type Id module type. + * @return void + */ +function modules_get_table_data(?int $id_agent_module, ?int $id_type) { - $id_type = db_get_value( - 'id_tipo_modulo', - 'tagente_modulo', - 'id_agente_modulo', - $id_agent_module - ); + if ($id_type === null) { + $id_type = db_get_value( + 'id_tipo_modulo', + 'tagente_modulo', + 'id_agente_modulo', + $id_agent_module + ); + } $name_type = db_get_value('nombre', 'ttipo_modulo', 'id_tipo', $id_type); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 83fefb93aa..ebea0146a1 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -66,6 +66,9 @@ define('REPORT_STATUS_NOT_INIT', 3); define('REPORT_STATUS_DOWNTIME', 4); define('REPORT_STATUS_IGNORED', 5); +// Clases. +use PandoraFMS\Module; + function reporting_user_can_see_report($id_report, $id_user=null) { @@ -699,7 +702,9 @@ function reporting_make_reporting_data( case 'last_value': $report['contents'][] = reporting_last_value( $report, - $content + $content, + $datetime, + $period ); break; @@ -4071,46 +4076,44 @@ function reporting_database_serialized($report, $content) /** * Show last value and state of module. * - * @param array $report Data report. - * @param array $content Content report. + * @param array $report Data report. + * @param array $content Content report. + * @param integer $datetime Date limit of report. + * @param integer $init_date Init date of report. * * @return array */ -function reporting_last_value($report, $content) +function reporting_last_value($report, $content, $datetime, $period) { global $config; + try { + $id_meta = null; + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($content['server_name']); + $server = metaconsole_get_connection_by_id($id_meta); + } + + $module = new Module($content['id_agent_module'], false, $server['id']); + } catch (\Exception $e) { + $result = []; + return reporting_check_structure_content($result); + } + $return['type'] = 'last_value'; if (empty($content['name'])) { $content['name'] = __('Last Value'); } - if (is_metaconsole()) { - $id_meta = metaconsole_get_id_server($content['server_name']); - $server = metaconsole_get_connection_by_id($id_meta); - if (metaconsole_connect($server) != NOERR) { - $result = []; - return reporting_check_structure_content($result); - } - } - - $id_agent = agents_get_module_id( - $content['id_agent_module'] - ); - $agent_alias = agents_get_alias($id_agent); - $module_name = modules_get_agentmodule_name( - $content['id_agent_module'] - ); - + $id_agent = $module->agent()->id_agente(); $id_agent_module = $content['id_agent_module']; - $agent_description = agents_get_description($id_agent); - $agent_group = agents_get_agent_group($id_agent); - $agent_address = agents_get_address($id_agent); - - $module_description = modules_get_agentmodule_descripcion( - $id_agent_module - ); + $agent_alias = $module->agent()->alias(); + $module_name = $module->name(); + $agent_description = $module->agent()->comentarios(); + $agent_group = $module->agent()->group(); + $agent_address = $module->agent()->field['direccion']; + $module_description = $module->descripcion(); $items_label = [ 'type' => $return['type'], @@ -4138,22 +4141,63 @@ function reporting_last_value($report, $content) $return['pagebreak'] = $content['pagebreak']; $return['subtitle'] = $agent_alias.' - '.$module_name; $return['description'] = $content['description']; - $return['date'] = reporting_get_date_text($report, $content); - $return['agent_name_db'] = agents_get_name($id_agent); + $return['agent_name_db'] = $module->agent()->id_agente(); $return['agent_name'] = $agent_alias; $return['module_name'] = $module_name; + $return['date'] = reporting_get_date_text($report, $content); - $sql = sprintf( - 'SELECT * - FROM tagente_estado - WHERE id_agente_modulo = %s', - $content['id_agent_module'] - ); + $result = $module->getStatus()->toArray(); - $result = db_get_row_sql($sql); + if ($result === false + || $result['estado'] == AGENT_MODULE_STATUS_NO_DATA + || $result['estado'] == AGENT_MODULE_STATUS_NOT_INIT + ) { + $result['utimestamp'] = ''; + $result['datos'] = __('No data to display within the selected interval'); + } - if ($result === false) { - $result = []; + if ($datetime < $result['utimestamp']) { + $id_tipo_modulo = $module->id_tipo_modulo(); + $table_data = modules_get_table_data(null, $id_tipo_modulo); + if ($period !== null) { + $sql = sprintf( + 'SELECT datos, utimestamp FROM %s WHERE id_agente_modulo = %d AND utimestamp BETWEEN %d AND %d ORDER BY utimestamp DESC', + $table_data, + $id_agent_module, + ($datetime - $period), + $datetime + ); + } else { + $sql = sprintf( + 'SELECT datos, utimestamp FROM %s WHERE id_agente_modulo = %d AND utimestamp <= %d ORDER BY utimestamp DESC', + $table_data, + $id_agent_module, + $datetime + ); + } + + $search_in_history_db = db_search_in_history_db($datetime); + + try { + $module->connectNode(); + } catch (\Exception $e) { + // Do not link items if failed to find them. + $module->restoreConnection(); + } + + $datos = db_get_row_sql($sql, $search_in_history_db); + + // Restore if needed. + $module->restoreConnection(); + + if ($datos !== false) { + $result['datos'] = $datos['datos']; + $result['utimestamp'] = $datos['utimestamp']; + } else { + $result['utimestamp'] = '-'; + $result['estado'] = AGENT_MODULE_STATUS_NO_DATA; + $result['datos'] = __('No data to display within the selected interval'); + } } $result['agent_name'] = $agent_alias; @@ -4161,10 +4205,6 @@ function reporting_last_value($report, $content) $return['data'] = $result; - if (is_metaconsole()) { - metaconsole_restore_db(); - } - return reporting_check_structure_content($return); } diff --git a/pandora_console/install.php b/pandora_console/install.php index a90c7fa1c6..5080f8e93c 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@