Merge remote-tracking branch 'origin/develop' into ent-8898-anida-mapas-de-red-no-actualizan-bien

This commit is contained in:
Ramon Novoa 2022-09-02 14:05:45 +02:00
commit fa74a2f91f
34 changed files with 484 additions and 35 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.764-220829
Version: 7.0NG.764-220831
Architecture: all
Priority: optional
Section: admin

View File

@ -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-220829"
pandora_version="7.0NG.764-220831"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.764';
use constant AGENT_BUILD => '220829';
use constant AGENT_BUILD => '220831';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.764
%define release 220829
%define release 220831
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.764
%define release 220829
%define release 220831
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.764"
PI_BUILD="220829"
PI_BUILD="220831"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{220829}
{220831}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.764 Build 220829")
#define PANDORA_VERSION ("7.0NG.764 Build 220831")
string pandora_path;
string pandora_dir;

View File

@ -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 220829))"
VALUE "ProductVersion", "(7.0NG.764(Build 220831))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.764-220829
Version: 7.0NG.764-220831
Architecture: all
Priority: optional
Section: admin

View File

@ -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-220829"
pandora_version="7.0NG.764-220831"
package_pear=0
package_pandora=1

View File

@ -319,7 +319,7 @@ if ($id_agente) {
$table_ip .= '<div class="label_select">';
$table_ip .= '<div class="label_select_parent">';
$table_ip .= '<div class="label_select_child_left">'.html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true).'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected').'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected IPs').'</div>';
$table_ip .= '</div></div>';
}

View File

@ -78,6 +78,14 @@ $agents_inventory_display_options['estado'] = __('Status');
$agents_inventory_display_options['agent_version'] = __('Version');
$agents_inventory_display_options['remote'] = __('Remote configuration');
// Modules inventory display options.
$modules_inventory_display_options = [];
$modules_inventory_display_options['alias'] = __('Name');
$modules_inventory_display_options['direccion'] = __('Description');
$modules_inventory_display_options['id_os'] = __('Tags');
$modules_inventory_display_options['id_grupo'] = __('Module groups');
$modules_inventory_display_options['secondary_groups'] = __('Group');
enterprise_include('/godmode/reporting/reporting_builder.item_editor.php');
require_once $config['homedir'].'/include/functions_agents.php';
if (enterprise_include_once('include/functions_metaconsole.php')) {
@ -901,6 +909,14 @@ switch ($action) {
$idAgentModule = $inventory_modules;
break;
case 'modules_inventory':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$selected_agent_group_filter = $es['agent_group_filter'];
$selected_module_group = $es['module_group'];
break;
case 'inventory':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
@ -3644,7 +3660,22 @@ $class = 'databox filters';
true,
'agent_group_filter',
$selected_agent_group_filter,
''
'',
'',
0,
false,
false,
false,
'',
false,
false,
false,
false,
'id_grupo',
false,
false,
false,
120
);
?>
</td>
@ -3820,6 +3851,47 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_module_group_filter" class="datos">
<td class="bolder">
<?php
echo __('Module group filter');
?>
</td>
<td>
<?php
$rows_select = [];
$rows_select[0] = __('Not assigned');
if ($is_metaconsole === false) {
$rows = db_get_all_rows_sql(
'SELECT * FROM tmodule_group ORDER BY name'
);
$rows = io_safe_output($rows);
if (empty($rows) === false) {
foreach ($rows as $module_group) {
$rows_select[$module_group['id_mg']] = $module_group['name'];
}
}
} else {
$rows_select = modules_get_modulegroups();
}
html_print_select($rows_select, 'modulegroup', $modulegroup, '', __($is_none), -1, true, false, true, '', false, 'width: 120px;');
html_print_select(
$rows_select,
'module_group',
$selected_module_group,
'',
__('All'),
-1,
false,
false,
true,
'',
false,
'width: 120px;'
);
?>
</td>
</tr>
</tbody>
</table>
@ -6139,6 +6211,8 @@ function chooseType() {
$("#row_agents_inventory_display_options").hide();
$("#row_agent_server_filter").hide();
$("#row_agent_group_filter").hide();
$("#row_module_group_filter").hide();
$("#row_module_group_filter").hide();
$("#row_os").hide();
$("#row_custom_field_filter").hide();
$("#row_custom_field").hide();
@ -6768,6 +6842,14 @@ function chooseType() {
break;
case 'modules_inventory':
$("#row_group").show();
$("#row_agent_server_filter").show();
$("#row_agent_group_filter").show();
$("#row_module_group_filter").show();
break;
case 'inventory':
$("#row_description").show();
$("#row_group").show();

View File

@ -2313,6 +2313,14 @@ switch ($action) {
$values['external_source'] = json_encode($es);
break;
case 'modules_inventory':
$es['agent_server_filter'] = get_parameter('agent_server_filter');
$es['module_group'] = get_parameter('module_group');
$es['agent_group_filter'] = get_parameter('agent_group_filter');
$values['external_source'] = json_encode($es);
break;
case 'IPAM_network':
$es['network_filter'] = get_parameter('network_filter');
$es['alive_ip'] = get_parameter('alive_ip');
@ -3081,6 +3089,14 @@ switch ($action) {
$values['external_source'] = json_encode($es);
break;
case 'modules_inventory':
$es['agent_server_filter'] = get_parameter('agent_server_filter');
$es['module_group'] = get_parameter('module_group');
$es['agent_group_filter'] = get_parameter('agent_group_filter');
$values['external_source'] = json_encode($es);
break;
case 'IPAM_network':
$es['network_filter'] = get_parameter('network_filter');
$es['alive_ip'] = get_parameter('alive_ip');

View File

@ -340,8 +340,19 @@ $table->data[8][1] = html_print_input_text(
true
);
$table->data[9][0] = __('Max. days before delete autodisabled agents');
$table->data[9][0] = __('Max. days before delete not initialized modules');
$table->data[9][1] = html_print_input_text(
'days_delete_not_initialized',
$config['days_delete_not_initialized'],
'',
5,
5,
true
);
$table->data[10][0] = __('Max. days before delete autodisabled agents');
$table->data[10][1] = html_print_input_text(
'days_autodisable_deletion',
$config['days_autodisable_deletion'],
'',
@ -350,8 +361,8 @@ $table->data[9][1] = html_print_input_text(
true
);
$table->data[10][0] = __('Retention period of past special days');
$table->data[10][1] = html_print_input_text(
$table->data[11][0] = __('Retention period of past special days');
$table->data[11][1] = html_print_input_text(
'num_past_special_days',
$config['num_past_special_days'],
'',
@ -360,8 +371,8 @@ $table->data[10][1] = html_print_input_text(
true
);
$table->data[11][0] = __('Max. macro data fields');
$table->data[11][1] = html_print_input_text(
$table->data[12][0] = __('Max. macro data fields');
$table->data[12][1] = html_print_input_text(
'max_macro_fields',
$config['max_macro_fields'],
'',
@ -374,8 +385,8 @@ $table->data[11][1] = html_print_input_text(
);
if (enterprise_installed()) {
$table->data[12][0] = __('Max. days before delete inventory data');
$table->data[12][1] = html_print_input_text(
$table->data[13][0] = __('Max. days before delete inventory data');
$table->data[13][1] = html_print_input_text(
'inventory_purge',
$config['inventory_purge'],
'',

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC220829';
$build_version = 'PC220831';
$pandora_version = 'v7.0NG.764';
// Do not overwrite default timezone set if defined.

View File

@ -816,6 +816,10 @@ function config_update_config()
$error_update[] = __('Max. days before delete unknown modules');
}
if (config_update_value('days_delete_not_initialized', (int) get_parameter('days_delete_not_initialized'), true) === false) {
$error_update[] = __('Max. days before delete not initialized modules');
}
if (config_update_value('days_compact', (int) get_parameter('days_compact'), true) === false) {
$error_update[] = __('Max. days before compact data');
}

View File

@ -774,6 +774,13 @@ function reporting_make_reporting_data(
);
break;
case 'modules_inventory':
$report['contents'][] = reporting_modules_inventory(
$report,
$content
);
break;
case 'inventory':
$report['contents'][] = reporting_inventory(
$report,
@ -2438,6 +2445,14 @@ function reporting_event_report_module(
}
/**
* Generate agents inventory report.
*
* @param array $report Report info.
* @param array $content Content info.
*
* @return array
*/
function reporting_agents_inventory($report, $content)
{
global $config;
@ -2470,7 +2485,7 @@ function reporting_agents_inventory($report, $content)
$custom_field_sql = '';
$search_sql = '';
if (!empty($es_agent_custom_fields)) {
if (empty(array_filter($es_agent_custom_fields)) === false) {
$custom_field_sql = 'INNER JOIN tagent_custom_data tacd ON tacd.id_agent = tagente.id_agente';
if ($es_agent_custom_fields[0] != 0) {
$custom_field_sql .= ' AND tacd.id_field IN ('.implode(',', $es_agent_custom_fields).')';
@ -2629,6 +2644,146 @@ function reporting_agents_inventory($report, $content)
}
/**
* Generate modules inventory report.
*
* @param array $report Report info.
* @param array $content Content info.
*
* @return array
*/
function reporting_modules_inventory($report, $content)
{
global $config;
$return['name'] = $content['name'];
$return['type'] = 'modules_inventory';
$return['title'] = $content['name'];
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$external_source = io_safe_input(json_decode($content['external_source'], true));
$es_agent_group_filter = $external_source['agent_group_filter'];
$module_group = $external_source['module_group'];
$es_agent_server_filter = $external_source['agent_server_filter'];
$search_sql = '';
if (empty($es_agent_group_filter) === false) {
$search_sql .= ' AND (ta.id_grupo = '.$es_agent_group_filter.' OR tasg.id_group = '.$es_agent_group_filter.')';
}
if (empty($module_group) === false && $module_group > -1) {
$search_sql .= ' AND tam.id_module_group = '.$module_group;
}
$user_groups_to_sql = '';
$user_groupsAR = users_get_groups($config['id_user'], 'AR');
$user_groups = $user_groupsAR;
$user_groups_to_sql = implode(',', array_keys($user_groups));
$sql = sprintf(
'SELECT tam.id_agente_modulo,
tam.nombre,
tam.descripcion,
tam.id_module_group,
ttm.id_tag,
ta.id_grupo AS group_id,
tasg.id_group AS sec_group_id
FROM tagente_modulo tam
INNER JOIN tagente ta
ON tam.id_agente = ta.id_agente
LEFT JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
LEFT JOIN ttag_module ttm
ON ttm.id_agente_modulo = tam.id_agente_modulo
WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)) %s',
$user_groups_to_sql,
$user_groups_to_sql,
$search_sql
);
if (is_metaconsole()) {
$servers_ids = array_column(metaconsole_get_servers(), 'id');
} else {
$servers_ids = [0];
}
$return_data = [];
foreach ($servers_ids as $server_id) {
if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id($server_id);
if ((int) $es_agent_server_filter !== 0
&& (int) $es_agent_server_filter !== (int) $server_id
) {
continue;
}
metaconsole_connect($server);
}
$agents = db_get_all_rows_sql($sql);
$return_data[$server_id] = $agents;
if (is_metaconsole()) {
metaconsole_restore_db();
}
}
$all_data = [];
foreach ($return_data as $server_agents) {
foreach ($server_agents as $agent) {
$all_data[] = $agent;
}
}
$return['data'] = $all_data;
$module_row_data = [];
foreach ($return['data'] as $row) {
if (is_array($module_row_data[$row['id_agente_modulo']]) === false) {
$module_row_data[$row['id_agente_modulo']]['nombre'] = $row['nombre'];
$module_row_data[$row['id_agente_modulo']]['descripcion'] = $row['descripcion'];
$module_row_data[$row['id_agente_modulo']]['id_module_group'] = $row['id_module_group'];
$module_row_data[$row['id_agente_modulo']]['id_tag'] = [];
$module_row_data[$row['id_agente_modulo']]['group_id'] = [];
$module_row_data[$row['id_agente_modulo']]['sec_group_id'] = [];
}
if (in_array($row['id_tag'], $module_row_data[$row['id_agente_modulo']]['id_tag']) === false
&& $row['id_tag'] !== null
) {
$module_row_data[$row['id_agente_modulo']]['id_tag'][] = $row['id_tag'];
}
if (in_array($row['group_id'], $module_row_data[$row['id_agente_modulo']]['group_id']) === false
&& $row['group_id'] !== null
) {
$module_row_data[$row['id_agente_modulo']]['group_id'][] = $row['group_id'];
}
if (in_array($row['sec_group_id'], $module_row_data[$row['id_agente_modulo']]['sec_group_id']) === false
&& $row['sec_group_id'] !== null
) {
$module_row_data[$row['id_agente_modulo']]['sec_group_id'][] = $row['sec_group_id'];
}
}
$return['data'] = $module_row_data;
return reporting_check_structure_content($return);
}
function reporting_inventory_changes($report, $content, $type)
{
global $config;

View File

@ -394,6 +394,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agents_inventory($table, $item);
break;
case 'modules_inventory':
reporting_html_modules_inventory($table, $item);
break;
case 'inventory':
reporting_html_inventory($table, $item);
break;
@ -1677,6 +1681,116 @@ function reporting_html_agents_inventory($table, $item, $pdf=0)
}
/**
* Print html modules inventory
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param boolean $pdf Print pdf true or false.
*
* @return string HTML code.
*/
function reporting_html_modules_inventory($table, $item, $pdf=0)
{
global $config;
$table1 = new stdClass();
$table1->width = '100%';
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->class = 'databox data';
$table1->cellpadding = 1;
$table1->cellspacing = 1;
$table1->styleTable = 'overflow: wrap; table-layout: fixed;';
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[1] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[2] = 'text-align: left;vertical-align: top; min-width: 100px';
$table1->style[3] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[4] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[5] = 'text-align: left;vertical-align: top; min-width: 100px';
$table1->head = [];
$table1->head[] = __('Name');
$table1->head[] = __('Description');
$table1->head[] = __('Module group');
$table1->head[] = __('Tags');
$table1->head[] = __('Agent group');
$table1->head[] = __('Agent secondary groups');
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
$table1->headstyle[3] = 'text-align: left';
$table1->headstyle[4] = 'text-align: left';
$table1->headstyle[5] = 'text-align: left';
$table1->data = [];
foreach ($item['data'] as $module_id => $module_data) {
$row = [];
$first_item = array_pop(array_reverse($module_data));
foreach ($module_data as $data_field_key => $data_field_value) {
if ($data_field_key === 'nombre') {
$column_value = $data_field_value;
} else if ($data_field_key === 'descripcion') {
$column_value = $data_field_value;
} else if ($data_field_key === 'id_module_group') {
$module_group_name = modules_get_modulegroup_name($data_field_value);
if ($module_group_name === '') {
$module_group_name = '-';
}
$column_value = $module_group_name;
} else if ($data_field_key === 'id_tag') {
$tags_names = array_map(
function ($tag_id) {
return db_get_value('name', 'ttag', 'id_tag', $tag_id);
},
$data_field_value
);
$column_value = implode('<br>', $tags_names);
} else if ($data_field_key === 'group_id') {
$column_value = groups_get_name($data_field_value[0]);
} else if ($data_field_key === 'sec_group_id') {
$sec_groups_names = array_map(function ($group_id) {
return groups_get_name($group_id);
},
$data_field_value
);
$column_value = implode('<br>', $sec_groups_names);
}
$row[] = $column_value;
}
$table1->data[] = $row;
if ($pdf !== 0) {
$table1->data[] = '<br />';
}
}
if ($pdf === 0) {
$table->colspan['permissions']['cell'] = 3;
$table->cellstyle['permissions']['cell'] = 'text-align: center;';
$table->data['permissions']['cell'] = html_print_table(
$table1,
true
);
} else {
return html_print_table(
$table1,
true
);
}
}
/**
* Print in html inventory changes reports
*

View File

@ -880,6 +880,13 @@ function reports_get_report_types($template=false, $not_editor=false)
];
}
if (!$template) {
$types['modules_inventory'] = [
'optgroup' => __('Inventory'),
'name' => __('Modules inventory'),
];
}
if ($config['enterprise_installed']) {
$types['inventory'] = [
'optgroup' => __('Inventory'),

View File

@ -129,7 +129,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.764';
$build = '220829';
$build = '220831';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.764
%define release 220829
%define release 220831
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.764
%define release 220829
%define release 220831
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.764
%define release 220829
%define release 220831
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -37,6 +37,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('block_size','20'),
('days_purge','45'),
('days_delete_unknown','0'),
('days_delete_not_initialized','0'),
('days_compact','0'),
('days_autodisable_deletion','30'),
('graph_res','5'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.764-220829
Version: 7.0NG.764-220831
Architecture: all
Priority: optional
Section: admin

View File

@ -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-220829"
pandora_version="7.0NG.764-220831"
package_cpan=0
package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.764";
my $pandora_build = "220829";
my $pandora_build = "220831";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.764";
my $pandora_build = "220829";
my $pandora_build = "220831";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.764
%define release 220829
%define release 220831
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.764
%define release 220829
%define release 220831
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.764"
PI_BUILD="220829"
PI_BUILD="220831"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.764 Build 220829";
my $version = "7.0NG.764 Build 220831";
# Pandora server configuration
my %conf;
@ -648,6 +648,8 @@ sub pandora_load_config_pdb ($) {
$conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'");
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
$conf->{'_days_delete_not_initialized'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_not_initialized'");
$conf->{'_delete_notinit'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_notinit'");
$conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'");
$conf->{'_delete_old_messages'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_messages'");
$conf->{'_delete_old_network_matrix'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_network_matrix'");
@ -836,6 +838,58 @@ sub pandora_checkdb_consistency {
usleep (100000);
}
}
# Perform a clean of not initialized modules.
if (defined($conf{'_days_delete_not_initialized'}) && $conf{'_days_delete_not_initialized'} > 0 && $conf->{'_delete_notinit'} eq "1") {
log_message ('CHECKDB',
"Deleting not initialized modules (More than " . $conf{'_days_delete_not_initialized'} . " days).");
my @modules = get_db_rows($dbh,
'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.id_agente
FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND (estado = 4 OR estado = 5)
AND utimestamp < UNIX_TIMESTAMP() - ?',
86400 * $conf{'_days_delete_not_initialized'});
foreach my $module (@modules) {
my $id_agente = $module->{'id_agente'};
my $id_agente_modulo = $module->{'id_agente_modulo'};
# Skip policy modules
my $is_policy_module = enterprise_hook('is_policy_module',
[$dbh, $id_agente_modulo]);
next if (defined($is_policy_module) && $is_policy_module);
# Mark the agent for module and alert counters update
db_do ($dbh,
'UPDATE tagente
SET update_module_count = 1, update_alert_count = 1
WHERE id_agente = ?', $id_agente);
# Delete the module
db_do ($dbh,
'DELETE FROM tagente_modulo
WHERE disabled = 0
AND id_agente_modulo = ?', $id_agente_modulo);
# Do a nanosleep here for 0,001 sec
usleep (100000);
# Delete any alerts associated to the module
db_do ($dbh, 'DELETE FROM talert_template_modules
WHERE id_agent_module = ?
AND NOT EXISTS (SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente_modulo = ?)',
$id_agente_modulo, $id_agente_modulo);
# Do a nanosleep here for 0,001 sec
usleep (100000);
}
}
log_message ('CHECKDB',
"Checking database consistency (Missing status).");

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.764 Build 220829";
my $version = "7.0NG.764 Build 220831";
# save program name for logging
my $progname = basename($0);
@ -1164,7 +1164,12 @@ sub cli_disable_group() {
}
my $result = pandora_disable_group ($conf, $dbh, $id_group);
if ($result != 0){
print_log "[INFO] Disabled ".$result." agents from group ".$group_name."\n\n";
} else {
print_log "[INFO] Disabled 0 agents from group ".$group_name."\n\n";
}
}
##############################################################################