Merge remote-tracking branch 'origin/develop' into ent-7074-Command-Center
Conflicts: pandora_console/extras/mr/46.sql
This commit is contained in:
commit
e5b2a27631
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.753-210406
|
||||
Version: 7.0NG.753-210407
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.753-210406"
|
||||
pandora_version="7.0NG.753-210407"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1016,7 +1016,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.753';
|
||||
use constant AGENT_BUILD => '210406';
|
||||
use constant AGENT_BUILD => '210407';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.753"
|
||||
PI_BUILD="210406"
|
||||
PI_BUILD="210407"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{210406}
|
||||
{210407}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.753(Build 210406)")
|
||||
#define PANDORA_VERSION ("7.0NG.753(Build 210407)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.753(Build 210406))"
|
||||
VALUE "ProductVersion", "(7.0NG.753(Build 210407))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.753-210406
|
||||
Version: 7.0NG.753-210407
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.753-210406"
|
||||
pandora_version="7.0NG.753-210407"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `info_merge` MEDIUMTEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE `tagent_custom_fields` MODIFY COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
|
||||
COMMIT;
|
|
@ -2519,7 +2519,7 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di
|
|||
-- ----------------------------------------------------------------------
|
||||
-- Add column in table `tagent_custom_fields`
|
||||
-- ----------------------------------------------------------------------
|
||||
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT '';
|
||||
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Add column in table `tnetflow_filter`
|
||||
|
|
|
@ -24,6 +24,14 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'],
|
|||
return;
|
||||
}
|
||||
|
||||
\ui_print_page_header(
|
||||
__('Monitoring').' » '.__('Clusters'),
|
||||
'images/chart.png',
|
||||
false,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
ui_require_css_file('first_task');
|
||||
?>
|
||||
<?php
|
||||
|
|
|
@ -931,24 +931,19 @@ foreach ($fields as $field) {
|
|||
}
|
||||
|
||||
if ($field['combo_values'] !== '') {
|
||||
$data_field[1] = html_print_select(
|
||||
$combo_values,
|
||||
'customvalue_'.$field['id_field'],
|
||||
$custom_value,
|
||||
'',
|
||||
__('None'),
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
$data_field[1] = html_print_input(
|
||||
[
|
||||
'type' => 'select_search',
|
||||
'fields' => $combo_values,
|
||||
'name' => 'customvalue_'.$field['id_field'],
|
||||
'selected' => $custom_value,
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => '',
|
||||
'return' => true,
|
||||
'sort' => false,
|
||||
'size' => '400px',
|
||||
'dropdownAutoWidth' => true,
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -400,7 +400,7 @@ if ($id_agente) {
|
|||
|
||||
// Module tab.
|
||||
$moduletab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente.'">'.html_print_image(
|
||||
'images/module.png',
|
||||
'images/gm_modules.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Modules'),
|
||||
|
@ -416,7 +416,7 @@ if ($id_agente) {
|
|||
|
||||
// Alert tab.
|
||||
$alerttab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'">'.html_print_image(
|
||||
'images/bell.png',
|
||||
'images/gm_alerts.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Alerts'),
|
||||
|
|
|
@ -33,7 +33,7 @@ if ($id_field) {
|
|||
$name = $field['name'];
|
||||
$display_on_front = $field['display_on_front'];
|
||||
$is_password_type = $field['is_password_type'];
|
||||
$combo_values = $field['combo_values'];
|
||||
$combo_values = $field['combo_values'] ? $field['combo_values'] : '';
|
||||
$is_combo_enable = $config['is_combo_enable'];
|
||||
ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, '');
|
||||
} else {
|
||||
|
@ -116,12 +116,12 @@ $table->data[4][0] = __('Combo values').ui_print_help_tip(
|
|||
__('Set values separated by comma'),
|
||||
true
|
||||
);
|
||||
$table->data[4][1] = html_print_input_text(
|
||||
$table->data[4][1] = html_print_textarea(
|
||||
'combo_values',
|
||||
3,
|
||||
65,
|
||||
io_safe_output($combo_values),
|
||||
'',
|
||||
35,
|
||||
200,
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -144,7 +144,7 @@ echo '</form>';
|
|||
|
||||
<script>
|
||||
$(document).ready (function () {
|
||||
if($('input[type=hidden][name=update_field]').val() == 1 && $('input[type=text][name=combo_values]').val() != ''){
|
||||
if($('input[type=hidden][name=update_field]').val() == 1 && $('#textarea_combo_values').val() != ''){
|
||||
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||
$('#configure_field-4').show();
|
||||
$('input[type=checkbox][name=is_password_type]').change(function (e) {
|
||||
|
@ -155,7 +155,7 @@ $(document).ready (function () {
|
|||
e.preventDefault();
|
||||
});
|
||||
$('input[type=checkbox][name=is_combo_enable]').change(function (e) {
|
||||
if($('input[type=text][name=combo_values]').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){
|
||||
if($('#textarea_combo_values').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){
|
||||
dialog_message("#message_set_combo");
|
||||
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||
$('#configure_field-4').show();
|
||||
|
|
|
@ -46,6 +46,8 @@ $create_command = (bool) get_parameter('create_command');
|
|||
$delete_command = (bool) get_parameter('delete_command');
|
||||
$copy_command = (bool) get_parameter('copy_command');
|
||||
|
||||
$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands';
|
||||
|
||||
if (is_ajax()) {
|
||||
$get_alert_command = (bool) get_parameter('get_alert_command');
|
||||
if ($get_alert_command) {
|
||||
|
@ -634,6 +636,12 @@ if ($commands === false) {
|
|||
$commands = [];
|
||||
}
|
||||
|
||||
// Pagination.
|
||||
$total_commands = count($commands);
|
||||
$offset = (int) get_parameter('offset');
|
||||
$limit = (int) $config['block_size'];
|
||||
$commands = array_slice($commands, $offset, $limit);
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$data = [];
|
||||
|
||||
|
@ -678,10 +686,17 @@ foreach ($commands as $command) {
|
|||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
if (count($table->data) > 0) {
|
||||
ui_pagination($total_commands, $url);
|
||||
if (isset($data) === true && count($table->data) > 0) {
|
||||
html_print_table($table);
|
||||
ui_pagination($total_commands, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]);
|
||||
ui_print_info_message(
|
||||
[
|
||||
'no_close' => true,
|
||||
'message' => __('No alert commands configured'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {
|
||||
|
@ -716,4 +731,4 @@ enterprise_hook('close_meta_frame');
|
|||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -882,9 +882,11 @@ foreach ($simple_alerts as $alert) {
|
|||
['title' => __('Add action')]
|
||||
);
|
||||
} else {
|
||||
$data[4] .= '<a href="javascript:show_add_action(\''.$alert['id'].'\');">';
|
||||
$data[4] .= html_print_image('images/add.png', true, ['title' => __('Add action'), 'class' => 'invert_filter']);
|
||||
$data[4] .= '</a>';
|
||||
if ((int) $alert['id_policy_alerts'] === 0) {
|
||||
$data[4] .= '<a href="javascript:show_add_action(\''.$alert['id'].'\');">';
|
||||
$data[4] .= html_print_image('images/add.png', true, ['title' => __('Add action'), 'class' => 'invert_filter']);
|
||||
$data[4] .= '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ require_once $config['homedir'].'/include/functions_groups.php';
|
|||
require_once $config['homedir'].'/include/functions_agents.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
if (is_metaconsole()) {
|
||||
if (is_metaconsole() === true) {
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
enterprise_include_once('meta/include/functions_agents_meta.php');
|
||||
enterprise_hook('open_meta_frame');
|
||||
}
|
||||
|
||||
if (is_ajax()) {
|
||||
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||
if (is_ajax() === true) {
|
||||
if (check_acl($config['id_user'], 0, 'AR') === false) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access Group Management');
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
|
@ -56,10 +56,10 @@ if (is_ajax()) {
|
|||
$get_group_agents = (bool) get_parameter('get_group_agents');
|
||||
$get_is_disabled = (bool) get_parameter('get_is_disabled');
|
||||
|
||||
if ($get_group_json) {
|
||||
if ($get_group_json === true) {
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
|
||||
if ($id_group == 0) {
|
||||
if ($id_group === 0) {
|
||||
$group = [
|
||||
'id_grupo' => 0,
|
||||
'nombre' => 'All',
|
||||
|
@ -72,7 +72,7 @@ if (is_ajax()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (! check_acl($config['id_user'], $id_group, 'AR')) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AR') === false) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Alert Management'
|
||||
|
@ -87,7 +87,7 @@ if (is_ajax()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($get_group_agents) {
|
||||
if ($get_group_agents === true) {
|
||||
ob_clean();
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$disabled = (int) get_parameter('disabled', 0);
|
||||
|
@ -108,10 +108,13 @@ if (is_ajax()) {
|
|||
// (by default and for compatibility show void agents).
|
||||
$show_void_agents = (int) get_parameter('show_void_agents', 1);
|
||||
$serialized = (bool) get_parameter('serialized', false);
|
||||
$serialized_separator = (string) get_parameter('serialized_separator', '|');
|
||||
$serialized_separator = (string) get_parameter(
|
||||
'serialized_separator',
|
||||
'|'
|
||||
);
|
||||
$force_serialized = (bool) get_parameter('force_serialized', false);
|
||||
|
||||
if (! check_acl($config['id_user'], $id_group, 'AR')) {
|
||||
if (check_acl($config['id_user'], $id_group, 'AR') === false) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Alert Management'
|
||||
|
@ -120,12 +123,15 @@ if (is_ajax()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (https_is_running()) {
|
||||
if (https_is_running() === true) {
|
||||
header('Content-type: application/json');
|
||||
}
|
||||
|
||||
if ($filter_agents_json != '') {
|
||||
$filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true);
|
||||
$filter['id_agente'] = json_decode(
|
||||
io_safe_output($filter_agents_json),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ($all_agents) {
|
||||
|
@ -142,7 +148,6 @@ if (is_ajax()) {
|
|||
$filter['status'] = $status_agents;
|
||||
}
|
||||
|
||||
// Juanma (22/05/2014) Fix: If remove void agents set.
|
||||
$_sql_post = ' 1=1 ';
|
||||
if ($show_void_agents == 0) {
|
||||
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
|
||||
|
@ -172,7 +177,7 @@ if (is_ajax()) {
|
|||
|
||||
$agents_aux = [];
|
||||
foreach ($agents as $key => $value) {
|
||||
if (preg_match('/'.$search.'/', io_safe_output($value))) {
|
||||
if (preg_match('/'.$search.'/', io_safe_output($value)) === true) {
|
||||
$agents_aux[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +202,10 @@ if (is_ajax()) {
|
|||
'id_tmetaconsole_setup' => $agent_info[0],
|
||||
]
|
||||
);
|
||||
} else if ($serialized && !is_metaconsole() && $force_serialized) {
|
||||
} else if ($serialized
|
||||
&& is_metaconsole() === false
|
||||
&& $force_serialized
|
||||
) {
|
||||
$agent_info = explode($serialized_separator, $k);
|
||||
$agent_disabled = db_get_value_filter(
|
||||
'disabled',
|
||||
|
@ -233,10 +241,14 @@ if (is_ajax()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($get_is_disabled) {
|
||||
if ($get_is_disabled === true) {
|
||||
$index = get_parameter('id_agent');
|
||||
|
||||
$agent_disabled = db_get_value_filter('disabled', 'tagente', ['id_agente' => $index]);
|
||||
$agent_disabled = db_get_value_filter(
|
||||
'disabled',
|
||||
'tagente',
|
||||
['id_agente' => $index]
|
||||
);
|
||||
|
||||
$return['disabled'] = $agent_disabled;
|
||||
$return['id_agent'] = $index;
|
||||
|
@ -268,8 +280,8 @@ if ($tab != 'credbox' && ! check_acl(
|
|||
include 'general/noaccess.php';
|
||||
return;
|
||||
} else if ($tab == 'credbox'
|
||||
&& !check_acl($config['id_user'], 0, 'UM')
|
||||
&& !check_acl($config['id_user'], 0, 'PM')
|
||||
&& check_acl($config['id_user'], 0, 'UM') === false
|
||||
&& check_acl($config['id_user'], 0, 'PM') === false
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
|
@ -339,7 +351,7 @@ switch ($tab) {
|
|||
}
|
||||
|
||||
// Header.
|
||||
if (defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === true) {
|
||||
agents_meta_print_header();
|
||||
echo '<div class="notify">';
|
||||
echo __('Edit or delete groups can cause problems with synchronization');
|
||||
|
@ -368,7 +380,7 @@ $delete_group = (bool) get_parameter('delete_group');
|
|||
$pure = get_parameter('pure', 0);
|
||||
|
||||
// Create group.
|
||||
if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
if (($create_group) && (check_acl($config['id_user'], 0, 'PM') === true)) {
|
||||
$name = (string) get_parameter('name');
|
||||
$icon = (string) get_parameter('icon');
|
||||
$id_parent = (int) get_parameter('id_parent');
|
||||
|
@ -492,7 +504,7 @@ if ($update_group) {
|
|||
}
|
||||
|
||||
// Delete group.
|
||||
if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
if (($delete_group) && (check_acl($config['id_user'], 0, 'PM') === true)) {
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
|
||||
$usedGroup = groups_check_used($id_group);
|
||||
|
@ -508,28 +520,42 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
|||
$success_nodes = [];
|
||||
$error_nodes = [];
|
||||
// Check if the group can be deleted or not.
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
$result_exist_group = db_get_row_filter('tgrupo', ['nombre' => $group_name, 'id_grupo' => $id_group]);
|
||||
if ($result_exist_group !== false) {
|
||||
$used_group = groups_check_used($id_group);
|
||||
// Save the names of the nodes that are empty and can be deleted, and those that cannot.
|
||||
if (!$used_group['return']) {
|
||||
$success_nodes[] .= $server['server_name'];
|
||||
$success_counter++;
|
||||
} else {
|
||||
$error_nodes[] .= $server['server_name'];
|
||||
$error_counter++;
|
||||
if (isset($servers) === true
|
||||
&& is_array($servers) === true
|
||||
) {
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
$result_exist_group = db_get_row_filter(
|
||||
'tgrupo',
|
||||
[
|
||||
'nombre' => $group_name,
|
||||
'id_grupo' => $id_group,
|
||||
]
|
||||
);
|
||||
if ($result_exist_group !== false) {
|
||||
$used_group = groups_check_used($id_group);
|
||||
// Save the names of the nodes that are empty
|
||||
// and can be deleted, and those that cannot.
|
||||
if (!$used_group['return']) {
|
||||
$success_nodes[] .= $server['server_name'];
|
||||
$success_counter++;
|
||||
} else {
|
||||
$error_nodes[] .= $server['server_name'];
|
||||
$error_counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
metaconsole_restore_db();
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
if ($error_counter > 0) {
|
||||
ui_print_error_message(
|
||||
__('The group %s could not be deleted because it is not empty in the nodes', $group_name).': '.implode(', ', $error_nodes)
|
||||
__(
|
||||
'The group %s could not be deleted because it is not empty in the nodes',
|
||||
$group_name
|
||||
).': '.implode(', ', $error_nodes)
|
||||
);
|
||||
$errors_meta = true;
|
||||
} else {
|
||||
|
@ -540,60 +566,80 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
|||
$success_deleting = [];
|
||||
$error_connecting_node = [];
|
||||
// Delete the group in the nodes.
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
$group = db_get_row_filter(
|
||||
'tgrupo',
|
||||
['id_grupo' => $id_group]
|
||||
);
|
||||
if (isset($servers) === true
|
||||
&& is_array($servers) === true
|
||||
) {
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
$group = db_get_row_filter(
|
||||
'tgrupo',
|
||||
['id_grupo' => $id_group]
|
||||
);
|
||||
|
||||
db_process_sql_update(
|
||||
'tgrupo',
|
||||
['parent' => $group['parent']],
|
||||
['parent' => $id_group]
|
||||
);
|
||||
db_process_sql_update(
|
||||
'tgrupo',
|
||||
['parent' => $group['parent']],
|
||||
['parent' => $id_group]
|
||||
);
|
||||
|
||||
db_process_sql_delete(
|
||||
'tgroup_stat',
|
||||
['id_group' => $id_group]
|
||||
);
|
||||
db_process_sql_delete(
|
||||
'tgroup_stat',
|
||||
['id_group' => $id_group]
|
||||
);
|
||||
|
||||
$result = db_process_sql_delete(
|
||||
'tgrupo',
|
||||
['id_grupo' => $id_group]
|
||||
);
|
||||
$result = db_process_sql_delete(
|
||||
'tgrupo',
|
||||
['id_grupo' => $id_group]
|
||||
);
|
||||
|
||||
if ($result === false) {
|
||||
$error_deleting[] .= $server['server_name'];
|
||||
$error_deleting_counter++;
|
||||
if ($result === false) {
|
||||
$error_deleting[] .= $server['server_name'];
|
||||
$error_deleting_counter++;
|
||||
} else {
|
||||
$success_deleting[] .= $server['server_name'];
|
||||
$success_deleting_counter++;
|
||||
}
|
||||
} else {
|
||||
$success_deleting[] .= $server['server_name'];
|
||||
$success_deleting_counter++;
|
||||
$error_deleting_counter++;
|
||||
$error_connecting_node[] .= $server['server_name'];
|
||||
}
|
||||
} else {
|
||||
$error_deleting_counter++;
|
||||
$error_connecting_node[] .= $server['server_name'];
|
||||
}
|
||||
|
||||
metaconsole_restore_db();
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
}
|
||||
|
||||
// If the group could not be deleted in any node, do not delete it in meta.
|
||||
// If the group could not be deleted in any node,
|
||||
// do not delete it in meta.
|
||||
if ($error_deleting_counter > 0) {
|
||||
$errors_meta = true;
|
||||
if (!empty($error_connecting_node)) {
|
||||
ui_print_error_message(__('Error connecting to %s', implode(', ', $error_connecting_node).'. The group has not been deleted in the metaconsole.'));
|
||||
if (empty($error_connecting_node) === false) {
|
||||
ui_print_error_message(
|
||||
__(
|
||||
'Error connecting to %s',
|
||||
implode(
|
||||
', ',
|
||||
$error_connecting_node
|
||||
).'. The group has not been deleted in the metaconsole.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($error_deleting)) {
|
||||
if (empty($error_deleting) === false) {
|
||||
ui_print_error_message(
|
||||
__('The group has not been deleted in the metaconsole due to an error in the node database').': '.implode(', ', $error_deleting)
|
||||
__(
|
||||
'The group has not been deleted in the metaconsole due to an error in the node database'
|
||||
).': '.implode(', ', $error_deleting)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($success_deleting_counter > 0) {
|
||||
ui_print_success_message(__('The group %s has been deleted in the nodes', $group_name).': '.implode(', ', $success_deleting));
|
||||
ui_print_success_message(
|
||||
__(
|
||||
'The group %s has been deleted in the nodes',
|
||||
$group_name
|
||||
).': '.implode(', ', $success_deleting)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,12 +670,17 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
|||
if ($result && (!$usedGroup['return'])) {
|
||||
ui_print_success_message(__('Group successfully deleted'));
|
||||
} else {
|
||||
ui_print_error_message(__('There was a problem deleting group'));
|
||||
ui_print_error_message(
|
||||
__('There was a problem deleting group')
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ui_print_error_message(
|
||||
sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables']))
|
||||
sprintf(
|
||||
__('The group is not empty. It is use in %s.'),
|
||||
implode(', ', $usedGroup['tables'])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -662,14 +713,14 @@ if ($tab == 'tree') {
|
|||
$search = (string) get_parameter('search', '');
|
||||
$block_size = $config['block_size'];
|
||||
|
||||
if (!empty($search)) {
|
||||
if (empty($search) === false) {
|
||||
$search_name = 'AND t.nombre LIKE "%'.$search.'%"';
|
||||
}
|
||||
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
if (users_can_manage_group_all('AR') === false) {
|
||||
$user_groups_acl = users_get_groups(false, 'AR');
|
||||
$groups_acl = implode(',', $user_groups_ACL);
|
||||
if (empty($groups_acl)) {
|
||||
if (empty($groups_acl) === true) {
|
||||
return ui_print_info_message(
|
||||
[
|
||||
'no_close' => true,
|
||||
|
@ -684,7 +735,14 @@ if ($tab == 'tree') {
|
|||
$form = "<form method='post' action=''>";
|
||||
$form .= "<table class='databox filters bolder' width='100%'>";
|
||||
$form .= '<tr><td>'.__('Search').' ';
|
||||
$form .= html_print_input_text('search', $search, '', 100, 100, true);
|
||||
$form .= html_print_input_text(
|
||||
'search',
|
||||
$search,
|
||||
'',
|
||||
100,
|
||||
100,
|
||||
true
|
||||
);
|
||||
$form .= '</td><td>';
|
||||
$form .= "<input name='find' type='submit' class='sub search' value='".__('Search')."'>";
|
||||
$form .= '<td></tr>';
|
||||
|
@ -713,7 +771,7 @@ if ($tab == 'tree') {
|
|||
|
||||
$groups = db_get_all_rows_sql($groups_sql);
|
||||
|
||||
if (!empty($groups)) {
|
||||
if (empty($groups) === false) {
|
||||
// Count all groups for pagination only saw user and filters.
|
||||
$groups_sql_count = sprintf(
|
||||
'SELECT count(*)
|
||||
|
@ -799,7 +857,7 @@ if ($tab == 'tree') {
|
|||
]
|
||||
).'</a>';
|
||||
|
||||
if (is_metaconsole()) {
|
||||
if (is_metaconsole() === true) {
|
||||
$confirm_message = __('Are you sure? This group will also be deleted in all the nodes.');
|
||||
} else {
|
||||
$confirm_message = __('Are you sure?');
|
||||
|
@ -841,11 +899,16 @@ if ($tab == 'tree') {
|
|||
'pagination-bottom'
|
||||
);
|
||||
} else {
|
||||
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined groups') ]);
|
||||
ui_print_info_message(
|
||||
[
|
||||
'no_close' => true,
|
||||
'message' => __('There are no defined groups'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (check_acl($config['id_user'], 0, 'PM') === true) {
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/groups/configure_group">';
|
||||
echo '<div class="action-buttons w100p">';
|
||||
html_print_submit_button(__('Create group'), 'crt', false, 'class="sub next"');
|
||||
|
@ -860,7 +923,7 @@ $tab = 'group_edition';
|
|||
|
||||
?>
|
||||
|
||||
<?php if (!is_metaconsole()) { ?>
|
||||
<?php if (is_metaconsole() === false) { ?>
|
||||
<script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script>
|
||||
<?php } else { ?>
|
||||
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
|
||||
|
@ -900,7 +963,6 @@ $tab = 'group_edition';
|
|||
|
||||
treeController.init({
|
||||
recipient: $("div#tree-controller-recipient"),
|
||||
//detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }),
|
||||
page: parameters['page'],
|
||||
emptyMessage: "<?php echo __('No data found'); ?>",
|
||||
foundMessage: "<?php echo __('Found groups'); ?>",
|
||||
|
|
|
@ -819,24 +819,17 @@ foreach ($fields as $field) {
|
|||
}
|
||||
|
||||
if ($field['combo_values'] !== '') {
|
||||
$data[1] = html_print_select(
|
||||
$combo_values,
|
||||
'customvalue_'.$field['id_field'],
|
||||
$custom_value,
|
||||
'',
|
||||
__('No change'),
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
$data[1] = html_print_input(
|
||||
[
|
||||
'type' => 'select_search',
|
||||
'fields' => $combo_values,
|
||||
'name' => 'customvalue_'.$field['id_field'],
|
||||
'selected' => $custom_value,
|
||||
'nothing' => __('No change'),
|
||||
'nothing_value' => '',
|
||||
'return' => true,
|
||||
'sort' => false,
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ if (defined('METACONSOLE')) {
|
|||
$sec = 'gmodules';
|
||||
}
|
||||
|
||||
if (is_management_allowed() === true) {
|
||||
if (is_management_allowed() === true || is_metaconsole()) {
|
||||
$create = (bool) get_parameter('create');
|
||||
$update = (bool) get_parameter('update');
|
||||
$delete = (bool) get_parameter('delete');
|
||||
|
@ -125,7 +125,7 @@ if ($delete) {
|
|||
['id_sg' => $id]
|
||||
);
|
||||
|
||||
if (($result !== false) and ($result1 !== false)) {
|
||||
if (($result !== false) && ($result1 !== false)) {
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
|
@ -187,7 +187,7 @@ if ($multiple_delete) {
|
|||
);
|
||||
}
|
||||
|
||||
if (($id || $new) && !$delete && !$multiple_delete && is_management_allowed() === true) {
|
||||
if (($id || $new) && !$delete && !$multiple_delete && (is_management_allowed() === true || is_metaconsole())) {
|
||||
include_once 'manage_nc_groups_form.php';
|
||||
return;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ $table->class = 'info_table';
|
|||
$table->head = [];
|
||||
$table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false);
|
||||
$table->head[0] = __('Name');
|
||||
if (is_management_allowed() === true) {
|
||||
if (is_management_allowed() === true || is_metaconsole()) {
|
||||
$table->head[1] = __('Action');
|
||||
}
|
||||
|
||||
|
@ -262,15 +262,15 @@ foreach ($groups as $group) {
|
|||
}
|
||||
|
||||
$table->cellclass[][1] = 'action_buttons';
|
||||
if (is_management_allowed() === true) {
|
||||
if (is_management_allowed() === true || is_metaconsole()) {
|
||||
$data[1] = "<a onclick='if(confirm(\"".__('Are you sure?')."\")) return true; else return false;'
|
||||
href='index.php?sec=".$sec.'&sec2=godmode/modules/manage_nc_groups&delete=1&id='.$group['id_sg']."&offset=0'>".html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>';
|
||||
href='index.php?sec=".$sec.'&sec2=godmode/modules/manage_nc_groups&delete=1&id='.$group['id_sg']."&offset=0'>".html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
if (is_management_allowed() === false) {
|
||||
if (is_management_allowed() === false && !is_metaconsole()) {
|
||||
ui_print_warning_message(__('This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.'));
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ if (isset($data)) {
|
|||
echo "<form method='post' action='index.php?sec=".$sec."&sec2=godmode/modules/manage_nc_groups'>";
|
||||
html_print_input_hidden('multiple_delete', 1);
|
||||
html_print_table($table);
|
||||
if (is_management_allowed() === true) {
|
||||
if (is_management_allowed() === true || is_metaconsole()) {
|
||||
echo "<div class='pdd_l_10px float-right mrgn_btn_15px'>";
|
||||
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
|
||||
echo '</div>';
|
||||
|
@ -289,7 +289,7 @@ if (isset($data)) {
|
|||
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined component groups') ]);
|
||||
}
|
||||
|
||||
if (is_management_allowed() === true) {
|
||||
if (is_management_allowed() === true || is_metaconsole()) {
|
||||
echo '<form method="post" action='.$url.'>';
|
||||
echo '<div class="float-right">';
|
||||
html_print_input_hidden('new', 1);
|
||||
|
|
|
@ -44,6 +44,9 @@ if (! check_acl($config['id_user'], 0, 'PM')
|
|||
return;
|
||||
}
|
||||
|
||||
// Load needed resources.
|
||||
ui_require_css_file('setup.multicolumn');
|
||||
|
||||
$update_config = get_parameter('update_config', 0);
|
||||
if ($update_config == 1 && $config['history_db_enabled'] == 1) {
|
||||
if (! isset($config['history_db_connection'])
|
||||
|
@ -649,7 +652,7 @@ $table_other->data[16][1] = html_print_input_text(
|
|||
|
||||
echo '<form id="form_setup" method="post">';
|
||||
|
||||
echo '<fieldset>';
|
||||
echo '<fieldset class="full-column">';
|
||||
echo '<legend>'.__('Database maintenance status').' '.ui_print_help_icon('database_maintenance_status_tab', true).'</legend>';
|
||||
html_print_table($table_status);
|
||||
echo '</fieldset>';
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -440,17 +440,21 @@ if (!defined('METACONSOLE')) {
|
|||
$table->valign[6] = 'top';
|
||||
}
|
||||
|
||||
$group_um = users_get_groups_UM($config['id_user']);
|
||||
|
||||
$info1 = [];
|
||||
|
||||
$user_is_admin = users_is_admin();
|
||||
// Is admin or has group permissions all.
|
||||
if ($user_is_admin || isset($group_um[0])) {
|
||||
|
||||
if ($user_is_admin) {
|
||||
$info1 = get_users($order);
|
||||
} else {
|
||||
foreach ($group_um as $group => $value) {
|
||||
$info1 = array_merge($info1, users_get_users_by_group($group, $value));
|
||||
$group_um = users_get_groups_UM($config['id_user']);
|
||||
// 0 is the group 'all'.
|
||||
if (isset($group_um[0])) {
|
||||
$info1 = get_users($order);
|
||||
} else {
|
||||
foreach ($group_um as $group => $value) {
|
||||
$info1 = array_merge($info1, users_get_users_by_group($group, $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -591,10 +595,10 @@ foreach ($info as $user_id => $user_info) {
|
|||
$data[4] .= '<div class="text_end">';
|
||||
foreach ($user_profiles as $row) {
|
||||
if ($total_profile <= 5) {
|
||||
$data[4] .= "<div class='left'>";
|
||||
$data[4] .= "<div class='float-left'>";
|
||||
$data[4] .= profile_get_name($row['id_perfil']);
|
||||
$data[4] .= ' / </div>';
|
||||
$data[4] .= "<div class='left pdd_l_5px'>";
|
||||
$data[4] .= "<div class='float-left pdd_l_5px'>";
|
||||
$data[4] .= groups_get_name($row['id_grupo'], true);
|
||||
$data[4] .= '</div>';
|
||||
|
||||
|
|
|
@ -1024,7 +1024,9 @@ class DiscoveryTaskList extends HTML
|
|||
*/
|
||||
public function getTargetWiz($task, $script=false)
|
||||
{
|
||||
if ($script !== false) {
|
||||
if ($script !== false
|
||||
|| (int) $task['type'] === DISCOVERY_HOSTDEVICES_CUSTOM
|
||||
) {
|
||||
switch ($script['type']) {
|
||||
case DISCOVERY_SCRIPT_APP_VMWARE:
|
||||
return 'wiz=app&mode=vmware&page=0';
|
||||
|
@ -1491,6 +1493,9 @@ class DiscoveryTaskList extends HTML
|
|||
$simple_data[] = $tmp;
|
||||
|
||||
if (is_array($data['modules'])) {
|
||||
// Alphabetically sort.
|
||||
ksort($data['modules'], (SORT_STRING | SORT_FLAG_CASE));
|
||||
|
||||
$simple_data = array_merge(
|
||||
$simple_data,
|
||||
array_reduce(
|
||||
|
|
|
@ -1865,11 +1865,12 @@ if ($get_table_response_command) {
|
|||
}
|
||||
|
||||
if ($get_events_fired) {
|
||||
global $config;
|
||||
$id = get_parameter('id_row');
|
||||
$idGroup = get_parameter('id_group');
|
||||
$agents = get_parameter('agents', null);
|
||||
|
||||
$query = ' AND id_evento > '.$id;
|
||||
$query = ' AND id_evento >= '.$id;
|
||||
|
||||
$type = [];
|
||||
$alert = get_parameter('alert_fired');
|
||||
|
@ -1889,7 +1890,10 @@ if ($get_events_fired) {
|
|||
if ($critical == 'true') {
|
||||
$resultCritical = alerts_get_event_status_group(
|
||||
$idGroup,
|
||||
'going_up_critical',
|
||||
[
|
||||
'going_up_critical',
|
||||
'going_down_critical',
|
||||
],
|
||||
$query,
|
||||
$agents
|
||||
);
|
||||
|
@ -1899,7 +1903,10 @@ if ($get_events_fired) {
|
|||
if ($warning == 'true') {
|
||||
$resultWarning = alerts_get_event_status_group(
|
||||
$idGroup,
|
||||
'going_up_warning',
|
||||
[
|
||||
'going_up_warning',
|
||||
'going_down_warning',
|
||||
],
|
||||
$query,
|
||||
$agents
|
||||
);
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Only accesible by ajax
|
||||
if (is_ajax()) {
|
||||
/**
|
||||
* Tree view.
|
||||
*
|
||||
* @category Tree
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
if (is_ajax() === true) {
|
||||
global $config;
|
||||
|
||||
// Login check.
|
||||
|
@ -34,7 +49,7 @@ if (is_ajax()) {
|
|||
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
||||
$getDetail = (bool) get_parameter('getDetail');
|
||||
|
||||
if ($getChildren) {
|
||||
if ($getChildren === true) {
|
||||
$type = get_parameter('type', 'group');
|
||||
$rootType = get_parameter('rootType', '');
|
||||
$id = get_parameter('id', -1);
|
||||
|
@ -55,47 +70,111 @@ if (is_ajax()) {
|
|||
|
||||
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
||||
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
||||
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||
$switch_type = !empty($rootType) ? $rootType : $type;
|
||||
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
|
||||
$switch_type = (empty($rootType) === false) ? $rootType : $type;
|
||||
switch ($switch_type) {
|
||||
case 'os':
|
||||
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeOS(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
break;
|
||||
|
||||
case 'module_group':
|
||||
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeModuleGroup(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeModule(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeTag(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
break;
|
||||
|
||||
case 'group':
|
||||
if (is_metaconsole()) {
|
||||
if (!class_exists('TreeGroupMeta')) {
|
||||
if (is_metaconsole() === true) {
|
||||
if (class_exists('TreeGroupMeta') === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeGroupMeta(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
} else {
|
||||
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeGroup(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'policies':
|
||||
if (!class_exists('TreePolicies')) {
|
||||
if (class_exists('TreePolicies') === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreePolicies(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
break;
|
||||
|
||||
case 'group_edition':
|
||||
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
$tree = new TreeGroupEdition(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
break;
|
||||
|
||||
case 'services':
|
||||
|
@ -112,7 +191,7 @@ if (is_ajax()) {
|
|||
break;
|
||||
|
||||
default:
|
||||
// FIXME. No error handler
|
||||
// No error handler.
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -123,14 +202,14 @@ if (is_ajax()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($getDetail) {
|
||||
if ($getDetail === true) {
|
||||
include_once $config['homedir'].'/include/functions_treeview.php';
|
||||
|
||||
$id = (int) get_parameter('id');
|
||||
$type = (string) get_parameter('type');
|
||||
|
||||
$server = [];
|
||||
if (is_metaconsole()) {
|
||||
if (is_metaconsole() === true) {
|
||||
$server_id = (int) get_parameter('serverID');
|
||||
$server = metaconsole_get_servers($server_id);
|
||||
}
|
||||
|
@ -142,7 +221,7 @@ if (is_ajax()) {
|
|||
echo '</style>';
|
||||
|
||||
echo '<div class="left_align backgrund_primary_important">';
|
||||
if (!empty($id) && !empty($type)) {
|
||||
if (empty($id) === false && empty($type) === false) {
|
||||
switch ($type) {
|
||||
case 'agent':
|
||||
treeview_printTable($id, $server, true);
|
||||
|
@ -157,7 +236,7 @@ if (is_ajax()) {
|
|||
break;
|
||||
|
||||
default:
|
||||
// Nothing
|
||||
// Nothing.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ if (file_exists($config['homedir'].'/'.ENTERPRISE_DIR.'/load_enterprise.php') ==
|
|||
}
|
||||
|
||||
// TESTING THE UPDATE MANAGER.
|
||||
enterprise_include_once('load_enterprise.php');
|
||||
enterprise_include_once('include/functions_enterprise_api.php');
|
||||
|
||||
$ipOrigin = $_SERVER['REMOTE_ADDR'];
|
||||
|
@ -316,7 +317,7 @@ if ($correctLogin) {
|
|||
}
|
||||
|
||||
// Logout.
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
if (session_status() !== PHP_SESSION_DISABLED) {
|
||||
$_SESSION = [];
|
||||
// Could give a warning if no session file is created. Ignore.
|
||||
@session_destroy();
|
||||
|
|
|
@ -185,6 +185,7 @@ class CustomNetScan extends Wizard
|
|||
$this->task['id_recon_server'] = $server_id;
|
||||
$this->task['id_group'] = $id_group;
|
||||
$this->task['interval_sweep'] = $interval;
|
||||
$this->task['type'] = DISCOVERY_HOSTDEVICES_CUSTOM;
|
||||
|
||||
if (isset($this->task['id_rt']) === false) {
|
||||
// Create.
|
||||
|
|
|
@ -1,15 +1,30 @@
|
|||
<?php
|
||||
// Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
/**
|
||||
* Tree view.
|
||||
*
|
||||
* @category Tree
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
class Tree
|
||||
{
|
||||
|
||||
|
|
|
@ -1,32 +1,86 @@
|
|||
<?php
|
||||
// Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
/**
|
||||
* Tree view.
|
||||
*
|
||||
* @category Tree
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/Tree.class.php';
|
||||
|
||||
/**
|
||||
* Tree group class.
|
||||
*/
|
||||
class TreeGroup extends Tree
|
||||
{
|
||||
|
||||
/**
|
||||
* Propagate ACL.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $propagateCounters = true;
|
||||
|
||||
/**
|
||||
* Display all groups.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $displayAllGroups = false;
|
||||
|
||||
|
||||
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR')
|
||||
{
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param string $type Type.
|
||||
* @param string $rootType Root.
|
||||
* @param integer $id Id.
|
||||
* @param integer $rootID Root Id.
|
||||
* @param boolean $serverID Server.
|
||||
* @param string $childrenMethod Method children.
|
||||
* @param string $access Access ACL.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$rootType='',
|
||||
$id=-1,
|
||||
$rootID=-1,
|
||||
$serverID=false,
|
||||
$childrenMethod='on_demand',
|
||||
$access='AR'
|
||||
) {
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
parent::__construct(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
|
||||
$this->L1fieldName = 'id_group';
|
||||
$this->L1extraFields = [
|
||||
|
@ -42,18 +96,37 @@ class TreeGroup extends Tree
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter propagate counters.
|
||||
*
|
||||
* @param boolean $value True or ffalse.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPropagateCounters($value)
|
||||
{
|
||||
$this->propagateCounters = (bool) $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter all groups.
|
||||
*
|
||||
* @param boolean $value True or ffalse.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDisplayAllGroups($value)
|
||||
{
|
||||
$this->displayAllGroups = (bool) $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getData()
|
||||
{
|
||||
if ($this->id == -1) {
|
||||
|
@ -66,22 +139,36 @@ class TreeGroup extends Tree
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter search groups.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getGroupSearchFilter()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* First level tree.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getFirstLevel()
|
||||
{
|
||||
$processed_items = $this->getProcessedGroups();
|
||||
|
||||
if (!empty($processed_items)) {
|
||||
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
|
||||
if (!empty($this->filter['searchGroup'])) {
|
||||
// Save the groups which intersect with the user groups
|
||||
$groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']);
|
||||
if ($groups == false) {
|
||||
if (empty($processed_items) === false) {
|
||||
// Filter by group name. This should be done after rerieving
|
||||
// the items cause we need the possible items descendants.
|
||||
if (empty($this->filter['searchGroup']) === false) {
|
||||
// Save the groups which intersect with the user groups.
|
||||
$groups = db_get_all_rows_filter(
|
||||
'tgrupo',
|
||||
['nombre' => '%'.$this->filter['searchGroup'].'%']
|
||||
);
|
||||
if ($groups === false) {
|
||||
$groups = [];
|
||||
}
|
||||
|
||||
|
@ -90,7 +177,7 @@ class TreeGroup extends Tree
|
|||
$groups,
|
||||
function ($userGroups, $group) use ($userGroupsACL) {
|
||||
$group_id = $group['id_grupo'];
|
||||
if (isset($userGroupsACL[$group_id])) {
|
||||
if (isset($userGroupsACL[$group_id]) === true) {
|
||||
$userGroups[$group_id] = $userGroupsACL[$group_id];
|
||||
}
|
||||
|
||||
|
@ -99,14 +186,22 @@ class TreeGroup extends Tree
|
|||
[]
|
||||
);
|
||||
|
||||
$result = self::extractGroupsWithIDs($processed_items, $ids_hash);
|
||||
$result = self::extractGroupsWithIDs(
|
||||
$processed_items,
|
||||
$ids_hash
|
||||
);
|
||||
|
||||
$processed_items = ($result === false) ? [] : $result;
|
||||
}
|
||||
|
||||
// groupID filter. To access the view from tactical views f.e.
|
||||
if (!empty($this->filter['groupID'])) {
|
||||
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL);
|
||||
// GroupID filter. To access the view from tactical views f.e.
|
||||
if (empty($this->filter['groupID']) === false) {
|
||||
$result = self::extractItemWithID(
|
||||
$processed_items,
|
||||
$this->filter['groupID'],
|
||||
'group',
|
||||
$this->strictACL
|
||||
);
|
||||
|
||||
$processed_items = ($result === false) ? [] : [$result];
|
||||
}
|
||||
|
@ -116,56 +211,64 @@ class TreeGroup extends Tree
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process group
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getProcessedGroups()
|
||||
{
|
||||
$processed_groups = [];
|
||||
// Index and process the groups
|
||||
// Index and process the groups.
|
||||
$groups = $this->getGroupCounters();
|
||||
|
||||
// If user have not permissions in parent, set parent node to 0 (all)
|
||||
// Avoid to do foreach for admins
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
// Avoid to do foreach for admins.
|
||||
if (users_can_manage_group_all('AR') === false) {
|
||||
foreach ($groups as $id => $group) {
|
||||
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
||||
if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
|
||||
$groups[$id]['parent'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the group hierarchy
|
||||
// Build the group hierarchy.
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||
if (isset($groups[$id]['parent']) === true
|
||||
&& ($groups[$id]['parent'] != 0)
|
||||
) {
|
||||
$parent = $groups[$id]['parent'];
|
||||
// Parent exists
|
||||
if (!isset($groups[$parent]['children'])) {
|
||||
// Parent exists.
|
||||
if (isset($groups[$parent]['children']) === false) {
|
||||
$groups[$parent]['children'] = [];
|
||||
}
|
||||
|
||||
// Store a reference to the group into the parent
|
||||
// Store a reference to the group into the parent.
|
||||
$groups[$parent]['children'][] = &$groups[$id];
|
||||
// This group was introduced into a parent
|
||||
// This group was introduced into a parent.
|
||||
$groups[$id]['have_parent'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the children groups
|
||||
// Sort the children groups.
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['children'])) {
|
||||
if (isset($groups[$id]['children']) === true) {
|
||||
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter groups and eliminates the reference to children groups out of her parent
|
||||
// Filter groups and eliminates the reference to
|
||||
// children groups out of her parent.
|
||||
$groups = array_filter(
|
||||
$groups,
|
||||
function ($group) {
|
||||
return !$group['have_parent'];
|
||||
}
|
||||
);
|
||||
// Propagate child counters to her parents
|
||||
if ($this->propagateCounters) {
|
||||
// Propagate child counters to her parents.
|
||||
if ($this->propagateCounters === true) {
|
||||
self::processCounters($groups);
|
||||
// Filter groups and eliminates the reference to empty groups
|
||||
// Filter groups and eliminates the reference to empty groups.
|
||||
$groups = $this->deleteEmptyGroups($groups);
|
||||
} else {
|
||||
$groups = $this->deleteEmptyGroupsNotPropagate($groups);
|
||||
|
|
|
@ -1,31 +1,81 @@
|
|||
<?php
|
||||
// Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
/**
|
||||
* Tree view.
|
||||
*
|
||||
* @category Tree
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/Tree.class.php';
|
||||
|
||||
/**
|
||||
* Tree group edition.
|
||||
*/
|
||||
class TreeGroupEdition extends TreeGroup
|
||||
{
|
||||
|
||||
|
||||
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR')
|
||||
{
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param string $type Type.
|
||||
* @param string $rootType Root.
|
||||
* @param integer $id Id.
|
||||
* @param integer $rootID Root Id.
|
||||
* @param boolean $serverID Server.
|
||||
* @param string $childrenMethod Method children.
|
||||
* @param string $access Access ACL.
|
||||
*/
|
||||
public function __construct(
|
||||
$type,
|
||||
$rootType='',
|
||||
$id=-1,
|
||||
$rootID=-1,
|
||||
$serverID=false,
|
||||
$childrenMethod='on_demand',
|
||||
$access='AR'
|
||||
) {
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
parent::__construct(
|
||||
$type,
|
||||
$rootType,
|
||||
$id,
|
||||
$rootID,
|
||||
$serverID,
|
||||
$childrenMethod,
|
||||
$access
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getData()
|
||||
{
|
||||
if ($this->id == -1) {
|
||||
|
@ -34,46 +84,54 @@ class TreeGroupEdition extends TreeGroup
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get process group.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getProcessedGroups()
|
||||
{
|
||||
$processed_groups = [];
|
||||
// Index and process the groups
|
||||
// Index and process the groups.
|
||||
$groups = $this->getGroupCounters();
|
||||
|
||||
// If user have not permissions in parent, set parent node to 0 (all)
|
||||
// Avoid to do foreach for admins
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
// Avoid to do foreach for admins.
|
||||
if (users_can_manage_group_all('AR') === false) {
|
||||
foreach ($groups as $id => $group) {
|
||||
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
||||
if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
|
||||
$groups[$id]['parent'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the group hierarchy
|
||||
// Build the group hierarchy.
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||
if (isset($groups[$id]['parent']) === true
|
||||
&& ($groups[$id]['parent'] != 0)
|
||||
) {
|
||||
$parent = $groups[$id]['parent'];
|
||||
// Parent exists
|
||||
if (!isset($groups[$parent]['children'])) {
|
||||
// Parent exists.
|
||||
if (isset($groups[$parent]['children']) === false) {
|
||||
$groups[$parent]['children'] = [];
|
||||
}
|
||||
|
||||
// Store a reference to the group into the parent
|
||||
// Store a reference to the group into the parent.
|
||||
$groups[$parent]['children'][] = &$groups[$id];
|
||||
// This group was introduced into a parent
|
||||
// This group was introduced into a parent.
|
||||
$groups[$id]['have_parent'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the children groups
|
||||
// Sort the children groups.
|
||||
foreach ($groups as $id => $group) {
|
||||
if (isset($groups[$id]['children'])) {
|
||||
if (isset($groups[$id]['children']) === true) {
|
||||
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter groups and eliminates the reference to children groups out of her parent
|
||||
// Filter groups and eliminates the reference
|
||||
// to children groups out of her parent.
|
||||
$groups = array_filter(
|
||||
$groups,
|
||||
function ($group) {
|
||||
|
@ -86,6 +144,11 @@ class TreeGroupEdition extends TreeGroup
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get group counters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getGroupCounters()
|
||||
{
|
||||
$messages = [
|
||||
|
@ -93,10 +156,25 @@ class TreeGroupEdition extends TreeGroup
|
|||
'cancel' => __('Cancel'),
|
||||
'messg' => __('Are you sure?'),
|
||||
];
|
||||
$sql = 'SELECT id_grupo AS gid,
|
||||
nombre as name, parent, icon
|
||||
|
||||
$group_acl = '';
|
||||
if (users_can_manage_group_all('AR') === false) {
|
||||
$user_groups_str = implode(',', $this->userGroupsArray);
|
||||
$group_acl = sprintf(
|
||||
'AND id_grupo IN (%s)',
|
||||
$user_groups_str
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT id_grupo AS gid,
|
||||
nombre as name,
|
||||
parent,
|
||||
icon
|
||||
FROM tgrupo
|
||||
';
|
||||
WHERE 1=1 %s',
|
||||
$group_acl
|
||||
);
|
||||
|
||||
$stats = db_get_all_rows_sql($sql);
|
||||
$group_stats = [];
|
||||
|
@ -107,7 +185,9 @@ class TreeGroupEdition extends TreeGroup
|
|||
$group_stats[$group['gid']]['id'] = $group['gid'];
|
||||
$group_stats[$group['gid']]['type'] = 'group';
|
||||
|
||||
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
||||
$group_stats[$group['gid']] = $this->getProcessedItem(
|
||||
$group_stats[$group['gid']]
|
||||
);
|
||||
$group_stats[$group['gid']]['delete']['messages'] = $messages;
|
||||
$group_stats[$group['gid']]['edit'] = 1;
|
||||
$group_stats[$group['gid']]['alerts'] = '';
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC210406';
|
||||
$build_version = 'PC210407';
|
||||
$pandora_version = 'v7.0NG.753';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -173,13 +173,22 @@ function alerts_get_event_status_group($idGroup, $type='alert_fired', $query='AN
|
|||
$idAgents = array_values($agents);
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_sql(
|
||||
$sql = sprintf(
|
||||
'SELECT id_evento
|
||||
FROM tevento
|
||||
WHERE estado = 0 AND id_agente IN (0,'.implode(',', $idAgents).') '.$typeWhere.$query.'
|
||||
ORDER BY id_evento DESC LIMIT 1'
|
||||
FROM tevento
|
||||
WHERE estado = 0
|
||||
AND id_agente IN (0, %s)
|
||||
%s
|
||||
%s
|
||||
ORDER BY id_evento DESC
|
||||
LIMIT 1',
|
||||
implode(',', $idAgents),
|
||||
$typeWhere,
|
||||
$query
|
||||
);
|
||||
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2125,8 +2134,6 @@ function get_group_alerts(
|
|||
$disabled = $filter;
|
||||
}
|
||||
|
||||
$filter .= ' AND talert_template_modules.disabled = 0 ';
|
||||
|
||||
switch ($disabled) {
|
||||
case 'notfired':
|
||||
$filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0';
|
||||
|
@ -2144,9 +2151,13 @@ function get_group_alerts(
|
|||
$filter .= ' AND talert_template_modules.disabled = 0';
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'all':
|
||||
$filter .= '';
|
||||
break;
|
||||
|
||||
default:
|
||||
$filter .= ' AND talert_template_modules.disabled = 0 ';
|
||||
break;
|
||||
}
|
||||
|
||||
// WHEN SELECT ALL TAGS TO FILTER ALERTS
|
||||
|
@ -2186,8 +2197,8 @@ function get_group_alerts(
|
|||
WHERE 1 = 0';
|
||||
} else {
|
||||
$subQuery = 'SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE delete_pending = 0
|
||||
FROM tagente_modulo tam
|
||||
WHERE delete_pending = 0 AND tam.disabled = 0
|
||||
AND id_agente IN (SELECT id_agente
|
||||
FROM tagente ta
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
|
|
|
@ -375,6 +375,103 @@ function api_get_test_event_replication_db()
|
|||
|
||||
|
||||
// -------------------------DEFINED OPERATIONS FUNCTIONS-----------------
|
||||
|
||||
|
||||
/**
|
||||
* Example: http://localhost/pandora_console/include/api.php?op=get&op2=license&user=admin&apipass=1234&pass=pandora&return_type=json
|
||||
* Retrieve license information.
|
||||
*
|
||||
* @param null $trash1 Not used.
|
||||
* @param null $trash1 Not used.
|
||||
* @param null $trash1 Not used.
|
||||
* @param string $returnType Return type (string, json...).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function api_get_license($trash1, $trash2, $trash3, $returnType='json')
|
||||
{
|
||||
global $config;
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
returnError('forbidden', $returnType);
|
||||
return;
|
||||
}
|
||||
|
||||
enterprise_include_once('include/functions_license.php');
|
||||
$license = enterprise_hook('license_get_info');
|
||||
if ($license === ENTERPRISE_NOT_HOOK) {
|
||||
// Not an enterprise environment?
|
||||
if (license_free()) {
|
||||
$license = 'PANDORA_FREE';
|
||||
}
|
||||
|
||||
returnData(
|
||||
$returnType,
|
||||
[
|
||||
'type' => 'array',
|
||||
'data' => ['license_mode' => $license],
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
returnData(
|
||||
$returnType,
|
||||
[
|
||||
'type' => 'array',
|
||||
'data' => $license,
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Example: http://localhost/pandora_console/include/api.php?op=get&op2=license_remaining&user=admin&apipass=1234&pass=pandora&return_type=json
|
||||
* Retrieve license status agents or modules left.
|
||||
*
|
||||
* @param null $trash1 Not used.
|
||||
* @param null $trash1 Not used.
|
||||
* @param null $trash1 Not used.
|
||||
* @param string $returnType Return type (string, json...).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function api_get_license_remaining(
|
||||
$trash1,
|
||||
$trash2,
|
||||
$trash3,
|
||||
$returnType='json'
|
||||
) {
|
||||
enterprise_include_once('include/functions_license.php');
|
||||
$license = enterprise_hook('license_get_info');
|
||||
if ($license === ENTERPRISE_NOT_HOOK) {
|
||||
if (license_free()) {
|
||||
returnData(
|
||||
$returnType,
|
||||
[
|
||||
'type' => 'integer',
|
||||
'data' => PHP_INT_MAX,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
returnError('get-license', 'Failed to verify license.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
returnData(
|
||||
$returnType,
|
||||
[
|
||||
'type' => 'integer',
|
||||
'data' => ($license['limit'] - $license['count_enabled']),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db)
|
||||
{
|
||||
$returnAllGroup = true;
|
||||
|
@ -6276,6 +6373,136 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate an alert
|
||||
*
|
||||
* @param string $id1 Alert template name (eg. 'Warning condition')
|
||||
* @param string $trash1 Do nnot use.
|
||||
* @param array $other [1] id/name agent.
|
||||
* [2] id/name module
|
||||
* [3] Use agent/module alias.
|
||||
* @param string $trash2 Do not use
|
||||
* @return void
|
||||
*/
|
||||
function api_set_validate_alert($id1, $trash1, $other, $trash2)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'LW')) {
|
||||
returnError('forbidden');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id1 === '') {
|
||||
returnError(
|
||||
'error_validate_alert',
|
||||
__('Error validating alert. Id_template cannot be left blank.')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][0] == '') {
|
||||
returnError(
|
||||
'error_validate_alert',
|
||||
__('Error validating alert. Id_agent cannot be left blank.')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][1] == '') {
|
||||
returnError(
|
||||
'error_validate_alert',
|
||||
__('Error validating alert. Id_module cannot be left blank.')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][2] == 1) {
|
||||
$use_alias = true;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'alert_name' => $id1,
|
||||
'id_agent' => $other['data'][0],
|
||||
'id_agent_module' => $other['data'][1],
|
||||
];
|
||||
|
||||
if ($use_alias === true) {
|
||||
$id_agents = agents_get_agent_id_by_alias($values['id_agent']);
|
||||
|
||||
foreach ($id_agents as $id) {
|
||||
$values['id_agent'] = $id['id_agente'];
|
||||
$values['id_agent_module'] = db_get_value_filter(
|
||||
'id_agente_modulo as id_module',
|
||||
'tagente_modulo',
|
||||
[
|
||||
'id_agente' => $values['id_agent'],
|
||||
'nombre' => $values['id_agent_module'],
|
||||
]
|
||||
);
|
||||
|
||||
$id_template = db_get_value_filter(
|
||||
'id as id_template',
|
||||
'talert_templates',
|
||||
[
|
||||
'name' => $values['alert_name'],
|
||||
]
|
||||
);
|
||||
|
||||
// Get alert id.
|
||||
$id_alert = db_get_value_filter(
|
||||
'id as id_alert',
|
||||
'talert_template_modules',
|
||||
[
|
||||
'id_agent_module' => $values['id_agent_module'],
|
||||
'id_alert_template' => $id_template,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$result = alerts_validate_alert_agent_module($id_alert);
|
||||
} else {
|
||||
$id_template = db_get_value_filter(
|
||||
'id as id_template',
|
||||
'talert_templates',
|
||||
[
|
||||
'name' => $values['alert_name'],
|
||||
]
|
||||
);
|
||||
|
||||
// Get alert id.
|
||||
$id_alert = db_get_value_filter(
|
||||
'id as id_alert',
|
||||
'talert_template_modules',
|
||||
[
|
||||
'id_agent_module' => $values['id_agent_module'],
|
||||
'id_alert_template' => $id_template,
|
||||
]
|
||||
);
|
||||
|
||||
if ($id_alert === false) {
|
||||
returnError(
|
||||
'error_validate_alert',
|
||||
__('Error validating alert. Specified alert does not exist.')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$result = alerts_validate_alert_agent_module($id_alert);
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
returnData('string', ['type' => 'string', 'data' => 'Alert succesfully validated']);
|
||||
} else {
|
||||
returnData('string', ['type' => 'string', 'data' => __('Error validating alert')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate all alerts. And return a message with the result of the operation.
|
||||
*
|
||||
|
@ -12315,6 +12542,7 @@ function api_set_create_tag($id, $trash1, $other, $returnType)
|
|||
|
||||
|
||||
// http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=2|system|3|admin|2|1|10|0|comments||Pandora||critical_inst|warning_inst|unknown_inst|other||&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
|
||||
// http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=textodelevento|10|2|0|admin|going_down_critical|4|&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
|
||||
function api_set_create_event($id, $trash1, $other, $returnType)
|
||||
{
|
||||
global $config;
|
||||
|
|
|
@ -3161,7 +3161,7 @@ function events_get_agent(
|
|||
} else {
|
||||
return events_get_events_no_grouped(
|
||||
$sql_where,
|
||||
(is_metaconsole() && $id_server) ? true : false,
|
||||
(is_metaconsole() === true && $id_server === false) ? true : false,
|
||||
$history
|
||||
);
|
||||
}
|
||||
|
@ -5152,7 +5152,8 @@ function events_page_comments($event, $ajax=false)
|
|||
$childrens_ids
|
||||
))) && $config['show_events_in_local'] == false || $config['event_replication'] == false
|
||||
) {
|
||||
$comments_form = '<br><div id="comments_form" class="w98p">';
|
||||
$event['evento'] = io_safe_output($event['evento']);
|
||||
$comments_form = '<br><div id="comments_form" style="width:98%;">';
|
||||
$comments_form .= html_print_textarea(
|
||||
'comment',
|
||||
3,
|
||||
|
@ -5336,16 +5337,22 @@ function events_get_count_events_by_agent(
|
|||
|
||||
$tagente = 'tagente';
|
||||
$tevento = 'tevento';
|
||||
$field_type = 'ta.id_agente';
|
||||
if ($dbmeta === true) {
|
||||
$tagente = 'tmetaconsole_agent';
|
||||
$tevento = 'tmetaconsole_event';
|
||||
$field_type = 'ta.id_tagente';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT
|
||||
'SELECT
|
||||
ta.id_agente,
|
||||
ta.alias as agent_name,
|
||||
count(*) as count
|
||||
FROM %s te
|
||||
%s
|
||||
INNER JOIN %s ta
|
||||
ON te.id_agente = ta.id_agente
|
||||
ON te.id_agente = %s
|
||||
INNER JOIN tgrupo tg
|
||||
ON (te.id_grupo = tg.id_grupo AND tg.id_grupo IN (%s))
|
||||
OR (tg.id_grupo = tasg.id_group AND tasg.id_group IN (%s))
|
||||
|
@ -5354,6 +5361,7 @@ function events_get_count_events_by_agent(
|
|||
$tevento,
|
||||
events_get_secondary_groups_left_join($tevento),
|
||||
$tagente,
|
||||
$field_type,
|
||||
implode(',', $id_group),
|
||||
implode(',', $id_group),
|
||||
$datelimit,
|
||||
|
@ -5411,6 +5419,9 @@ function events_get_count_events_validated_by_user(
|
|||
) {
|
||||
global $config;
|
||||
$tevento = 'tevento';
|
||||
if ($dbmeta === true) {
|
||||
$tevento = 'tmetaconsole_event';
|
||||
}
|
||||
|
||||
// Group.
|
||||
$tgroup_join = '';
|
||||
|
@ -5433,6 +5444,7 @@ function events_get_count_events_validated_by_user(
|
|||
);
|
||||
}
|
||||
|
||||
$sql_filter = '';
|
||||
if (!empty($filter['id_agent'])) {
|
||||
$sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']);
|
||||
}
|
||||
|
@ -5607,6 +5619,9 @@ function events_get_count_events_by_criticity(
|
|||
global $config;
|
||||
|
||||
$tevento = 'tevento';
|
||||
if ($dbmeta === true) {
|
||||
$tevento = 'tmetaconsole_event';
|
||||
}
|
||||
|
||||
$sql_filter = '';
|
||||
$tgroup_join = '';
|
||||
|
@ -5794,6 +5809,9 @@ function events_get_count_events_validated(
|
|||
) {
|
||||
global $config;
|
||||
$tevento = 'tevento';
|
||||
if ($dbmeta === true) {
|
||||
$tevento = 'tmetaconsole_event';
|
||||
}
|
||||
|
||||
// Group.
|
||||
$sql_filter = '';
|
||||
|
|
|
@ -2136,7 +2136,7 @@ function html_print_input_text_extended(
|
|||
'list',
|
||||
];
|
||||
|
||||
$output = '<input '.($password ? 'type="password" autocomplete="'.$autocomplete.'" ' : 'type="text" ');
|
||||
$output = '<input '.($password ? 'type="password" autocomplete="'.$autocomplete.'" ' : 'type="text" autocomplete="'.$autocomplete.'"');
|
||||
|
||||
if ($readonly && (!is_array($attributes) || !array_key_exists('readonly', $attributes))) {
|
||||
$output .= 'readonly="readonly" ';
|
||||
|
@ -2406,7 +2406,7 @@ function html_print_input_text(
|
|||
$function='',
|
||||
$class='',
|
||||
$onChange='',
|
||||
$autocomplete='',
|
||||
$autocomplete='off',
|
||||
$autofocus=false,
|
||||
$onKeyDown='',
|
||||
$formTo='',
|
||||
|
@ -2445,10 +2445,6 @@ function html_print_input_text(
|
|||
$attr['onkeyup'] = $onKeyUp;
|
||||
}
|
||||
|
||||
if ($autocomplete !== '') {
|
||||
$attr['autocomplete'] = $autocomplete;
|
||||
}
|
||||
|
||||
if ($autofocus === true) {
|
||||
$attr['autofocus'] = $autofocus;
|
||||
}
|
||||
|
@ -2474,7 +2470,7 @@ function html_print_input_text(
|
|||
$return,
|
||||
false,
|
||||
$function,
|
||||
'off',
|
||||
$autocomplete,
|
||||
$disabled
|
||||
);
|
||||
}
|
||||
|
@ -2546,6 +2542,10 @@ function html_print_input_email(array $settings):string
|
|||
$settings['size'] = 255;
|
||||
}
|
||||
|
||||
if (isset($settings['autocomplete']) === false) {
|
||||
$settings['autocomplete'] = 'off';
|
||||
}
|
||||
|
||||
foreach ($settings as $attribute => $attr_value) {
|
||||
// Check valid attribute.
|
||||
if (in_array($attribute, $valid_attrs) === false) {
|
||||
|
@ -2632,6 +2632,10 @@ function html_print_input_number(array $settings):string
|
|||
$settings['maxlength'] = 255;
|
||||
}
|
||||
|
||||
if (isset($settings['autocomplete']) === false) {
|
||||
$settings['autocomplete'] = 'off';
|
||||
}
|
||||
|
||||
foreach ($settings as $attribute => $attr_value) {
|
||||
// Check valid attribute.
|
||||
if (in_array($attribute, $valid_attrs) === false) {
|
||||
|
@ -4420,7 +4424,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : 'off'),
|
||||
((isset($data['autofocus']) === true) ? $data['autofocus'] : false),
|
||||
((isset($data['onKeyDown']) === true) ? $data['onKeyDown'] : ''),
|
||||
((isset($data['form']) === true) ? $data['form'] : ''),
|
||||
|
@ -4605,6 +4609,28 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
);
|
||||
break;
|
||||
|
||||
case 'select_search':
|
||||
$output .= html_print_select_search(
|
||||
$data['fields'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||
((isset($data['dropdownAutoWidth']) === true) ? $data['dropdownAutoWidth'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select_metaconsole_nodes':
|
||||
$output .= html_print_select_from_sql(
|
||||
'SELECT `id`, `server_name` FROM `tmetaconsole_setup`',
|
||||
|
@ -5154,3 +5180,147 @@ function html_print_datalist(
|
|||
echo $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print or return selector with search bar.
|
||||
*
|
||||
* @param string $fields Select fields
|
||||
* @param boolean $name Name of input field.
|
||||
* @param array $selected Array with dropdown values. Example:
|
||||
* $fields["value"] = "label".
|
||||
* @param string $script Javascript onChange code.
|
||||
* @param mixed $nothing Label when nothing is selected.
|
||||
* @param array $nothing_value Value when nothing is selected.
|
||||
* @param string $return Return string or dump to output.
|
||||
* @param boolean $multiple Enable multiple select.
|
||||
* @param mixed $sort Sort values or not (default false).
|
||||
* @param boolean $class CSS classes to apply.
|
||||
* @param boolean $disabled Disabled or enabled.
|
||||
* @param boolean $style CSS inline style.
|
||||
* @param string $option_style CSS inline style in array format.
|
||||
* @param string $size Style, size (width) of element.
|
||||
* @param boolean $simple_multiple_options Discovery simple multiple inputs.
|
||||
* @param boolean $required Required input.
|
||||
* @param boolean $dropdownAutoWidth Set dropdown auto width.
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_select_search(
|
||||
$fields=[],
|
||||
$name=null,
|
||||
$selected='',
|
||||
$script='',
|
||||
$nothing='',
|
||||
$nothing_value=0,
|
||||
$return=false,
|
||||
$multiple=false,
|
||||
$sort=false,
|
||||
$class='',
|
||||
$disabled=false,
|
||||
$style=false,
|
||||
$option_style=false,
|
||||
$size=false,
|
||||
$simple_multiple_options=false,
|
||||
$required=false,
|
||||
$dropdownAutoWidth=false
|
||||
) {
|
||||
$output = '';
|
||||
|
||||
ui_require_css_file('select2.min');
|
||||
ui_require_javascript_file('select2.min');
|
||||
|
||||
if ($name === null) {
|
||||
static $idcounter = [];
|
||||
if (isset($idcounter[$name]) === true) {
|
||||
$idcounter[$name]++;
|
||||
} else {
|
||||
$idcounter[$name] = 0;
|
||||
}
|
||||
|
||||
$name = 'select'.$idcounter[$name];
|
||||
}
|
||||
|
||||
if (empty($nothing) === false) {
|
||||
$fields[$nothing_value] = $nothing;
|
||||
}
|
||||
|
||||
$output .= html_print_select(
|
||||
$fields,
|
||||
$name,
|
||||
$selected,
|
||||
$script,
|
||||
$nothing,
|
||||
$nothing_value,
|
||||
$return,
|
||||
$multiple,
|
||||
$sort,
|
||||
$class,
|
||||
$disabled,
|
||||
$style,
|
||||
$option_style,
|
||||
$size,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$simple_multiple_options,
|
||||
$required
|
||||
);
|
||||
|
||||
if (empty($size) === true) {
|
||||
$size = '100%';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<style type="text/css">
|
||||
.select2-search__field {
|
||||
background: url('<?php echo ui_get_full_url('images/zoom.png'); ?>') no-repeat;
|
||||
background-position: right 10px center;
|
||||
background-size: 1em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('select[name="<?php echo $name; ?>"]').each(
|
||||
function() {
|
||||
$(this).select2({
|
||||
multiple: <?php echo ($multiple) ? 'true' : 'false'; ?>,
|
||||
placeholder: "<?php echo __('Please select...'); ?>",
|
||||
debug: 0,
|
||||
width: '<?php echo $size; ?>',
|
||||
dropdownAutoWidth : '<?php echo $dropdownAutoWidth; ?>',
|
||||
templateResult: function(node) {
|
||||
if (!node.id) {
|
||||
return node.text;
|
||||
}
|
||||
return $('<span style="padding-left:' + (5 * node.level) + 'px;">' + node.text + '</span>');
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
<?php
|
||||
if (empty($fields) === true) {
|
||||
?>
|
||||
$('select[name="<?php echo $name; ?>"]').val(null).trigger("change");
|
||||
$('select[name="<?php echo $name; ?>"] option[value=""]').each(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$output .= ob_get_clean();
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
}
|
|
@ -2307,7 +2307,10 @@ function modules_get_agentmodule_data_for_humans($module)
|
|||
switch ($module['id_tipo_modulo']) {
|
||||
case 15:
|
||||
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
|
||||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
if (($value == '.1.3.6.1.2.1.1.3.0'
|
||||
|| $value == '.1.3.6.1.2.1.25.1.1.0')
|
||||
&& modules_get_unit_macro($module['data'], $module['unit']) === true
|
||||
) {
|
||||
if ($module['post_process'] > 0) {
|
||||
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
|
||||
} else {
|
||||
|
@ -2328,7 +2331,10 @@ function modules_get_agentmodule_data_for_humans($module)
|
|||
switch ($module['id_tipo_modulo']) {
|
||||
case 15:
|
||||
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
|
||||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
if (($value == '.1.3.6.1.2.1.1.3.0'
|
||||
|| $value == '.1.3.6.1.2.1.25.1.1.0')
|
||||
&& modules_get_unit_macro($module['data'], $module['unit']) === true
|
||||
) {
|
||||
if ($module['post_process'] > 0) {
|
||||
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
|
||||
} else {
|
||||
|
|
|
@ -189,6 +189,14 @@ function reporting_make_reporting_data(
|
|||
|
||||
$metaconsole_on = is_metaconsole();
|
||||
$index_content = 0;
|
||||
|
||||
usort(
|
||||
$contents,
|
||||
function ($a, $b) {
|
||||
return ($a['order'] <=> $b['order']);
|
||||
}
|
||||
);
|
||||
|
||||
foreach ($contents as $content) {
|
||||
$content['name'] = io_safe_input($content['name']);
|
||||
$content['description'] = io_safe_input($content['description']);
|
||||
|
@ -1828,9 +1836,8 @@ function reporting_event_report_group(
|
|||
$content['name'] = __('Event Report Group');
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
if (is_metaconsole() === true && empty($content['server_name']) === false) {
|
||||
$id_meta = metaconsole_get_id_server($content['server_name']);
|
||||
|
||||
$server = metaconsole_get_connection_by_id($id_meta);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
@ -1924,7 +1931,7 @@ function reporting_event_report_group(
|
|||
$filter_event_filter_exclude
|
||||
);
|
||||
|
||||
if (empty($data)) {
|
||||
if (empty($data) === true) {
|
||||
$return['failed'] = __('No events');
|
||||
} else {
|
||||
$return['data'] = array_reverse($data);
|
||||
|
@ -1952,10 +1959,9 @@ function reporting_event_report_group(
|
|||
$return['chart']['by_criticity'] = null;
|
||||
$return['chart']['validated_vs_unvalidated'] = null;
|
||||
$server_name = $content['server_name'];
|
||||
if (is_metaconsole() && $server_name != '') {
|
||||
$metaconsole_dbtable = false;
|
||||
if (is_metaconsole() === true && empty($server_name) === true) {
|
||||
$metaconsole_dbtable = true;
|
||||
} else {
|
||||
$metaconsole_dbtable = false;
|
||||
}
|
||||
|
||||
if ($event_graph_by_agent) {
|
||||
|
@ -2065,11 +2071,11 @@ function reporting_event_report_group(
|
|||
);
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
if (is_metaconsole() === true) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
// total_events.
|
||||
// Total events.
|
||||
if ($return['data'] != '') {
|
||||
$return['total_events'] = count($return['data']);
|
||||
} else {
|
||||
|
|
|
@ -458,7 +458,7 @@ function tactical_monitor_alerts($group_array, $strict_user=false, $id_group_str
|
|||
$sql = "SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo IN $group_clause_strict AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.disabled = 0 AND tagente_modulo.disabled = 0
|
||||
AND talert_template_modules.disabled = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo";
|
||||
|
@ -470,7 +470,7 @@ function tactical_monitor_alerts($group_array, $strict_user=false, $id_group_str
|
|||
"SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
|
||||
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.disabled = 0 AND tagente_modulo.disabled = 0
|
||||
AND talert_template_modules.disabled = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"
|
||||
|
@ -499,7 +499,8 @@ function tactical_monitor_fired_alerts($group_array, $strict_user=false, $id_gro
|
|||
WHERE tagente.id_grupo IN $group_clause_strict AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0 AND talert_template_modules.disabled = 0";
|
||||
AND times_fired > 0 AND talert_template_modules.disabled = 0
|
||||
AND tagente.disabled = 0 AND tagente_modulo.disabled = 0";
|
||||
|
||||
$count = db_get_sql($sql);
|
||||
return $count;
|
||||
|
@ -511,7 +512,8 @@ function tactical_monitor_fired_alerts($group_array, $strict_user=false, $id_gro
|
|||
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0 AND talert_template_modules.disabled = 0"
|
||||
AND times_fired > 0 AND talert_template_modules.disabled = 0
|
||||
AND tagente.disabled = 0 AND tagente_modulo.disabled = 0"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4272,16 +4272,16 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me
|
|||
}
|
||||
} else {
|
||||
if ($proxy) {
|
||||
if (is_metaconsole() && $metaconsole_root) {
|
||||
$fullurl .= ENTERPRISE_DIR.'/meta';
|
||||
}
|
||||
|
||||
$fullurl .= '/';
|
||||
} else {
|
||||
if ($add_name_php_file) {
|
||||
$fullurl .= $_SERVER['SCRIPT_NAME'];
|
||||
} else {
|
||||
$fullurl .= $config['homeurl_static'].'/';
|
||||
|
||||
if (is_metaconsole() && $metaconsole_root) {
|
||||
$fullurl .= 'enterprise/meta/';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -763,7 +763,7 @@ function newsletter_wiz_modal(
|
|||
$output .= __('Do you want to be up to date?');
|
||||
$output .= '" class="invisible">';
|
||||
$output .= '<div class="register_update_manager">';
|
||||
$output .= html_print_image('image/pandora_big_circle.png', true);
|
||||
$output .= html_print_image('images/pandora_circle_big.png', true);
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<div class="newsletter_div">';
|
||||
|
|
|
@ -409,7 +409,7 @@ function print_excerpt(id_div, response) {
|
|||
category_names(elem.categories) +
|
||||
"</span></p>" +
|
||||
updated +
|
||||
elem.content.rendered +
|
||||
format_download_link(elem.content.rendered) +
|
||||
'<div class="view_web"><a href="' +
|
||||
elem.link +
|
||||
'" target="_blank"><button class="sub next">' +
|
||||
|
@ -516,3 +516,14 @@ function show_error_msg(selector, message_error) {
|
|||
$(selector).append("<div id='empty_result'>" + message_error + "</div>");
|
||||
}
|
||||
}
|
||||
|
||||
function format_download_link(html) {
|
||||
const regex = /href="(?!\bhttps?:\/\/\b)(?!pandorafms.com)(.*)"/gm;
|
||||
var str = html;
|
||||
const subst = `href="https://pandorafms.com$1"`;
|
||||
|
||||
// The substituted value will be contained in the result variable
|
||||
const result = str.replace(regex, subst);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#form_setup {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-items: baseline;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
background-color: #fff;
|
||||
border: 1px solid #e2e2e2;
|
||||
padding: 0.5em;
|
||||
margin: 0px 1em;
|
||||
margin-bottom: 20px;
|
||||
position: relative;
|
||||
border-radius: 5px;
|
||||
flex: 1 1 700px;
|
||||
}
|
||||
|
||||
.full-column {
|
||||
width: 100%;
|
||||
flex: none;
|
||||
margin: 0 0 20px;
|
||||
}
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.753';
|
||||
$build = '210406';
|
||||
$build = '210407';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -18,6 +18,14 @@ body {
|
|||
font-size: 10px !important;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.invisible {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ui-header .ui-title {
|
||||
font-size: 14px !important;
|
||||
}
|
||||
|
@ -1086,6 +1094,11 @@ li.ui-btn {
|
|||
border-radius: 0px;
|
||||
}
|
||||
|
||||
.center {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* For mobiles */
|
||||
@media screen and (max-width: 750px) {
|
||||
.ui-content > .ui-btn {
|
||||
|
|
|
@ -286,9 +286,28 @@ class Agent
|
|||
];
|
||||
}
|
||||
|
||||
// Module searchbox.
|
||||
$ui->beginForm('javascript:agent_filter_modules();');
|
||||
$ui->formAddInput(
|
||||
[
|
||||
'id' => 'filter-modules',
|
||||
'name' => 'filter-modules',
|
||||
]
|
||||
);
|
||||
$ui->formAddInput(
|
||||
[
|
||||
'id' => 'filter-modules',
|
||||
'name' => 'filter-modules',
|
||||
'type' => 'submit',
|
||||
'value' => __('Search'),
|
||||
]
|
||||
);
|
||||
$filtering = $ui->getEndForm();
|
||||
|
||||
$modules->setFilters($filters);
|
||||
$modules->disabledColumns(['agent']);
|
||||
$ui->contentBeginCollapsible(__('Modules'));
|
||||
$ui->contentCollapsibleAddItem($filtering);
|
||||
$ui->contentCollapsibleAddItem($modules->listModulesHtml(0, true));
|
||||
$ui->contentEndCollapsible();
|
||||
|
||||
|
@ -389,6 +408,33 @@ class Agent
|
|||
set_same_heigth();
|
||||
}
|
||||
});
|
||||
|
||||
function agent_filter_modules() {
|
||||
$.mobile.showPageLoadingMsg();
|
||||
$.ajax ({
|
||||
type: 'POST',
|
||||
url: 'index.php',
|
||||
dataType: 'text',
|
||||
data: {
|
||||
'action': 'ajax',
|
||||
'parameter1': 'agent',
|
||||
'id': ".$this->id.",
|
||||
'parameter2': 'filter-modules',
|
||||
'filter': $('#filter-modules').val()
|
||||
},
|
||||
success: function(r) {
|
||||
$.mobile.hidePageLoadingMsg();
|
||||
var className = $('#list_agent_Modules').attr('class');
|
||||
$('#list_agent_Modules').parent().html(r);
|
||||
$('#list_agent_Modules').addClass(className);
|
||||
},
|
||||
error: function(r, t, e) {
|
||||
$.mobile.hidePageLoadingMsg();
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>"
|
||||
);
|
||||
|
||||
|
@ -397,4 +443,40 @@ class Agent
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bob do something!
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ajax($parameter2=null)
|
||||
{
|
||||
$system = System::getInstance();
|
||||
|
||||
if ($parameter2 === 'filter-modules') {
|
||||
$name_filter = $system->getRequest('filter', '');
|
||||
$modules = new Modules();
|
||||
|
||||
if ($system->getConfig('metaconsole')) {
|
||||
$filters = [
|
||||
'id_agent' => $this->agent['id_tagente'],
|
||||
'all_modules' => true,
|
||||
'status' => -1,
|
||||
'name' => $name_filter,
|
||||
];
|
||||
} else {
|
||||
$filters = [
|
||||
'id_agent' => $this->id,
|
||||
'all_modules' => true,
|
||||
'status' => -1,
|
||||
'name' => $name_filter,
|
||||
];
|
||||
}
|
||||
|
||||
$modules->setFilters($filters);
|
||||
$modules->disabledColumns(['agent']);
|
||||
echo $modules->listModulesHtml(0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ class Modules
|
|||
|
||||
private $free_search = '';
|
||||
|
||||
private $name = '';
|
||||
|
||||
private $module_group = -1;
|
||||
|
||||
private $tag = '';
|
||||
|
@ -106,6 +108,10 @@ class Modules
|
|||
if (isset($filters['status'])) {
|
||||
$this->status = $filters['status'];
|
||||
}
|
||||
|
||||
if (isset($filters['name'])) {
|
||||
$this->name = $filters['name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -374,6 +380,14 @@ class Modules
|
|||
);
|
||||
}
|
||||
|
||||
// Search by module name.
|
||||
if ($this->name != '') {
|
||||
$sql_conditions .= sprintf(
|
||||
" AND lower(tagente_modulo.nombre) LIKE lower('%%%s%%') ",
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
|
||||
// Part SQL fro Status
|
||||
if ($this->status == AGENT_MODULE_STATUS_NORMAL) {
|
||||
// Normal
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Events sounds.
|
||||
*
|
||||
* @category Sounds
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Don't start a session before this import.
|
||||
// The session is configured and started inside the config process.
|
||||
require_once '../../include/config.php';
|
||||
require_once '../../include/functions.php';
|
||||
require_once '../../include/functions_db.php';
|
||||
|
@ -20,7 +33,7 @@ require_once '../../include/auth/mysql.php';
|
|||
|
||||
global $config;
|
||||
|
||||
// Check user
|
||||
// Check user.
|
||||
check_login();
|
||||
$config['id_user'] = $_SESSION['id_usuario'];
|
||||
|
||||
|
@ -29,7 +42,10 @@ $event_w = check_acl($config['id_user'], 0, 'EW');
|
|||
$event_m = check_acl($config['id_user'], 0, 'EM');
|
||||
$access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'ER'));
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'ER') && ! check_acl($config['id_user'], 0, 'EW') && ! check_acl($config['id_user'], 0, 'EM')) {
|
||||
if (check_acl($config['id_user'], 0, 'ER') === false
|
||||
&& check_acl($config['id_user'], 0, 'EW') === false
|
||||
&& check_acl($config['id_user'], 0, 'EM') === false
|
||||
) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to access event viewer');
|
||||
include 'general/noaccess.php';
|
||||
|
||||
|
@ -49,7 +65,7 @@ echo '<title>'.__('Sound Events').'</title>';
|
|||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
@ -72,7 +88,12 @@ $conn_title = __('Connection with server has been lost');
|
|||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||
ui_require_javascript_file('connection_check');
|
||||
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
||||
ui_print_message_dialog(
|
||||
$conn_title,
|
||||
$conn_text,
|
||||
'connection',
|
||||
'/images/error_1.png'
|
||||
);
|
||||
|
||||
$table = new StdClass;
|
||||
$table->width = '100%';
|
||||
|
@ -83,16 +104,91 @@ $table->rowclass[1] = 'bold_top';
|
|||
$table->rowclass[2] = 'bold_top';
|
||||
|
||||
$table->data[0][0] = __('Group');
|
||||
$table->data[0][1] = html_print_select_groups(false, $access, true, 'group', '', 'changeGroup();', '', 0, true, false, true, '', false, 'max-width:200px;').'<br />'.'<br />';
|
||||
$table->data[0][1] = html_print_select_groups(
|
||||
false,
|
||||
$access,
|
||||
true,
|
||||
'group',
|
||||
'',
|
||||
'changeGroup();',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'max-width:200px;'
|
||||
).'<br /><br />';
|
||||
|
||||
$table->data[0][2] = __('Type');
|
||||
$table->data[0][3] = html_print_checkbox('alert_fired', 'alert_fired', true, true, false, 'changeType();').__('Alert fired').'<br />'.html_print_checkbox('critical', 'critical', true, true, false, 'changeType();').__('Monitor critical').'<br />'.html_print_checkbox('unknown', 'unknown', true, true, false, 'changeType();').__('Monitor unknown').'<br />'.html_print_checkbox('warning', 'warning', true, true, false, 'changeType();').__('Monitor warning').'<br />';
|
||||
$table->data[0][3] = html_print_checkbox(
|
||||
'alert_fired',
|
||||
'alert_fired',
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'changeType();'
|
||||
);
|
||||
$table->data[0][3] .= __('Alert fired').'<br />';
|
||||
$table->data[0][3] .= html_print_checkbox(
|
||||
'critical',
|
||||
'critical',
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'changeType();'
|
||||
);
|
||||
$table->data[0][3] .= __('Monitor critical').'<br />';
|
||||
$table->data[0][3] .= html_print_checkbox(
|
||||
'unknown',
|
||||
'unknown',
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'changeType();'
|
||||
);
|
||||
$table->data[0][3] .= __('Monitor unknown').'<br />';
|
||||
$table->data[0][3] .= html_print_checkbox(
|
||||
'warning',
|
||||
'warning',
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'changeType();'
|
||||
);
|
||||
$table->data[0][3] .= __('Monitor warning').'<br />';
|
||||
|
||||
$table->data[1][0] = __('Agent');
|
||||
$table->data[1][1] = html_print_select($agents, 'id_agents[]', true, false, '', '', true, true, '', '', '', 'max-width:200px; height:100px', '', false, '', '', true);
|
||||
$table->data[1][1] = html_print_select(
|
||||
$agents,
|
||||
'id_agents[]',
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'max-width:200px; height:100px',
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][2] = __('Event');
|
||||
$table->data[1][3] = html_print_textarea('events_fired', 200, 20, '', 'readonly="readonly" style="max-height:100px; resize:none;"', true);
|
||||
$table->data[1][3] = html_print_textarea(
|
||||
'events_fired',
|
||||
200,
|
||||
20,
|
||||
'',
|
||||
'readonly="readonly" style="max-height:100px; resize:none;"',
|
||||
true
|
||||
);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
|
@ -100,13 +196,41 @@ $table = new StdClass;
|
|||
$table->width = '100%';
|
||||
$table->class = 'w16px sound_div_background text_center';
|
||||
|
||||
$table->data[0][0] = '<a href="javascript: toggleButton();">'.html_print_image('images/play.button.png', true, ['id' => 'button']).'</a>';
|
||||
$table->data[0][0] = '<a href="javascript: toggleButton();">';
|
||||
$table->data[0][0] .= html_print_image(
|
||||
'images/play.button.png',
|
||||
true,
|
||||
['id' => 'button']
|
||||
);
|
||||
$table->data[0][0] .= '</a>';
|
||||
|
||||
$table->data[0][1] .= '<a href="javascript: ok();">'.html_print_image('images/ok.button.png', true, ['style' => 'margin-left: 15px;']).'</a>';
|
||||
$table->data[0][1] = '<a href="javascript: ok();">';
|
||||
$table->data[0][1] .= html_print_image(
|
||||
'images/ok.button.png',
|
||||
true,
|
||||
['style' => 'margin-left: 15px;']
|
||||
);
|
||||
$table->data[0][1] .= '</a>';
|
||||
|
||||
$table->data[0][2] .= '<a href="javascript: test_sound_button();">'.html_print_image('images/icono_test.png', true, ['id' => 'button_try', 'style' => 'margin-left: 15px;']).'</a>';
|
||||
$table->data[0][2] = '<a href="javascript: test_sound_button();">';
|
||||
$table->data[0][2] .= html_print_image(
|
||||
'images/icono_test.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'button_try',
|
||||
'style' => 'margin-left: 15px;',
|
||||
]
|
||||
);
|
||||
$table->data[0][2] .= '</a>';
|
||||
|
||||
$table->data[0][3] .= html_print_image('images/tick_sound_events.png', true, ['id' => 'button_status', 'style' => 'margin-left: 15px;']);
|
||||
$table->data[0][3] = html_print_image(
|
||||
'images/tick_sound_events.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'button_status',
|
||||
'style' => 'margin-left: 15px;',
|
||||
]
|
||||
);
|
||||
|
||||
html_print_table($table);
|
||||
?>
|
||||
|
@ -149,10 +273,12 @@ function changeGroup() {
|
|||
},
|
||||
function (data) {
|
||||
$("#id_agents").empty();
|
||||
|
||||
jQuery.each (data, function (id, value) {
|
||||
if (value != "") {
|
||||
$("#id_agents").append('<option value="' + id + '">' + value + '</option>');
|
||||
$("#id_agents")
|
||||
.append(
|
||||
'<option value="' + id + '">' + value + '</option>'
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -187,14 +313,14 @@ function toggleButton() {
|
|||
if (button_play_status == 'pause') {
|
||||
$("#button").attr('src', '../../images/play.button.png');
|
||||
stopSound();
|
||||
|
||||
|
||||
button_play_status = 'play';
|
||||
}
|
||||
else {
|
||||
$("#button").attr('src', '../../images/pause.button.png');
|
||||
forgetPreviousEvents();
|
||||
startSound();
|
||||
|
||||
|
||||
button_play_status = 'pause';
|
||||
}
|
||||
}
|
||||
|
@ -207,9 +333,7 @@ function ok() {
|
|||
|
||||
function stopSound() {
|
||||
$('audio').remove();
|
||||
|
||||
$('body').css('background', '#494949');
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
|
@ -263,13 +387,21 @@ function check_event() {
|
|||
var actual_text = $('#textarea_events_fired').val();
|
||||
if (actual_text == "") {
|
||||
$('#textarea_events_fired').val(data['message'] + "\n");
|
||||
} else {
|
||||
$('#textarea_events_fired')
|
||||
.val(actual_text + "\n" + data['message'] + "\n");
|
||||
}
|
||||
else {
|
||||
$('#textarea_events_fired').val(actual_text + "\n" + data['message'] + "\n");
|
||||
}
|
||||
$('#button_status').attr('src','../../images/sound_events_console_alert.gif');
|
||||
$('#button_status')
|
||||
.attr(
|
||||
'src','../../images/sound_events_console_alert.gif'
|
||||
);
|
||||
$('audio').remove();
|
||||
$('body').append("<audio src='../../" + data['sound'] + "' autoplay='true' hidden='true' loop='true'>");
|
||||
if(data['sound'] == '') {
|
||||
data['sound'] = 'include/sounds/Star_Trek_emergency_simulation.wav';
|
||||
}
|
||||
|
||||
$('body')
|
||||
.append("<audio src='../../" + data['sound'] + "' autoplay='true' hidden='true' loop='true'>");
|
||||
}
|
||||
},
|
||||
"json"
|
||||
|
@ -278,7 +410,8 @@ function check_event() {
|
|||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
setInterval("check_event()", (10 * 1000)); //10 seconds between ajax request
|
||||
//10 seconds between ajax request
|
||||
setInterval("check_event()", (10 * 1000));
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -2050,7 +2050,7 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields` (
|
|||
`name` varchar(45) NOT NULL default '',
|
||||
`display_on_front` tinyint(1) NOT NULL default 0,
|
||||
`is_password_type` tinyint(1) NOT NULL default 0,
|
||||
`combo_values` VARCHAR(255) DEFAULT '',
|
||||
`combo_values` TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id_field`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.753-210406
|
||||
Version: 7.0NG.753-210407
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.753-210406"
|
||||
pandora_version="7.0NG.753-210407"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.753";
|
||||
my $pandora_build = "210406";
|
||||
my $pandora_build = "210407";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -681,7 +681,12 @@ sub pandora_process_alert ($$$$$$$$;$$) {
|
|||
$alert->{'critical_instructions'} = $critical_instructions;
|
||||
$alert->{'warning_instructions'} = $warning_instructions;
|
||||
$alert->{'unknown_instructions'} = $unknown_instructions;
|
||||
|
||||
|
||||
# Generate event only if not quieted by module or agent.
|
||||
return if ((ref($module) eq 'HASH' && $module->{'quiet'} != "0")
|
||||
|| (ref($agent) eq 'HASH' && $agent->{'quiet'} != "0")
|
||||
|| (ref($alert) eq 'HASH' && $alert->{'disable_event'} != "0"));
|
||||
|
||||
# Generate an event
|
||||
if ($table eq 'tevent_alert') {
|
||||
pandora_event ($pa_config, "Alert ceased (" .
|
||||
|
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.753";
|
||||
my $pandora_build = "210406";
|
||||
my $pandora_build = "210407";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.753
|
||||
%define release 210406
|
||||
%define release 210407
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.753"
|
||||
PI_BUILD="210406"
|
||||
PI_BUILD="210407"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.753 PS210406";
|
||||
my $version = "7.0NG.753 PS210407";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.753 PS210406";
|
||||
my $version = "7.0NG.753 PS210407";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
@ -176,6 +176,7 @@ sub help_screen{
|
|||
help_screen_line('--get_alert_actions_meta', '[<server_name> <action_name> <separator> <return_type>]', 'get all alert actions in nodes');
|
||||
help_screen_line('--update_alert_template', "<template_name> <field_to_change> \n\t <new_value>", 'Update a field of an alert template');
|
||||
help_screen_line('--validate_all_alerts', '', 'Validate all the alerts');
|
||||
help_screen_line('--validate_alert', '<template_name> <agent_id> <module_id> [<use_alias>]', 'Validate alert given angent, module and alert');
|
||||
help_screen_line('--create_special_day', "<special_day> <same_day> <description> <group>", 'Create special day');
|
||||
help_screen_line('--delete_special_day', '<special_day>', 'Delete special day');
|
||||
help_screen_line('--update_special_day', "<special_day> <field_to_change> <new_value>", 'Update a field of a special day');
|
||||
|
@ -4532,6 +4533,86 @@ sub cli_validate_all_alerts() {
|
|||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Validate all the alerts
|
||||
# Related option: --validate_alert
|
||||
##############################################################################
|
||||
|
||||
sub cli_validate_alert() {
|
||||
my ($template_name, $agent_id, $module_id, $use_alias) = @ARGV[2..6];
|
||||
my $id_agent = '';
|
||||
my $id_agentmodule = '';
|
||||
|
||||
my $result = 0;
|
||||
|
||||
if (defined $use_alias and $use_alias eq 'use_alias') {
|
||||
my @id_agents = get_agent_ids_from_alias($dbh,$agent_id);
|
||||
if(!@id_agents) {
|
||||
print (STDERR "[ERROR] Error: The agent '$agent_id' not exists.\n\n");
|
||||
}
|
||||
|
||||
foreach my $id (@id_agents) {
|
||||
if(defined($agent_id) && $agent_id ne '') {
|
||||
$id_agent = $id->{'id_agente'};
|
||||
exist_check($id_agent,'agent',$agent_id);
|
||||
|
||||
if($module_id ne '') {
|
||||
$module_id = get_agent_module_id($dbh, $module_id, $id_agent);
|
||||
if ($module_id eq -1) {
|
||||
next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $id_alert_agent_module = '';
|
||||
|
||||
if(defined($template_name) && $template_name ne '') {
|
||||
my $id_template = get_template_id($dbh,$template_name);
|
||||
exist_check($id_template,'template',$template_name);
|
||||
$id_alert_agent_module = get_template_module_id($dbh,$module_id,$id_template);
|
||||
exist_check($id_alert_agent_module,'template module',$template_name);
|
||||
}
|
||||
|
||||
|
||||
$result = pandora_validate_alert_id($id_alert_agent_module, $id, $module_id, $template_name);
|
||||
print_log "[INFO] Validating alert for agent '$id->{'nombre'}'\n\n";
|
||||
}
|
||||
} else {
|
||||
if(defined($agent_id) && $agent_id ne '') {
|
||||
my $agent_name = get_agent_name($dbh,$agent_id);
|
||||
exist_check($agent_id,'agent',$agent_name);
|
||||
|
||||
if($module_id ne '') {
|
||||
my $module_name = get_module_name($dbh, $module_id);
|
||||
exist_check($module_id,'module',$module_name);
|
||||
}
|
||||
}
|
||||
|
||||
my $id_alert_agent_module = '';
|
||||
|
||||
if(defined($template_name) && $template_name ne '') {
|
||||
my $id_template = get_template_id($dbh,$template_name);
|
||||
exist_check($id_template,'template',$template_name);
|
||||
$id_alert_agent_module = get_template_module_id($dbh,$module_id,$id_template);
|
||||
exist_check($id_alert_agent_module,'template module',$template_name);
|
||||
}
|
||||
|
||||
$result = pandora_validate_alert_id($id_alert_agent_module, $id_agent, $module_id, $template_name);
|
||||
print_log "[INFO] Validating alert for agent '$agent_id'\n\n";
|
||||
}
|
||||
|
||||
if($result == 0) {
|
||||
print_log "[ERROR] Alert could not be validated\n\n";
|
||||
}
|
||||
else {
|
||||
print_log "[INFO] Alert succesfully validated\n\n";
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Validate the alerts of a given policy
|
||||
# Related option: --validate_policy_alerts
|
||||
|
@ -7505,6 +7586,10 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 0);
|
||||
cli_validate_all_alerts();
|
||||
}
|
||||
elsif ($param eq '--validate_alert') {
|
||||
param_check($ltotal, 5,4);
|
||||
cli_validate_alert();
|
||||
}
|
||||
elsif ($param eq '--validate_policy_alerts') {
|
||||
param_check($ltotal, 1);
|
||||
cli_validate_policy_alerts();
|
||||
|
@ -8416,4 +8501,59 @@ sub cli_event_in_progress() {
|
|||
);
|
||||
|
||||
print "\n$result\n";
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Validates an alert given id alert, id module, id angent and template name.
|
||||
##############################################################################
|
||||
sub pandora_validate_alert_id($$$$) {
|
||||
my ($id_alert_agent_module, $agent_id, $id_agent_module, $template_name) = @_;
|
||||
|
||||
|
||||
my $group_id = get_agent_group($dbh, $agent_id);
|
||||
|
||||
my $critical_instructions = get_db_value($dbh, 'SELECT critical_instructions from tagente_modulo WHERE id_agente_modulo = ?', $agent_id);
|
||||
my $warning_instructions = get_db_value($dbh, 'SELECT warning_instructions from tagente_modulo WHERE id_agente_modulo = ?', $agent_id);
|
||||
my $unknown_instructions = get_db_value($dbh, 'SELECT unknown_instructions from tagente_modulo WHERE id_agente_modulo = ?', $agent_id);
|
||||
|
||||
my $parameters = {
|
||||
'times_fired' => 0,
|
||||
'internal_counter' => 0,
|
||||
};
|
||||
|
||||
my $result = db_process_update($dbh, 'talert_template_modules', $parameters,{'id' => $id_alert_agent_module});
|
||||
|
||||
return 0 unless $result != 0;
|
||||
|
||||
my $module_name = safe_output(get_db_value($dbh, 'SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ?', $id_agent_module));
|
||||
|
||||
|
||||
# Update fired alert count on the agent
|
||||
db_process_update($dbh, 'tagente', {'update_alert_count' => 1}, {'id_agente' => $agent_id});
|
||||
|
||||
my $event = 'Manual validation of alert '.$template_name.' assigned to '.$module_name.'';
|
||||
|
||||
pandora_event(
|
||||
$conf,
|
||||
$event,
|
||||
$group_id,
|
||||
$agent_id,
|
||||
0,
|
||||
$id_alert_agent_module,
|
||||
$id_agent_module,
|
||||
'alert_manual_validation',
|
||||
1,
|
||||
$dbh,
|
||||
0,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$critical_instructions,
|
||||
$warning_instructions,
|
||||
$unknown_instructions,
|
||||
''
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
Loading…
Reference in New Issue