Merge branch 'ent-9662-second-round' of brutus.artica.es:artica/pandorafms into ent-9662-second-round

This commit is contained in:
Pablo Aragon 2023-03-29 12:13:05 +02:00
commit 1a82056039
39 changed files with 698 additions and 43 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.770-230328 Version: 7.0NG.770-230329
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil} %global __os_install_post %{nil}
%define name pandorafms_agent_linux %define name pandorafms_agent_linux
%define version 7.0NG.770 %define version 7.0NG.770
%define release 230328 %define release 230329
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil} %global __os_install_post %{nil}
%define name pandorafms_agent_linux %define name pandorafms_agent_linux
%define version 7.0NG.770 %define version 7.0NG.770
%define release 230328 %define release 230329
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.770" PI_VERSION="7.0NG.770"
PI_BUILD="230328" PI_BUILD="230329"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{230328} {230329}
ViewReadme ViewReadme
{Yes} {Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.770-230328 Version: 7.0NG.770-230329
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -729,16 +729,31 @@ function mainAgentsModules()
if (isset($modules_selected[0]) === true && $modules_selected[0]) { if (isset($modules_selected[0]) === true && $modules_selected[0]) {
$all_modules = []; $all_modules = [];
foreach ($modules_selected as $key => $value) { foreach ($modules_selected as $key => $value) {
$name = modules_get_agentmodule_name($value); if (is_int($value)) {
$sql = "SELECT id_agente_modulo $name = modules_get_agentmodule_name($value);
FROM tagente_modulo $sql = "SELECT id_agente_modulo
WHERE nombre = '".$name."';"; FROM tagente_modulo
WHERE nombre = '".$name."';";
$result_sql = db_get_all_rows_sql($sql); $result_sql = db_get_all_rows_sql($sql);
if (is_array($result_sql)) { if (is_array($result_sql)) {
foreach ($result_sql as $key => $value) { foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name); $all_modules[$value['id_agente_modulo']] = io_safe_output($name);
}
}
} else {
$name = $value;
$sql = "SELECT id_agente_modulo
FROM tagente_modulo
WHERE nombre = '".$name."';";
$result_sql = db_get_all_rows_sql($sql);
if (is_array($result_sql)) {
foreach ($result_sql as $key => $value) {
$all_modules[$value['id_agente_modulo']] = io_safe_output($name);
}
} }
} }
} }
@ -838,7 +853,7 @@ function mainAgentsModules()
echo '<tr>'; echo '<tr>';
echo "<th width='140px' class='pdd_r_10px align_right'>".__('Agents').' / '.__('Modules').'</th>'; echo "<th width='40px' class='pdd_r_10px align_left'>".__('Agents').' / '.__('Modules').'</th>';
if ($hor_offset > 0) { if ($hor_offset > 0) {
$new_hor_offset = ($hor_offset - $block); $new_hor_offset = ($hor_offset - $block);
@ -958,7 +973,7 @@ function mainAgentsModules()
foreach ($module['id'] as $module_id) { foreach ($module['id'] as $module_id) {
if (!$match && array_key_exists($module_id, $agent_modules)) { if (!$match && array_key_exists($module_id, $agent_modules)) {
echo "<td class='center'>"; echo "<td class='center' style='text-align:left;'>";
$win_handle = dechex(crc32($module_id.$module['name'])); $win_handle = dechex(crc32($module_id.$module['name']));
$graph_type = return_graphtype(modules_get_agentmodule_type($module_id)); $graph_type = return_graphtype(modules_get_agentmodule_type($module_id));
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)"; $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)";

View File

@ -1,5 +1,19 @@
START TRANSACTION; START TRANSACTION;
CREATE TABLE IF NOT EXISTS `tconsole` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_console` BIGINT NOT NULL DEFAULT 0,
`description` TEXT,
`version` TINYTEXT,
`last_execution` INT UNSIGNED NOT NULL DEFAULT 0,
`console_type` TINYINT NOT NULL DEFAULT 0,
`timezone` TINYTEXT,
`public_url` TEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tuser_task_scheduled` ADD COLUMN `id_console` BIGINT NOT NULL DEFAULT 0;
ALTER TABLE `tdatabase` ADD COLUMN `ssh_status` TINYINT UNSIGNED DEFAULT 0; ALTER TABLE `tdatabase` ADD COLUMN `ssh_status` TINYINT UNSIGNED DEFAULT 0;
ALTER TABLE `tdatabase` ADD COLUMN `db_status` TINYINT UNSIGNED DEFAULT 0; ALTER TABLE `tdatabase` ADD COLUMN `db_status` TINYINT UNSIGNED DEFAULT 0;
ALTER TABLE `tdatabase` ADD COLUMN `replication_status` TINYINT UNSIGNED DEFAULT 0; ALTER TABLE `tdatabase` ADD COLUMN `replication_status` TINYINT UNSIGNED DEFAULT 0;

View File

@ -0,0 +1,69 @@
<?php
/**
* Consoles manager.
*
* @category Tools
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
use PandoraFMS\Console;
use PandoraFMS\View;
// Begin.
global $config;
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === false
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Consoles Management'
);
include 'general/noaccess.php';
exit;
}
$ajax_url = ui_get_full_url('ajax.php');
$message = '';
$error = false;
// Check is any consoles are registered.
$results = db_get_all_rows_in_table('tconsole');
$message = '';
if ($results === false) {
$message = ui_print_info_message(
__('If you want to have your consoles registered, you must define them by editing config.php in each individual console and wait for cron to run in order to be registered.')
);
}
View::render(
'consoles/list',
[
'ajax_url' => $ajax_url,
'message' => $message,
]
);

View File

@ -308,6 +308,13 @@ if ($access_console_node === true) {
$sub['godmode/servers/modificar_server']['id'] = 'Manage_servers'; $sub['godmode/servers/modificar_server']['id'] = 'Manage_servers';
} }
if ((bool) check_acl($config['id_user'], 0, 'PM') === true
|| is_user_admin($config['id_user']) === true
) {
$sub['godmode/consoles/consoles']['text'] = __('Manage consoles');
$sub['godmode/consoles/consoles']['id'] = 'Manage consoles';
}
// This subtabs are only for Pandora Admin. // This subtabs are only for Pandora Admin.
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
enterprise_hook('ha_cluster'); enterprise_hook('ha_cluster');

View File

@ -0,0 +1,96 @@
<?php
/**
* Ajax script for Consoles' List view.
*
* @category Consoles
* @package Community
* @subpackage Software agents repository
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ==========================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnológicas S.L
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannot redistribute it without written permission of copyright holder.
* ============================================================================
*/
// Begin.
global $config;
// Login check.
check_login();
require_once $config['homedir'].'/include/functions_ui.php';
use PandoraFMS\Console;
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === false
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Consoles Management'
);
include 'general/noaccess.php';
exit;
}
$get_all_datatables_formatted = (bool) get_parameter('get_all_datatables_formatted');
$delete = (bool) get_parameter('delete');
if ($get_all_datatables_formatted === true) {
$results = db_get_all_rows_in_table('tconsole', 'id_console');
if ($results === false) {
$results = [];
}
$count = count($results);
if ($results) {
$data = array_reduce(
$results,
function ($carry, $item) {
$item['last_execution'] = ui_print_timestamp($item['last_execution'], true);
$item['console_type'] = ((int) $item['console_type'] === 1) ? __('Reporting').'&nbsp&nbsp'.html_print_image('images/report_list.png', true) : __('Standard');
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$carry[] = $tmp;
return $carry;
}
);
}
// Datatables format: RecordsTotal && recordsfiltered.
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
return;
}
if ($delete === true) {
$id = get_parameter('id');
try {
$console = new Console($id);
$console->delete();
$console->save();
echo json_encode(['result' => __('Console successfully deleted')]);
} catch (Exception $e) {
echo json_encode(['result' => $e->getMessage()]);
}
return;
}

View File

@ -393,6 +393,10 @@ function process_user_login_remote($login, $pass, $api=false)
$user_info['metaconsole_access_node'] = $config['ldap_adv_user_node']; $user_info['metaconsole_access_node'] = $config['ldap_adv_user_node'];
} }
if (isset($config['timezonevisual']) === true) {
$user_info['timezone'] = $config['timezonevisual'];
}
$permissions = fill_permissions_ldap($sr); $permissions = fill_permissions_ldap($sr);
if (empty($permissions) === true) { if (empty($permissions) === true) {
$config['auth_error'] = __('User not found in database or incorrect password'); $config['auth_error'] = __('User not found in database or incorrect password');

View File

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

View File

@ -579,6 +579,10 @@ function config_update_config()
$error_update[] = __('Automatically assigned no hierarchy'); $error_update[] = __('Automatically assigned no hierarchy');
} }
if (config_update_value('timezonevisual', (string) get_parameter('timezonevisual'), true) === false) {
$error_update[] = __('Automatically timezone visual');
}
if (config_update_value('autocreate_blacklist', get_parameter('autocreate_blacklist'), true) === false) { if (config_update_value('autocreate_blacklist', get_parameter('autocreate_blacklist'), true) === false) {
$error_update[] = __('Autocreate blacklist'); $error_update[] = __('Autocreate blacklist');
} }

View File

@ -4387,12 +4387,53 @@ function events_page_details($event, $server_id=0)
$data = []; $data = [];
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last contact').'</div>'; $data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last contact').'</div>';
$data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : ui_print_timestamp($agent['ultimo_contacto'], true);
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
if (!$user_timezone) {
$timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($agent['ultimo_contacto']);
$total_sec += $dif;
$last_contact = date($config['date_format'], $total_sec);
$last_contact_value = ui_print_timestamp($last_contact, true);
} else {
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
date_default_timezone_set($user_timezone);
$last_contact_value = human_time_comparation(strtotime($agent['ultimo_contacto']), 'large');
}
$data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : $last_contact_value;
$table_details->data[] = $data; $table_details->data[] = $data;
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
if (!$user_timezone) {
$timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($agent['ultimo_contacto_remoto']);
$total_sec += $dif;
$lr_contact = date($config['date_format'], $total_sec);
} else {
$lr_contact = date($config['date_format'], strtotime($agent['ultimo_contacto_remoto']));
}
$data = []; $data = [];
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last remote contact').'</div>'; $data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last remote contact').'</div>';
$data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : date_w_fixed_tz($agent['ultimo_contacto_remoto']); $data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : $lr_contact;
$table_details->data[] = $data; $table_details->data[] = $data;
$data = []; $data = [];
@ -4879,6 +4920,13 @@ function events_page_general($event)
$data[1] .= __('Last event').': '; $data[1] .= __('Last event').': ';
$data[1] .= date($config['date_format'], $event['timestamp_last']); $data[1] .= date($config['date_format'], $event['timestamp_last']);
} else { } else {
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
if ($user_timezone) {
date_default_timezone_set($user_timezone);
} else {
date_default_timezone_set($config['timezone']);
}
$data[1] = date($config['date_format'], $event['utimestamp']); $data[1] = date($config['date_format'], $event['utimestamp']);
} }

View File

@ -751,7 +751,7 @@ function filemanager_file_explorer(
&& ($readOnly === false) && ($readOnly === false)
) { ) {
$data[4] .= '<form method="post" action="'.$url.'" style="">'; $data[4] .= '<form method="post" action="'.$url.'" style="">';
$data[4] .= '<input type="image" style="margin-top: 2px;height:21px" class="invert_filter main_menu_icon" src="../../images/delete.svg" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; $data[4] .= '<input type="image" style="margin-top: 2px;height:21px" class="invert_filter main_menu_icon" src="images/delete.svg" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true); $data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true);
$data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['server_unique_identifier']), true); $data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['server_unique_identifier']), true);
$data[4] .= html_print_input_hidden('delete_file', 1, true); $data[4] .= html_print_input_hidden('delete_file', 1, true);

View File

@ -0,0 +1,138 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Console entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
/**
* PandoraFMS console entity.
*/
class Console extends Entity
{
/**
* Builds a PandoraFMS\Console object from given id.
*
* @param integer $id Id console.
*/
public function __construct(?int $id=null)
{
$table = 'tconsole';
$filter = ['id' => $id];
$this->existsInDB = false;
if (is_numeric($id) === true
&& $id > 0
) {
parent::__construct(
$table,
$filter,
null,
false
);
$this->existsInDB = true;
} else {
// Create empty skel.
parent::__construct($table, null);
}
}
/**
* Saves current definition of a Console to database.
*
* @return mixed Affected rows of false in case of error.
* @throws \Exception On error.
*/
public function save()
{
if ($this->fields['id'] > 0) {
// Update.
$updates = $this->fields;
$rs = \db_process_sql_update(
$this->table,
$updates,
['id' => $this->fields['id']]
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
} else {
// Creation.
$inserts = $this->fields;
// Clean null fields.
foreach ($inserts as $k => $v) {
if ($v === null) {
unset($inserts[$k]);
}
}
$rs = \db_process_sql_insert(
$this->table,
$inserts
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
$this->fields['id'] = $rs;
}
return true;
}
/**
* Remove this Console.
*
* @return void
*/
public function delete()
{
if ($this->existsInDB === true) {
\db_process_delete_temp(
$this->table,
'id',
$this->fields['id']
);
}
}
}

View File

@ -5885,7 +5885,12 @@ div.switch_radio_button label:last-of-type {
cursor: pointer; cursor: pointer;
} }
.switch_radio_button input:checked + label, .switch_radio_button input:checked + label {
background-color: var(--primary-color);
box-shadow: none;
color: var(--secondary-color) !important;
}
.switch_radio_button input:checked:has(.custom_checkbox) { .switch_radio_button input:checked:has(.custom_checkbox) {
background-color: var(--primary-color); background-color: var(--primary-color);
box-shadow: none; box-shadow: none;

View File

@ -131,7 +131,7 @@
<div style='padding-bottom: 50px'> <div style='padding-bottom: 50px'>
<?php <?php
$version = '7.0NG.770'; $version = '7.0NG.770';
$build = '230328'; $build = '230329';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -536,10 +536,31 @@ if (is_ajax() === true) {
(empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp, (empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp,
true true
); );
$tmp->timestamp = ui_print_timestamp(
$tmp->utimestamp, $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
true if (!$user_timezone) {
); $timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($tmp->timestamp);
$total_sec += $dif;
$last_contact = date($config['date_format'], $total_sec);
$last_contact_value = ui_print_timestamp($last_contact, true);
} else {
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
date_default_timezone_set($user_timezone);
$title = date($config['date_format'], strtotime($tmp->timestamp));
$value = human_time_comparation(strtotime($tmp->timestamp), 'large');
$last_contact_value = '<span title="'.$title.'">'.$value.'</span>';
}
$tmp->timestamp = $last_contact_value;
if (is_numeric($tmp->data) === true) { if (is_numeric($tmp->data) === true) {
$tmp->data = format_numeric( $tmp->data = format_numeric(

View File

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

View File

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

View File

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

View File

@ -3769,6 +3769,7 @@ CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` (
`flag_delete` TINYINT UNSIGNED NOT NULL DEFAULT 0, `flag_delete` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`id_grupo` INT UNSIGNED NOT NULL DEFAULT 0, `id_grupo` INT UNSIGNED NOT NULL DEFAULT 0,
`enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1, `enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1,
`id_console` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -4189,6 +4190,21 @@ CREATE TABLE IF NOT EXISTS `tmonitor_filter` (
PRIMARY KEY (`id_filter`) PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- ---------------------------------------------------------------------
-- Table `tconsole`
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tconsole` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_console` BIGINT NOT NULL DEFAULT 0,
`description` TEXT,
`version` TINYTEXT,
`last_execution` INT UNSIGNED NOT NULL DEFAULT 0,
`console_type` TINYINT NOT NULL DEFAULT 0,
`timezone` TINYTEXT,
`public_url` TEXT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tagent_filter` -- Table `tagent_filter`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -4207,6 +4223,7 @@ CREATE TABLE IF NOT EXISTS `tagent_filter` (
PRIMARY KEY (`id_filter`) PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- ---------------------------------------------------------------------
-- Table `tevent_sound` -- Table `tevent_sound`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
CREATE TABLE `tevent_sound` ( CREATE TABLE `tevent_sound` (

View File

@ -0,0 +1,217 @@
<?php
/**
* Console: Consoles list page.
*
* @category View
* @package Pandora FMS
* @subpackage Alert
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Header.
\ui_print_page_header(
// Title.
__('%s registered consoles', $config['rb_product_name']),
// Icon.
'',
// Return.
false,
// Help.
'',
// Godmode.
true,
// Options.
''
);
if (empty($message) === false) {
echo $message;
}
// Auxiliar to display deletion modal.
echo '<div id="delete_modal" class="invisible"></div>';
echo '<div id="msg" class="invisible"></div>';
// Consoles list.
try {
$columns = [
'id_console',
'description',
'version',
'last_execution',
'console_type',
'timezone',
'public_url',
'options',
];
$column_names = [
__('Console ID'),
__('Description'),
__('Version'),
__('Last Execution'),
__('Console type'),
__('Timezone'),
__('Public URL'),
[
'text' => __('Options'),
'class' => 'action_buttons',
],
];
$tableId = 'consoles_list';
// Load datatables user interface.
ui_print_datatable(
[
'id' => $tableId,
'class' => 'info_table',
'style' => 'width: 99%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'include/ajax/consoles.ajax',
'ajax_data' => ['get_all_datatables_formatted' => 1],
'ajax_postprocess' => 'process_datatables_item(item)',
'no_sortable_columns' => [-1],
'order' => [
'field' => 'id',
'direction' => 'asc',
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
?>
<script type="text/javascript">
/**
* Process datatable item before draw it.
*/
function process_datatables_item(item) {
item.options = '<a href="javascript:" onclick="delete_key(\'';
item.options += item.id;
item.options += '\')" ><?php echo html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); ?></a>';
}
/**
* Delete selected key
*/
function delete_key(id) {
$('#delete_modal').empty();
$('#delete_modal').html('<?php echo __('<span>Are you sure?</span><br><br><i>WARNING: you also need to delete config.php options in your console or delete the whole console.</i>'); ?>');
$('#delete_modal').dialog({
title: '<?php echo __('Delete'); ?>',
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');
cleanupDOM();
}
},
{
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: 'include/ajax/consoles.ajax',
delete: 1,
id
},
datatype: "json",
success: function (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 = $("#<?php echo $tableId; ?>").DataTable();
dt_<?php echo $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>

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.770-230328 Version: 7.0NG.770-230329
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil} %global __os_install_post %{nil}
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.770 %define version 7.0NG.770
%define release 230328 %define release 230329
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil} %global __os_install_post %{nil}
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.770 %define version 7.0NG.770
%define release 230328 %define release 230329
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

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

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.770 Build 230328"; my $version = "7.0NG.770 Build 230329";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

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