Merge remote-tracking branch 'origin/develop' into ent-9714-traducciones

Conflicts:
	pandora_console/include/visual-console-client/maintenanceMode.png
	visual_console_client/src/lib/maintenanceMode.png
This commit is contained in:
Daniel Barbero 2022-11-04 11:14:20 +01:00
commit 39df7fe13a
82 changed files with 53250 additions and 49273 deletions

View File

@ -170,7 +170,7 @@ http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
execute_cmd "yum install -y $extra_repos" "Installing extra repositories"
execute_cmd "yum-config-manager --enable remi-php74" "Configuring PHP"
execute_cmd "yum-config-manager --enable remi-php80" "Configuring PHP"
# Install percona Database
#[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf

View File

@ -20,7 +20,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$MYVER" ] || MYVER=57
[ "$PHPVER" ] || PHPVER=7
[ "$PHPVER" ] || PHPVER=8
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora

View File

@ -21,7 +21,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$PHPVER" ] || PHPVER=7.4
[ "$PHPVER" ] || PHPVER=8.0
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora
@ -138,6 +138,9 @@ check_root_permissions
# Connectivity
check_repo_connection
#Install awk, sed, grep if not present
execute_cmd "apt install -y gawk sed grep" 'Installing needed tools'
# Systemd
execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
@ -155,7 +158,7 @@ execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
execute_cmd "awk --version" 'Checking needed tools: awk'
execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed'
execute_cmd "apt --version" 'Checking needed tools: dnf'
execute_cmd "apt --version" 'Checking needed tools: apt'
# Creating working directory
rm -rf "$WORKDIR" &>> "$LOGFILE"

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.765-221028
Version: 7.0NG.765-221104
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.765-221028"
pandora_version="7.0NG.765-221104"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.765"
PI_BUILD="221028"
PI_BUILD="221104"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{221028}
{221104}
ViewReadme
{Yes}

View File

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

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.765(Build 221028))"
VALUE "ProductVersion", "(7.0NG.765(Build 221104))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.765-221028
Version: 7.0NG.765-221104
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.765-221028"
pandora_version="7.0NG.765-221104"
package_pear=0
package_pandora=1

View File

@ -1,5 +1,9 @@
START TRANSACTION;
ALTER TABLE `trecon_task` ADD COLUMN `snmp_skip_non_enabled_ifs` TINYINT UNSIGNED DEFAULT 1;
ALTER TABLE `tlayout` ADD COLUMN `maintenance_mode` TEXT;
ALTER TABLE `tusuario` ADD COLUMN `auth_token_secret` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2;
@ -7,4 +11,6 @@ ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT '
ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
ALTER TABLE `tcredential_store` MODIFY COLUMN `product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM';
COMMIT;

View File

@ -140,6 +140,49 @@ if ($id_module_type >= 6 && $id_module_type <= 7) {
push_table_simple($data, 'target_ip');
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$data = [];
$data[0] = __('Credential store');
$data[1] = html_print_select(
$fields,
'credentials',
0,
'',
__('None'),
0,
true,
false,
false,
'',
false,
false,
'',
false
);
push_table_simple($data, 'snmp_credentials');
}
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
@ -316,6 +359,7 @@ if ($id_module_type < 15 || $id_module_type > 18) {
// NOT SNMP.
$table_simple->rowstyle['snmp_1'] = 'display: none';
$table_simple->rowstyle['snmp_2'] = 'display: none';
$table_simple->rowstyle['snmp_credentials'] = 'display: none';
}
// For a policy.
@ -569,6 +613,49 @@ $(document).ready (function () {
$(this).css ("width", "180px");
});
$("#credentials").change (function() {
if ($('#credentials').val() !== '0') {
$.ajax({
method: "post",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: {
page: "godmode/agentes/agent_wizard",
method: "getCredentials",
identifier: $('#credentials').val()
},
datatype: "json",
success: function(data) {
data = JSON.parse(data);
extra = JSON.parse(data['extra_1']);
$('#snmp_version').val(extra['version']);
$('#snmp_version').trigger('change');
$('#text-snmp_community').val(extra['community']);
if (extra['version'] === '3') {
$('#snmp3_security_level').val(extra['securityLevelV3']);
$('#snmp3_security_level').trigger('change');
$('#text-snmp3_auth_user').val(extra['authUserV3']);
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
$('#snmp3_auth_method').val(extra['authMethodV3']);
$('#snmp3_auth_method').trigger('change');
$('#password-snmp3_auth_pass').val(extra['authPassV3']);
if (extra['securityLevelV3'] === 'authPriv') {
$('#snmp3_privacy_method').val(extra['privacyMethodV3']);
$('#snmp3_privacy_method').trigger('change');
$('#password-snmp3_privacy_pass').val(extra['privacyPassV3']);
}
}
}
},
error: function(e) {
console.error(e);
}
});
}
});
$("#id_module_type").click (
function () {
$(this).css ("width", "auto");

View File

@ -59,7 +59,7 @@ if ($id_group) {
}
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->style[0] = 'font-weight: bold';

View File

@ -141,6 +141,7 @@ if ($table !== null) {
unset($table);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data = [];

View File

@ -0,0 +1,717 @@
<?php
/**
* View for edit users in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 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.
* ============================================================================
*/
// Begin.
check_login();
global $config;
if (users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access massive edit users'
);
include 'general/noaccess.php';
return;
}
if (is_management_allowed() === false) {
if (is_metaconsole() === false) {
$url = '<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure='.(int) $config['pure']
).'">'.__('metaconsole').'</a>';
} else {
$url = __('any node');
}
ui_print_warning_message(
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
$url
)
);
return;
}
if (is_metaconsole() === true) {
include_once $config['homedir'].'/include/functions_visual_map.php';
open_meta_frame();
}
$edit_users = (int) get_parameter('edit_users');
if ($edit_users === 1) {
$users = get_parameter('id_users', false, false);
if ($users !== false) {
$update = [];
$language = (string) get_parameter('language', '-1');
if ($language !== '-1') {
$update['language'] = $language;
}
$block_size_change = (int) get_parameter('block_size_change');
if ($block_size_change === 0) {
$block_size = (int) get_parameter('block_size', -1);
if ($block_size !== -1) {
$update['block_size'] = $block_size;
}
}
$section = get_parameter('section', '-1');
if ($section !== '-1') {
$update['section'] = $section;
}
$data_section = get_parameter('data_section', '');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
$section = io_safe_output($section);
if (($section === 'Event list') || ($section === 'Group view')
|| ($section === 'Alert detail') || ($section === 'Tactical view')
|| ($section === 'Default')
) {
$update['data_section'] = '';
} else if ($section === 'Dashboard') {
$update['data_section'] = $dashboard;
} else if ($section === 'Visual console') {
$update['data_section'] = $visual_console;
}
$event = (int) get_parameter('event_filter', -1);
if ($event !== -1) {
$update['default_event_filter'] = $event;
}
$autorefresh_list = get_parameter_post('autorefresh_list', [0 => '-1']);
if ($autorefresh_list[0] !== '-1') {
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
$update['autorefresh_white_list'] = '';
} else {
$update['autorefresh_white_list'] = json_encode($autorefresh_list);
}
}
$time_autorefresh = (int) get_parameter('time_autorefresh', -1);
if ($time_autorefresh !== -1) {
$update['time_autorefresh'] = $time_autorefresh;
}
$timezone = (string) get_parameter('timezone', '-1');
if ($timezone !== '-1') {
$update['timezone'] = $timezone;
}
$disabled = (int) get_parameter('disabled', -1);
if ($disabled !== -1) {
$update['disabled'] = $disabled;
}
$error = [];
$success = [];
foreach ($users as $key => $user) {
if (empty($update) === false) {
$result = update_user($user, $update);
if ($result === false) {
$error[] = $user;
} else {
$success[] = $user;
}
} else {
$error[] = $user;
}
}
if (empty($success) === false) {
ui_print_success_message(
__(
'Users updated successfully (%s)',
implode(
',',
$success
)
)
);
}
if (empty($error) === false) {
ui_print_error_message(
__(
'Users cannot be updated (%s)',
implode(',', $error)
)
);
}
}
}
if (is_metaconsole() === false) {
include 'include/javascript/timezonepicker/includes/parser.inc';
// Read in options for map builder.
$bases = [
'gray' => 'Gray',
'blue-marble' => 'Blue marble',
'night-electric' => 'Night Electric',
'living' => 'Living Earth',
];
$local_file = 'include/javascript/timezonepicker/images/gray-400.png';
// Dimensions must always be exact since the imagemap does not scale.
$array_size = getimagesize($local_file);
$map_width = $array_size[0];
$map_height = $array_size[1];
$timezones = timezone_picker_parse_files(
$map_width,
$map_height,
'include/javascript/timezonepicker/tz_world.txt',
'include/javascript/timezonepicker/tz_islands.txt'
);
}
$get_users = get_users();
$users = [];
if (empty($get_users) === false) {
foreach ($get_users as $key => $value) {
$users[$key] = $key;
}
}
$users_div = '<div class="label_select"><p class="edit_user_labels">'.__('Users').'</p>';
$users_div .= html_print_select(
$users,
'id_users[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
).'</div>';
echo '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=edit_users">';
echo '<div class="user_edit_second_row white_box">';
echo '<div class="" style="width:65%">'.$users_div.'</div>';
echo '</div>';
// Language.
$language_db = db_get_all_rows_sql('SELECT id_language, name FROM tlanguage');
array_unshift($language_db, ['id_language' => 'default', 'name' => __('Default')]);
$language_list = [];
foreach ($language_db as $key => $value) {
$language_list[$value['id_language']] = $value['name'];
}
$language = '<div class="label_select"><p class="edit_user_labels">'.__('Language').'</p>';
$language .= html_print_select(
$language_list,
'language',
'',
'',
__('No change'),
-1,
true,
false,
false
).'</div>';
// Pagination.
$block_size = $config['global_block_size'];
$size_pagination = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Block size for pagination').'</p>';
$size_pagination .= html_print_input_text('block_size', $block_size, '', 5, 5, true);
$size_pagination .= html_print_checkbox_switch('block_size_change', 1, 1, true);
$size_pagination .= '<span>'.__('No change').'</span>';
$size_pagination .= '</div>';
// Home screen.
$home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true).'</p>';
$values = [
'-1' => __('No change'),
'Default' => __('Default'),
'Visual console' => __('Visual console'),
'Event list' => __('Event list'),
'Group view' => __('Group view'),
'Tactical view' => __('Tactical view'),
'Alert detail' => __('Alert detail'),
'Other' => __('Other'),
'Dashboard' => __('Dashboard'),
];
$home_screen .= html_print_select(
$values,
'section',
'',
'show_data_section();',
'',
-1,
true,
false,
false,
'',
false,
'',
'',
10
).'</div>';
$dashboards = get_user_dashboards($config['id_user']);
$dashboards_aux = [];
if ($dashboards === false) {
$dashboards = ['None' => 'None'];
} else {
foreach ($dashboards as $key => $dashboard) {
$dashboards_aux[$dashboard['id']] = $dashboard['name'];
}
}
$home_screen .= '<div id="show_db" style="display: none; width: 100%;">';
$home_screen .= html_print_select($dashboards_aux, 'dashboard', '', '', '', '', true, false, false, '');
$home_screen .= '</div>';
$layouts = visual_map_get_user_layouts($config['id_user'], true);
$layouts_aux = [];
if (empty($layouts) === true) {
$layouts_aux = ['None' => 'None'];
} else {
foreach ($layouts as $layout) {
$layouts_aux[$layout] = $layout;
}
}
$home_screen .= '<div id="show_vc" style="display: none; width: 100%;">';
$home_screen .= html_print_select($layouts_aux, 'visual_console', '', '', '', '', true);
$home_screen .= '</div>';
$home_screen .= html_print_input_text('data_section', '', '', 60, 255, true, false);
// Event filter.
$user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true))));
$event_list = db_get_all_rows_sql('SELECT id_filter, id_name AS name FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')');
if (empty($event_list) === true) {
$event_list = [];
}
array_unshift($event_list, ['id_filter' => 'none', 'name' => __('None')]);
$event_filter = '<div class="label_select"><p class="edit_user_labels">'.__('Event filter').'</p>';
$event_filter .= html_print_select(
$event_list,
'event_filter',
'',
'',
__('No change'),
-1,
true,
false,
false
).'</div>';
// Autorefresh.
$autorefresh_list_out = [];
if (is_metaconsole() === false || is_centralized() === true) {
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
$autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail';
$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
$autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map';
$autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer';
$autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
if (enterprise_installed()) {
$autorefresh_list_out['general/sap_view'] = 'SAP view';
}
}
$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view';
$autorefresh_list_out['operation/agentes/group_view'] = 'Group view';
$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail';
$autorefresh_list_out['enterprise/operation/services/services'] = 'Services';
$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard';
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
$autorefresh_list_out['operation/events/events'] = 'Events';
$autorefresh_show = '<p class="edit_user_labels">'._('Autorefresh').ui_print_help_tip(
__('This will activate autorefresh in selected pages'),
true
).'</p>';
$select_out = html_print_select(
$autorefresh_list_out,
'autorefresh_list_out[]',
'',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%;min-height: 150px;'
);
$arrows = ' ';
$autorefresh_list = [];
$autorefresh_list['-1'] = __('No change');
$autorefresh_list[] = __('None');
$select_in = html_print_select(
$autorefresh_list,
'autorefresh_list[]',
'-1',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%;min-height: 150px;'
);
$table_ichanges = '<div class="autorefresh_select">
<div class="autorefresh_select_list_out">
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
<div>'.$select_out.'</div>
</div>
<div class="autorefresh_select_arrows" style="display:grid">
<a href="javascript:">'.html_print_image(
'images/darrowright_green.png',
true,
[
'id' => 'right_autorefreshlist',
'alt' => __('Push selected pages into autorefresh list'),
'title' => __('Push selected pages into autorefresh list'),
]
).'</a>
<a href="javascript:">'.html_print_image(
'images/darrowleft_green.png',
true,
[
'id' => 'left_autorefreshlist',
'alt' => __('Pop selected pages out of autorefresh list'),
'title' => __('Pop selected pages out of autorefresh list'),
]
).'</a>
</div>
<div class="autorefresh_select_list">
<p class="autorefresh_select_text">'.__('List of pages with autorefresh').': </p>
<div>'.$select_in.'</div>
</div>
</div>';
$autorefresh_show .= $table_ichanges;
// Time autorefresh.
$times = get_refresh_time_array();
$time_autorefresh = '<div class="label_select"><p class="edit_user_labels">'.__('Time autorefresh');
$time_autorefresh .= ui_print_help_tip(
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
true
).'</p>';
$time_autorefresh .= html_print_select(
$times,
'time_autorefresh',
'',
'',
__('No change'),
'-1',
true,
false,
false
).'</div>';
$timezone = '<div class="label_select"><p class="edit_user_labels">'.__('Timezone').ui_print_help_tip(__('The timezone must be that of the associated server.'), true).'</p>';
$timezone .= html_print_timezone_select('timezone', '-1', __('No change'), '-1').'</div>';
$timezone_map = '';
if (is_metaconsole() === false) {
foreach ($timezones as $timezone_name => $tz) {
if ($timezone_name == 'America/Montreal') {
$timezone_name = 'America/Toronto';
} else if ($timezone_name == 'Asia/Chongqing') {
$timezone_name = 'Asia/Shanghai';
}
$area_data_timezone_polys .= '';
foreach ($tz['polys'] as $coords) {
$area_data_timezone_polys .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="poly" coords="'.implode(',', $coords).'" />';
}
$area_data_timezone_rects .= '';
foreach ($tz['rects'] as $coords) {
$area_data_timezone_rects .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="rect" coords="'.implode(',', $coords).'" />';
}
}
$timezone_map = '<div id="timezone-picker" style="width:0px">
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
<img class="timezone-pin pdd_t_4px" src="include/javascript/timezonepicker/images/pin.png" />
<map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map>
</div>';
}
// Status (Disable / Enable).
$status = '</br>';
$status .= '<div class="label_select"><p class="edit_user_labels">'.__('Status').'</p>';
$table = new StdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data[0][0] = __('No change');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
-1,
'',
-1,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[0][0] .= __('Disable');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
1,
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[0][0] .= __('Enable');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
0,
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
);
$status .= html_print_table($table, true);
echo '<div id="users_options" class="user_edit_second_row white_box" style="display: none">';
echo sprintf(
'<div class="edit_user_options">%s %s %s %s %s %s %s %s %s %s</div>',
$language,
$size_pagination,
$skin,
$home_screen,
$event_filter,
$autorefresh_show,
$time_autorefresh,
$timezone,
$timezone_map,
$status
);
echo '</div>';
attachActionButton('edit_users', 'update', '100%');
echo '</form>';
if (is_metaconsole() === false) {
// Include OpenLayers and timezone user map library.
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js').'"></script>'."\n\t";
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.maphilight.min.js').'"></script>'."\n\t";
// Closes no meta condition.
?>
<style>
/* Styles for timezone map */
#timezone-picker div.timezone-picker {
margin: 0 auto;
}
</style>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
// Set up the picker to update target timezone and country select lists.
$('#timezone-image').timezonePicker({
target: '#timezone',
});
// Optionally an auto-detect button to trigger JavaScript geolocation.
$('#timezone-detect').click(function() {
$('#timezone-image').timezonePicker('detectLocation');
});
});
</script>
<?php
} else {
close_meta_frame();
}
?>
<script type="text/javascript">
$(document).ready(function() {
show_data_section();
$('#id_users').change(function() {
const users = $("#id_users option:selected").length;
if (users === 0) {
$('#users_options').hide();
} else {
$('#users_options').show();
}
});
$("#right_autorefreshlist").click (function () {
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function (key, value) {
imodule_name = $(value).html();
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
id_imodule = $(value).attr('value');
$("select[name='autorefresh_list[]']").append($("<option></option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
// $("select[name='autorefresh_list[]']").val(id_imodule).prop("selected", "selected");
$("#autorefresh_list_out").find("option[value='" + id_imodule + "']").remove();
$("#autorefresh_list").find("option[value='-1']").remove();
$("#autorefresh_list").find("option[value='0']").remove();
if($("#autorefresh_list_out option").length == 0) {
$("select[name='autorefresh_list_out[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
}
}
});
$('#autorefresh_list option').prop('selected', true);
});
$("#left_autorefreshlist").click (function () {
jQuery.each($("select[name='autorefresh_list[]'] option:selected"), function (key, value) {
imodule_name = $(value).html();
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
id_imodule = $(value).attr('value');
$("#autorefresh_list").find("option[value='" + id_imodule + "']").remove();
$("#autorefresh_list_out").find("option[value='0']").remove();
$("select[name='autorefresh_list_out[]']").append($("<option><option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
$("#autorefresh_list_out option").last().remove();
if($("#autorefresh_list option").length == 0) {
$("select[name='autorefresh_list[]']").append($("<option></option>").val('-1').html('<i><?php echo __('No change'); ?></i>'));
$("select[name='autorefresh_list[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
$('#autorefresh_list').val('-1').prop('selected', true);
}
}
});
});
});
function show_data_section () {
section = $("#section").val();
switch (section) {
case <?php echo "'".'Dashboard'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "inline-grid");
break;
case <?php echo "'".'Visual console'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "");
$("#show_vc").css("display", "inline-grid");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Event list'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Group view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Tactical view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Alert detail'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Other'."'"; ?>:
$("#text-data_section").css("display", "");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
default:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
}
}
</script>

View File

@ -70,10 +70,16 @@ $options_agents = [
];
if (check_acl($config['id_user'], 0, 'UM')) {
$options_users = [
'add_profiles' => __('Bulk profile add'),
'delete_profiles' => __('Bulk profile delete'),
];
if (is_metaconsole() === false) {
$options_users = [
'add_profiles' => __('Bulk profile add'),
'delete_profiles' => __('Bulk profile delete'),
];
}
if (users_is_admin() === true) {
$options_users['edit_users'] = __('Edit users in bulk');
}
} else {
$options_users = [];
}
@ -479,6 +485,10 @@ switch ($option) {
include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php';
break;
case 'edit_users':
include_once $config['homedir'].'/godmode/massive/massive_edit_users.php';
break;
default:
if (!enterprise_hook('massive_operations', [$option])) {
include_once $config['homedir'].'/godmode/massive/massive_config.php';

View File

@ -137,7 +137,13 @@ if (isset($_GET['server'])) {
if ($server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$buttons['agent_editor'] = [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=agent_editor&pure='.$pure.'">'.html_print_image('images/agent.png', true, ['title' => __('Advanced editor')]).'</a>',
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=agent_editor&pure='.$pure.'">'.html_print_image('images/agent.png', true, ['title' => __('Manage agents')]).'</a>',
];
$buttons['collections'] = [
'active' => false,
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=collections&pure='.$pure.'">'.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'</a>',
];
}
@ -160,6 +166,8 @@ if (isset($_GET['server'])) {
}
} else if ($tab === 'agent_editor' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$advanced_editor = 'agent_editor';
} else if ($tab === 'collections' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
$advanced_editor = 'collections';
}
enterprise_include('godmode/servers/server_disk_conf_editor.php');

View File

@ -76,6 +76,7 @@ if ($generate_trap) {
);
}
$table = new stdClass();
$traps_generator = '<form method="POST" action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_trap_generator">';
$table->width = '100%';
$table->class = 'databox filters';

View File

@ -549,6 +549,43 @@ if ($create_user) {
$password_new = '';
$password_confirm = '';
$new_user = true;
} else {
$pm = db_get_value_filter('pandora_management', 'tperfil', ['id_perfil' => $profile2]);
if ((int) $pm === 1) {
$user_source = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($user_source === false) {
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
if ((int) $notification['id'] === 1 || (int) $notification['id'] === 5) {
$notification_user = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($notification_user === false) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
}
}
}
}
}
}
ui_print_result_message(
@ -845,6 +882,43 @@ if ($add_profile && empty($json_profile)) {
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
if ($return === false) {
$is_err = true;
} else {
$pm = db_get_value_filter('pandora_management', 'tperfil', ['id_perfil' => $profile2]);
if ((int) $pm === 1) {
$user_source = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($user_source === false) {
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
if ((int) $notification['id'] === 1 || (int) $notification['id'] === 5) {
$notification_user = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
if ($notification_user === false) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id,
]
);
}
}
}
}
}
}
ui_print_result_message(

View File

@ -509,6 +509,7 @@ class HostDevices extends Wizard
$snmp_privacy_pass = get_parameter('snmp_privacy_pass', null);
$snmp_auth_method = get_parameter('snmp_auth_method', null);
$snmp_security_level = get_parameter('snmp_security_level', null);
$snmp_skip_non_enabled_ifs = get_parameter_switch('snmp_skip_non_enabled_ifs');
$auth_strings = get_parameter('auth_strings', []);
if ($snmp_version == 3) {
@ -556,6 +557,7 @@ class HostDevices extends Wizard
$this->task['snmp_privacy_pass'] = $snmp_privacy_pass;
$this->task['snmp_auth_method'] = $snmp_auth_method;
$this->task['snmp_security_level'] = $snmp_security_level;
$this->task['snmp_skip_non_enabled_ifs'] = $snmp_skip_non_enabled_ifs;
$this->task['auth_strings'] = '';
if (is_array($auth_strings) === true) {
$this->task['auth_strings'] = join(
@ -1215,6 +1217,24 @@ class HostDevices extends Wizard
],
];
$form['inputs'][] = [
'hidden' => 1,
'block_id' => 'snmp_options_skip_non_enabled_ifs',
'class' => 'indented',
'block_content' => [
[
'label' => __('Skip non-enabled interfaces'),
'arguments' => [
'name' => 'snmp_skip_non_enabled_ifs',
'type' => 'switch',
'value' => (isset($this->task['snmp_enabled']) === true) ? $this->task['snmp_skip_non_enabled_ifs'] : 1,
'size' => 25,
'return' => true,
],
],
],
];
// SNMP Options pack v1.
$form['inputs'][] = [
'hidden' => 1,
@ -1487,6 +1507,7 @@ class HostDevices extends Wizard
function SNMPExtraShow(target) {
$("#snmp_options_basic").hide();
$("#snmp_options_skip_non_enabled_ifs").hide();
$("#snmp_options_v3").hide();
if (document.getElementsByName("snmp_enabled")[0].checked) {
$("#snmp_extra").show();
@ -1494,6 +1515,7 @@ class HostDevices extends Wizard
$("#snmp_options_v3").show();
} else {
$("#snmp_options_basic").show();
$("#snmp_options_skip_non_enabled_ifs").show();
}
}
}
@ -1519,6 +1541,7 @@ class HostDevices extends Wizard
// Hide unusable sections
$("#snmp_extra").hide();
$("#snmp_options_basic").hide();
$("#snmp_options_skip_non_enabled_ifs").hide();
$("#snmp_options_v3").hide();
// Disable snmp dependant checks

View File

@ -37,6 +37,7 @@ $ajax = true;
$render_map = (bool) get_parameter('render_map', false);
$graph_javascript = (bool) get_parameter('graph_javascript', false);
$force_remote_check = (bool) get_parameter('force_remote_check', false);
$update_maintanance_mode = (bool) get_parameter('update_maintanance_mode', false);
$load_css_cv = (bool) get_parameter('load_css_cv', false);
if ($render_map) {
@ -99,3 +100,29 @@ if ($load_css_cv === true) {
echo $output;
return;
}
if ($update_maintanance_mode === true) {
$idVisualConsole = (int) get_parameter('idVisualConsole', 0);
$mode = (bool) get_parameter('mode', false);
$values = [];
if ($mode === true) {
$values['maintenance_mode'] = json_encode(
[
'user' => $config['id_user'],
'timestamp' => time(),
]
);
} else {
$values['maintenance_mode'] = null;
}
$result = db_process_sql_update(
'tlayout',
$values,
['id' => $idVisualConsole]
);
echo json_encode(['result' => $result]);
return;
}

View File

@ -809,7 +809,44 @@ function update_user(string $id_user, array $values)
return false;
}
return db_process_sql_update('tusuario', $values, ['id_user' => $id_user]);
$output = db_process_sql_update('tusuario', $values, ['id_user' => $id_user]);
if (isset($values['is_admin']) === true && (bool) $values['is_admin'] === true) {
// Administrator user must be activated in all notifications sections.
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
$user_source = db_get_value_filter(
'id_source',
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
if ($user_source !== false) {
@db_process_sql_update(
'tnotification_source_user',
['enabled' => 1],
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
} else if ((int) $notification['id'] === 1 || (int) $notification['id'] === 5) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
}
}
}
return $output;
}

View File

@ -33,6 +33,7 @@ global $config;
require_once $config['homedir'].'/include/class/HTML.class.php';
require_once $config['homedir'].'/include/functions_snmp_browser.php';
require_once $config['homedir'].'/include/functions_wmi.php';
require_once $config['homedir'].'/include/class/CredentialStore.class.php';
use PandoraFMS\Module;
@ -696,6 +697,43 @@ class AgentWizard extends HTML
'return' => true,
],
];
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$inputs[] = [
'label' => __('Credential store'),
'id' => 'slc-credential',
'arguments' => [
'name' => 'credential',
'input_class' => 'flex-row',
'type' => 'select',
'nothing' => __('None'),
'nothing_value' => 0,
'fields' => $fields,
'class' => '',
'return' => true,
'sort' => true,
],
];
}
}
$hint_server = '&nbsp;';
@ -716,6 +754,43 @@ class AgentWizard extends HTML
];
if ($this->actionType === 'snmp') {
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$inputs[] = [
'label' => __('Credential store'),
'id' => 'slc-credential',
'arguments' => [
'name' => 'credential',
'input_class' => 'flex-row',
'type' => 'select',
'nothing' => __('None'),
'nothing_value' => 0,
'fields' => $fields,
'class' => '',
'return' => true,
'sort' => true,
],
];
}
$inputs[] = [
'label' => __('SNMP community'),
'id' => 'txt-community',
@ -1336,6 +1411,21 @@ class AgentWizard extends HTML
}
/**
* Build an array with Product credentials.
*
* @return array with credentials (pass and id).
*/
public function getCredentials(string $identifier='')
{
if (empty($identifier) === true) {
$identifier = get_parameter('identifier', '');
}
echo json_encode(credentialStore::getKey($identifier));
}
/**
* Prepare data module to create.
*
@ -5813,6 +5903,58 @@ class AgentWizard extends HTML
filterInterfaces();
});
$('#credential').change(function() {
if ($('#credential').val() !== '0') {
$.ajax({
method: "post",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: {
page: "<?php echo $this->ajaxController; ?>",
method: "getCredentials",
identifier: $('#credential').val()
},
datatype: "json",
success: function(data) {
data = JSON.parse(data);
if ($('#text-namespaceWMI').length > 0) {
// WMI.
$('#text-namespaceWMI').val(data['extra_1']);
$('#text-usernameWMI').val(data['username']);
$('#password-passwordWMI').val(data['password']);
} else {
// SNMP.
extra = JSON.parse(data['extra_1']);
$('#version').val(extra['version']);
$('#version').trigger('change');
$('#text-community').val(extra['community']);
if (extra['version'] === '3') {
$('#securityLevelV3').val(extra['securityLevelV3']);
$('#securityLevelV3').trigger('change');
$('#text-authUserV3').val(extra['authUserV3']);
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
$('#authMethodV3').val(extra['authMethodV3']);
$('#authMethodV3').trigger('change');
$('#password-authPassV3').val(extra['authPassV3']);
if (extra['securityLevelV3'] === 'authPriv') {
$('#privacyMethodV3').val(extra['privacyMethodV3']);
$('#privacyMethodV3').trigger('change');
$('#password-privacyPassV3').val(extra['privacyPassV3']);
}
}
}
}
},
error: function(e) {
showMsg(e);
}
});
}
});
// Loading.
$('#submit-sub-protocol').click(function() {
$('.wizard-result').remove();

View File

@ -679,7 +679,6 @@ class ConsoleSupervisor
$max_age = 0;
break;
case 'NOTIF.LICENSE.EXPIRATION':
case 'NOTIF.FILES.ATTACHMENT':
case 'NOTIF.FILES.DATAIN':
case 'NOTIF.FILES.DATAIN.BADXML':
@ -846,7 +845,9 @@ class ConsoleSupervisor
}
// Expiry.
if (($days_to_expiry <= 15) && ($days_to_expiry > 0)) {
if (($days_to_expiry <= 15) && ($days_to_expiry > 0)
&& ((is_user_admin($config['id_user'])) || (check_acl($config['id_user'], 0, 'PM')))
) {
if ($config['license_mode'] == 1) {
$title = __('License is about to expire');
$msg = 'Your license will expire in %d days. Please, contact our sales department.';
@ -867,7 +868,7 @@ class ConsoleSupervisor
'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license',
]
);
} else if ($days_to_expiry < 0) {
} else if (($days_to_expiry <= 0) && ((is_user_admin($config['id_user'])) || (check_acl($config['id_user'], 0, 'PM')))) {
if ($config['license_mode'] == 1) {
$title = __('Expired license');
$msg = __('Your license has expired. Please, contact our sales department.');

View File

@ -617,33 +617,71 @@ class CredentialStore extends Wizard
$password = $google_creds->private_key_id;
}
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) === true || (empty($password) === true)) {
$error = __('You must specify a username and/or password');
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
$error = __('Identifier with forbidden characters. Check the documentation.');
}
if ($product !== 'SNMP') {
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) === true || (empty($password) === true)) {
$error = __('You must specify a username and/or password');
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
$error = __('Identifier with forbidden characters. Check the documentation.');
}
if (isset($error) === true) {
$this->ajaxMsg('error', $error);
exit;
}
if (isset($error) === true) {
$this->ajaxMsg('error', $error);
exit;
}
// Encrypt content (if needed).
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
// Encrypt content (if needed).
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
} else {
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
];
$community = (string) get_parameter('community', '');
$version = (string) get_parameter('version', '1');
$extra_json = [
'community' => $community,
'version' => $version,
];
if ($version === '3') {
$securityLevelV3 = (string) get_parameter('securityLevelV3', 'authNoPriv');
$extra_json['securityLevelV3'] = $securityLevelV3;
$authUserV3 = (string) get_parameter('authUserV3', '');
$extra_json['authUserV3'] = $authUserV3;
if ($securityLevelV3 === 'authNoPriv' || $securityLevelV3 === 'authPriv') {
$authUserV3 = (string) get_parameter('authUserV3', '');
$extra_json['authUserV3'] = $authUserV3;
$authMethodV3 = (string) get_parameter('authMethodV3', 'MD5');
$extra_json['authMethodV3'] = $authMethodV3;
$authPassV3 = (string) get_parameter('authPassV3', '');
$extra_json['authPassV3'] = $authPassV3;
if ($securityLevelV3 === 'authPriv') {
$privacyMethodV3 = (string) get_parameter('privacyMethodV3', 'AES');
$extra_json['privacyMethodV3'] = $privacyMethodV3;
$privacyPassV3 = (string) get_parameter('privacyPassV3', '');
$extra_json['privacyPassV3'] = $privacyPassV3;
}
}
}
$values['extra_1'] = json_encode($extra_json);
}
// Spaces are not allowed.
$values['identifier'] = \io_safe_input(
@ -947,6 +985,8 @@ class CredentialStore extends Wizard
'AZURE' => __('Azure'),
'SAP' => __('SAP'),
'GOOGLE' => __('Google'),
'WMI' => __('WMI'),
'SNMP' => __('SNMP'),
],
'selected' => (isset($values['product']) ? $values['product'] : 'CUSTOM'),
'disabled' => (bool) $values['product'],
@ -989,6 +1029,19 @@ class CredentialStore extends Wizard
$extra1_type = 'textarea';
break;
case 'WMI':
$extra_1_label = __('Namespace');
$extra1 = true;
$extra2 = false;
break;
case 'SNMP':
$user = false;
$pass = false;
$extra1 = false;
$extra2 = false;
break;
case 'CUSTOM':
case 'SAP':
$user_label = __('Account ID');
@ -1059,6 +1112,141 @@ class CredentialStore extends Wizard
];
}
if ($values['product'] === 'SNMP') {
$json_values = json_decode($values['extra_1'], true);
$inputs[] = [
'label' => __('SNMP community'),
'id' => 'li_snmp_1',
'arguments' => [
'name' => 'community',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $json_values['community'],
'return' => true,
],
];
$inputs[] = [
'label' => __('SNMP version'),
'id' => 'li_snmp_2',
'arguments' => [
'name' => 'version',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'showVersion()',
'fields' => [
'1' => __('1'),
'2' => __('2'),
'2c' => __('2c'),
'3' => __('3'),
],
'selected' => (isset($json_values['version']) ? $json_values['version'] : '1'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Security level'),
'id' => 'li_snmp_3',
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
'arguments' => [
'name' => 'securityLevelV3',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'showSecurity()',
'fields' => [
'authNoPriv' => __('Authenticated and non-private method'),
'authPriv' => __('Authenticated and private method'),
'noAuthNoPriv' => __('Non-authenticated and non-private method'),
],
'selected' => (isset($json_values['securityLevelV3']) ? $json_values['securityLevelV3'] : 'authNoPriv'),
'return' => true,
],
];
$inputs[] = [
'label' => __('User authentication'),
'id' => 'li_snmp_4',
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
'arguments' => [
'name' => 'authUserV3',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $json_values['authUserV3'],
'return' => true,
],
];
$authNoPrivate = (
isset($json_values['securityLevelV3']) &&
($json_values['securityLevelV3'] === 'authNoPriv' || $json_values['securityLevelV3'] === 'authPriv')
) ? '' : 'display: none;';
$inputs[] = [
'label' => __('Authentication method'),
'id' => 'li_snmp_5',
'style' => $authNoPrivate,
'arguments' => [
'name' => 'authMethodV3',
'input_class' => 'flex-row',
'type' => 'select',
'fields' => [
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'selected' => (isset($json_values['authMethodV3']) ? $json_values['authMethodV3'] : 'MD5'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Password authentication'),
'id' => 'li_snmp_6',
'style' => $authNoPrivate,
'arguments' => [
'name' => 'authPassV3',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $json_values['authPassV3'],
'return' => true,
],
];
$authPrivate = (isset($json_values['securityLevelV3']) && $json_values['securityLevelV3'] === 'authPriv')
? ''
: 'display: none;';
$inputs[] = [
'label' => __('Privacy method'),
'id' => 'li_snmp_7',
'style' => $authPrivate,
'arguments' => [
'name' => 'privacyMethodV3',
'input_class' => 'flex-row',
'type' => 'select',
'fields' => [
'AES' => __('AES'),
'DES' => __('DES'),
],
'selected' => (isset($json_values['privacyMethodV3']) ? $json_values['privacyMethodV3'] : 'AES'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Privacy pass'),
'id' => 'li_snmp_8',
'style' => $authPrivate,
'arguments' => [
'name' => 'privacyPassV3',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $json_values['privacyPassV3'],
'return' => true,
],
];
}
return $this->printForm(
[
'form' => $form,
@ -1175,9 +1363,248 @@ class CredentialStore extends Wizard
$('<textarea name="extra_1" id="text-extra_1">'+val+'</textarea>')
);
$('#div-extra_1').show();
} else if ($('#product :selected').val() == "WMI") {
$('#div-username label').text('<?php echo __('Username'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-extra_1 label').text('<?php echo __('Namespace'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').show();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "SNMP") {
$('#div-username').hide();
$('#div-password').hide();
$('#div-extra_1').hide();
$('#div-extra_2').hide();
if ($('#li_snmp_1').length > 0) {
console.log($('#li_snmp_1').length);
const test = '<?php echo $json_values; ?>';
console.log(test);
} else {
const ul = $('#modal_form').children('ul')[0];
// SNMP community.
const li_community = document.createElement("li");
li_community.id = 'li_snmp_1';
const label_community = document.createElement("label");
label_community.textContent = '<?php echo __('SNMP community'); ?>';
const input_community = document.createElement("input");
input_community.type = 'text';
input_community.className = 'text_input';
input_community.name = 'community';
li_community.append(label_community);
li_community.append(input_community);
ul.append(li_community);
// SNMP version.
const li_version = document.createElement("li");
li_version.id = 'li_snmp_2';
const label_version = document.createElement("label");
label_version.textContent = '<?php echo __('SNMP version'); ?>';
const select_version = document.createElement("select");
select_version.name = 'version';
select_version.id = 'version';
select_version.onchange = function() {
showVersion();
};
let option1 = document.createElement("option");
let option2 = document.createElement("option");
let option2c = document.createElement("option");
let option3 = document.createElement("option");
option1.value = '1';
option1.text = '1';
option2.value = '2';
option2.text = '2';
option2c.value = '2c';
option2c.text = '2c';
option3.value = '3';
option3.text = '3';
select_version.appendChild(option1);
select_version.appendChild(option2);
select_version.appendChild(option2c);
select_version.appendChild(option3);
li_version.append(label_version);
li_version.append(select_version);
ul.append(li_version);
$("#version").select2();
// Security.
const li_security = document.createElement("li");
li_security.id = 'li_snmp_3';
const label_security = document.createElement("label");
label_security.textContent = '<?php echo __('Security level'); ?>';
const select_security = document.createElement("select");
select_security.name = 'securityLevelV3';
select_security.id = 'securityLevelV3';
select_security.onchange = function() {
showSecurity();
}
option1 = document.createElement("option");
option2 = document.createElement("option");
option3 = document.createElement("option");
option1.value = 'authNoPriv';
option1.text = '<?php echo __('Authenticated and non-private method'); ?>';
option2.value = 'authPriv';
option2.text = '<?php echo __('Authenticated and private method'); ?>';
option3.value = 'noAuthNoPriv';
option3.text = '<?php echo __('Non-authenticated and non-private method'); ?>';
select_security.appendChild(option1);
select_security.appendChild(option2);
select_security.appendChild(option3);
li_security.append(label_security);
li_security.append(select_security);
ul.append(li_security);
$("#securityLevelV3").select2();
// User.
const li_user = document.createElement("li");
li_user.id = 'li_snmp_4';
const label_user = document.createElement("label");
label_user.textContent = '<?php echo __('User authentication'); ?>';
const input_user = document.createElement("input");
input_user.type = 'text';
input_user.className = 'text_input';
input_user.name = 'authUserV3';
li_user.append(label_user);
li_user.append(input_user);
ul.append(li_user);
// Authentication method.
const li_method = document.createElement("li");
li_method.id = 'li_snmp_5';
const label_method = document.createElement("label");
label_method.textContent = '<?php echo __('Authentication method'); ?>';
const select_method = document.createElement("select");
select_method.name = 'authMethodV3';
select_method.id = 'method';
option1 = document.createElement("option");
option2 = document.createElement("option");
option1.value = 'MD5';
option1.text = '<?php echo __('MD5'); ?>';
option2.value = 'SHA';
option2.text = '<?php echo __('SHA'); ?>';
select_method.appendChild(option1);
select_method.appendChild(option2);
li_method.append(label_method);
li_method.append(select_method);
ul.append(li_method);
$("#method").select2();
// Password.
const li_password = document.createElement("li");
li_password.id = 'li_snmp_6';
const label_password = document.createElement("label");
label_password.textContent = '<?php echo __('Password authentication'); ?>';
const input_password = document.createElement("input");
input_password.type = 'password';
input_password.className = 'text_input';
input_password.name = 'authPassV3';
li_password.append(label_password);
li_password.append(input_password);
ul.append(li_password);
// Privacy method.
const li_privacy = document.createElement("li");
li_privacy.id = 'li_snmp_7';
const label_privacy = document.createElement("label");
label_privacy.textContent = '<?php echo __('Privacy method'); ?>';
const select_privacy = document.createElement("select");
select_privacy.name = 'privacyMethodV3';
select_privacy.id = 'privacy';
option1 = document.createElement("option");
option2 = document.createElement("option");
option1.value = 'AES';
option1.text = '<?php echo __('AES'); ?>';
option2.value = 'DES';
option2.text = '<?php echo __('DES'); ?>';
select_privacy.appendChild(option1);
select_privacy.appendChild(option2);
li_privacy.append(label_privacy);
li_privacy.append(select_privacy);
ul.append(li_privacy);
$("#privacy").select2();
// Privacy pass.
const li_privacyPassV3 = document.createElement("li");
li_privacyPassV3.id = 'li_snmp_8';
const label_privacyPassV3 = document.createElement("label");
label_privacyPassV3.textContent = '<?php echo __('Privacy pass'); ?>';
const input_privacyPassV3 = document.createElement("input");
input_privacyPassV3.type = 'password';
input_privacyPassV3.className = 'text_input';
input_privacyPassV3.name = 'privacyPassV3';
li_privacyPassV3.append(label_privacyPassV3);
li_privacyPassV3.append(input_privacyPassV3);
ul.append(li_privacyPassV3);
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
}
}
function showVersion() {
if ($('#version').val() === '3') {
$('#li_snmp_3').show();
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
} else {
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
}
function showSecurity() {
const value = $('#securityLevelV3').val();
switch (value) {
case 'noAuthNoPriv':
$('#li_snmp_4').show();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
break;
case 'authPriv':
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
$('#li_snmp_7').show();
$('#li_snmp_8').show();
break;
case 'authNoPriv':
default:
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
break;
}
}
function hideSNMP() {
$('#li_snmp_1').hide();
$('#li_snmp_2').hide();
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
/**
* Process ajax responses and shows a dialog with results.
*/

View File

@ -485,6 +485,10 @@ class HTML
$class = '';
}
if (empty($input['style']) === false) {
$style_li = $input['style'];
}
if (isset($input['class']) === true) {
$class = $input['class'].$class;
}
@ -498,7 +502,7 @@ class HTML
}
// Print independent block of inputs.
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'">';
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
if (isset($input['wrapper']) === true) {
$output .= '<'.$input['wrapper'].' id="'.($input['block_id'] ?? '').'" class="'.$class.'">';
@ -562,7 +566,7 @@ class HTML
}
if (!$direct) {
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'">';
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
}
if (isset($input['label']) === true) {

View File

@ -0,0 +1,689 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Controller for collections
*
* @category Controller
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 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.
* ============================================================================
*/
// Begin.
global $config;
// Necessary classes for extends.
require_once $config['homedir'].'/include/class/HTML.class.php';
require_once $config['homedir'].'/include/functions_servers.php';
enterprise_include_once('include/functions_satellite.php');
enterprise_include_once('include/functions_collection.php');
/**
* Class SatelliteCollection
*/
class SatelliteCollection extends HTML
{
/**
* Allowed methods to be called using AJAX request.
*
* @var array
*/
public $AJAXMethods = [
'draw',
'addCollection',
'deleteCollection',
'loadModal',
];
/**
* Ajax page.
*
* @var string
*/
private $ajaxController;
/**
* Class constructor
*
* @param string $ajaxController Ajax controller.
*/
public function __construct(string $ajaxController)
{
global $config;
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === true
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Satellite agents'
);
include 'general/noaccess.php';
return;
}
// Set the ajax controller.
$this->ajaxController = $ajaxController;
// Capture all parameters before start.
$this->satellite_server = (int) get_parameter('server_remote');
if ($this->satellite_server !== 0) {
$this->satellite_name = servers_get_name($this->satellite_server);
$this->satellite_config = (array) config_satellite_get_config_file($this->satellite_name);
}
}
/**
* Run view
*
* @return void
*/
public function run()
{
// Javascript.
ui_require_jquery_file('pandora');
// CSS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
$this->createBlock();
if (is_metaconsole() === true) {
// Only in case of Metaconsole, format the frame.
open_meta_frame();
}
// Datatables list.
try {
$columns = [
'name',
'dir',
'description',
'actions',
];
$column_names = [
__('Name'),
__('Dir'),
__('Description'),
__('Actions'),
];
$this->tableId = 'satellite_collections';
// Load datatables user interface.
ui_print_datatable(
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,
'ajax_data' => [
'method' => 'draw',
'server_remote' => $this->satellite_server,
],
'ajax_postprocces' => 'process_datatables_item(item)',
'no_sortable_columns' => [
0,
1,
2,
3,
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Search'),
'type' => 'text',
'name' => 'filter_search',
'size' => 12,
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
if (is_metaconsole() === true) {
// Close the frame.
close_meta_frame();
}
echo '<div id="aux" class="invisible"></div>';
echo '<div id="msg" class="invisible"></div>';
// Load own javascript file.
echo $this->loadJS();
}
/**
* Get the data for draw the table.
*
* @return void.
*/
public function draw()
{
global $config;
// Init data.
$data = [];
// Count of total records.
$count = 0;
// Catch post parameters.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$order = get_datatable_order(true);
$filters = get_parameter('filter', []);
try {
ob_start();
// Gets all collections (database).
$collections = collection_get_collections(null, $filters['filter_search']);
if (empty($collections) === false) {
$data = $collections;
}
// All satellite conf collections.
foreach ($this->satellite_config as $line) {
$regex = '/^file_collection\s(\S+)/m';
if (preg_match($regex, $line, $matches, PREG_OFFSET_CAPTURE, 0) > 0) {
$key = array_search($matches[1][0], array_column($data, 'short_name'));
if ($key !== false) {
$data[$key]['delete'] = true;
}
}
}
if (empty($data) === false) {
$data = array_reduce(
$data,
function ($carry, $item) {
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$delete = (int) isset($tmp->delete);
$tmp->dir = $tmp->short_name;
$tmp->actions = '';
$tmp->actions .= html_print_image(
($delete === 0) ? 'images/add.png' : 'images/cross.png',
true,
[
'border' => '0',
'class' => 'action_button_img mrgn_lft_05em invert_filter',
'onclick' => ($delete === 0)
? 'add_collection(\''.$tmp->short_name.'\')'
: 'delete_collection(\''.$tmp->short_name.'\')',
]
);
$carry[] = $tmp;
return $carry;
}
);
}
if (empty($data) === true) {
$total = 0;
$data = [];
} else {
$total = count($data);
$data = array_slice($data, $start, $length, false);
}
echo json_encode(
[
'data' => $data,
'recordsTotal' => $total,
'recordsFiltered' => $total,
]
);
// Capture output.
$response = ob_get_clean();
} catch (Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
exit;
}
// If not valid, show error with issue.
json_decode($response);
if (json_last_error() === JSON_ERROR_NONE) {
// If valid dump.
echo $response;
} else {
echo json_encode(
['error' => $response]
);
}
exit;
}
/**
* Add collection to satellite conf.
*
* @return void
*/
public function addCollection()
{
$short_name = get_parameter('short_name');
if ($this->parseSatelliteConf('add', $short_name) === false) {
$this->ajaxMsg('error', __('Error adding collection'));
} else {
$this->ajaxMsg('result', _('Collection '.$short_name.' added.'));
}
exit;
}
/**
* Delete collection to satellite conf.
*
* @return void
*/
public function deleteCollection()
{
$short_name = get_parameter('short_name');
if ($this->parseSatelliteConf('delete', $short_name) === false) {
$this->ajaxMsg('error', __('Error deleting collection'));
} else {
$this->ajaxMsg('result', _('Collection '.$short_name.' deleted.'));
}
exit;
}
/**
* Parse satellite configuration .
*
* @param string $action Action to perform (add, delete).
* @param string $short_name Short name.
*
* @return boolean
*/
private function parseSatelliteConf(string $action, string $short_name)
{
switch ($action) {
case 'delete':
$pos = preg_grep('/^file_collection '.$short_name.'/', $this->satellite_config);
if (empty($pos) === false) {
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
unset($this->satellite_config[$key_pos]);
}
$conf = implode('', $this->satellite_config);
break;
default:
case 'add':
$pos = preg_grep('/^file_collection/', $this->satellite_config);
if (empty($pos) === false) {
$string_collection = 'file_collection '.$short_name."\n";
$key_pos = array_keys($pos)[(count($pos) - 1)];
$array1 = array_slice($this->satellite_config, 0, ($key_pos + 1));
$array2 = array_slice($this->satellite_config, ($key_pos + 1));
$array_merge = array_merge($array1, [$string_collection], $array2);
$this->satellite_config = $array_merge;
// Check config.
if (empty($this->satellite_config) === true) {
return false;
}
} else {
$pos = preg_grep('/^\#\sFile\scollections/', $this->satellite_config);
$string_collection = 'file_collection '.$short_name."\n";
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
$key_pos++;
$array1 = array_slice($this->satellite_config, 0, $key_pos);
$array2 = array_slice($this->satellite_config, $key_pos);
// Add collection to conf.
$array_merge = array_merge($array1, [$string_collection], $array2);
$this->satellite_config = $array_merge;
// Check config.
if (empty($this->satellite_config) === true) {
return false;
}
}
$conf = implode('', $this->satellite_config);
break;
}
return $this->saveAgent($conf);
}
/**
* Saves agent to satellite cofiguration file.
*
* @param string $new_conf Config file.
*
* @return boolean|void
*/
private function saveAgent(string $new_conf)
{
global $config;
if (empty($new_conf) === true) {
return false;
}
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'Update remote config for server '.$this->satellite_name
);
// Convert to config file encoding.
$encoding = config_satellite_get_encoding($new_conf);
if ($encoding !== false) {
$converted_server_config = mb_convert_encoding($new_conf, $encoding, 'UTF-8');
if ($converted_server_config !== false) {
$new_conf = $converted_server_config;
}
}
// Get filenames.
if ($this->satellite_server !== false) {
$files = config_satellite_get_satellite_config_filenames($this->satellite_name);
} else {
$files = [];
$files['conf'] = $config['remote_config'].'/conf/'.md5($this->satellite_name).'.srv.conf';
$files['md5'] = $config['remote_config'].'/md5/'.md5($this->satellite_name).'.srv.md5';
}
// Save configuration.
$result = file_put_contents($files['conf'], $new_conf);
if ($result === false) {
return false;
}
// Save configuration md5.
$result = file_put_contents($files['md5'], md5($new_conf));
}
/**
* Checks if target method is available to be called using AJAX.
*
* @param string $method Target method.
*
* @return boolean True allowed, false not.
*/
public function ajaxMethod(string $method)
{
return in_array($method, $this->AJAXMethods);
}
/**
* Minor function to dump json message as ajax response.
*
* @param string $type Type: result || error.
* @param string $msg Message.
*
* @return void
*/
private function ajaxMsg(string $type, string $msg)
{
if ($type === 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__($msg),
'',
true
),
]
);
} else {
echo json_encode(
[
$type => ui_print_success_message(
__($msg),
'',
true
),
]
);
}
exit;
}
/**
* Create file_collections blocks
*
* @return void
*/
public function createBlock()
{
$init = preg_grep('/^\#\sFile\scollections/', $this->satellite_config);
if (empty($init) === true) {
$collection = "# File collections\n";
array_push($this->satellite_config, "\n");
array_push($this->satellite_config, $collection);
array_push($this->satellite_config, "\n");
$conf = implode('', $this->satellite_config);
$this->saveAgent($conf);
}
}
/**
* Load Javascript code.
*
* @return string.
*/
public function loadJS()
{
// Nothing for this moment.
ob_start();
// Javascript content.
?>
<script type="text/javascript">
/**
* Add collection.
*/
function add_collection(short_name) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Add collection'); ?>',
buttons: [{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
}
},
{
text: 'Add',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/collections_satellite',
method: 'addCollection',
short_name: short_name,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function(data) {
console.log(data);
showMsg(data);
},
error: function(e) {
showMsg(e);
}
});
}
}
]
});
}
/**
* Delete collection.
*/
function delete_collection(short_name) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Delete collection'); ?>',
buttons: [{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
}
},
{
text: 'Delete',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/collections_satellite',
method: 'deleteCollection',
short_name: short_name,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function(data) {
console.log(data);
showMsg(data);
},
error: function(e) {
showMsg(e);
}
});
}
}
]
});
}
/**
* Process ajax responses and shows a dialog with results.
*/
function showMsg(data) {
var title = "<?php echo __('Success'); ?>";
var dt_satellite_agents = $("#satellite_collections").DataTable();
dt_<?php echo $this->tableId; ?>.draw(false);
var text = '';
var failed = 0;
try {
data = JSON.parse(data);
text = data['result'];
} catch (err) {
title = "<?php echo __('Failed'); ?>";
text = err.message;
failed = 1;
}
if (!failed && data['error'] != undefined) {
title = "<?php echo __('Failed'); ?>";
text = data['error'];
failed = 1;
}
if (data['report'] != undefined) {
data['report'].forEach(function (item){
text += '<br>'+item;
});
}
$('#msg').empty();
$('#msg').html(text);
$('#msg').dialog({
width: 450,
position: {
my: 'center',
at: 'center',
of: window,
collision: 'fit'
},
title: title,
buttons: [
{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: 'OK',
click: function(e) {
if (!failed) {
$(".ui-dialog-content").dialog("close");
$('.info').hide();
} else {
$(this).dialog('close');
}
}
}
]
});
}
</script>
<?php
// EOF Javascript content.
return ob_get_clean();
}
}

View File

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

View File

@ -359,10 +359,12 @@ function mysql_db_get_all_rows_in_table($table, $order_field='', $order='ASC')
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function mysql_db_process_sql_insert($table, $values)
function mysql_db_process_sql_insert($table, $values, $sqltostring=false)
{
// Empty rows or values not processed
if (empty($values)) {
global $config;
// Empty rows or values not processed.
if (empty($values) === true) {
return false;
}
@ -374,7 +376,7 @@ function mysql_db_process_sql_insert($table, $values)
$i = 1;
$max = count($values);
foreach ($values as $field => $value) {
// Add the correct escaping to values
// Add the correct escaping to values.
if ($field[0] != '`') {
$field = '`'.$field.'`';
}
@ -402,7 +404,30 @@ function mysql_db_process_sql_insert($table, $values)
$query .= ' VALUES ('.$values_str.')';
return db_process_sql($query, 'insert_id');
$values_insert = [];
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
&& (bool) $config['centralized_management'] === true
) {
$values_insert = [
'table' => $table,
'values' => $values,
];
}
if ($sqltostring === true) {
return $query;
}
return db_process_sql(
$query,
'insert_id',
'',
true,
$status,
true,
$values_insert
);
}

View File

@ -1567,6 +1567,10 @@ function config_update_config()
$error_update[] = __('Enable history event');
}
if (config_update_value('history_trap_enabled', get_parameter('history_trap_enabled'), true) === false) {
$error_update[] = __('Enable history trap');
}
if (config_update_value('history_db_user', get_parameter('history_db_user'), true) === false) {
$error_update[] = __('Database user');
}
@ -1604,6 +1608,22 @@ function config_update_config()
$error_update[] = __('Event Days');
}
$history_trap_days = get_parameter('history_trap_days');
if (is_numeric($history_trap_days) === false
|| $history_trap_days <= 0
|| config_update_value('history_trap_days', $history_trap_days) === false
) {
$error_update[] = __('Trap Days');
}
$trap_history_purge = get_parameter('history_traps_days_purge');
if (is_numeric($trap_history_purge) === false
|| $trap_history_purge <= 0
|| config_update_value('trap_history_purge', $trap_history_purge) === false
) {
$error_update[] = __('Trap history purge');
}
$history_db_step = get_parameter('history_db_step');
if (!is_numeric($history_db_step)
|| $history_db_step <= 0
@ -1668,6 +1688,14 @@ function config_update_config()
$error_update[] = __('Historical database events purge');
}
if ($dbm->setConfigToken(
'trap_history_purge',
get_parameter('history_traps_days_purge')
) !== true
) {
$error_update[] = __('Historical database traps purge');
}
if ($dbm->setConfigToken(
'string_purge',
get_parameter('history_dbh_string_purge')
@ -2528,6 +2556,10 @@ function config_process_config()
config_update_value('history_event_enabled', false);
}
if (!isset($config['history_trap_enabled'])) {
config_update_value('history_trap_enabled', false);
}
if (!isset($config['history_db_host'])) {
config_update_value('history_db_host', '');
}
@ -2564,6 +2596,14 @@ function config_process_config()
config_update_value('history_event_days', 90);
}
if (!isset($config['history_trap_days'])) {
config_update_value('history_trap_days', 90);
}
if (!isset($config['trap_history_purge'])) {
config_update_value('trap_history_purge', 180);
}
if (!isset($config['history_db_step'])) {
config_update_value('history_db_step', 0);
}

View File

@ -1338,30 +1338,42 @@ function db_get_cached_queries()
* This function comes back with an array in case of SELECT
* in case of UPDATE, DELETE etc. with affected rows
* an empty array in case of SELECT without results
* Queries that return data will be cached so queries don't get repeated
* Queries that return data will be cached so queries don't get repeated.
*
* @param string SQL statement to execute
* @param string $sql SQL statement to execute.
* @param string $rettype What type of info to return in case of INSERT/UPDATE.
* 'affected_rows' will return mysql_affected_rows (default value)
* 'insert_id' will return the ID of an autoincrement value
* 'info' will return the full (debug) information of a query.
* @param string $dbconnection Info conecction.
* @param boolean $cache Cache.
* @param string $status The status and type of query (support only postgreSQL).
* @param boolean $autocommit Set autocommit transaction mode true/false (Only oracle).
* @param array $values Values (Only type insert).
*
* @param string What type of info to return in case of INSERT/UPDATE.
* 'affected_rows' will return mysql_affected_rows (default value)
* 'insert_id' will return the ID of an autoincrement value
* 'info' will return the full (debug) information of a query
*
* @param string $status The status and type of query (support only postgreSQL).
*
* @param boolean $autocommit (Only oracle) Set autocommit transaction mode true/false
*
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error.
*/
function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache=true, &$status=null, $autocommit=true)
{
function db_process_sql(
$sql,
$rettype='affected_rows',
$dbconnection='',
$cache=true,
&$status=null,
$autocommit=true,
$values_insert=[]
) {
global $config;
$rc = false;
switch ($config['dbtype']) {
case 'mysql':
default:
$rc = @mysql_db_process_sql($sql, $rettype, $dbconnection, $cache);
$rc = @mysql_db_process_sql(
$sql,
$rettype,
$dbconnection,
$cache
);
break;
case 'postgresql':
@ -1373,7 +1385,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
break;
}
db_sync($dbconnection, $sql, $rc);
db_sync(
$dbconnection,
$sql,
$rc,
$rettype,
$values_insert
);
return $rc;
}
@ -1388,8 +1406,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
*
* @return void
*/
function db_sync($dbconnection, $sql, $rc)
{
function db_sync(
$dbconnection,
$sql,
$rc,
$rettype='affected_rows',
$values_insert=[]
) {
global $config;
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
@ -1401,6 +1424,16 @@ function db_sync($dbconnection, $sql, $rc)
// Synchronize changes to nodes if needed.
$sync = new Synchronizer();
if ($sync !== null) {
if ($rettype === 'insert_id') {
$forceSql = $sync->updateInsertQueryAddPrimaryKey(
$values_insert,
$rc
);
if (empty($forceSql) === false) {
$sql = $forceSql;
}
}
if ($sync->queue($sql, $rc) === false) {
// Launch events per failed query.
$errors = $sync->getLatestErrors();
@ -1696,13 +1729,13 @@ function db_process_delete_temp($table, $row, $value, $custom_value=false)
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function db_process_sql_insert($table, $values, $autocommit=true)
function db_process_sql_insert($table, $values, $autocommit=true, $sqltostring=false)
{
global $config;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_insert($table, $values);
return mysql_db_process_sql_insert($table, $values, $sqltostring);
break;
case 'postgresql':

View File

@ -4735,12 +4735,12 @@ function html_print_autocomplete_modules(
*
* @return string HTML code
*/
function html_print_timezone_select($name, $selected='')
function html_print_timezone_select($name, $selected='', $nothing='', $nothing_value='')
{
$timezones_index = timezone_identifiers_list();
$timezones = timezone_identifiers_list();
$timezones = array_combine($timezones_index, $timezones);
return html_print_select($timezones, $name, $selected, '', __('None'), '', true, false, false);
$timezones = array_combine($timezones, $timezones);
$timezones = (['' => __('none')] + $timezones);
return html_print_select($timezones, $name, $selected, '', $nothing, $nothing_value, true, false, false);
}

View File

@ -125,7 +125,6 @@ function notifications_get_subtypes(?string $source=null)
$subtypes = [
'System status' => [
'NOTIF.LICENSE.LIMITED',
'NOTIF.LICENSE.EXPIRATION',
'NOTIF.FILES.ATTACHMENT',
'NOTIF.FILES.DATAIN',
'NOTIF.FILES.DATAIN.BADXML',

View File

@ -3708,6 +3708,8 @@ function visual_map_print_visual_map(
// End function
// Start function
/**
* Get a list with the layouts for a user.
*
@ -3719,8 +3721,6 @@ function visual_map_print_visual_map(
*
* @return array A list of layouts the user can see.
*/
function visual_map_get_user_layouts(
$id_user=0,
$only_names=false,
@ -3729,6 +3729,7 @@ function visual_map_get_user_layouts(
$favourite=false,
$check_user_groups=true
) {
$where = '';
if (! is_array($filter)) {
$filter = [];
} else {
@ -3819,17 +3820,19 @@ function visual_map_get_user_layouts(
$retval[$layout['id']] = $layout;
}
// add_perms
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
}
if ($only_names === false) {
// Aad_perms.
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
}
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
}
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
}
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
}
}
}

View File

@ -154,8 +154,10 @@ $(document).ready(function() {
if (selector == "search") {
$("#search_title_result h2").append(
"<span class='pandora_green_text'>" + search_modules + "</span>"
"<span class='pandora_green_text' id='search_string'></span>"
);
$("#search_string").text(search_modules);
}
if (total_posts < 1) {

View File

@ -1386,6 +1386,12 @@ function dashboardLoadVC(settings) {
: "dashboard"
);
if (settings.props.maintenanceMode != null) {
if (settings.props.maintenanceMode.user !== settings.id_user) {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
if (settings.mobile_view_orientation_vc === true) {
$(window).on("orientationchange", function() {
$(container).width($(window).height());

View File

@ -13,20 +13,26 @@ function configure_modules_form() {
$("#id_module_type").change(function() {
if (id_modules_icmp.in_array(this.value)) {
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-tcp_send, tr#simple-tcp_receive"
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials, tr#simple-tcp_send, tr#simple-tcp_receive"
).hide();
$("#text-tcp_port").attr("disabled", "1");
} else if (id_modules_snmp.in_array(this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").show();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).show();
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
$("#text-tcp_port").removeAttr("disabled");
} else if (id_modules_tcp.in_array(this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).hide();
$("tr#simple-tcp_send, tr#simple-tcp_receive").show();
$("#text-tcp_port").removeAttr("disabled");
} else if (id_modules_exec.in_array(this.value)) {
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).hide();
$("#text-tcp_port").attr("disabled", false);
}
});

View File

@ -117,6 +117,15 @@ function createVisualConsole(
visualConsole.updateElements(items);
}
if (
visualConsole.props.maintenanceMode != null &&
visualConsole.props.maintenanceMode.user !== id_user
) {
visualConsole.enableMaintenanceMode();
} else {
visualConsole.disableMaintenanceMode();
}
// Emit the VC update event.
if (onUpdate) onUpdate(prevProps, visualConsole.props);
} catch (ignored) {} // eslint-disable-line no-empty
@ -159,6 +168,7 @@ function createVisualConsole(
// Initialize the Visual Console.
try {
visualConsole = new VisualConsole(container, props, items);
// VC Item clicked.
visualConsole.onItemClick(function(e) {
var data = e.item.props || {};
@ -357,7 +367,6 @@ function createVisualConsole(
})
.init();
});
// VC Item resized.
visualConsole.onItemResized(function(e) {
var item = e.item;
@ -473,6 +482,11 @@ function createVisualConsole(
updateVisualConsole(visualConsole.props.id, interval, null, dimensions);
}
},
forceUpdateVisualConsole: function() {
asyncTaskManager.cancel("visual-console");
asyncTaskManager.cancel("visual-console-start");
updateVisualConsole(visualConsole.props.id);
},
createItem: function(typeString) {
var type;
switch (typeString) {

File diff suppressed because it is too large Load Diff

View File

@ -90,6 +90,7 @@ final class Container extends Model
'backgroundURL' => static::extractBackgroundUrl($data),
'relationLineWidth' => (int) $data['relationLineWidth'],
'hash' => static::extractHash($data),
'maintenanceMode' => static::extractMaintenanceMode($data),
];
}
@ -238,6 +239,45 @@ final class Container extends Model
}
/**
* Extract a background color value.
*
* @param array $data Unknown input data structure.
*
* @return mixed String representing the color (not empty) or null.
*/
private static function extractMaintenanceMode(array $data)
{
global $config;
$maintenance_mode = static::notEmptyStringOr(
static::issetInArray(
$data,
[
'maintenanceMode',
'maintenance_mode',
]
),
null
);
$result = null;
if ($maintenance_mode !== null) {
$result = json_decode($maintenance_mode, true);
$result['date'] = date(
$config['date_format'],
$result['timestamp']
);
$result['timestamp'] = human_time_description_raw(
(time() - $result['timestamp'])
);
}
return $result;
}
/**
* Extract the "is favorite" switch value.
*

View File

@ -7,6 +7,14 @@
margin-top: 5px;
}
.is-maintenance {
background-image: url(maintenanceMode.png) !important;
}
.is-maintenance :nth-child(1) {
display: none;
}
.visual-console-item {
position: absolute;
display: flex;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@ -358,6 +358,7 @@ class Visualmap
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'id_user' => $config['id_user'],
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
]
);

View File

@ -122,7 +122,7 @@ if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, 'AW')) {
$idAgent = get_parameter_get('id_agente', 0);
// Show alerts for specific agent
// Show alerts for specific agent.
if ($idAgent != 0) {
$url = $url.'&id_agente='.$idAgent;
@ -179,7 +179,7 @@ if ($idAgent != 0) {
);
$idGroup = $id_group;
// If there is no agent defined, it means that it cannot search for the secondary groups
// If there is no agent defined, it means that it cannot search for the secondary groups.
$all_groups = [$id_group];
$print_agent = true;
@ -335,7 +335,9 @@ if ($free_search != '') {
}
$alert_action = empty(alerts_get_alert_actions_filter()) === false ? alerts_get_alert_actions_filter() : ['' => __('No actions')];
$alert_action = empty(alerts_get_alert_actions_filter()) === false
? alerts_get_alert_actions_filter()
: ['' => __('No actions')];
ob_start();
@ -352,7 +354,7 @@ if ($free_search != '') {
'ajax_url' => 'include/ajax/alert_list.ajax',
'ajax_data' => [
'get_agent_alerts_datatable' => 1,
'id_agent' => $id_agent,
'id_agent' => $idAgent,
'url' => $url,
'agent_view_page' => true,
'all_groups' => $all_groups,
@ -395,7 +397,7 @@ if ($free_search != '') {
'ajax_url' => 'include/ajax/alert_list.ajax',
'ajax_data' => [
'get_agent_alerts_datatable' => 1,
'id_agent' => $id_agent,
'id_agent' => $idAgent,
'url' => $url,
],
'drawCallback' => 'alerts_table_controls()',
@ -451,7 +453,7 @@ if ($free_search != '') {
echo $html_content;
}
// strict user hidden
// Strict user hidden.
echo '<div id="strict_hidden" class="invisible">';
html_print_input_text('strict_user_hidden', $strict_user);

View File

@ -97,7 +97,7 @@ if ($edit_networkmap) {
return;
}
$name = io_safe_output($values['name']);
$name = io_safe_output_html($values['name']);
// Id group of the map itself, not data source.
$id_group_map = $values['id_group_map'];

View File

@ -302,7 +302,7 @@ if (empty($all_address_agents)) {
switch ($config['dbtype']) {
case 'mysql':
$sql = 'SELECT *
FROM ttrap
FROM ttrap
WHERE (
`source` IN ('.implode(',', $address_by_user_groups).") OR
`source`='' OR
@ -671,8 +671,18 @@ $filter_resume['group_by'] = $group_by;
$filter_resume['hours_ago'] = $hours_ago;
$filter_resume['trap_type'] = $trap_types[$trap_type];
$traps = db_get_all_rows_sql($sql);
$trapcount = (int) db_get_value_sql($sql_count);
$traps = db_get_all_rows_sql($sql, true);
$trapcount = (int) db_get_value_sql($sql_count, false, true);
// Re-sort traps by timestamp if history db is enabled.
if ($config['history_db_enabled'] == 1) {
usort(
$traps,
function ($a, $b) {
return strtotime($a['timestamp']) < strtotime($b['timestamp']);
}
);
}
// No traps.
if (empty($traps)) {

View File

@ -281,6 +281,12 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
"<?php echo get_parameter('hash', ''); ?>"
);
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);

View File

@ -33,7 +33,6 @@ global $config;
check_login();
require_once $config['homedir'].'/vendor/autoload.php';
// TODO: include file functions.
require_once $config['homedir'].'/include/functions_visual_map.php';
@ -103,6 +102,9 @@ $aclRead = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VR')
$aclWrite = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VW');
$aclManage = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VM');
// Maintenance Mode.
$maintenanceMode = $visualConsoleData['maintenanceMode'];
if ($aclRead === false && $aclWrite === false && $aclManage === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
@ -398,18 +400,54 @@ if ($pure === false) {
echo '</div>';
if ($aclWrite === true || $aclManage === true) {
if (!is_metaconsole()) {
echo '<a id ="force_check" href="" style="margin-right: 25px;">'.html_print_image(
echo '<div class="flex-row" style="width:220px;">';
if (is_metaconsole() === false) {
echo '<div id="force_check_control" class="flex-column">';
echo html_print_label(__('Force'), 'force-mode', true);
echo '<a id ="force_check" href="">';
echo html_print_image(
'images/target.png',
true,
[
'title' => __('Force remote checks'),
'class' => 'invert_filter',
]
).'</a>';
);
echo '</a>';
echo '</div>';
}
echo html_print_checkbox_switch('edit-mode', 1, false, true);
$disabled_edit_mode = false;
if ($aclManage === true) {
$value_maintenance_mode = true;
if ($maintenanceMode === null) {
$value_maintenance_mode = false;
} else {
if ($maintenanceMode['user'] !== $config['id_user']) {
$disabled_edit_mode = true;
}
}
echo '<div id="maintenance-mode-control" class="flex-column">';
echo html_print_label(
__('Maintenance'),
'maintenance-mode',
true
);
echo html_print_checkbox_switch(
'maintenance-mode',
1,
$value_maintenance_mode,
true
);
echo '</div>';
}
echo '<div id="edit-mode-control" class="flex-column">';
echo html_print_label(__('Edit'), 'edit-mode', true);
echo html_print_checkbox_switch('edit-mode', 1, false, true, $disabled_edit_mode);
echo '</div>';
echo '</div>';
}
echo '</div>';
@ -661,6 +699,18 @@ ui_require_css_file('form');
window.history.replaceState({}, document.title, href);
}
}
if(newProps.maintenanceMode != null) {
$('input[name=maintenance-mode]').prop('checked', true);
if(newProps.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
$('input[name=edit-mode]').prop('disabled', true);
} else {
$('input[name=edit-mode]').prop('disabled', false);
}
} else {
$('input[name=maintenance-mode]').prop('checked', false);
$('input[name=edit-mode]').prop('disabled', false);
}
}
// Add the datetime when the item was received.
@ -676,26 +726,88 @@ ui_require_css_file('form');
items,
baseUrl,
<?php echo ($refr * 1000); ?>,
handleUpdate
handleUpdate,
false,
undefined,
'<?php echo $config['id_user']; ?>',
);
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
<?php
if ($edit_capable === true) {
?>
// Enable/disable the edition mode.
$('input[name=edit-mode]').change(function(event) {
var maintenanceMode = visualConsoleManager.visualConsole.props.maintenanceMode;
if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0);
$('#force_check').hide();
$('#edit-controls').css('visibility', '');
} else {
visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden');
$('#force_check').show();
}
resetInterval();
});
// Enable/disable the maintenance mode.
$('input[name=maintenance-mode]').click(function(event) {
event.preventDefault();
const idVisualConsole = '<?php echo $visualConsoleId; ?>';
const mode = ($(this).prop('checked') === true) ? 1 : 0;
var maintenanceMode = visualConsoleManager.visualConsole.props.maintenanceMode;
var msg = '';
if(maintenanceMode == null) {
msg = '<?php echo __('Are you sure you wish to set the visual console in maintenance mode'); ?>';
msg += '?';
} else if (maintenanceMode.user === '<?php echo $config['id_user']; ?>') {
msg += '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?';
} else {
msg = '<?php echo __('The visual console was set to maintenance mode'); ?>';
msg += ' ' + '<span title="'+maintenanceMode.date+'">' + maintenanceMode.timestamp + '</span>';
msg += ' ' + '<?php echo __('ago by user'); ?>';
msg += ' ' + maintenanceMode.user;
msg += '. ' + '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?';
}
confirmDialog({
title: '<?php echo __('Maintenance mode'); ?>',
message: msg,
onAccept: function() {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "include/ajax/visual_console.ajax",
update_maintanance_mode: true,
idVisualConsole: idVisualConsole,
mode: mode
},
success: function (data) {
if(data.result) {
$('input[name=maintenance-mode]').prop('checked', mode);
$('input[name=maintenance-mode]').trigger('change');
resetInterval();
}
},
error: function (err) {
console.error(err);
}
});
}
});
});
<?php
}
@ -797,6 +909,7 @@ if ($edit_capable === true) {
function resetInterval() {
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>);
visualConsoleManager.forceUpdateVisualConsole();
}
/**

View File

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

View File

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

View File

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

View File

@ -764,7 +764,7 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
CREATE TABLE IF NOT EXISTS `tcredential_store` (
`identifier` VARCHAR(100) NOT NULL,
`id_group` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0,
`product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP') DEFAULT 'CUSTOM',
`product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM',
`username` TEXT,
`password` TEXT,
`extra_1` TEXT,
@ -874,6 +874,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`summary` TEXT,
`type` INT NOT NULL DEFAULT 0,
`subnet_csv` TINYINT UNSIGNED DEFAULT 0,
`snmp_skip_non_enabled_ifs` TINYINT UNSIGNED DEFAULT 1,
PRIMARY KEY (`id_rt`),
KEY `recon_task_daemon` (`id_recon_server`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -1678,6 +1679,7 @@ CREATE TABLE IF NOT EXISTS `tlayout` (
`background_color` VARCHAR(50) NOT NULL DEFAULT '#FFF',
`is_favourite` INT UNSIGNED NOT NULL DEFAULT 0,
`auto_adjust` INT UNSIGNED NOT NULL DEFAULT 0,
`maintenance_mode` TEXT,
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -1335,18 +1335,18 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System&#x20
--
INSERT INTO `tlayout`
VALUES
(1, 'Demo&#x20;visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0, 0),
(2,'Demo&#x20;visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0, 0),
(3,'Worldmap',0,'map_world.jpg',1080,1920,'white',0, 0),
(4,'Europe',0,'map_europe_1.jpg',1080,1920,'white',0, 0),
(5,'USA',0,'map_USA.jpg',1080,1920,'white',0, 0),
(6,'Spain',0,'map_spain.jpg',1080,1920,'white',0, 0),
(7,'Madrid',0,'map_madrid.jpg',1080,1920,'white',0, 0),
(8,'Germany',0,'map_germany_1.jpg',1080,1920,'white',0, 0),
(9,'France',0,'map_france.jpg',1080,1920,'white',0, 0),
(10,'Catalonia',0,'map_catalonia.jpg',1080,1920,'white',0, 0),
(11,'Basque&#x20;Country',0,'map_basque-country.jpg',1080,1920,'white',0, 0),
(12,'Andalusia',0,'map_andalusia.jpg',1080,1920,'white',0, 0)
(1, 'Demo&#x20;visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0, 0, null),
(2,'Demo&#x20;visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0, 0, null),
(3,'Worldmap',0,'map_world.jpg',1080,1920,'white',0, 0, null),
(4,'Europe',0,'map_europe_1.jpg',1080,1920,'white',0, 0, null),
(5,'USA',0,'map_USA.jpg',1080,1920,'white',0, 0, null),
(6,'Spain',0,'map_spain.jpg',1080,1920,'white',0, 0, null),
(7,'Madrid',0,'map_madrid.jpg',1080,1920,'white',0, 0, null),
(8,'Germany',0,'map_germany_1.jpg',1080,1920,'white',0, 0, null),
(9,'France',0,'map_france.jpg',1080,1920,'white',0, 0, null),
(10,'Catalonia',0,'map_catalonia.jpg',1080,1920,'white',0, 0, null),
(11,'Basque&#x20;Country',0,'map_basque-country.jpg',1080,1920,'white',0, 0, null),
(12,'Andalusia',0,'map_andalusia.jpg',1080,1920,'white',0, 0, null)
;
--

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.765-221028
Version: 7.0NG.765-221104
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.765-221028"
pandora_version="7.0NG.765-221104"
package_cpan=0
package_pandora=1

View File

@ -453,6 +453,9 @@ sub pandora_server_tasks ($) {
}
}
# Check if snmptrapd is freeze.
pandora_snmptrapd_still_working ($pa_config, $dbh);
# Event auto-expiry
my $expiry_time = $pa_config->{"event_expiry_time"};
my $expiry_window = $pa_config->{"event_expiry_window"};

View File

@ -747,3 +747,6 @@ alertserver_queue 0
tentacle_service_watchdog 1
# Enable (1) or disable (0) the parameter of mysql ssl certification (mysql_ssl_verify_server_cert) (enabled by default).
verify_mysql_ssl_cert 1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765";
my $pandora_build = "221028";
my $pandora_build = "221104";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash
@ -229,6 +229,7 @@ sub pandora_load_config {
$pa_config->{"dbssl"} = 0;
$pa_config->{"dbsslcapath"} = "";
$pa_config->{"dbsslcafile"} = "";
$pa_config->{"verify_mysql_ssl_cert"} = "0";
$pa_config->{"basepath"} = $pa_config->{'pandora_path'}; # Compatibility with Pandora 1.1
$pa_config->{"incomingdir"} = "/var/spool/pandora/data_in";
$pa_config->{"user"} = "pandora"; # environment settings default user owner for files generated
@ -724,6 +725,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^dbsslcafile\s(.*)/i) {
$pa_config->{'dbsslcafile'}= clean_blank($1);
}
elsif ($parametro =~ m/^verify_mysql_ssl_cert\s(.*)/i) {
$pa_config->{'verify_mysql_ssl_cert'}= clean_blank($1);
}
elsif ($parametro =~ m/^dbuser\s(.*)/i) {
$pa_config->{'dbuser'}= clean_blank($1);
}

View File

@ -114,6 +114,7 @@ use Encode;
use Encode::CN;
use XML::Simple;
use HTML::Entities;
use Tie::File;
use Time::Local;
use Time::HiRes qw(time);
eval "use POSIX::strftime::GNU;1" if ($^O =~ /win/i);
@ -215,6 +216,7 @@ our @EXPORT = qw(
pandora_module_keep_alive_nd
pandora_module_unknown
pandora_output_password
pandora_snmptrapd_still_working
pandora_planned_downtime
pandora_planned_downtime_set_quiet_elements
pandora_planned_downtime_unset_quiet_elements
@ -7191,6 +7193,43 @@ sub notification_get_groups {
return @results;
}
########################################################################
=head2 C<< pandora_snmptrapd_still_working (I<$pa_config>, I<$dbh>) >>
snmptrapd sometimes freezes and eventually its status needs to be checked.
=cut
########################################################################
sub pandora_snmptrapd_still_working ($$) {
my ($pa_config, $dbh) = @_;
if ($pa_config->{'snmpserver'} eq '1') {
# Variable that defines the maximum time of delay between kksks.
my $timeMaxLapse = 3600;
# Check last snmptrapd saved in DB.
my $lastTimestampSaved = get_db_value($dbh, 'SELECT UNIX_TIMESTAMP(timestamp)
FROM ttrap
ORDER BY timestamp DESC
LIMIT 1');
# Read the last log file line.
my $snmptrapdFile = $pa_config->{'snmp_logfile'};
tie my @snmptrapdFileComplete, 'Tie::File', $snmptrapdFile;
my $lastTimestampLogFile = $snmptrapdFileComplete[-1];
my ($protocol, $date, $time) = split(/\[\*\*\]/, $lastTimestampLogFile, 4);
# If time or date not filled in, probably havent caught any snmptraps yet.
if ($time ne '' && $date ne '') {
my ($hour, $min, $sec) = split(/:/, $time, 3);
my ($year, $month, $day) = split(/-/, $date, 3);
my $lastTimestampLogFile = timelocal($sec,$min,$hour,$day,$month-1,$year);
if ($lastTimestampSaved ne $lastTimestampLogFile && $lastTimestampLogFile gt ($lastTimestampSaved + $timeMaxLapse)) {
my $lapseMessage = "snmptrapd service probably is stuck.";
logger($pa_config, $lapseMessage, 1);
pandora_event ($pa_config, $lapseMessage, 0, 0, 4, 0, 0, 'system', 0, $dbh);
}
}
}
}
# End of function declaration
# End of defined Code

View File

@ -1665,9 +1665,12 @@ sub set_ssl_opts($) {
}
# Enable SSL.
$SSL_OPTS = "mysql_ssl=1;mysql_ssl_optional=1;mysql_ssl_verify_server_cert=1";
$SSL_OPTS = "mysql_ssl=1;mysql_ssl_optional=1";
# Set additional SSL options.
if (defined($pa_config->{'verify_mysql_ssl_cert'}) && $pa_config->{'verify_mysql_ssl_cert'} ne "") {
$SSL_OPTS .= ";mysql_ssl_verify_server_cert=" . $pa_config->{'verify_mysql_ssl_cert'};
}
if (defined($pa_config->{'dbsslcapath'}) && $pa_config->{'dbsslcapath'} ne "") {
$SSL_OPTS .= ";mysql_ssl_ca_path=" . $pa_config->{'dbsslcapath'};
}

View File

@ -273,6 +273,7 @@ sub data_consumer ($$) {
snmp_security_level => $task->{'snmp_security_level'},
snmp_timeout => $task->{'snmp_timeout'},
snmp_version => $task->{'snmp_version'},
snmp_skip_non_enabled_ifs => $task->{'snmp_skip_non_enabled_ifs'},
subnets => \@subnets,
task_id => $task->{'id_rt'},
vlan_cache_enabled => $task->{'vlan_enabled'},
@ -723,9 +724,12 @@ sub PandoraFMS::Recon::Base::create_interface_modules($$) {
foreach my $if_index (@output) {
next unless ($if_index =~ /^[0-9]+$/);
# Check the status of the interface.
my $if_status = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index");
next unless $if_status == 1;
if ($self->{'task_data'}{'snmp_skip_non_enabled_ifs'} == 1) {
# Check the status of the interface.
my $if_status = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index");
next unless $if_status == 1;
}
# Fill the module description with the IP and MAC addresses.
my $mac = $self->get_if_mac($device, $if_index);

View File

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

View File

@ -215,6 +215,7 @@ sub new {
snmp_security_level => '',
snmp_timeout => 2,
snmp_version => 1,
snmp_skip_non_enabled_ifs => 1,
subnets => [],
autoconfiguration_enabled => 0,
@ -312,6 +313,7 @@ sub new {
$self->{'snmp_privacy_method'} = '';
$self->{'snmp_privacy_pass'} = '';
$self->{'snmp_security_level'} = '';
$self->{'snmp_skip_non_enabled_ifs'} = '';
}
return $self;

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.765 Build 221028";
my $version = "7.0NG.765 Build 221104";
# Pandora server configuration
my %conf;
@ -631,6 +631,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_event_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'event_purge'");
$conf->{'_trap_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'trap_purge'");
$conf->{'_trap_history_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'trap_purge'");
$conf->{'_audit_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'audit_purge'");
$conf->{'_string_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'string_purge'");
$conf->{'_gis_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'gis_purge'");
@ -641,6 +642,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_step_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'step_compact'");
$conf->{'_history_db_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_enabled'");
$conf->{'_history_event_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_enabled'");
$conf->{'_history_trap_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_trap_enabled'");
$conf->{'_history_db_host'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_host'");
$conf->{'_history_db_port'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_port'");
$conf->{'_history_db_name'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_name'");
@ -650,6 +652,7 @@ sub pandora_load_config_pdb ($) {
$conf->{'_history_db_adv'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_adv'");
$conf->{'_history_db_string_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_string_days'");
$conf->{'_history_event_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_days'");
$conf->{'_history_trap_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_trap_days'");
$conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'");
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
@ -897,18 +900,11 @@ sub pandora_checkdb_consistency {
log_message ('CHECKDB',
"Checking database consistency (Missing status).");
my @modules = get_db_rows ($dbh, 'SELECT * FROM tagente_modulo');
my @modules = get_db_rows ($dbh, 'SELECT m.id_agente, m.id_agente_modulo, e.id_agente_estado FROM tagente_modulo AS m LEFT JOIN tagente_estado AS e ON m.id_agente_modulo = e.id_agente_modulo WHERE e.id_agente_estado IS NULL');
foreach my $module (@modules) {
my $id_agente_modulo = $module->{'id_agente_modulo'};
my $id_agente = $module->{'id_agente'};
# check if exist in tagente_estado and create if not
my $count = get_db_value ($dbh,
'SELECT COUNT(*)
FROM tagente_estado
WHERE id_agente_modulo = ?', $id_agente_modulo);
next if (defined ($count) && $count > 0);
db_do ($dbh,
'INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente_modulo, 0, '1970-01-01 00:00:00', 1, $id_agente, '1970-01-01 00:00:00', 0, 0, 0, 0);
log_message ('CHECKDB',
@ -923,17 +919,10 @@ sub pandora_checkdb_consistency {
# tagente_modulo, if there is any, delete it
#-------------------------------------------------------------------
@modules = get_db_rows ($dbh, 'SELECT * FROM tagente_estado');
@modules = get_db_rows ($dbh, 'SELECT e.id_agente_modulo, m.id_agente FROM tagente_estado AS e LEFT JOIN tagente_modulo AS m ON e.id_agente_modulo = m.id_agente_modulo WHERE m.id_agente IS NULL');
foreach my $module (@modules) {
my $id_agente_modulo = $module->{'id_agente_modulo'};
# check if exist in tagente_estado and create if not
my $count = get_db_value ($dbh,
'SELECT COUNT(*)
FROM tagente_modulo
WHERE id_agente_modulo = ?', $id_agente_modulo);
next if (defined ($count) && $count > 0);
db_do ($dbh, 'DELETE FROM tagente_estado
WHERE id_agente_modulo = ?', $id_agente_modulo);
@ -1133,6 +1122,26 @@ sub pandoradb_history ($$) {
log_message ('', "\n");
}
# Delete old traps.
if ($conf->{'_trap_history_purge'} > 0) {
log_message ('PURGE', "Deleting traps older than " . $conf->{'_trap_history_purge'} . " days from ttrap (history).", '');
my $trap_limit = strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - 86400 * $conf->{'_trap_history_purge'}));
my $traps_to_delete = get_db_value ($dbh, "SELECT COUNT(*) FROM ttrap WHERE timestamp < ?", $trap_limit);
while($traps_to_delete > 0) {
db_delete_limit($dbh, 'ttrap', "timestamp < ?", $BIG_OPERATION_STEP, $trap_limit);
$traps_to_delete = $traps_to_delete - $BIG_OPERATION_STEP;
# Mark the progress.
log_message ('', ".");
# Do not overload the MySQL server.
usleep (10000);
}
log_message ('', "\n");
}
# Update tconfig with last time of database maintance time (now)
db_do ($dbh, "DELETE FROM tconfig WHERE token = 'db_maintance'");
db_do ($dbh, "INSERT INTO tconfig (token, value) VALUES ('db_maintance', '".time()."')");
@ -1163,6 +1172,9 @@ sub pandoradb_main {
if (defined($conf{'_history_event_enabled'}) && $conf->{'_history_event_enabled'} ne "" && $conf->{'_history_event_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_event', [$dbh, $history_dbh, $conf->{'_history_event_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
}
if (defined($conf{'_history_trap_enabled'}) && $conf->{'_history_trap_enabled'} ne "" && $conf->{'_history_trap_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_trap', [$dbh, $history_dbh, $conf->{'_history_trap_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
}
}
# Only active database should be compacted. Disabled for historical database.
@ -1270,13 +1282,20 @@ if ($conf{'_force'} == 0 && pandora_is_master(\%conf) == 0) {
exit 1;
}
# Set the lock name for pandora_db.
my $lock_name = $conf{'dbname'};
# Get a lock on the main database.
my $db_lock = db_get_lock ($dbh, $conf{'dbname'} . '_pandora_db', $LOCK_TIMEOUT, 1);
if ($db_lock == 0) {
log_message ('', " [*] Another instance of DB Tool seems to be running on the main database.\n\n");
exit 1;
}
# Release the database lock in forced mode.
if ($conf{'_force'} == 1) {
log_message ('', " [*] Releasing database lock.\n\n");
db_release_pandora_lock($dbh, $lock_name, $LOCK_TIMEOUT);
# Get a lock on the history database.
if (defined($history_dbh)) {
my $history_lock = db_get_lock ($history_dbh, $conf{'_history_db_name'} . '_pandora_db', $LOCK_TIMEOUT, 1);
if ($history_lock == 0) {
log_message ('', " [*] Another instance of DB Tool seems to be running on the history database.\n\n");
exit 1;
}
}
# Get a lock merging.
@ -1293,13 +1312,6 @@ if ($lock_merge_events == 0) {
exit 1;
}
# Get a lock on dbname.
my $lock = db_get_pandora_lock ($dbh, $lock_name, $LOCK_TIMEOUT);
if ($lock == 0) {
log_message ('', " [*] Another instance of DB Tool seems to be running.\n\n");
exit 1;
}
# Main
pandoradb_main(\%conf, $dbh, $h_conf, $history_dbh);
@ -1336,9 +1348,6 @@ if (scalar(@types) != 0) {
db_do($dbh, "UPDATE talert_commands SET fields_values='[\"\", \"\", \"\",\"\",\"" . $query_string . "\",\"\",\"\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\",\"_integria_type_custom_field_\"]' WHERE name=\"Integria&#x20;IMS&#x20;Ticket\"");
}
# Release the lock
db_release_pandora_lock ($dbh, $lock_name);
# Cleanup and exit
db_disconnect ($history_dbh) if defined ($history_dbh);
db_disconnect ($dbh);

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.765 Build 221028";
my $version = "7.0NG.765 Build 221104";
# save program name for logging
my $progname = basename($0);

View File

@ -591,6 +591,9 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
});
// Metadata state.
if (this.meta.maintenanceMode) {
box.classList.add("is-maintenance");
}
if (this.meta.editMode) {
box.classList.add("is-editing");
}
@ -877,8 +880,12 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
}
// Change metadata related things.
if (!prevMeta || prevMeta.editMode !== this.meta.editMode) {
if (this.meta.editMode) {
if (
!prevMeta ||
prevMeta.editMode !== this.meta.editMode ||
prevMeta.maintenanceMode !== this.meta.maintenanceMode
) {
if (this.meta.editMode && this.meta.maintenanceMode === false) {
this.elementRef.classList.add("is-editing");
} else {
this.elementRef.classList.remove("is-editing");

View File

@ -159,6 +159,12 @@ export interface VisualConsoleProps extends Size {
backgroundColor: string | null;
isFavorite: boolean;
relationLineWidth: number;
maintenanceMode: MaintenanceModeInterface | null;
}
export interface MaintenanceModeInterface {
user: string;
timestamp: number;
}
/**
@ -181,7 +187,8 @@ export function visualConsolePropsDecoder(
backgroundURL,
backgroundColor,
isFavorite,
relationLineWidth
relationLineWidth,
maintenanceMode
} = data;
if (id == null || isNaN(parseInt(id))) {
@ -202,6 +209,7 @@ export function visualConsolePropsDecoder(
backgroundColor: notEmptyStringOr(backgroundColor, null),
isFavorite: parseBoolean(isFavorite),
relationLineWidth: parseIntOr(relationLineWidth, 0),
maintenanceMode: maintenanceMode,
...sizePropsDecoder(data)
};
}
@ -1222,6 +1230,28 @@ export default class VisualConsole {
this.containerRef.classList.remove("is-editing");
}
/**
* Enable the maintenance mode.
*/
public enableMaintenanceMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, maintenanceMode: true };
});
this.containerRef.classList.add("is-maintenance");
this.containerRef.classList.remove("is-editing");
}
/**
* Disable the maintenance mode.
*/
public disableMaintenanceMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, maintenanceMode: false };
});
this.containerRef.classList.remove("is-maintenance");
this.containerRef.classList.add("is-editing");
}
/**
* Select an item.
* @param itemId Item Id.

View File

@ -275,6 +275,7 @@ export function itemMetaDecoder(data: UnknownObject): ItemMeta | never {
receivedAt,
error,
editMode: parseBoolean(data.editMode),
maintenanceMode: parseBoolean(data.maintenanceMode),
isFromCache: parseBoolean(data.isFromCache),
isFetching: false,
isUpdating: false,

View File

@ -133,6 +133,7 @@ describe("itemMetaDecoder function", () => {
isFetching: false,
isUpdating: false,
editMode: false,
maintenanceMode: false,
isBeingMoved: false,
isBeingResized: false,
isSelected: false,
@ -154,6 +155,7 @@ describe("itemMetaDecoder function", () => {
isFetching: false,
isUpdating: false,
editMode: true,
maintenanceMode: false,
isBeingMoved: false,
isBeingResized: false,
isSelected: false,

View File

@ -61,5 +61,6 @@ export interface ItemMeta {
isBeingMoved: boolean;
isBeingResized: boolean;
editMode: boolean;
maintenanceMode: boolean;
lineMode: boolean;
}

View File

@ -7,6 +7,14 @@
margin-top: 5px;
}
.is-maintenance {
background-image: url(./lib/maintenanceMode.png) !important;
}
.is-maintenance :nth-child(1) {
display: none;
}
.visual-console-item {
position: absolute;
display: flex;