bulk operations agents in meta #8290

This commit is contained in:
Daniel Barbero Martin 2022-01-24 12:19:09 +01:00
parent 7c2000c34d
commit 2fccdd12cb
7 changed files with 225 additions and 231 deletions

View File

@ -115,8 +115,6 @@ if (is_ajax() === true) {
$force_serialized = (bool) get_parameter('force_serialized', false); $force_serialized = (bool) get_parameter('force_serialized', false);
$nodes = (array) get_parameter('nodes', []); $nodes = (array) get_parameter('nodes', []);
hd($nodes, true);
if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) { if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',

View File

@ -63,9 +63,16 @@ function process_manage_delete($id_agents)
$count_deleted = 0; $count_deleted = 0;
$agent_id_restore = 0; $agent_id_restore = 0;
hd('borrando');
hd($id_agents);
foreach ($id_agents as $id_agent) { foreach ($id_agents as $id_agent) {
$success = agents_delete_agent($id_agent); hd($id_agent);
if (!$success) { // TODO:XXX.
// $success = agents_delete_agent($id_agent);
$success = false;
if ($success === false) {
$agent_id_restore = $id_agent; $agent_id_restore = $id_agent;
break; break;
} }
@ -73,11 +80,22 @@ function process_manage_delete($id_agents)
$count_deleted++; $count_deleted++;
} }
if (!$success) { if ($success === false) {
if (is_metaconsole() === true) {
$array_id = explode('|', $agent_id_restore);
$alias = agents_get_alias_metaconsole(
$array_id[1],
'none',
$array_id[0]
);
} else {
$alias = agents_get_alias($agent_id_restore);
}
ui_print_error_message( ui_print_error_message(
sprintf( sprintf(
__('There was an error deleting the agent, the operation has been cancelled Could not delete agent %s'), __('There was an error deleting the agent, the operation has been cancelled Could not delete agent %s'),
agents_get_name($agent_id_restore) $alias
) )
); );
@ -125,24 +143,6 @@ if ($delete === true) {
} }
} }
if (is_metaconsole() === false && is_management_allowed() === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. Bulk operations is read only. Go to %s to manage it.',
$url_link
)
);
}
$table = new stdClass; $table = new stdClass;
$table->id = 'delete_table'; $table->id = 'delete_table';
$table->class = 'databox filters'; $table->class = 'databox filters';
@ -291,10 +291,10 @@ $table->data[3][1] = html_print_select(
$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents'; $url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents';
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$ulr = 'index.php?sec=advanced&sec2=advanced/massive_operations&tab=massive_agents&pure=0&option=delete_agents'; $url = 'index.php?sec=advanced&sec2=advanced/massive_operations&tab=massive_agents&pure=0&option=delete_agents';
} }
echo '<form method="post" id="form_agents" action="'.$url.'">'; echo '<form method="post" id="from_agents" action="'.$url.'">';
html_print_table($table); html_print_table($table);
if (is_metaconsole() === true || is_management_allowed() === true) { if (is_metaconsole() === true || is_management_allowed() === true) {

View File

@ -38,13 +38,13 @@ if (! check_acl($config['id_user'], 0, 'AW')) {
return; return;
} }
require_once 'include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once 'include/functions_ui.php'; require_once $config['homedir'].'/include/functions_ui.php';
require_once 'include/functions_alerts.php'; require_once $config['homedir'].'/include/functions_alerts.php';
require_once 'include/functions_modules.php'; require_once $config['homedir'].'/include/functions_modules.php';
require_once 'include/functions_servers.php'; require_once $config['homedir'].'/include/functions_servers.php';
require_once 'include/functions_gis.php'; require_once $config['homedir'].'/include/functions_gis.php';
require_once 'include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
if (is_ajax()) { if (is_ajax()) {
@ -171,7 +171,7 @@ if ($update_agents) {
} }
} }
// CONF FILE DELETION // CONF FILE DELETION.
if (isset($values['delete_conf'])) { if (isset($values['delete_conf'])) {
unset($values['delete_conf']); unset($values['delete_conf']);
$n_deleted = 0; $n_deleted = 0;
@ -339,7 +339,7 @@ if ($update_agents) {
} }
$info = []; $info = [];
// Update Custom Fields // Update Custom Fields.
foreach ($fields as $field) { foreach ($fields as $field) {
$info[$field['id_field']] = $field['name']; $info[$field['id_field']] = $field['name'];
$value = get_parameter('customvalue_'.$field['id_field']); $value = get_parameter('customvalue_'.$field['id_field']);
@ -354,7 +354,7 @@ if ($update_agents) {
); );
if ($old_value === false) { if ($old_value === false) {
// Create custom field if not exist // Create custom field if not exist.
$result = db_process_sql_insert( $result = db_process_sql_insert(
'tagent_custom_data', 'tagent_custom_data',
[ [
@ -400,8 +400,6 @@ if ($update_agents) {
$id_group = 0; $id_group = 0;
$groups = users_get_groups();
$table = new StdClass(); $table = new StdClass();
$table->id = 'delete_table'; $table->id = 'delete_table';
$table->class = 'databox filters'; $table->class = 'databox filters';
@ -479,8 +477,11 @@ $table->data[2][0] = __('Agents');
$table->data[2][0] .= '<span id="agent_loading" class="invisible">'; $table->data[2][0] .= '<span id="agent_loading" class="invisible">';
$table->data[2][0] .= html_print_image('images/spinner.png', true); $table->data[2][0] .= html_print_image('images/spinner.png', true);
$table->data[2][0] .= '</span>'; $table->data[2][0] .= '</span>';
$enabled_agents = agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false)), ['disabled' => 0], 'none'); $all_agents = agents_get_group_agents(
$all_agents = (agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false)), ['disabled' => 1], 'none') + $enabled_agents); array_keys(users_get_groups($config['id_user'], 'AW', false)),
false,
'none'
);
$table->data[2][1] = html_print_select( $table->data[2][1] = html_print_select(
$all_agents, $all_agents,
@ -490,6 +491,21 @@ $table->data[2][1] = html_print_select(
'', '',
'', '',
true, true,
true,
true,
'',
false,
'min-width: 500px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true true
); );
@ -523,9 +539,6 @@ $table->size[3] = '35%';
$table->data = []; $table->data = [];
$groups = users_get_groups($config['id_user'], 'AW', false);
$agents = agents_get_group_agents(array_keys($groups));
$modules = db_get_all_rows_sql( $modules = db_get_all_rows_sql(
'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
WHERE id_agente = '.$id_parent WHERE id_agente = '.$id_parent
@ -610,7 +623,7 @@ $table->data[3][1] .= ' <span id="os_preview">';
$table->data[3][1] .= ui_print_os_icon($id_os, false, true); $table->data[3][1] .= ui_print_os_icon($id_os, false, true);
$table->data[3][1] .= '</span>'; $table->data[3][1] .= '</span>';
// Network server // Network server.
$none = ''; $none = '';
if ($server_name == '' && $id_agente) { if ($server_name == '' && $id_agente) {
$none = __('None'); $none = __('None');
@ -632,7 +645,7 @@ $table->data[4][1] = html_print_select(
'width: 150px;' 'width: 150px;'
); );
// Description // Description.
$table->data[5][0] = __('Description'); $table->data[5][0] = __('Description');
$table->data[5][1] = html_print_input_text('description', $description, '', 45, 255, true); $table->data[5][1] = html_print_input_text('description', $description, '', 45, 255, true);
@ -663,27 +676,27 @@ $table->style = [];
$table->style[0] = 'font-weight: bold; width: 150px;'; $table->style[0] = 'font-weight: bold; width: 150px;';
$table->data = []; $table->data = [];
// Custom ID // Custom ID.
$table->data[0][0] = __('Custom ID'); $table->data[0][0] = __('Custom ID');
$table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true); $table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true);
// Learn mode / Normal mode // Learn mode / Normal mode.
$table->data[1][0] = __('Module definition'); $table->data[1][0] = __('Module definition');
$table->data[1][1] = __('No change').' '.html_print_radio_button_extended('mode', -1, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] = __('No change').' '.html_print_radio_button_extended('mode', -1, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] .= __('Learning mode').' '.html_print_radio_button_extended('mode', 1, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= __('Learning mode').' '.html_print_radio_button_extended('mode', 1, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] .= __('Normal mode').' '.html_print_radio_button_extended('mode', 0, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= __('Normal mode').' '.html_print_radio_button_extended('mode', 0, '', $mode, false, '', 'class="mrgn_right_40px"', true);
$table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extended('mode', 2, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extended('mode', 2, '', $mode, false, '', 'class="mrgn_right_40px"', true);
// Status (Disabled / Enabled) // Status (Disabled / Enabled).
$table->data[2][0] = __('Status'); $table->data[2][0] = __('Status');
$table->data[2][1] = __('No change').' '.html_print_radio_button_extended('disabled', -1, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[2][1] = __('No change').' '.html_print_radio_button_extended('disabled', -1, '', $disabled, false, '', 'class="mrgn_right_40px"', true);
$table->data[2][1] .= __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[2][1] .= __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'class="mrgn_right_40px"', true);
$table->data[2][1] .= __('Active').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[2][1] .= __('Active').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'class="mrgn_right_40px"', true);
// Remote configuration // Remote configuration.
$table->data[3][0] = __('Remote configuration'); $table->data[3][0] = __('Remote configuration');
// Delete remote configuration // Delete remote configuration.
$table->data[3][1] = '<div id="delete_configurations" class="invisible">'.__('Delete available remote configurations').' ('; $table->data[3][1] = '<div id="delete_configurations" class="invisible">'.__('Delete available remote configurations').' (';
$table->data[3][1] .= '<span id="n_configurations"></span>'; $table->data[3][1] .= '<span id="n_configurations"></span>';
$table->data[3][1] .= ') '.html_print_checkbox_extended('delete_conf', 1, 0, false, '', 'class="mrgn_right_40px"', true).'</div>'; $table->data[3][1] .= ') '.html_print_checkbox_extended('delete_conf', 1, 0, false, '', 'class="mrgn_right_40px"', true).'</div>';
@ -701,7 +714,7 @@ $path = 'images/gis_map/icons/';
// TODO set better method the path // TODO set better method the path
if ($icon_path == '') { if ($icon_path == '') {
$display_icons = 'none'; $display_icons = 'none';
// Hack to show no icon. Use any given image to fix not found image errors // Hack to show no icon. Use any given image to fix not found image errors.
$path_without = 'images/spinner.png'; $path_without = 'images/spinner.png';
$path_default = 'images/spinner.png'; $path_default = 'images/spinner.png';
$path_ok = 'images/spinner.png'; $path_ok = 'images/spinner.png';
@ -865,7 +878,6 @@ var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?
//Use this function for change 3 icons when change the selectbox //Use this function for change 3 icons when change the selectbox
$(document).ready (function () { $(document).ready (function () {
var checked = $("#cascade_protection").val(); var checked = $("#cascade_protection").val();
$("#cascade_protection_module").attr("disabled", 'disabled'); $("#cascade_protection_module").attr("disabled", 'disabled');
$("#cascade_protection").change(function () { $("#cascade_protection").change(function () {
@ -892,9 +904,9 @@ $(document).ready (function () {
$("#safe_mode_module").attr("disabled", "disabled"); $("#safe_mode_module").attr("disabled", "disabled");
$('#safe_mode_module').empty(); $('#safe_mode_module').empty();
$("#safe_mode_module").append($("<option></option>").attr("value", 'Any').html('Any')); $("#safe_mode_module").append($("<option></option>").attr("value", 'Any').html('Any'));
} }
}); });
// Fill modules in Safe Operation Mode. // Fill modules in Safe Operation Mode.
function refreshSafeModules(){ function refreshSafeModules(){
var idAgents = Array(); var idAgents = Array();
@ -908,7 +920,7 @@ $(document).ready (function () {
"id_agent" : idAgents, "id_agent" : idAgents,
"selection_mode": "common" "selection_mode": "common"
}; };
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
params, params,
function (data, status) { function (data, status) {
@ -927,15 +939,14 @@ $(document).ready (function () {
); );
} }
$("#form_agent").submit(function() { $("#form_agent").submit(function() {
var get_parameters_count = window.location.href.slice( var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length; window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_agent").serializeArray().length; var post_parameters_count = $("#form_agent").serializeArray().length;
var count_parameters = var count_parameters =
get_parameters_count + post_parameters_count; get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) { if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>"); alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false; return false;
@ -978,19 +989,19 @@ $(document).ready (function () {
refreshSafeModules(); refreshSafeModules();
} }
}); });
$("#id_group").change (function () { $("#id_group").change (function () {
$("#form_agents").attr("style", "display: none"); $("#form_agents").attr("style", "display: none");
}); });
$("select#id_os").pandoraSelectOS (); $("select#id_os").pandoraSelectOS ();
var recursion; var recursion;
$("#checkbox-recursion2").click(function () { $("#checkbox-recursion2").click(function () {
recursion = this.checked ? 1 : 0; recursion = this.checked ? 1 : 0;
$("#id_group").trigger("change"); $("#id_group").trigger("change");
}); });
$("#id_group").pandoraSelectGroupAgent ({ $("#id_group").pandoraSelectGroupAgent ({
status_agents: function () { status_agents: function () {
return $("#status_agents").val(); return $("#status_agents").val();
@ -1004,27 +1015,26 @@ $(document).ready (function () {
return disabled; return disabled;
} }
}); });
$("#status_agents").change(function() { $("#status_agents").change(function() {
$("#id_group").trigger("change"); $("#id_group").trigger("change");
}); });
disabled = 2; disabled = 2;
$("#id_group").trigger("change"); //$("#id_group").trigger("change");
}); });
function changeIcons() { function changeIcons() {
var icon = $("#icon_path :selected").val(); var icon = $("#icon_path :selected").val();
$("#icon_without_status").attr("src", "images/spinner.png"); $("#icon_without_status").attr("src", "images/spinner.png");
$("#icon_default").attr("src", "images/spinner.png"); $("#icon_default").attr("src", "images/spinner.png");
$("#icon_ok").attr("src", "images/spinner.png"); $("#icon_ok").attr("src", "images/spinner.png");
$("#icon_bad").attr("src", "images/spinner.png"); $("#icon_bad").attr("src", "images/spinner.png");
$("#icon_warning").attr("src", "images/spinner.png"); $("#icon_warning").attr("src", "images/spinner.png");
if (icon.length == 0) { if (icon.length == 0) {
$("#icon_without_status").attr("style", "display:none;"); $("#icon_without_status").attr("style", "display:none;");
$("#icon_default").attr("style", "display:none;"); $("#icon_default").attr("style", "display:none;");

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -29,6 +29,8 @@
// Begin. // Begin.
check_login(); check_login();
global $config;
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -38,16 +40,20 @@ if (! check_acl($config['id_user'], 0, 'AW')) {
return; return;
} }
require_once 'include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once 'include/functions_alerts.php'; require_once $config['homedir'].'/include/functions_alerts.php';
require_once 'include/functions_modules.php'; require_once $config['homedir'].'/include/functions_modules.php';
require_once 'include/functions_massive_operations.php'; require_once $config['homedir'].'/include/functions_massive_operations.php';
enterprise_include('godmode/massive/massive_operations.php'); enterprise_include('godmode/massive/massive_operations.php');
$tab = (string) get_parameter('tab', 'massive_agents'); $tab = (string) get_parameter('tab', 'massive_agents');
$option = (string) get_parameter('option'); $option = (string) get_parameter('option');
$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations';
if (is_metaconsole() === true) {
$url = 'index.php?sec=advanced&sec2=advanced/massive_operations&tab=massive_agents&pure=0';
}
$options_alerts = [ $options_alerts = [
'add_alerts' => __('Bulk alert add'), 'add_alerts' => __('Bulk alert add'),
@ -62,6 +68,11 @@ $options_agents = [
'edit_agents' => __('Bulk agent edit'), 'edit_agents' => __('Bulk agent edit'),
'delete_agents' => __('Bulk agent delete'), 'delete_agents' => __('Bulk agent delete'),
]; ];
if (is_metaconsole() === true) {
$options_agents = [
'delete_agents' => __('Bulk agent delete'),
];
}
if (check_acl($config['id_user'], 0, 'UM')) { if (check_acl($config['id_user'], 0, 'UM')) {
$options_users = [ $options_users = [
@ -114,28 +125,31 @@ if ($options_services === ENTERPRISE_NOT_HOOK) {
} }
if (in_array($option, array_keys($options_alerts))) { if (in_array($option, array_keys($options_alerts)) === true) {
$tab = 'massive_alerts'; $tab = 'massive_alerts';
} else if (in_array($option, array_keys($options_agents))) { } else if (in_array($option, array_keys($options_agents)) === true) {
$tab = 'massive_agents'; $tab = 'massive_agents';
} else if (in_array($option, array_keys($options_users))) { } else if (in_array($option, array_keys($options_users)) === true) {
$tab = 'massive_users'; $tab = 'massive_users';
} else if (in_array($option, array_keys($options_modules))) { } else if (in_array($option, array_keys($options_modules)) === true) {
$tab = 'massive_modules'; $tab = 'massive_modules';
} else if (in_array($option, array_keys($options_policies))) { } else if (in_array($option, array_keys($options_policies)) === true) {
$tab = 'massive_policies'; $tab = 'massive_policies';
} else if (in_array($option, array_keys($options_snmp))) { } else if (in_array($option, array_keys($options_snmp)) === true) {
$tab = 'massive_snmp'; $tab = 'massive_snmp';
} else if (in_array($option, array_keys($options_satellite))) { } else if (in_array($option, array_keys($options_satellite)) === true) {
$tab = 'massive_satellite'; $tab = 'massive_satellite';
} else if (in_array($option, array_keys($options_plugins))) { } else if (in_array($option, array_keys($options_plugins)) === true) {
$tab = 'massive_plugins'; $tab = 'massive_plugins';
} else if (in_array($option, array_keys($options_services))) { } else if (in_array($option, array_keys($options_services)) === true) {
$tab = 'massive_services'; $tab = 'massive_services';
} }
if ($tab == 'massive_agents' && $option == '') { if ($tab === 'massive_agents' && empty($option) === true) {
$option = 'edit_agents'; $option = 'edit_agents';
if (is_metaconsole() === true) {
$option = 'delete_agents';
}
} }
if ($tab == 'massive_modules' && $option == '') { if ($tab == 'massive_modules' && $option == '') {
@ -212,7 +226,7 @@ if ($option == '') {
} }
$alertstab = [ $alertstab = [
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'.html_print_image( 'text' => '<a href="'.$url.'&tab=massive_alerts">'.html_print_image(
'images/bell.png', 'images/bell.png',
true, true,
[ [
@ -224,7 +238,7 @@ $alertstab = [
]; ];
$userstab = [ $userstab = [
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">'.html_print_image( 'text' => '<a href="'.$url.'&tab=massive_users">'.html_print_image(
'images/user.png', 'images/user.png',
true, true,
[ [
@ -236,7 +250,7 @@ $userstab = [
]; ];
$agentstab = [ $agentstab = [
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">'.html_print_image( 'text' => '<a href="'.$url.'&tab=massive_agents">'.html_print_image(
'images/agent.png', 'images/agent.png',
true, true,
[ [
@ -247,138 +261,116 @@ $agentstab = [
'active' => $tab == 'massive_agents', 'active' => $tab == 'massive_agents',
]; ];
$modulestab = [ $modulestab = [
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">'.html_print_image( 'text' => '<a href="'.$url.'&tab=massive_modules">'.html_print_image(
'images/module.png', 'images/module.png',
true, true,
[ [
'title' => __('Modules operations'), 'title' => __('Modules operations'),
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>', ).'</a>',
'active' => $tab == 'massive_modules', 'active' => $tab == 'massive_modules',
]; ];
$pluginstab = [ $pluginstab = [
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_plugins">'.html_print_image( 'text' => '<a href="'.$url.'&tab=massive_plugins">'.html_print_image(
'images/plugin.png', 'images/plugin.png',
true, true,
[ [
'title' => __('Plugins operations'), 'title' => __('Plugins operations'),
'class' => 'invert_filter', 'class' => 'invert_filter',
] ]
).'</a>', ).'</a>',
'active' => $tab == 'massive_plugins', 'active' => $tab == 'massive_plugins',
]; ];
$policiestab = enterprise_hook('massive_policies_tab'); $policiestab = enterprise_hook('massive_policies_tab');
if ($policiestab == ENTERPRISE_NOT_HOOK) { if ($policiestab == ENTERPRISE_NOT_HOOK) {
$policiestab = ''; $policiestab = '';
} }
$snmptab = enterprise_hook('massive_snmp_tab'); $snmptab = enterprise_hook('massive_snmp_tab');
if ($snmptab == ENTERPRISE_NOT_HOOK) { if ($snmptab == ENTERPRISE_NOT_HOOK) {
$snmptab = ''; $snmptab = '';
} }
$satellitetab = enterprise_hook('massive_satellite_tab'); $satellitetab = enterprise_hook('massive_satellite_tab');
if ($satellitetab == ENTERPRISE_NOT_HOOK) { if ($satellitetab == ENTERPRISE_NOT_HOOK) {
$satellitetab = ''; $satellitetab = '';
} }
$servicestab = enterprise_hook('massive_services_tab'); $servicestab = enterprise_hook('massive_services_tab');
if ($servicestab == ENTERPRISE_NOT_HOOK) { if ($servicestab == ENTERPRISE_NOT_HOOK) {
$servicestab = ''; $servicestab = '';
} }
$onheader = []; $onheader = [];
$onheader['massive_agents'] = $agentstab; $onheader['massive_agents'] = $agentstab;
$onheader['massive_modules'] = $modulestab; $onheader['massive_modules'] = $modulestab;
$onheader['massive_plugins'] = $pluginstab; $onheader['massive_plugins'] = $pluginstab;
if (check_acl($config['id_user'], 0, 'UM')) { if (check_acl($config['id_user'], 0, 'UM')) {
$onheader['user_agents'] = $userstab; $onheader['user_agents'] = $userstab;
} }
$onheader['massive_alerts'] = $alertstab; $onheader['massive_alerts'] = $alertstab;
$onheader['policies'] = $policiestab; $onheader['policies'] = $policiestab;
$onheader['snmp'] = $snmptab; $onheader['snmp'] = $snmptab;
$onheader['satellite'] = $satellitetab; $onheader['satellite'] = $satellitetab;
$onheader['services'] = $servicestab; $onheader['services'] = $servicestab;
/* // Header.
Hello there! :) if (is_metaconsole() === false) {
ui_print_page_header(
__('Bulk operations').' &raquo; '.$options[$option],
'images/gm_massive_operations.png',
false,
$help_header,
true,
$onheader,
false,
'massivemodal'
);
} else {
massive_meta_print_header();
}
We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :( // Checks if the PHP configuration is correctly.
if ((get_cfg_var('max_execution_time') != 0)
|| (get_cfg_var('max_input_time') != -1)
) {
echo '<div id="notify_conf" class="notify">';
echo __('In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: <i>sudo vi /etc/php5/apache2/php.ini;</i><br> And set your timeout parameters to a correct value: <br><i> max_execution_time = 0</i> and <i>max_input_time = -1</i>');
echo '</div>';
}
You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years. // Catch all submit operations in this view to display Wait banner.
$submit_action = get_parameter('go');
$submit_update = get_parameter('updbutton');
$submit_del = get_parameter('del');
$submit_template_disabled = get_parameter('id_alert_template_disabled');
$submit_template_enabled = get_parameter('id_alert_template_enabled');
$submit_template_not_standby = get_parameter('id_alert_template_not_standby');
$submit_template_standby = get_parameter('id_alert_template_standby');
$submit_add = get_parameter('crtbutton');
// Waiting spinner.
ui_print_spinner(__('Loading'));
// Modal for show messages.
html_print_div(
[
'id' => 'massive_modal',
'content' => '',
]
);
*/ // Load common JS files.
ui_require_javascript_file('massive_operations');
ui_print_page_header( ?>
__('Bulk operations').' &raquo; '.$options[$option],
'images/gm_massive_operations.png',
false,
$help_header,
true,
$onheader,
false,
'massivemodal'
);
// Checks if the PHP configuration is correctly.
if ((get_cfg_var('max_execution_time') != 0)
|| (get_cfg_var('max_input_time') != -1)
) {
echo '<div id="notify_conf" class="notify">';
echo __('In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: <i>sudo vi /etc/php5/apache2/php.ini;</i><br> And set your timeout parameters to a correct value: <br><i> max_execution_time = 0</i> and <i>max_input_time = -1</i>');
echo '</div>';
}
if ($tab == 'massive_policies' && is_management_allowed() === false) {
if (is_metaconsole() === false) {
$url = '<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/policymanager'
).'">'.__('metaconsole').'</a>';
} else {
$url = __('any node');
}
ui_print_warning_message(
__(
'This node is configured with centralized mode. All policies information is read only. Go to %s to manage it.',
$url
)
);
return;
}
// Catch all submit operations in this view to display Wait banner.
$submit_action = get_parameter('go');
$submit_update = get_parameter('updbutton');
$submit_del = get_parameter('del');
$submit_template_disabled = get_parameter('id_alert_template_disabled');
$submit_template_enabled = get_parameter('id_alert_template_enabled');
$submit_template_not_standby = get_parameter('id_alert_template_not_standby');
$submit_template_standby = get_parameter('id_alert_template_standby');
$submit_add = get_parameter('crtbutton');
// Waiting spinner.
ui_print_spinner(__('Loading'));
// Modal for show messages.
html_print_div(
[
'id' => 'massive_modal',
'content' => '',
]
);
// Load common JS files.
ui_require_javascript_file('massive_operations');
?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
@ -411,25 +403,25 @@ $agentstab = [
</script> </script>
<?php <?php
if (is_management_allowed() === false && $option == 'delete_agents') { if (is_management_allowed() === false) {
if (is_metaconsole() === false) { if (is_metaconsole() === false) {
$url = '<a target="_blank" href="'.ui_get_meta_url( $text_warning = '<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=monitoring&sec2=monitoring/wizard/wizard' 'index.php?sec=monitoring&sec2=monitoring/wizard/wizard'
).'">'.__('metaconsole').'</a>'; ).'">'.__('metaconsole').'</a>';
} else { } else {
$url = __('any node'); $text_warning = __('any node');
} }
ui_print_warning_message( ui_print_warning_message(
__( __(
'This node is configured with centralized mode. To delete agents go to %s', 'This node is configured with centralized mode. To delete agents go to %s',
$url $text_warning
) )
); );
} }
echo '<br />'; echo '<br />';
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">'; echo '<form method="post" id="form_options" action="'.$url.'">';
echo '<table border="0"><tr><td>'; echo '<table border="0"><tr><td>';
echo __('Action'); echo __('Action');
echo '</td><td>'; echo '</td><td>';
@ -444,7 +436,7 @@ html_print_select(
false, false,
false false
); );
if ($option == 'edit_agents' || $option == 'edit_modules') { if ($option === 'edit_agents' || $option === 'edit_modules') {
ui_print_help_tip(__('The blank fields will not be updated')); ui_print_help_tip(__('The blank fields will not be updated'));
} }
@ -454,64 +446,64 @@ echo '<br />';
switch ($option) { switch ($option) {
case 'delete_alerts': case 'delete_alerts':
include_once 'godmode/massive/massive_delete_alerts.php'; include_once $config['homedir'].'/godmode/massive/massive_delete_alerts.php';
break; break;
case 'add_alerts': case 'add_alerts':
include_once 'godmode/massive/massive_add_alerts.php'; include_once $config['homedir'].'/godmode/massive/massive_add_alerts.php';
break; break;
case 'delete_action_alerts': case 'delete_action_alerts':
include_once 'godmode/massive/massive_delete_action_alerts.php'; include_once $config['homedir'].'/godmode/massive/massive_delete_action_alerts.php';
break; break;
case 'add_action_alerts': case 'add_action_alerts':
include_once 'godmode/massive/massive_add_action_alerts.php'; include_once $config['homedir'].'/godmode/massive/massive_add_action_alerts.php';
break; break;
case 'enable_disable_alerts': case 'enable_disable_alerts':
include_once 'godmode/massive/massive_enable_disable_alerts.php'; include_once $config['homedir'].'/godmode/massive/massive_enable_disable_alerts.php';
break; break;
case 'standby_alerts': case 'standby_alerts':
include_once 'godmode/massive/massive_standby_alerts.php'; include_once $config['homedir'].'/godmode/massive/massive_standby_alerts.php';
break; break;
case 'add_profiles': case 'add_profiles':
include_once 'godmode/massive/massive_add_profiles.php'; include_once $config['homedir'].'/godmode/massive/massive_add_profiles.php';
break; break;
case 'delete_profiles': case 'delete_profiles':
include_once 'godmode/massive/massive_delete_profiles.php'; include_once $config['homedir'].'/godmode/massive/massive_delete_profiles.php';
break; break;
case 'delete_agents': case 'delete_agents':
include_once 'godmode/massive/massive_delete_agents.php'; include_once $config['homedir'].'/godmode/massive/massive_delete_agents.php';
break; break;
case 'edit_agents': case 'edit_agents':
include_once 'godmode/massive/massive_edit_agents.php'; include_once $config['homedir'].'/godmode/massive/massive_edit_agents.php';
break; break;
case 'delete_modules': case 'delete_modules':
include_once 'godmode/massive/massive_delete_modules.php'; include_once $config['homedir'].'/godmode/massive/massive_delete_modules.php';
break; break;
case 'edit_modules': case 'edit_modules':
include_once 'godmode/massive/massive_edit_modules.php'; include_once $config['homedir'].'/godmode/massive/massive_edit_modules.php';
break; break;
case 'copy_modules': case 'copy_modules':
include_once 'godmode/massive/massive_copy_modules.php'; include_once $config['homedir'].'/godmode/massive/massive_copy_modules.php';
break; break;
case 'edit_plugins': case 'edit_plugins':
include_once 'godmode/massive/massive_edit_plugins.php'; include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php';
break; break;
default: default:
if (!enterprise_hook('massive_operations', [$option])) { if (!enterprise_hook('massive_operations', [$option])) {
include_once 'godmode/massive/massive_config.php'; include_once $config['homedir'].'/godmode/massive/massive_config.php';
} }
break; break;
} }

View File

@ -1369,10 +1369,6 @@ function agents_get_group_agents(
]; ];
} }
hd($table_name, true);
hd($filter, true);
hd($fields, true);
$result = db_get_all_rows_filter($table_name, $filter, $fields); $result = db_get_all_rows_filter($table_name, $filter, $fields);
if ($result === false) { if ($result === false) {

View File

@ -77,8 +77,6 @@
: config.disabled : config.disabled
}; };
console.log(opts);
jQuery.post( jQuery.post(
"ajax.php", "ajax.php",
opts, opts,

View File

@ -1,4 +1,4 @@
/** global $ */ /* global $, confirmDialog, showSpinner, hideSpinner */
function massiveOperationValidation(contents, totalCount, limit, thisForm) { function massiveOperationValidation(contents, totalCount, limit, thisForm) {
var output = false; var output = false;