Merge remote-tracking branch 'origin/develop' into ent-12511-error-handeling-en-los-clusters-no-es-del-todo-correcto

This commit is contained in:
daniel 2023-12-13 10:05:07 +01:00
commit 56f50bf4b0
152 changed files with 3555 additions and 1141 deletions

View File

@ -234,6 +234,21 @@ module_description Number of cron task files
module_unit files module_unit files
module_end module_end
# This module /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_begin
module_name Syslog
module_description Search for ssh string into /var/log/syslog file
module_type log
module_regexp /var/log/syslog
module_pattern ssh
module_end
#Hardening plugin for security compliance analysis. Enable to use it.
#module_begin
#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150
#module_absoluteinterval 7d
#module_end
# Plugin example # Plugin example
@ -241,11 +256,6 @@ module_end
module_plugin pandora_df module_plugin pandora_df
# This parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_plugin grep_log /var/log/syslog Syslog ssh
# Get disk space free in MB # Get disk space free in MB
#module_begin #module_begin
#module_name disk_root_free #module_name disk_root_free
@ -270,7 +280,6 @@ module_plugin grep_log /var/log/syslog Syslog ssh
#module_end #module_end
# Plugin for inventory on the agent. # Plugin for inventory on the agent.
# module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users process ip route # module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users process ip route
# Example of preconditions # Example of preconditions
@ -304,3 +313,12 @@ module_plugin grep_log /var/log/syslog Syslog ssh
# This plugin runs several security checks in a Linux system # This plugin runs several security checks in a Linux system
#module_plugin pandora_security_check #module_plugin pandora_security_check
# Extraction module example
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -147,22 +147,23 @@ module_max_critical 20
module_end module_end
# Log events # Log events
# Get logs from System source.
module_begin module_begin
module_name System Events (TermService) module_name System Events (TermService)
module_type async_string
module_logevent
module_description Log Events coming from Terminal Service module_description Log Events coming from Terminal Service
module_type log
module_logevent
module_source System module_source System
module_application TermService
module_end module_end
# Get logs from Security source.
module_begin module_begin
module_name Security Events (Invalid Login) module_name Security Events
module_type async_string module_description Security log events
module_description Security log events for invalid login attempt module_type log
module_logevent module_logevent
module_source Security module_source Security
module_eventcode 529
module_end module_end
# Check if Dhcp service is enabled # Check if Dhcp service is enabled
@ -219,6 +220,12 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs"
# module_description Free space on drive D: (%) # module_description Free space on drive D: (%)
# module_end # module_end
# Hardening plugin for security compliance analysis.
# module_begin
# module_plugin "%PROGRAMFILES%\Pandora_Agent\util\pandora_hardening.exe -t 150"
# module_absoluteinterval 7d
# module_end
# Sample of Windows inventory module (ONLY ENTERPRISE)! # Sample of Windows inventory module (ONLY ENTERPRISE)!
#module_begin #module_begin
#module_name Inventory #module_name Inventory
@ -345,3 +352,12 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs"
#module_exec echo 5 #module_exec echo 5
#module_description Postcondition test module #module_description Postcondition test module
#module_end #module_end
# Example of collector module
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -2179,16 +2179,7 @@ sub configure ($) {
#Launch tentacle server in proxy mode if configured #Launch tentacle server in proxy mode if configured
if ($Conf{'proxy_mode'}) { if ($Conf{'proxy_mode'}) {
return 1 if (launch_tentacle_proxy() != 0);
#Check if user is root
if ($> != 0) {
if (launch_tentacle_proxy() != 0) {
return 1;
}
} else {
error ('Proxy mode can not be launched as root');
return 1;
}
} }
# Add the plugins directory to the PATH # Add the plugins directory to the PATH

View File

@ -157,12 +157,32 @@ module_exec last | head -1
module_description Last Login module_description Last Login
module_end module_end
# Plugin example #Hardening plugin for security compliance analysis. Enable to use it.
#module_begin
#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150
#module_absoluteinterval 7d
#module_end
# This parses /var/log/syslog file, under the module name "syslog" # This module parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information. # And search for "ssh" string into it, sending only that information.
module_begin
module_name Syslog
module_description Search for ssh string into /var/log/syslog file
module_type log
module_regexp /var/log/syslog
module_pattern ssh
module_end
module_plugin grep_log /var/log/syslog Syslog ssh # Plugin example
# Plugin for inventory on the agent. # Plugin for inventory on the agent.
# module_plugin inventory 1 cpu ram video nic hd cdrom software # module_plugin inventory 1 cpu ram video nic hd cdrom software
# Extraction module example
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -372,13 +372,32 @@ module_end
#module_description XGrid #module_description XGrid
#module_end #module_end
#Hardening plugin for security compliance analysis. Enable to use it.
#module_begin
#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150
#module_absoluteinterval 7d
#module_end
# This module parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_begin
module_name Syslog
module_description Log collection modules
module_type log
module_regexp /var/log/syslog
module_pattern ssh
module_end
# Plugin example # Plugin example
# This parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
#module_plugin grep_log /var/log/syslog Syslog ssh
# Plugin for inventory on the agent. # Plugin for inventory on the agent.
# module_plugin inventory 1 cpu ram video nic hd cdrom software # module_plugin inventory 1 cpu ram video nic hd cdrom software
# Extraction module example
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.774-231129 Version: 7.0NG.774-231213
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.774-231129" pandora_version="7.0NG.774-231213"
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

@ -271,11 +271,17 @@ module_plugin pandora_netusage
module_plugin autodiscover --default module_plugin autodiscover --default
# Plugin for inventory on the agent. # Plugin for inventory on the agent.
#module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route # module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route
# Log collection modules. This will collect log files for forensic analysis and store everything # Log collection modules. This will collect log files for forensic analysis and store everything
# This is for LOG monitoring. Different than log monitoring. # This is for LOG monitoring. Different than log monitoring.
#module_plugin grep_log_module /var/log/messages Syslog \.\* module_begin
module_name Syslog
module_description Log collection modules
module_type log
module_regexp /var/log/messages
module_pattern .*
module_end
# Another samples of monitoring modules # Another samples of monitoring modules
@ -317,9 +323,9 @@ module_plugin autodiscover --default
#module_absoluteinterval 7d #module_absoluteinterval 7d
#module_end #module_end
# Logs extraction # Extraction module example
#module_begin #module_begin
#module_name Syslog #module_name Collector
#module_description Logs extraction module #module_description Logs extraction module
#module_type log #module_type log
#module_regexp /var/log/logfile.log #module_regexp /var/log/logfile.log

View File

@ -1039,7 +1039,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.774'; use constant AGENT_VERSION => '7.0NG.774';
use constant AGENT_BUILD => '231129'; use constant AGENT_BUILD => '231213';
# 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;
@ -4436,14 +4436,7 @@ my $PID = $$;
#Launch tentacle server in proxy mode if configured #Launch tentacle server in proxy mode if configured
if ($Conf{'proxy_mode'}) { if ($Conf{'proxy_mode'}) {
launch_tentacle_proxy();
#Check if user is root
if ($> != 0) {
launch_tentacle_proxy();
} else {
log_message ('error', 'Proxy mode can not be launched as root');
exit 1;
}
} }
# Advice if YAML::Tiny is allowed in this system # Advice if YAML::Tiny is allowed in this system

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.774 %define version 7.0NG.774
%define release 231129 %define release 231213
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin %define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux %define source_name pandorafms_agent_linux
%define version 7.0NG.774 %define version 7.0NG.774
%define release 231129 %define release 231213
%define debug_package %{nil} %define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin %define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux %define source_name pandorafms_agent_linux
%define version 7.0NG.774 %define version 7.0NG.774
%define release 231129 %define release 231213
%define debug_package %{nil} %define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin %define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux %define source_name pandorafms_agent_linux
%define version 7.0NG.774 %define version 7.0NG.774
%define release 231129 %define release 231213
Summary: Pandora FMS Linux agent, binary version Summary: Pandora FMS Linux agent, binary 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.774 %define version 7.0NG.774
%define release 231129 %define release 231213
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.774" PI_VERSION="7.0NG.774"
PI_BUILD="231129" PI_BUILD="231213"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -179,6 +179,22 @@ module_description Total number of TCP connections active
module_group Networking module_group Networking
module_end module_end
# Get logs from System source.
module_begin
module_name Eventlog_System
module_type log
module_logevent
module_source System
module_end
# Get logs from Security source.
module_begin
module_name Eventlog_Security
module_type log
module_logevent
module_source Security
module_end
# Example plugin to retrieve drive usage # Example plugin to retrieve drive usage
module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs" module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs"
@ -273,22 +289,6 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default
#module_type generic_data_string #module_type generic_data_string
#module_end #module_end
# Get logs from System source. Need enterprise version.
#module_begin
#module_name Eventlog_System
#module_type log
#module_logevent
#module_source System
#module_end
# Get logs from Security source. Need enterprise version.
#module_begin
#module_name Eventlog_Security
#module_type log
#module_logevent
#module_source Security
#module_end
# Get logs from Application source. Need enterprise version. # Get logs from Application source. Need enterprise version.
#module_begin #module_begin
#module_name Eventlog_Application #module_name Eventlog_Application

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{231129} {231213}
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.774 Build 231129") #define PANDORA_VERSION ("7.0NG.774 Build 231213")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Pandora FMS" VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.774(Build 231129))" VALUE "ProductVersion", "(7.0NG.774(Build 231213))"
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.774-231129 Version: 7.0NG.774-231213
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.774-231129" pandora_version="7.0NG.774-231213"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true
$_SESSION = []; $_SESSION = [];
session_destroy(); session_destroy();
header_remove('Set-Cookie'); header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); if (isset($_COOKIE[session_name()]) === true) {
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
}
if ($config['auth'] === 'saml' && empty($public_hash) === true) { if ($config['auth'] === 'saml' && empty($public_hash) === true) {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';

View File

@ -34,11 +34,11 @@ if ((bool) $config['metaconsole']) {
include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_modules.php';
include_once $config['homedir'].'/include/functions_users.php'; include_once $config['homedir'].'/include/functions_users.php';
} else { } else {
include_once '../include/config.php'; include_once __DIR__.'/../include/config.php';
include_once '../include/functions_agents.php'; include_once __DIR__.'/../include/functions_agents.php';
include_once '../include/functions_reporting.php'; include_once __DIR__.'/../include/functions_reporting.php';
include_once '../include/functions_modules.php'; include_once __DIR__.'/../include/functions_modules.php';
include_once '../include/functions_users.php'; include_once __DIR__.'/../include/functions_users.php';
} }

View File

@ -31,7 +31,7 @@ function view_logfile($file_name, $toggle=false)
} else { } else {
$file_size = filesize($file_name); $file_size = filesize($file_name);
if ($memory_limit < $file_size) { if ($memory_limit < $file_size && $memory_limit !== '-1') {
$code .= '<pre><h2>'.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')</h2>'; $code .= '<pre><h2>'.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')</h2>';
$code .= '<h2>'.__('The preview file is imposible.').'</h2>'; $code .= '<h2>'.__('The preview file is imposible.').'</h2>';
} else if ($file_size > ($config['max_log_size'] * 1000)) { } else if ($file_size > ($config['max_log_size'] * 1000)) {
@ -117,6 +117,7 @@ function pandoralogs_extension_main()
view_logfile($config['homedir'].'/log/console.log', true); view_logfile($config['homedir'].'/log/console.log', true);
} }
view_logfile('/var/log/php-fpm/www-error.log', true);
view_logfile($logs_directory.'/pandora_server.log', true); view_logfile($logs_directory.'/pandora_server.log', true);
view_logfile($logs_directory.'/pandora_server.error', true); view_logfile($logs_directory.'/pandora_server.error', true);

View File

@ -1720,3 +1720,4 @@ include/functions_integriaims.php
include/ajax/integria_incidents.ajax.php include/ajax/integria_incidents.ajax.php
enterprise/operation/log/log_source.php enterprise/operation/log/log_source.php
enterprise/include/class/LogSource.class.php enterprise/include/class/LogSource.class.php
include/chart_generator.php

View File

@ -1,4 +1,4 @@
pandorafms.vmware=9959cc3e5cc6bfcfadd6d05b56d4a11b pandorafms.vmware=248788e0fb2cd4e11623e4a52ee7d05b
pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe
pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.mssql=1cc215409741d19080269ffba112810e
pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6

View File

@ -1,18 +1,33 @@
START TRANSACTION; START TRANSACTION;
-- Telegram and vonage default alerts
UPDATE talert_actions ALTER TABLE `tevento`
SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' ADD COLUMN `event_custom_id` TEXT NULL AFTER `module_status`;
WHERE id=9;
UPDATE talert_actions SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmetaconsole_agent' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE());
SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmetaconsole_agent` DROP COLUMN `transactional_agent`', 'SELECT ""');
WHERE id=11; prepare stmt from @sqlstmt;
execute stmt;
SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tagente' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE());
SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_agent`', 'SELECT ""');
prepare stmt from @sqlstmt;
execute stmt;
ALTER TABLE `tdashboard`
ADD COLUMN `date_range` TINYINT NOT NULL DEFAULT 0 AFTER `cells_slideshow`,
ADD COLUMN `date_from` INT NOT NULL DEFAULT 0 AFTER `date_range`,
ADD COLUMN `date_to` INT NOT NULL DEFAULT 0 AFTER `date_from`;
-- Delete table tagent_access -- Delete table tagent_access
DROP TABLE tagent_access; DROP TABLE IF EXISTS tagent_access;
ALTER TABLE `tevent_rule` DROP COLUMN `user_comment`;
ALTER TABLE `tevent_rule` DROP COLUMN `operator_user_comment`;
ALTER TABLE treport_content ADD check_unknowns_graph tinyint DEFAULT 0 NULL; ALTER TABLE treport_content ADD check_unknowns_graph tinyint DEFAULT 0 NULL;
ALTER TABLE `tevent_filter` ADD COLUMN `regex` TEXT NULL AFTER `private_filter_user`;
-- Update macros for plugin oracle -- Update macros for plugin oracle
UPDATE `tdiscovery_apps` SET `version` = '1.1' WHERE `short_name` = 'pandorafms.oracle'; UPDATE `tdiscovery_apps` SET `version` = '1.1' WHERE `short_name` = 'pandorafms.oracle';
SET @id_app := (SELECT `id_app` FROM `tdiscovery_apps` WHERE `short_name` = 'pandorafms.oracle'); SET @id_app := (SELECT `id_app` FROM `tdiscovery_apps` WHERE `short_name` = 'pandorafms.oracle');
@ -23,5 +38,20 @@ INSERT IGNORE INTO `tdiscovery_apps_tasks_macros` (`id_task`, `macro`, `type`, `
INSERT IGNORE INTO `tdiscovery_apps_tasks_macros` (`id_task`, `macro`, `type`, `value`, `temp_conf`) SELECT id_rt, '_clientPath_', 'custom', '', 0 FROM `trecon_task` WHERE `id_app` = @id_app; INSERT IGNORE INTO `tdiscovery_apps_tasks_macros` (`id_task`, `macro`, `type`, `value`, `temp_conf`) SELECT id_rt, '_clientPath_', 'custom', '', 0 FROM `trecon_task` WHERE `id_app` = @id_app;
UPDATE `trecon_task` SET `setup_complete` = 1 WHERE `id_app` = @id_app; UPDATE `trecon_task` SET `setup_complete` = 1 WHERE `id_app` = @id_app;
-- Update lts updates
UPDATE tconfig SET value='1' WHERE token='lts_updates';
SELECT @generic_data := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "generic_data";
SELECT @generic_proc := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "generic_proc";
SELECT @async_data := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "async_data";
SELECT @async_proc := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "async_proc";
UPDATE `tagente_modulo` INNER JOIN `tservice` ON `tagente_modulo`.`custom_integer_1` = `tservice`.`id` SET `tagente_modulo`.`id_tipo_modulo` = @generic_data WHERE `tagente_modulo`.`id_tipo_modulo` = @async_data;
UPDATE `tagente_modulo` INNER JOIN `tservice` ON `tagente_modulo`.`custom_integer_1` = `tservice`.`id` SET `tagente_modulo`.`id_tipo_modulo` = @generic_proc WHERE `tagente_modulo`.`id_tipo_modulo` = @async_proc;
-- Telegram and vonage default alerts
UPDATE talert_actions SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' WHERE id=9;
UPDATE talert_actions SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' WHERE id=11;
UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.vmware';
COMMIT; COMMIT;

View File

@ -35,7 +35,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$notifications_numbers['last_id'] $notifications_numbers['last_id']
).'</div>'; ).'</div>';
$header_welcome = ''; $header_welcome = '';
if (check_acl($config['id_user'], $group, 'AW')) { if (check_acl($config['id_user'], 0, 'AW')) {
$header_welcome .= '<div id="welcome-icon-header">'; $header_welcome .= '<div id="welcome-icon-header">';
$header_welcome .= html_print_image( $header_welcome .= html_print_image(
'images/wizard@svg.svg', 'images/wizard@svg.svg',
@ -455,19 +455,28 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
); );
$header_logout .= '</a></div>'; $header_logout .= '</a></div>';
if (enterprise_installed()) {
$subtitle_header = $config['custom_subtitle_header'];
$class_header = '';
} else {
$subtitle_header = __('the Flexible Monitoring System (OpenSource version)');
echo '<div id="dialog_why_enterprise" class="invisible"></div>';
$class_header = 'underline-hover modal_module_list';
}
if (is_reporting_console_node() === true) { if (is_reporting_console_node() === true) {
echo '<div class="header_left">'; echo '<div class="header_left '.$class_header.'">';
echo '<span class="header_title">'; echo '<span class="header_title">';
echo $config['custom_title_header']; echo $config['custom_title_header'];
echo '</span>'; echo '</span>';
echo '<span class="header_subtitle">'; echo '<span class="header_subtitle">';
echo $config['custom_subtitle_header']; echo $subtitle_header;
echo '</span>'; echo '</span>';
echo '</div>'; echo '</div>';
echo '<div class="header_center"></div>'; echo '<div class="header_center"></div>';
echo '<div class="header_right">'.$modal_help, $header_user, $header_logout.'</div>'; echo '<div class="header_right">'.$modal_help, $header_user, $header_logout.'</div>';
} else { } else {
echo '<div class="header_left"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$config['custom_subtitle_header'].'</span></div> echo '<div class="header_left '.$class_header.'"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$subtitle_header.'</span></div>
<div class="header_center">'.$header_searchbar.'</div> <div class="header_center">'.$header_searchbar.'</div>
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $modal_help, $header_setup, $header_user, $header_logout.'</div>'; <div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $modal_help, $header_setup, $header_user, $header_logout.'</div>';
} }
@ -916,6 +925,46 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$(document).ready (function () { $(document).ready (function () {
<?php if (enterprise_installed() === false) { ?>
$('.header_left').on('click', function(){
// Hidden tips modal.
$(".window").css("display", "none");
jQuery.post(
"ajax.php",
{
page: "include/functions_menu",
'why_enterprise': "true"
},
function(data) {
if (data) {
$("#dialog_why_enterprise").html(data);
// Open dialog
$("#dialog_why_enterprise").dialog({
resizable: false,
draggable: false,
modal: true,
show: {
effect: "fade",
duration: 200
},
hide: {
effect: "fade",
duration: 200
},
closeOnEscape: true,
width: 700,
height: 450,
close: function(){
$('#dialog_why_enterprise').html('');
}
});
}
},
"html"
);
});
<?php } ?>
// Check new notifications on a periodic way // Check new notifications on a periodic way
setInterval(check_new_notifications, 60000); setInterval(check_new_notifications, 60000);

View File

@ -600,43 +600,176 @@ html_print_div(
'content' => html_print_table($tableAgent, true).$CodeQRTable, 'content' => html_print_table($tableAgent, true).$CodeQRTable,
] ]
); );
/*
TODO REVIEW
$table_satellite = '';
if ($remote_agent === true) {
// Satellite server selector.
$satellite_servers = db_get_all_rows_filter(
'tserver',
['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE],
[
'id_server',
'name',
]
);
$satellite_names = []; // Basic Options.
if (empty($satellite_servers) === false) { $tableBasicAgent = new stdClass();
foreach ($satellite_servers as $s_server) { $tableBasicAgent->class = 'filter-table-adv';
$satellite_names[$s_server['id_server']] = $s_server['name']; $tableBasicAgent->data = [];
$disabledBasic = false;
$tableClassDisabled = '';
if ($new_agent === true || $remote_agent === false || $has_remote_conf === false) {
$disabledBasic = true;
$tableClassDisabled = ' basic-options-disabled';
}
if (enterprise_installed()) {
// Get all plugins (BASIC OPTIONS).
$agent_plugin = new PandoraFMS\Agent($id_agente);
$plugins = $agent_plugin->getPlugins();
// Check if some plugin was enabled/disabled in conf.
foreach ($plugins as $key => $row) {
if (preg_match('/pandora_hardening/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$security_hardening = 0;
} else {
$security_hardening = 1;
}
} }
$table_satellite = '<div class="label_select"><p class="input_label">'.__('Satellite').'</p>'; if ($id_os === '1' || $id_os === '8') {
$table_satellite .= '<div class="label_select_parent">'; if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$enable_log_collector = 0;
} else {
$enable_log_collector = 1;
}
}
$table_satellite .= html_print_input( if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$enable_inventory = 0;
} else {
$enable_inventory = 1;
}
}
} else {
if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) {
if ($row['disabled'] === 1) {
$enable_inventory = 0;
} else {
$enable_inventory = 1;
}
}
}
}
if ($id_os === '9') {
$modules = $agent_plugin->getModules();
foreach ($modules as $key => $row) {
if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$enable_log_collector = 0;
} else {
$enable_log_collector = 1;
}
}
}
}
unset($agent_plugin, $plugins);
if (($new_agent === true && $config['current_package'] >= 774) || ($agent_version >= 774 && $new_agent === false)) {
if ($disabledBasic === true || $has_remote_conf === false) {
$message = __('Remote config disabled, please activate to enable agent basic options');
$tableBasicAgent->data[] = '<span>'.$message.'</span>';
}
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable security hardening monitoring'),
html_print_input(
[ [
'type' => 'select', 'type' => 'switch',
'fields' => $satellite_names, 'id' => 'security_hardening',
'name' => 'satellite_server', 'name' => 'security_hardening',
'selected' => $satellite_server, 'value' => $security_hardening,
'nothing' => __('None'), 'disabled' => $disabledBasic,
'nothinf_value' => 0,
'return' => true,
] ]
).'<div class="label_select_child_icons"></div></div></div>'; ).html_print_input_hidden('options_package', '1', true)
);
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable log collection'),
html_print_input(
[
'type' => 'switch',
'id' => 'enable_log_collector',
'name' => 'enable_log_collector',
'value' => $enable_log_collector,
'disabled' => $disabledBasic,
]
)
);
} }
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable inventory'),
html_print_input(
[
'type' => 'switch',
'id' => 'enable_inventory',
'name' => 'enable_inventory',
'value' => $enable_inventory,
'disabled' => $disabledBasic,
]
).html_print_input_hidden('enable_basic_options', '1', true)
);
if ($config['ehorus_enabled'] === '1') {
$pandoraRC_Id = html_print_image(
'images/alert_recovered@svg.svg',
true,
[
'class' => 'invert_filter main_menu_icon',
'title' => __('Pandora RC connected with id ').$config['ehorus_custom_field'],
]
);
} else {
$pandoraRC_Id = html_print_image(
'images/alerts.svg',
true,
[
'class' => 'invert_filter main_menu_icon',
'title' => __('This agent do not have a Pandora RC agent installed, install one.'),
]
);
} }
*/
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable remote control'),
$pandoraRC_Id
);
$WarningPackage = '';
if (($new_agent === true && $config['current_package'] < 774) || ($agent_version < 774 && $new_agent === false)) {
$WarningPackage = html_print_image(
'images/alert-yellow@svg.svg',
true,
[
'title' => __('Only available for agents 774 or higher'),
'alt' => __('Only available for agents 774 or higher'),
'class' => 'main_menu_icon mrgn_lft_5px',
]
);
}
} else {
$tableBasicAgent->data[] = '<span>'.__('Remote config is enabled only in the Enteprise version').'</span>';
$tableBasicAgent->data[] .= html_print_input_hidden(
'enable_basic_options',
'0',
true
);
}
ui_toggle(
html_print_table($tableBasicAgent, true),
'<span class="subsection_header_title">'.__('Basic options').$WarningPackage.'</span>',
'',
'basic_options',
true,
false,
'white_box_content',
'no-border white_table_graph'.$tableClassDisabled,
'box-flat white_table_graph invisible'
);
// Advanced options. // Advanced options.
$tableAdvancedAgent = new stdClass(); $tableAdvancedAgent = new stdClass();
@ -1277,7 +1410,8 @@ ui_require_jquery_file('bgiframe');
}); });
$("#checkbox-cascade_protection").change(function () { $("#checkbox-cascade_protection").change(function () {
var checked = $("#checkbox-cascade_protection").is(":checked"); if (checked) { var checked = $("#checkbox-cascade_protection").is(":checked");
if (checked) {
$("#cascade_protection_module").removeAttr("disabled"); $("#cascade_protection_module").removeAttr("disabled");
$("#text-id_parent").attr("required", "required"); $("#text-id_parent").attr("required", "required");
} }
@ -1332,5 +1466,17 @@ ui_require_jquery_file('bgiframe');
} }
}); });
check_basic_options();
$('#id_os').on('change', function(){
check_basic_options();
})
}); });
function check_basic_options(){
if ($('#id_os').val() == 1 || $('#id_os').val() == 8 || $('#id_os').val() == 9) {
$('#basic_options').removeClass('invisible');
} else {
$('#basic_options').addClass('invisible');
}
}
</script> </script>

View File

@ -232,7 +232,7 @@ if ($create_agent) {
$cps = (int) get_parameter_switch('cps', -1); $cps = (int) get_parameter_switch('cps', -1);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0); $fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2); $vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
$agent_version = $config['current_package'];
$secondary_groups = (array) get_parameter('secondary_groups_selected', ''); $secondary_groups = (array) get_parameter('secondary_groups_selected', '');
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
@ -300,6 +300,7 @@ if ($create_agent) {
'cps' => $cps, 'cps' => $cps,
'fixed_ip' => $fixed_ip, 'fixed_ip' => $fixed_ip,
'vul_scan_enabled' => $vul_scan_enabled, 'vul_scan_enabled' => $vul_scan_enabled,
'agent_version' => $agent_version,
] ]
); );
} else { } else {
@ -1015,6 +1016,13 @@ if ($update_agent) {
$satellite_server = (int) get_parameter('satellite_server', 0); $satellite_server = (int) get_parameter('satellite_server', 0);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0); $fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2); $vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
$security_vunerability = (int) get_parameter_switch('security_vunerability', 0);
$security_hardening = (int) get_parameter_switch('security_hardening', 0);
$security_monitoring = (int) get_parameter_switch('security_monitoring', 0);
$enable_log_collector = (int) get_parameter_switch('enable_log_collector', 0);
$enable_inventory = (int) get_parameter_switch('enable_inventory', 0);
$enable_basic_options = get_parameter('enable_basic_options');
$options_package = get_parameter('options_package', '0');
if ($fields === false) { if ($fields === false) {
$fields = []; $fields = [];
@ -1243,6 +1251,81 @@ if ($update_agent) {
); );
} }
} }
if ($enable_basic_options === '1') {
// Get all plugins (BASIC OPTIONS).
$agent = new PandoraFMS\Agent($id_agente);
$plugins = $agent->getPlugins();
foreach ($plugins as $key => $row) {
// Only check plugins when agent package is bigger than 774.
if ($options_package === '1') {
if (preg_match('/pandora_hardening/', $row['raw']) === 1) {
if ($security_hardening === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) {
if ($enable_log_collector === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
}
// Inventory switch enable when basic options are enabled.
if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) {
if ($enable_inventory === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
// Inventory switch enable when basic options are enabled.
if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) {
if ($enable_inventory === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
}
$modules = $agent->getModules();
foreach ($modules as $key => $row) {
if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) {
if ($enable_log_collector === 1) {
if ($row['disabled'] === 1) {
$agent->enableModule($row['module_name'], $row);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disableModule($row['module_name'], $row);
}
}
}
}
}
} }
// Read agent data // Read agent data
@ -1300,6 +1383,19 @@ if ($id_agente) {
$satellite_server = (int) $agent['satellite_server']; $satellite_server = (int) $agent['satellite_server'];
$fixed_ip = (int) $agent['fixed_ip']; $fixed_ip = (int) $agent['fixed_ip'];
$vul_scan_enabled = (int) $agent['vul_scan_enabled']; $vul_scan_enabled = (int) $agent['vul_scan_enabled'];
if (strpos($agent['agent_version'], '(')) {
$agent_version = (int) explode('.', explode('(', $agent['agent_version'])[0])[2];
} else {
if (strpos($agent['agent_version'], 'build') || strpos($agent['agent_version'], 'Build')) {
$agent_version = (int) explode('.', explode('build', $agent['agent_version'])[0])[2];
} else {
if (strpos($agent['agent_version'], '.')) {
$agent_version = (int) explode('.', $agent['agent_version'])[2];
} else {
$agent_version = $agent['agent_version'];
}
}
}
} }
$update_module = (bool) get_parameter('update_module'); $update_module = (bool) get_parameter('update_module');

View File

@ -566,10 +566,10 @@ if ($search != '') {
if ($id != '') { if ($id != '') {
$aux = $id[0]['id_agent']; $aux = $id[0]['id_agent'];
$search_sql = sprintf( $search_sql = sprintf(
' AND ( nombre LIKE "%%%s%%" ' AND ( REPLACE(nombre, "&#x20;", " ") LIKE "%%%s%%"
OR alias LIKE "%%%s%%" OR REPLACE(alias, "&#x20;", " ") LIKE "%%%s%%"
OR comentarios LIKE "%%%s%%" OR REPLACE(comentarios, "&#x20;", " ") LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%") OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND REPLACE(description, "&#x20;", " ") LIKE "%%%s%%")
OR tagente.id_agente = %d', OR tagente.id_agente = %d',
$search, $search,
$search, $search,
@ -591,10 +591,10 @@ if ($search != '') {
$search_sql .= ')'; $search_sql .= ')';
} else { } else {
$search_sql = sprintf( $search_sql = sprintf(
' AND ( nombre ' AND ( REPLACE(nombre, "&#x20;", " ")
LIKE "%%%s%%" OR alias LIKE "%%%s%%" OR REPLACE(alias, "&#x20;", " ")
LIKE "%%%s%%" OR comentarios LIKE "%%%s%%" LIKE "%%%s%%" OR REPLACE(comentarios, "&#x20;", " ") LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%"))', OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND REPLACE(description, "&#x20;", " ") LIKE "%%%s%%"))',
$search, $search,
$search, $search,
$search, $search,

View File

@ -38,6 +38,7 @@ $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_servers.php'; require_once $config['homedir'].'/include/functions_servers.php';
require_once $config['homedir'].'/include/functions_macros.php';
$search_string = get_parameter('search_string'); $search_string = get_parameter('search_string');
@ -574,7 +575,7 @@ $where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
$search_string_entities = io_safe_input($search_string); $search_string_entities = io_safe_input($search_string);
$basic_where = sprintf( $basic_where = sprintf(
"(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND", "(REPLACE(nombre, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(nombre, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, '&#x20;', ' ') LIKE '%%%s%%') AND",
$search_string, $search_string,
$search_string_entities, $search_string_entities,
$search_string, $search_string,
@ -949,7 +950,23 @@ if ($modules !== false) {
); );
if (strlen($module['ip_target']) !== 0) { if (strlen($module['ip_target']) !== 0) {
$title .= '<br/>IP: '.$module['ip_target']; // Check if value is custom field.
if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') {
$custom_field_name = substr($module['ip_target'], 1, -1);
$custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name);
if (isset($custom_value) && $custom_value !== false) {
$title .= '<br/>IP: '.$custom_value;
} else {
$array_macros = return_agent_macros($id_agente);
if (isset($array_macros[$module['ip_target']])) {
$title .= '<br/>IP: '.$array_macros[$module['ip_target']];
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
}
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
} }
// This module is initialized ? (has real data). // This module is initialized ? (has real data).

View File

@ -171,7 +171,7 @@ foreach ($password_fields as $k => $p) {
} }
$(document).ready(function () { $(document).ready(function () {
if ($("#id_plugin").val() === 0) { if ($("#id_plugin").val() !== 0) {
changePluginSelect(); changePluginSelect();
} }
}); });

View File

@ -256,7 +256,7 @@ $schedule = io_safe_output(
$data[0] = ''; $data[0] = '';
$data[0] .= html_print_input_hidden('schedule', $schedule, true); $data[0] .= html_print_input_hidden('schedule', $schedule, true);
$data[0] .= '<div id="calendar_map"></div>'; $data[0] .= '<div id="calendar_map" class="alert_view_calendar"></div>';
$data[1] = ''; $data[1] = '';
$table_conditions->data[] = $data; $table_conditions->data[] = $data;

View File

@ -115,6 +115,7 @@ $fields_available['module_status'] = __('Module Status');
$fields_available['mini_severity'] = __('Severity mini'); $fields_available['mini_severity'] = __('Severity mini');
$fields_available['module_custom_id'] = __('Module custom ID'); $fields_available['module_custom_id'] = __('Module custom ID');
$fields_available['custom_data'] = __('Custom data'); $fields_available['custom_data'] = __('Custom data');
$fields_available['event_custom_id'] = __('Event Custom ID');
// Remove fields already selected. // Remove fields already selected.

View File

@ -243,10 +243,15 @@ switch ($action) {
$map_default_altitude = get_parameter('map_default_altitude'); $map_default_altitude = get_parameter('map_default_altitude');
$map_group_id = get_parameter('map_group_id'); $map_group_id = get_parameter('map_group_id');
$map_levels_zoom = get_parameter('map_levels_zoom', 16); $map_levels_zoom = get_parameter('map_levels_zoom', 16);
$map_connection_list_temp = explode(',', get_parameter('map_connection_list')); $map_connection_list_temp = explode(',', get_parameter('map_connection_list'));
$map_connection_list_temp_string = implode(',', $map_connection_list_temp);
if (strlen($map_connection_list_temp_string) > 0) {
$where_map_connection = ' WHERE id_tmap_connection IN('.$map_connection_list_temp_string.')';
} else {
$where_map_connection = '';
}
$listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'); $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'.$where_map_connection);
foreach ($map_connection_list_temp as $index => $value) { foreach ($map_connection_list_temp as $index => $value) {
$cleanValue = trim($value); $cleanValue = trim($value);
@ -256,7 +261,6 @@ switch ($action) {
} }
$map_connection_default = get_parameter('map_connection_default'); $map_connection_default = get_parameter('map_connection_default');
$map_connection_list = []; $map_connection_list = [];
foreach ($listConnectionTemp as $idMapConnection) { foreach ($listConnectionTemp as $idMapConnection) {
$default = 0; $default = 0;
@ -485,7 +489,7 @@ foreach ($listConnectionTemp as $connectionTemp) {
$table->data[1][0] = __('Add Map connection').$iconError; $table->data[1][0] = __('Add Map connection').$iconError;
$table->data[1][1] = "<table class='no-class' border='0' id='map_connection'> $table->data[1][1] = "<table class='no-class' border='0' id='map_connection'>
<tr> <tr>
<td>".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)." <td>".html_print_select($listConnection, 'select-map_connection_list', '', '', '', '0', true)."
</td> </td>
<td > <td >
<a href='javascript: addConnectionMap();'>".html_print_image( <a href='javascript: addConnectionMap();'>".html_print_image(

View File

@ -111,7 +111,8 @@ if ($delete) {
$alerts_agent_modules = []; $alerts_agent_modules = [];
foreach ($agent_alerts['simple'] as $agent_alert) { foreach ($agent_alerts['simple'] as $agent_alert) {
if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) { if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) {
$alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); // $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id'));
$alerts_agent_modules[] = $agent_alert['id'];
} }
} }
@ -126,7 +127,7 @@ if ($delete) {
$agent_module_actions = []; $agent_module_actions = [];
foreach ($alerts_agent_modules as $alert_agent_module) { foreach ($alerts_agent_modules as $alert_agent_module) {
$agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module['id'], ['id', 'id_alert_action']); $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module, ['id', 'id_alert_action']);
foreach ($agent_module_actions as $agent_module_action) { foreach ($agent_module_actions as $agent_module_action) {
foreach ($actions as $action) { foreach ($actions as $action) {

View File

@ -478,8 +478,8 @@ if ($access_console_node === true) {
} }
} }
$sub2['godmode/setup/setup&section=ehorus']['text'] = __('Pandora RC'); $sub2['godmode/setup/setup&section=pandorarc']['text'] = __('Pandora RC');
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; $sub2['godmode/setup/setup&section=pandorarc']['refr'] = 0;
$sub2['godmode/setup/setup&section=ITSM']['text'] = __('ITSM'); $sub2['godmode/setup/setup&section=ITSM']['text'] = __('ITSM');
$sub2['godmode/setup/setup&section=ITSM']['refr'] = 0; $sub2['godmode/setup/setup&section=ITSM']['refr'] = 0;
@ -575,12 +575,13 @@ if ($access_console_node === true) {
continue; continue;
} }
$extmenu = [];
if ($extension['godmode_menu']['name'] !== __('DB Schema check') && $extension['godmode_menu']['name'] !== __('DB interface')) { if ($extension['godmode_menu']['name'] !== __('DB Schema check') && $extension['godmode_menu']['name'] !== __('DB interface')) {
$extmenu = $extension['godmode_menu']; $extmenu = $extension['godmode_menu'];
} }
// Check the ACL for this user. // Check the ACL for this user.
if ((bool) check_acl($config['id_user'], 0, $extmenu['acl']) === false) { if ((bool) check_acl($config['id_user'], 0, ($extmenu['acl'] ?? '')) === false) {
continue; continue;
} }
@ -732,7 +733,7 @@ if ((bool) $config['pure'] === false) {
echo '<div id="about-div"></div>'; echo '<div id="about-div"></div>';
// Need to be here because the translate string. // Need to be here because the translate string.
if (check_acl($config['id_user'], $group, 'AW')) { if (check_acl($config['id_user'], 0, 'AW')) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$("#conf_wizard").click(function() { $("#conf_wizard").click(function() {

View File

@ -729,7 +729,7 @@ if ($search_id_group) {
} }
if ($search_string != '') { if ($search_string != '') {
$filter[] = '(name LIKE '."'%".$search_string."%'".'OR description LIKE '."'%".$search_string."%'".'OR tcp_send LIKE '."'%".$search_string."%'".'OR tcp_rcv LIKE '."'%".$search_string."%'".')'; $filter[] = '(REPLACE(name, "&#x20;", " ") LIKE '."'%".$search_string."%'".' OR REPLACE(REPLACE(description, "&#x20;", " "), "&#x20", " ")LIKE '."'%".$search_string."%'".' OR REPLACE(tcp_send, "&#x20;", " ") LIKE '."'%".$search_string."%'".'OR REPLACE(tcp_rcv, "&#x20;", " ") LIKE '."'%".$search_string."%'".')';
} }
$total_components = network_components_get_network_components( $total_components = network_components_get_network_components(

View File

@ -1642,7 +1642,7 @@ if (is_metaconsole() === true) {
10, 10,
false, false,
false, false,
true, false,
'', '',
false, false,
false, false,
@ -1676,7 +1676,7 @@ if (is_metaconsole() === true) {
10, 10,
false, false,
false, false,
true, false,
'', '',
false, false,
false, false,
@ -1730,7 +1730,7 @@ if (is_metaconsole() === true) {
10, 10,
false, false,
false, false,
true, false,
'', '',
false, false,
false, false,
@ -1755,7 +1755,7 @@ if (is_metaconsole() === true) {
<td > <td >
<?php <?php
html_print_extended_select_for_time( html_print_extended_select_for_time(
'period', 'period3',
(string) $period, (string) $period,
'onselect=loadLogAgents();', 'onselect=loadLogAgents();',
'', '',
@ -1793,7 +1793,7 @@ if (is_metaconsole() === true) {
10, 10,
false, false,
false, false,
true, false,
'', '',
false, false,
false, false,
@ -7030,7 +7030,7 @@ function loadLogAgents() {
params["get_agent_source"] = 1; params["get_agent_source"] = 1;
params["log_alert"] = 1; params["log_alert"] = 1;
params["page"] = "enterprise/include/ajax/log_viewer.ajax"; params["page"] = "enterprise/include/ajax/log_viewer.ajax";
params["date"] = $('#period_select').val(); params["date"] = $('#period3_select').val();
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
dataType: "json", dataType: "json",

View File

@ -1643,7 +1643,7 @@ switch ($action) {
$es['log_number'] = $log_number; $es['log_number'] = $log_number;
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period3');
$good_format = true; $good_format = true;
break; break;
@ -1661,7 +1661,7 @@ switch ($action) {
$es['log_number'] = $log_number; $es['log_number'] = $log_number;
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period3');
$values['period_range'] = get_parameter('period_range'); $values['period_range'] = get_parameter('period_range');
$values['show_graph'] = get_parameter('combo_graph_options'); $values['show_graph'] = get_parameter('combo_graph_options');
$values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent');
@ -2755,7 +2755,7 @@ switch ($action) {
$es['log_number'] = $log_number; $es['log_number'] = $log_number;
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period3');
$good_format = true; $good_format = true;
break; break;
@ -2773,7 +2773,7 @@ switch ($action) {
$es['log_number'] = $log_number; $es['log_number'] = $log_number;
$values['external_source'] = json_encode($es); $values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period3');
$values['period_range'] = get_parameter('period_range'); $values['period_range'] = get_parameter('period_range');
$values['show_graph'] = get_parameter('combo_graph_options'); $values['show_graph'] = get_parameter('combo_graph_options');
$values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent');

View File

@ -539,6 +539,7 @@ foreach ($layoutDatas as $layoutData) {
$table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true); $table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true);
$table->data[($i + 1)][5] .= '<a href="'.$url_delete.'"onclick="javascript: if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>'; $table->data[($i + 1)][5] .= '<a href="'.$url_delete.'"onclick="javascript: if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>';
$table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true); $table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true);
$table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true);
// Second row // Second row
$table->data[($i + 2)]['icon'] = ''; $table->data[($i + 2)]['icon'] = '';
@ -789,14 +790,6 @@ if ($x > ini_get('max_input_vars')) {
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
if (is_metaconsole() === false) {
echo '<form id="vc_elem_form" method="post" action="index.php?sec=network&sec2=godmode/reporting/visual_console_builder&tab='.$activeTab.'&id_visual_console='.$visualConsole['id'].'">';
html_print_input_hidden('action', 'update');
} else {
echo "<form id='vc_elem_form' method='post' action='index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap&pure=0&tab=list_elements&id_visual_console=".$idVisualConsole."'>";
html_print_input_hidden('action2', 'update');
}
html_print_table($table); html_print_table($table);
// Form for multiple delete. // Form for multiple delete.
@ -806,15 +799,14 @@ if (is_metaconsole() === false) {
$url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id']; $url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id'];
} }
echo '</form>';
$buttons = html_print_submit_button( $buttons = html_print_submit_button(
__('Update'), __('Update'),
'go', 'go',
false, false,
[ [
'icon' => 'next', 'icon' => 'next',
'form' => 'vc_elem_form', 'form' => 'vc_elem_form',
'onclick' => 'submit_update_json()',
], ],
true true
); );
@ -976,4 +968,76 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/');
return false; return false;
} }
function submit_update_json() {
var array_update = [];
$('input[id^=hidden-updated_]').each(function(){
var id = $(this).attr('id').split('_')[1];
var label = $('#hidden-label_'+id).val();
var image = $('#image_'+id).val();
var width = $('#text-width_'+id).val();
var height = $('#text-height_'+id).val();
var pos_x = $('#text-left_'+id).val();
var pos_y = $('#text-top_'+id).val();
var parent = $('#parent_'+id).val();
var agent = $('#hidden-agent_'+id).val();
var module = $('#module_'+id).val();
var period = $('#hidden-period_'+id).val();
var map_linked = $('#map_linked_'+id).val();
var id_server = $('#id_server_id_'+id).val();
var rowtype = $('rowtype_'+id).val();
var custom_graph = $('#custom_graph_'+id).val();
array_update.push({
'id': id,
'label': label,
'image': image,
'width': width,
'height': height,
'pos_x': pos_x,
'pos_y': pos_y,
'parent': parent,
'agent': agent,
'module': module,
'period': period,
'map_linked': map_linked,
'rowtype': rowtype,
'custom_graph': custom_graph,
'id_server': id_server,
});
});
var background_width = $('#text-width').val();
var background_height = $('#text-height').val();
if (background_height > 0 && background_width > 0){
$.ajax({
type: "POST",
url: "ajax.php",
data: {
page: "godmode/reporting/visual_console_builder",
action: "update_json",
tab: "list_elements",
array_update: JSON.stringify(array_update),
id_visual_console: "<?php echo (is_metaconsole() === true) ? $idVisualConsole : $visualConsole['id']; ?>",
background: $('#background').val(),
background_width: $('#text-width').val(),
background_height: $('#text-height').val(),
},
dataType: "json",
complete: function (data) {
location.reload();
}
});
} else {
confirmDialog({
title: "<?php echo __('Error.'); ?>",
message: "<?php echo __('The width and height property is required and should greater than 0'); ?>",
strOKButton: "<?php echo __('Close'); ?>",
hideCancelButton: true,
size: 300,
});
}
}
</script> </script>

View File

@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues(
'update', 'update',
'delete', 'delete',
'multiple_delete', 'multiple_delete',
'update_json',
], ],
'new' 'new'
); );
@ -163,7 +164,10 @@ switch ($activeTab) {
$background_color = (string) get_parameter('background_color'); $background_color = (string) get_parameter('background_color');
$width = (int) get_parameter('width'); $width = (int) get_parameter('width');
$height = (int) get_parameter('height'); $height = (int) get_parameter('height');
$visualConsoleName = (string) io_safe_input(get_parameter('name')); $visualConsoleName = (string) get_parameter('name');
$visualConsoleName = str_replace('&lt;', '', $visualConsoleName);
$visualConsoleName = str_replace('&gt;', '', $visualConsoleName);
$visualConsoleName = (string) io_safe_input($visualConsoleName);
$is_favourite = (int) get_parameter('is_favourite_sent'); $is_favourite = (int) get_parameter('is_favourite_sent');
$auto_adjust = (int) get_parameter('auto_adjust_sent'); $auto_adjust = (int) get_parameter('auto_adjust_sent');
@ -523,6 +527,110 @@ switch ($activeTab) {
} }
break; break;
case 'update_json':
// Update background.
$background = get_parameter('background');
$width = get_parameter('background_width');
$height = get_parameter('background_height');
if ($width == 0 && $height == 0) {
$sizeBackground = getimagesize(
$config['homedir'].'/images/console/background/'.$background
);
$width = $sizeBackground[0];
$height = $sizeBackground[1];
}
db_process_sql_update(
'tlayout',
[
'background' => $background,
'width' => $width,
'height' => $height,
],
['id' => $idVisualConsole]
);
// Return the updated visual console.
$visualConsole = db_get_row_filter(
'tlayout',
['id' => $idVisualConsole]
);
// Update elements in visual map.
$idsElements = db_get_all_rows_filter(
'tlayout_data',
['id_layout' => $idVisualConsole],
[
'id',
'type',
]
);
$array_update = json_decode(io_safe_output(get_parameter('array_update')), true);
if (count($array_update)) {
foreach ($array_update as $row) {
$id = $row['id'];
$values = [];
$values['label'] = $row['label'];
$values['image'] = $row['image'];
$values['width'] = $row['width'];
$values['height'] = $row['height'];
$values['pos_x'] = $row['pos_x'];
$values['pos_y'] = $row['pos_y'];
switch ($row['rowtype']) {
case NETWORK_LINK:
case LINE_ITEM:
continue 2;
break;
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$values['period'] = $row['period'];
break;
case MODULE_GRAPH:
$values['period'] = $row['period'];
unset($values['image']);
break;
case GROUP_ITEM:
$values['id_group'] = $row['group'];
break;
case CIRCULAR_PROGRESS_BAR:
case CIRCULAR_INTERIOR_PROGRESS_BAR:
case PERCENTILE_BUBBLE:
case PERCENTILE_BAR:
unset($values['height']);
break;
}
if (defined('METACONSOLE')) {
$values['id_metaconsole'] = $row['id_server'];
}
$values['id_agent'] = $row['agent'];
$values['id_agente_modulo'] = $row['module'];
$values['id_custom_graph'] = $row['custom_graph'];
$values['parent_item'] = $row['parent'];
$values['id_layout_linked'] = $row['map_linked'];
if (enterprise_installed()) {
enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id);
}
db_process_sql_update('tlayout_data', $values, ['id' => $id]);
}
return true;
}
break;
case 'delete': case 'delete':
$id_element = get_parameter('id_element'); $id_element = get_parameter('id_element');
$result = db_process_sql_delete('tlayout_data', ['id' => $id_element]); $result = db_process_sql_delete('tlayout_data', ['id' => $id_element]);

View File

@ -184,7 +184,7 @@ $buttons['ITSM'] = [
$buttons['ehorus'] = [ $buttons['ehorus'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ehorus').'">'.html_print_image( 'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=pandorarc').'">'.html_print_image(
'images/RC.png', 'images/RC.png',
true, true,
[ [
@ -297,7 +297,7 @@ switch ($section) {
$help_header = 'setup_flow_tab'; $help_header = 'setup_flow_tab';
break; break;
case 'ehorus': case 'pandorarc':
$buttons['ehorus']['active'] = true; $buttons['ehorus']['active'] = true;
$subpage = __('Pandora RC'); $subpage = __('Pandora RC');
$help_header = 'setup_ehorus_tab'; $help_header = 'setup_ehorus_tab';
@ -442,7 +442,7 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_visuals.php'; include_once $config['homedir'].'/godmode/setup/setup_visuals.php';
break; break;
case 'ehorus': case 'pandorarc':
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
break; break;

View File

@ -187,7 +187,8 @@ $button_test .= '&nbsp;<span id="ITSM-message" class="invisible"></span>';
$row['control'] = html_print_label_input_block( $row['control'] = html_print_label_input_block(
__('Test connection pandora to ITSM'), __('Test connection pandora to ITSM'),
$button_test $button_test,
['div_class' => 'ITSM-remote-setup-ITSM_token']
); );
$table_remote->data['ITSM_test'] = $row; $table_remote->data['ITSM_test'] = $row;

View File

@ -405,19 +405,6 @@ $table->data[$i++][] = html_print_label_input_block(
$table->data[$i][] = html_print_label_input_block( $table->data[$i][] = html_print_label_input_block(
__('Enable Sflow'),
html_print_checkbox_switch_extended(
'activate_sflow',
1,
$config['activate_sflow'],
$rbt_disabled,
'',
'',
true
),
);
$table->data[$i++][] = html_print_label_input_block(
__('General network path'), __('General network path'),
html_print_input_text( html_print_input_text(
'general_network_path', 'general_network_path',
@ -733,7 +720,7 @@ $table->data[$i++][] = html_print_label_input_block(
); );
$help_tip = ui_print_help_tip( $help_tip = ui_print_help_tip(
__('If there are any &#x22;In process&#x22; events with a specific Extra ID and a New event with that Extra ID is received, it will be created as &#x22;In process&#x22; instead.'), __('If there are any &#x22;In process&#x22; events with a specific Extra ID and a New event with that Extra ID is received, it will be created as &#x22;In process&#x22; instead. The new events also inherit Event Custom ID'),
true true
); );
@ -1126,9 +1113,9 @@ $(document).ready (function () {
id_imodule = $(value).attr('value'); id_imodule = $(value).attr('value');
$("select[name='inventory_changes_blacklist[]']") $("select[name='inventory_changes_blacklist[]']")
.append( .append(
$("<option></option>") $("<option selected='selected'></option>")
.val(id_imodule) .val(id_imodule)
.html('<i>' + imodule_name + '</i>') .text(imodule_name)
); );
$("#inventory_changes_blacklist_out") $("#inventory_changes_blacklist_out")
.find("option[value='" + id_imodule + "']").remove(); .find("option[value='" + id_imodule + "']").remove();
@ -1154,7 +1141,7 @@ $(document).ready (function () {
.append( .append(
$("<option></option>") $("<option></option>")
.val(id_imodule) .val(id_imodule)
.html('<i>' + imodule_name + '</i>') .text(imodule_name)
); );
$("#inventory_changes_blacklist") $("#inventory_changes_blacklist")
.find("option[value='" + id_imodule + "']").remove(); .find("option[value='" + id_imodule + "']").remove();
@ -1170,12 +1157,15 @@ $(document).ready (function () {
} }
} }
}); });
$("#inventory_changes_blacklist > option").each(function(key, value) {
$(value).prop('selected',true).trigger('change');
});
}); });
$("#submit-update_button").click(function () { $("#inventory_changes_blacklist > option").each(function(key, value) {
$('#inventory_changes_blacklist option').map(function(){ $(value).prop('selected',true).trigger('change');
$(this).prop('selected', true);
});
}); });
}); });
</script> </script>

View File

@ -83,6 +83,19 @@ $table->data[3][] = html_print_label_input_block(
html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true)
); );
$table->data[4][] = html_print_label_input_block(
__('Enable Sflow'),
html_print_checkbox_switch_extended(
'activate_sflow',
1,
$config['activate_sflow'],
$rbt_disabled,
'',
'',
true
),
);
echo '<form class="max_floating_element_size" id="netflow_setup" method="post">'; echo '<form class="max_floating_element_size" id="netflow_setup" method="post">';
html_print_table($table); html_print_table($table);
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);

View File

@ -61,7 +61,7 @@ $license = db_get_value(
); );
if (isset($config['lts_updates']) === false) { if (isset($config['lts_updates']) === false) {
$config['lts_updates'] = false; $config['lts_updates'] = true;
} }
if (empty($license) === true) { if (empty($license) === true) {

View File

@ -0,0 +1,111 @@
<?php
/**
* Modal LTS versions update manager.
*
* @category Update Manager
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ 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;
check_login();
// The ajax is in include/ajax/update_manager.php.
if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Setup Management'
);
include 'general/noaccess.php';
return;
}
require_once $config['homedir'].'/vendor/autoload.php';
$php_version = phpversion();
$php_version_array = explode('.', $php_version);
if ($php_version_array[0] < 7) {
include_once 'general/php_message.php';
}
?>
<!-- Lts Updates. -->
<div id="lts-updates" title="
<?php echo __('LTS versions'); ?>
" class="invisible">
<div style="display: flex; justify-content: space-between">
<div style="width: 250px; padding: 36px">
<?php
echo html_print_image(
'images/info-warning.svg',
true,
[ 'style' => 'padding-top: 30px' ]
);
?>
</div>
<div style="padding: 5px 90px 5px 5px;">
<p class="lato font_10pt bolder">
<?php
echo __('There are two types of versions in Pandora FMS: the LTS versions (Long-Term Support), e.g: 772 LTS, and the RRR (Regular Rolling Release) versions, e.g: 771, 773, 774, 775.');
?>
</p>
<p class="lato font_10pt bolder">
<?php
echo __('LTS versions have frequent, periodic updates (fixes), correcting both security problems and critical bugs detected in the tool. These are the versions we recommend to use in production environments.');
?>
</p>
<p class="lato font_10pt bolder">
<?php
echo __('RRR versions incorporate new features in each version, as well as bug fixes, but due to their dynamic nature, errors are more likely.');
?>
</p>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
// Lts Updates.
$("#lts-updates").dialog({
resizable: true,
draggable: true,
modal: true,
width: 740,
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: true,
buttons: [{
text: "OK",
click: function() {
$(this).dialog("close");
}
}],
open: function(event, ui) {
$(".ui-dialog-titlebar-close").hide();
}
});
});
</script>

View File

@ -119,11 +119,13 @@ switch ($tab) {
case 'setup': case 'setup':
include $config['homedir'].'/godmode/update_manager/update_manager.setup.php'; include $config['homedir'].'/godmode/update_manager/update_manager.setup.php';
include $config['homedir'].'/godmode/update_manager/modal_lts_update.php';
break; break;
case 'offline': case 'offline':
$mode = \UpdateManager\UI\Manager::MODE_OFFLINE; $mode = \UpdateManager\UI\Manager::MODE_OFFLINE;
include $config['homedir'].'/godmode/um_client/index.php'; include $config['homedir'].'/godmode/um_client/index.php';
include $config['homedir'].'/godmode/update_manager/modal_lts_update.php';
break; break;
case 'online': case 'online':
@ -163,5 +165,6 @@ switch ($tab) {
$mode = \UpdateManager\UI\Manager::MODE_ONLINE; $mode = \UpdateManager\UI\Manager::MODE_ONLINE;
include $config['homedir'].'/godmode/um_client/index.php'; include $config['homedir'].'/godmode/um_client/index.php';
include $config['homedir'].'/godmode/update_manager/modal_lts_update.php';
break; break;
} }

View File

@ -63,6 +63,10 @@ if (users_is_admin()) {
} }
} }
if (isset($config['lts_updates']) === false) {
config_update_value('lts_updates', 1);
}
if (!$action_update_url_update_manager) { if (!$action_update_url_update_manager) {
$url_update_manager = get_parameter( $url_update_manager = get_parameter(
'url_update_manager', 'url_update_manager',

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icons/Dark/20/desacoplar-ventana</title>
<g id="Icons/Dark/20/desacoplar-ventana" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Back" transform="translate(3, 1)">
<rect id="Rectangle-2" stroke="#3F3F3F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" x="0" y="0" width="20" height="16" rx="1"></rect>
<path d="M3,4 C3.55228475,4 4,3.55228475 4,3 C4,2.44771525 3.55228475,2 3,2 C2.44771525,2 2,2.44771525 2,3 C2,3.55228475 2.44771525,4 3,4 Z M6,4 C6.55228475,4 7,3.55228475 7,3 C7,2.44771525 6.55228475,2 6,2 C5.44771525,2 5,2.44771525 5,3 C5,3.55228475 5.44771525,4 6,4 Z M9,4 C9.55228475,4 10,3.55228475 10,3 C10,2.44771525 9.55228475,2 9,2 C8.44771525,2 8,2.44771525 8,3 C8,3.55228475 8.44771525,4 9,4 Z" id="Oval-2" fill="#3F3F3F"></path>
</g>
<g id="Front" transform="translate(0, 8)">
<rect id="Rectangle-2" fill="#3F3F3F" x="0" y="0" width="20" height="16" rx="1"></rect>
<path d="M3,4 C3.55228475,4 4,3.55228475 4,3 C4,2.44771525 3.55228475,2 3,2 C2.44771525,2 2,2.44771525 2,3 C2,3.55228475 2.44771525,4 3,4 Z M6,4 C6.55228475,4 7,3.55228475 7,3 C7,2.44771525 6.55228475,2 6,2 C5.44771525,2 5,2.44771525 5,3 C5,3.55228475 5.44771525,4 6,4 Z M9,4 C9.55228475,4 10,3.55228475 10,3 C10,2.44771525 9.55228475,2 9,2 C8.44771525,2 8,2.44771525 8,3 C8,3.55228475 8.44771525,4 9,4 Z" id="Oval-2" fill="#FFFFFF"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icons/Dark/20/minimizar</title>
<g id="Icons/Dark/20/minimizar" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Rectangle" fill="#3F3F3F" x="2" y="18" width="20" height="4" rx="2"></rect>
</g>
</svg>

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -435,6 +435,7 @@ if ($get_agent_alerts_datatable === true) {
} }
$idGroup = $filter_alert['ag_group']; $idGroup = $filter_alert['ag_group'];
$search_sg = $filter_alert['search_sg'];
$tag_filter = $filter_alert['tag']; $tag_filter = $filter_alert['tag'];
$action_filter = $filter_alert['action']; $action_filter = $filter_alert['action'];
@ -651,31 +652,30 @@ if ($get_agent_alerts_datatable === true) {
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php'; include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
if ($idAgent !== 0) { if ($idAgent !== 0) {
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); $alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); $countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter);
} else { } else {
$id_groups = array_keys( $id_groups = array_keys(
users_get_groups($config['id_user'], 'AR', false) users_get_groups($config['id_user'], 'AR', false)
); );
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter, $search_sg);
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter, $search_sg);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
} }
} else { } else {
if ($idAgent !== 0) { if ($idAgent !== 0) {
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); $alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter);
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); $countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter);
} else { } else {
$id_groups = array_keys( $id_groups = array_keys(
users_get_groups($config['id_user'], $access, false) users_get_groups($config['id_user'], $access, false)
); );
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false); $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter, false, $search_sg);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false); $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter, false, $search_sg);
} }
} }

View File

@ -92,6 +92,7 @@ $get_id_source_event = get_parameter('get_id_source_event');
$node_id = (int) get_parameter('node_id', 0); $node_id = (int) get_parameter('node_id', 0);
$settings_modal = get_parameter('settings', 0); $settings_modal = get_parameter('settings', 0);
$parameters_modal = get_parameter('parameters', 0); $parameters_modal = get_parameter('parameters', 0);
$update_event_custom_id = get_parameter('update_event_custom_id', 0);
$draw_events_graph = get_parameter('drawEventsGraph', false); $draw_events_graph = get_parameter('drawEventsGraph', false);
// User private filter. // User private filter.
@ -313,6 +314,7 @@ if ($save_event_filter) {
$values['severity'] = implode(',', get_parameter('severity', -1)); $values['severity'] = implode(',', get_parameter('severity', -1));
$values['status'] = get_parameter('status'); $values['status'] = get_parameter('status');
$values['search'] = get_parameter('search'); $values['search'] = get_parameter('search');
$values['regex'] = get_parameter('regex');
$values['not_search'] = get_parameter('not_search'); $values['not_search'] = get_parameter('not_search');
$values['text_agent'] = get_parameter('text_agent'); $values['text_agent'] = get_parameter('text_agent');
$values['id_agent'] = get_parameter('id_agent'); $values['id_agent'] = get_parameter('id_agent');
@ -381,6 +383,7 @@ if ($update_event_filter) {
$values['severity'] = implode(',', get_parameter('severity', -1)); $values['severity'] = implode(',', get_parameter('severity', -1));
$values['status'] = get_parameter('status'); $values['status'] = get_parameter('status');
$values['search'] = get_parameter('search'); $values['search'] = get_parameter('search');
$values['regex'] = get_parameter('regex');
$values['not_search'] = get_parameter('not_search'); $values['not_search'] = get_parameter('not_search');
$values['text_agent'] = get_parameter('text_agent'); $values['text_agent'] = get_parameter('text_agent');
$values['id_agent'] = get_parameter('id_agent'); $values['id_agent'] = get_parameter('id_agent');
@ -640,6 +643,8 @@ function load_form_filter() {
$("#status").val(val); $("#status").val(val);
if (i == 'search') if (i == 'search')
$('#text-search').val(val); $('#text-search').val(val);
if (i == 'regex')
$('#text-regex').val(val);
if (i == 'not_search') if (i == 'not_search')
$('#checkbox-not_search').val(val); $('#checkbox-not_search').val(val);
if (i == 'text_agent') if (i == 'text_agent')
@ -970,6 +975,7 @@ function save_new_filter() {
"severity" : $("#severity").val(), "severity" : $("#severity").val(),
"status" : $("#status").val(), "status" : $("#status").val(),
"search" : $("#text-search").val(), "search" : $("#text-search").val(),
"regex" : $('#text-regex').val(),
"not_search" : $("#checkbox-not_search").val(), "not_search" : $("#checkbox-not_search").val(),
"text_agent" : $("#text_id_agent").val(), "text_agent" : $("#text_id_agent").val(),
"id_agent" : $('input:hidden[name=id_agent]').val(), "id_agent" : $('input:hidden[name=id_agent]').val(),
@ -1050,6 +1056,7 @@ function save_update_filter() {
"severity" : $("#severity").val(), "severity" : $("#severity").val(),
"status" : $("#status").val(), "status" : $("#status").val(),
"search" : $("#text-search").val(), "search" : $("#text-search").val(),
"regex" : $('#text-regex').val(),
"not_search" : $("#checkbox-not_search").val(), "not_search" : $("#checkbox-not_search").val(),
"text_agent" : $("#text_id_agent").val(), "text_agent" : $("#text_id_agent").val(),
"id_agent" : $('input:hidden[name=id_agent]').val(), "id_agent" : $('input:hidden[name=id_agent]').val(),
@ -2644,6 +2651,8 @@ if ($get_events_fired) {
$filter['date_to'] = date('Y-m-d', $end); $filter['date_to'] = date('Y-m-d', $end);
$filter['time_from'] = date('H:i:s', $start); $filter['time_from'] = date('H:i:s', $start);
$filter['time_to'] = date('H:i:s', $end); $filter['time_to'] = date('H:i:s', $end);
$filter['severity'] = explode(',', $filter['severity']);
$data = events_get_all( $data = events_get_all(
['te.*'], ['te.*'],
$filter $filter
@ -2754,6 +2763,52 @@ if ($draw_row_response_info === true) {
return; return;
} }
if ($update_event_custom_id) {
$event_custom_id = get_parameter('event_custom_id');
$event_id = get_parameter('event_id');
$server_id = 0;
if (is_metaconsole() === true) {
$server_id = (int) get_parameter('server_id');
}
// Safe custom fields for hacks.
if (preg_match('/script/i', io_safe_output($event_custom_id))) {
$return = false;
} else {
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
$return = events_event_custom_id(
$event_id,
$event_custom_id
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
$return = false;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
}
echo ($return === true) ? 'update_ok' : 'update_error';
return;
}
if ((bool) $draw_events_graph === true) { if ((bool) $draw_events_graph === true) {
$filter = get_parameter('filter'); $filter = get_parameter('filter');
$output = event_print_graph($filter); $output = event_print_graph($filter);

View File

@ -35,6 +35,7 @@ if (check_login()) {
include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_agents.php';
include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_modules.php';
include_once $config['homedir'].'/include/functions_ui.php'; include_once $config['homedir'].'/include/functions_ui.php';
include_once $config['homedir'].'/include/functions_macros.php';
enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_metaconsole.php');
$get_plugin_macros = get_parameter('get_plugin_macros'); $get_plugin_macros = get_parameter('get_plugin_macros');
@ -755,6 +756,7 @@ if (check_login()) {
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
$id_agent = (int) get_parameter('id_agente'); $id_agent = (int) get_parameter('id_agente');
$id_agente = $id_agent; $id_agente = $id_agent;
$id_grupo = agents_get_agent_group($id_agent);
$show_notinit = (bool) get_parameter('show_notinit'); $show_notinit = (bool) get_parameter('show_notinit');
$cluster_list = (int) get_parameter('cluster_list'); $cluster_list = (int) get_parameter('cluster_list');
$sortField = (string) get_parameter('sort_field'); $sortField = (string) get_parameter('sort_field');
@ -1206,7 +1208,23 @@ if (check_login()) {
); );
if (strlen($module['ip_target']) !== 0) { if (strlen($module['ip_target']) !== 0) {
$title .= '<br/>IP: '.$module['ip_target']; // Check if value is custom field.
if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') {
$custom_field_name = substr($module['ip_target'], 1, -1);
$custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name);
if (isset($custom_value) && $custom_value !== false) {
$title .= '<br/>IP: '.$custom_value;
} else {
$array_macros = return_agent_macros($id_agente);
if (isset($array_macros[$module['ip_target']])) {
$title .= '<br/>IP: '.$array_macros[$module['ip_target']];
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
}
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
} }
$last_status_change_text = __('Time elapsed since last status change: '); $last_status_change_text = __('Time elapsed since last status change: ');

View File

@ -1,324 +0,0 @@
<?php
/**
* Generate charts with given parameters.
*
* @category ChartGenerator.
* @package Pandora FMS
* @subpackage Opensource.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ 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.
require_once __DIR__.'/config.php';
require_once __DIR__.'/functions.php';
require_once __DIR__.'/functions_db.php';
require_once __DIR__.'/auth/mysql.php';
require_once $config['homedir'].'/include/lib/User.php';
require_once $config['homedir'].'/include/functions_reporting.php';
require_once $config['homedir'].'/include/functions_graph.php';
require_once $config['homedir'].'/include/functions_custom_graphs.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_tags.php';
$data_raw = get_parameter('data');
$data_decoded = json_decode(io_safe_output($data_raw), true);
if (json_last_error() === JSON_ERROR_NONE) {
$data = $data_decoded['data'];
$session_id = $data_decoded['session_id'];
$type_graph_pdf = $data_decoded['type_graph_pdf'];
$id_user = $data_decoded['id_user'];
$slicebar = $data_decoded['slicebar'];
$slicebar_value = $data_decoded['slicebar_value'];
$data_combined = [];
if (isset($data_decoded['data_combined']) === true) {
$data_combined = $data_decoded['data_combined'];
}
$data_module_list = [];
if (isset($data_decoded['data_module_list']) === true) {
$data_module_list = $data_decoded['data_module_list'];
}
}
// Initialize session.
global $config;
// Care whit this!!! check_login not working if you remove this.
$config['id_user'] = $id_user;
$_SESSION['id_usuario'] = $id_user;
// Checks for server api req.
$bypassLogin = false;
if ($data_decoded['apipass'] !== null
&& ($config['server_unique_identifier'] === $_SESSION['id_usuario'])
) {
$apiPassword = io_output_password(
db_get_value_filter(
'value',
'tconfig',
['token' => 'api_password']
)
);
if ($apiPassword === $data_decoded['apipass']) {
$bypassLogin = true;
}
}
if (!isset($config[$slicebar])) {
$config[$slicebar] = $slicebar_value;
}
// Try to initialize session using existing php session id.
$user = new PandoraFMS\User(['phpsessionid' => $session_id]);
if (check_login(false) === false && $bypassLogin !== true) {
// Error handler.
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Access denied</title>
<link rel="stylesheet" href="styles/pandora.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="styles/pandora_minimal.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui.min.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui_custom.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<script language="javascript" type='text/javascript' src='javascript/pandora.js?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='javascript/pandora_ui.js?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.current.js?v=<?php echo $config['current_package']; ?>'></script>
</head>
<body>
<h1>Access is not granted</h1>
<div id="container-chart-generator-item" style="display:none; margin:0px;width:100px;height:100px;">
</body>
</html>
<?php
exit;
}
// Access granted.
$params = $data;
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'inherit';
}
// Metaconsole connection to the node.
$server_id = 0;
if (isset($params['server_id']) === true) {
$server_id = $params['server_id'];
}
if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
// Error connecting.
if (metaconsole_connect($server) !== NOERR) {
?>
<html>
<body>
<?php
ui_print_error_message(
__('There was a problem connecting with the node')
);
?>
</body>
</html>
<?php
exit;
}
}
$user_language = get_user_language($config['id_user']);
if (file_exists('languages/'.$user_language.'.mo') === true) {
$cfr = new CachedFileReader('languages/'.$user_language.'.mo');
$l10n = new gettext_reader($cfr);
$l10n->load_tables();
}
$hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph</title>
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/pandora.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/pandora_minimal.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/js/jquery-ui.min.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/js/jquery-ui_custom.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/pandora_ui.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/jquery.current.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/jquery.pandora.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/jquery-ui.min.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/pandora.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.time.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.pie.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.crosshair.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.stack.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.selection.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.resize.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.threshold.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.threshold.multiple.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.symbol.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.exportdata.pandora.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.axislabels.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script type="text/javascript">
var phpTimezone = "<?php echo date_default_timezone_get(); ?>";
</script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/pandora.flot.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/chartjs/chart.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/chartjs/chartjs-plugin-datalabels.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
</head>
<body style='width:794px; margin: 0px; background-color: <?php echo $params['backgroundColor']; ?>;'>
<?php
$params['only_image'] = false;
$params['menu'] = false;
$params['disable_black'] = true;
$params_combined = $data_combined;
$module_list = $data_module_list;
$viewport = [
'width' => 0,
'height' => 0,
];
$style = 'width:100%;';
if (isset($params['options']['viewport']) === true) {
$viewport = $params['options']['viewport'];
if (empty($viewport['width']) === false) {
$style .= 'width:'.$viewport['width'].'px;';
}
if (empty($viewport['height']) === false) {
$style .= 'height:'.$viewport['height'].'px;';
}
}
echo '<div id="container-chart-generator-item" style="'.$style.' margin:0px;">';
switch ($type_graph_pdf) {
case 'combined':
$params['pdf'] = true;
$result = graphic_combined_module(
$module_list,
$params,
$params_combined
);
echo $result;
break;
case 'sparse':
$params['pdf'] = true;
echo grafico_modulo_sparse($params);
break;
case 'pie_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'PIE',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'vbar_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'BAR',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'ring_graph':
$params['pdf'] = true;
$params['options']['width'] = 500;
$params['options']['height'] = 500;
$chart = get_build_setup_charts(
'DOUGHNUT',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'line_graph':
$params['pdf'] = true;
$params['options']['width'] = '100%';
$params['options']['height'] = 200;
$chart = get_build_setup_charts(
'LINE',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'slicebar':
// TO-DO Cambiar esto para que se pase por POST, NO SE PUEDE PASAR POR GET.
$params['graph_data'] = json_decode(io_safe_output($config[$params['tokem_config']]), true);
delete_config_token($params['tokem_config']);
echo flot_slicesbar_graph(
$params['graph_data'],
$params['period'],
$params['width'],
$params['height'],
$params['legend'],
$params['colors'],
$params['fontpath'],
$params['round_corner'],
$params['homeurl'],
$params['watermark'],
$params['adapt_key'],
$params['stat_winalse'],
$params['id_agent'],
$params['full_legend_daterray'],
$params['not_interactive'],
$params['ttl'],
$params['sizeForTicks'],
$params['show'],
$params['date_to'],
$params['server_id']
);
break;
default:
// Code...
break;
}
echo '</div>';
?>
</body>
</html>

View File

@ -118,7 +118,7 @@ class ConfigPEN extends HTML
if (is_array($filter)) { if (is_array($filter)) {
if (!empty($filter['free_search'])) { if (!empty($filter['free_search'])) {
$sql_filters[] = vsprintf( $sql_filters[] = vsprintf(
' AND (lower(`manufacturer`) like lower("%%%s%%") ' AND (lower(REPLACE(manufacturer, "&#x20;", " ")) like lower("%%%s%%")
OR pen = "%s") ', OR pen = "%s") ',
array_fill(0, 2, $filter['free_search']) array_fill(0, 2, $filter['free_search'])
); );

View File

@ -2383,7 +2383,7 @@ class ConsoleSupervisor
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
'title' => __('This instance is not registered in the Update manager section'), 'title' => __('This instance is not registered in the Warp Update section'),
'message' => __('Click here to start the registration process'), 'message' => __('Click here to start the registration process'),
'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online',
] ]
@ -2404,13 +2404,17 @@ class ConsoleSupervisor
{ {
global $config; global $config;
include_once $config['homedir'].'/include/functions_update_manager.php'; include_once $config['homedir'].'/include/functions_update_manager.php';
$server_name = db_get_value_filter(
'name',
'tserver',
[ 'server_type' => '1' ]
);
if (update_manager_verify_api() === false) { if (update_manager_verify_api() === false) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.API.ACCESS', 'type' => 'NOTIF.API.ACCESS',
'title' => __('Cannot access the Pandora FMS API '), 'title' => __('Cannot access the Pandora FMS API '),
'message' => __('Please check the configuration, some components may fail due to this misconfiguration.'), 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'),
] ]
); );
} else { } else {

View File

@ -701,6 +701,10 @@ class Diagnostics extends Wizard
{ {
global $config; global $config;
// Get version comment DB.
$sql_version_comment = 'select @@version_comment as version_comment';
$version_comment = db_get_sql($sql_version_comment);
$result = [ $result = [
'error' => false, 'error' => false,
'data' => [ 'data' => [
@ -716,6 +720,14 @@ class Diagnostics extends Wizard
'name' => __('DB Schema Build'), 'name' => __('DB Schema Build'),
'value' => $config['db_scheme_build'], 'value' => $config['db_scheme_build'],
], ],
'dbVersion' => [
'name' => __('Engine version'),
'value' => $config['dbconnection']->server_info,
],
'dbVersionComment' => [
'name' => __('Version comment'),
'value' => $version_comment,
],
], ],
]; ];

View File

@ -333,6 +333,7 @@ class TreeService extends Tree
$services[$service['id']]['id'] = $service['id']; $services[$service['id']]['id'] = $service['id'];
$services[$service['id']]['description'] = $service['description']; $services[$service['id']]['description'] = $service['description'];
$services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id']; $services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id'];
$services[$service['id']]['title'] = services_get_parents_title((int) $service['id']);
} }
return $services; return $services;
@ -627,6 +628,7 @@ class TreeService extends Tree
$tmp['type'] = 'services'; $tmp['type'] = 'services';
$tmp['rootType'] = 'services'; $tmp['rootType'] = 'services';
$tmp['children'] = []; $tmp['children'] = [];
$tmp['servicesChildren'] = services_get_services_children($item->service()->id());
$tmp['serviceDetail'] = ui_get_full_url( $tmp['serviceDetail'] = ui_get_full_url(
'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.$item->service()->id() 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.$item->service()->id()
); );
@ -731,7 +733,10 @@ class TreeService extends Tree
if (isset($this->filter['searchService']) === true if (isset($this->filter['searchService']) === true
&& empty($this->filter['searchService']) === false && empty($this->filter['searchService']) === false
) { ) {
return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')"; $whereAncestors = ' AND ts.name LIKE "%'.$this->filter['searchService'].'%"
OR ts.description LIKE "%'.$this->filter['searchService'].'%"';
return $whereAncestors;
} }
return ''; return '';

View File

@ -606,7 +606,7 @@ class WelcomeWindow extends Wizard
], ],
[ [
'arguments' => [ 'arguments' => [
'label' => __("Let's do it!"), 'label' => __('Let&apos;s do it!'),
'type' => 'button', 'type' => 'button',
'attributes' => [ 'attributes' => [
'class' => 'secondary', 'class' => 'secondary',

View File

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

View File

@ -306,32 +306,48 @@ function format_for_graph(
} }
function human_milliseconds_to_string($seconds) function human_milliseconds_to_string($seconds, $size_text='large')
{ {
$ret = ''; $ret = '';
// get the days // get the days
$days = intval(intval($seconds) / (360000 * 24)); $days = intval(intval($seconds) / (360000 * 24));
if ($days > 0) { if ($days > 0) {
$ret .= "$days days "; if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$days d").' ';
} else {
$ret .= "$days days ";
}
} }
// get the hours // get the hours
$hours = ((intval($seconds) / 360000) % 24); $hours = ((intval($seconds) / 360000) % 24);
if ($hours > 0) { if ($hours > 0) {
$ret .= "$hours hours "; if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$hours h").' ';
} else {
$ret .= "$hours hours ";
}
} }
// get the minutes // get the minutes
$minutes = ((intval($seconds) / 6000) % 60); $minutes = ((intval($seconds) / 6000) % 60);
if ($minutes > 0) { if ($minutes > 0) {
$ret .= "$minutes minutes "; if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$minutes m").' ';
} else {
$ret .= "$minutes minutes ";
}
} }
// get the seconds // get the seconds
$seconds = ((intval($seconds) / 100) % 60); $seconds = ((intval($seconds) / 100) % 60);
if ($seconds > 0) { if ($seconds > 0) {
$ret .= "$seconds seconds"; if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$seconds s").' ';
} else {
$ret .= "$seconds seconds ";
}
} }
return $ret; return $ret;
@ -990,6 +1006,70 @@ function get_parameter($name, $default='')
} }
function get_parameter_date($name, $default='', $date_format='Y/m/d')
{
$date_end = get_parameter('date_end', 0);
$time_end = get_parameter('time_end');
$datetime_end = strtotime($date_end.' '.$time_end);
$custom_date = get_parameter('custom_date', 0);
$range = get_parameter('range', SECONDS_1DAY);
$date_text = get_parameter('range_text', SECONDS_1DAY);
$date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY);
$date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less));
$time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less));
$datetime_init = strtotime($date_init.' '.$time_init);
if ($custom_date === '1') {
if ($datetime_init >= $datetime_end) {
$datetime_init = $date_init_less;
}
$date_init = date('Y/m/d H:i:s', $datetime_init);
$date_end = date('Y/m/d H:i:s', $datetime_end);
$period = ($datetime_end - $datetime_init);
} else if ($custom_date === '2') {
$date_units = get_parameter('range_units');
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units)));
$period = (strtotime($date_end) - strtotime($date_init));
} else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) {
if ($range === 'this_week') {
$monday = date('Y/m/d', strtotime('last monday'));
$sunday = date('Y/m/d', strtotime($monday.' +6 days'));
$period = (strtotime($sunday) - strtotime($monday));
$date_init = $monday;
$date_end = $sunday;
} else if ($range === 'this_month') {
$date_end = date('Y/m/d', strtotime('last day of this month'));
$first_of_month = date('Y/m/d', strtotime('first day of this month'));
$date_init = $first_of_month;
$period = (strtotime($date_end) - strtotime($first_of_month));
} else if ($range === 'past_month') {
$date_end = date('Y/m/d', strtotime('last day of previous month'));
$first_of_month = date('Y/m/d', strtotime('first day of previous month'));
$date_init = $first_of_month;
$period = (strtotime($date_end) - strtotime($first_of_month));
} else if ($range === 'past_week') {
$date_end = date('Y/m/d', strtotime('sunday', strtotime('last week')));
$first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week')));
$date_init = $first_of_week;
$period = (strtotime($date_end) - strtotime($first_of_week));
}
} else {
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range));
$period = (strtotime($date_end) - strtotime($date_init));
}
return [
'date_init' => date($date_format, strtotime($date_init)),
'date_end' => date($date_format, strtotime($date_end)),
'period' => $period,
];
}
/** /**
* Get a parameter from a get request. * Get a parameter from a get request.
* *
@ -4310,48 +4390,22 @@ function generator_chart_to_pdf(
$module_list=false $module_list=false
) { ) {
global $config; global $config;
$hack_metaconsole = '';
if (is_metaconsole()) { if (is_metaconsole() === true) {
$hack_metaconsole = '../..'; $hack_metaconsole = '../..';
} else {
$hack_metaconsole = '';
} }
$url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php';
if (!$params['return_img_base_64']) { if (!$params['return_img_base_64']) {
$img_file = 'img_'.uniqid().'.png'; $img_file = 'img_'.uniqid().'.png';
$img_path = $config['homedir'].'/attachment/'.$img_file; $img_path = $config['homedir'].'/attachment/'.$img_file;
$img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file; $img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file;
} }
$session_id = session_id(); if ($type_graph_pdf !== 'combined') {
if ($type_graph_pdf === 'combined') { $params_combined = [];
$data = [ $module_list = [];
'data' => $params,
'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf,
'data_module_list' => $module_list,
'data_combined' => $params_combined,
'id_user' => $config['id_user'],
'slicebar' => $_SESSION['slicebar'],
'slicebar_value' => $config[$_SESSION['slicebar']],
'apipass' => get_parameter('apipass', null),
];
} else {
$data = [
'data' => $params,
'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf,
'id_user' => $config['id_user'],
'slicebar' => $_SESSION['slicebar'],
'slicebar_value' => $config[$_SESSION['slicebar']],
'apipass' => get_parameter('apipass', null),
];
} }
unset($data['data']['graph_data']);
// If not install chromium avoid 500 convert tu images no data to show. // If not install chromium avoid 500 convert tu images no data to show.
$chromium_dir = io_safe_output($config['chromium_path']); $chromium_dir = io_safe_output($config['chromium_path']);
$result_ejecution = exec($chromium_dir.' --version'); $result_ejecution = exec($chromium_dir.' --version');
@ -4371,22 +4425,16 @@ function generator_chart_to_pdf(
// Creates a new page. // Creates a new page.
$page = $browser->createPage(); $page = $browser->createPage();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url); // Generate Html.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $html = chart_generator(
curl_setopt($curl, CURLOPT_POSTFIELDS, ['data' => json_encode($data)]); $type_graph_pdf,
$params,
$params_combined,
$module_list
);
$response = curl_exec($curl); $page->setHtml($html);
curl_close($curl);
$page->setHtml($response);
/*
//For debug url with parameters.
$navigation = $page->navigate($url.'?data='.urlencode(json_encode($data)));
$navigation->waitForNavigation(Page::DOM_CONTENT_LOADED);
*/
// Dynamic. // Dynamic.
$dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue(); $dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue();
@ -4433,6 +4481,211 @@ function generator_chart_to_pdf(
} }
/**
* Html print chart for chromium
*
* @param string $type_graph_pdf Chart mode.
* @param array $params Params.
* @param array $params_combined Params Combined charts.
* @param array $module_list Module list Combined charts.
*
* @return string Output Html.
*/
function chart_generator(
string $type_graph_pdf,
array $params,
array $params_combined=[],
array $module_list=[]
) : string {
global $config;
include_once $config['homedir'].'/include/graphs/functions_d3.php';
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'inherit';
}
$hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
$output = '<!DOCTYPE>';
$output .= '<html>';
$output .= '<head>';
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
$output .= '<title>Pandora FMS Graph</title>';
$output .= '<script type="text/javascript">';
$output .= 'var phpTimezone = "'.date_default_timezone_get().'";';
$output .= 'var configHomeurl = "'.((is_metaconsole() === false) ? $config['homeurl'] : '../../').'";';
$output .= '</script>';
$css_files = [
'pandora' => 'include/styles/',
'pandora_minimal' => 'include/styles/',
'jquery-ui.min' => 'include/styles/js/',
'jquery-ui_custom' => 'include/styles/js/',
];
foreach ($css_files as $name => $path) {
$output .= ui_require_css_file($name, $path, true, true);
}
$js_files = [
'pandora_ui' => 'include/javascript/',
'jquery.current' => 'include/javascript/',
'jquery.pandora' => 'include/javascript/',
'jquery-ui.min' => 'include/javascript/',
'date' => 'include/javascript/timezone/src/',
'pandora' => 'include/javascript/',
'jquery.flot' => 'include/graphs/flot/',
'jquery.flot.min' => 'include/graphs/flot/',
'jquery.flot.time' => 'include/graphs/flot/',
'jquery.flot.pie' => 'include/graphs/flot/',
'jquery.flot.crosshair.min' => 'include/graphs/flot/',
'jquery.flot.stack.min' => 'include/graphs/flot/',
'jquery.flot.selection.min' => 'include/graphs/flot/',
'jquery.flot.resize.min' => 'include/graphs/flot/',
'jquery.flot.threshold' => 'include/graphs/flot/',
'jquery.flot.threshold.multiple' => 'include/graphs/flot/',
'jquery.flot.symbol.min' => 'include/graphs/flot/',
'jquery.flot.exportdata.pandora' => 'include/graphs/flot/',
'jquery.flot.axislabels' => 'include/graphs/flot/',
'pandora.flot' => 'include/graphs/flot/',
'chart' => 'include/graphs/chartjs/',
'chartjs-plugin-datalabels.min' => 'include/graphs/chartjs/',
];
foreach ($js_files as $name => $path) {
$output .= ui_require_javascript_file($name, $path, true, true);
}
$output .= include_javascript_d3(true, true);
$output .= '</head>';
$output .= '<body style="width:794px; margin: 0px; background-color:'.$params['backgroundColor'].';">';
$params['only_image'] = false;
$params['menu'] = false;
$params['disable_black'] = true;
$viewport = [
'width' => 0,
'height' => 0,
];
$style = 'width:100%;';
if (isset($params['options']['viewport']) === true) {
$viewport = $params['options']['viewport'];
if (empty($viewport['width']) === false) {
$style .= 'width:'.$viewport['width'].'px;';
}
if (empty($viewport['height']) === false) {
$style .= 'height:'.$viewport['height'].'px;';
}
}
$output .= '<div id="container-chart-generator-item" style="'.$style.' margin:0px;">';
switch ($type_graph_pdf) {
case 'combined':
$params['pdf'] = true;
$result = graphic_combined_module(
$module_list,
$params,
$params_combined
);
$output .= $result;
break;
case 'sparse':
$params['pdf'] = true;
$output .= grafico_modulo_sparse($params);
break;
case 'pie_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'PIE',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'vbar_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'BAR',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'ring_graph':
$params['pdf'] = true;
$params['options']['width'] = 500;
$params['options']['height'] = 500;
$chart = get_build_setup_charts(
'DOUGHNUT',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'line_graph':
$params['pdf'] = true;
$params['options']['width'] = '100%';
$params['options']['height'] = 200;
$chart = get_build_setup_charts(
'LINE',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'slicebar':
$output .= flot_slicesbar_graph(
$params['graph_data'],
$params['period'],
$params['width'],
$params['height'],
$params['legend'],
$params['colors'],
$params['fontpath'],
$params['round_corner'],
$params['homeurl'],
$params['watermark'],
$params['adapt_key'],
$params['stat_winalse'],
$params['id_agent'],
$params['full_legend_daterray'],
$params['not_interactive'],
$params['ttl'],
$params['sizeForTicks'],
$params['show'],
$params['date_to'],
$params['server_id']
);
break;
default:
// Code...
break;
}
$output .= '</div>';
$output .= '</body>';
$output .= '</html>';
return $output;
}
/** /**
* Get the product name. * Get the product name.
* *

View File

@ -2169,13 +2169,16 @@ function get_group_alerts(
$strict_user=false, $strict_user=false,
$tag=false, $tag=false,
$action_filter=false, $action_filter=false,
$alert_action=true $alert_action=true,
$search_sg=false
) { ) {
global $config; global $config;
$group_query = ''; $group_query = '';
if (!empty($idGroup)) { if (!empty($idGroup)) {
$group_query = ' AND id_grupo = '.$idGroup; $group_query = ' AND id_grupo = '.$idGroup;
if ((bool) $search_sg === true) {
$group_query .= ' OR tasg.id_group = '.$idGroup;
}
} }
if (is_array($filter)) { if (is_array($filter)) {

View File

@ -82,7 +82,7 @@ function parseOtherParameter($other, $otherType, $rawDecode)
case 'url_encode': case 'url_encode':
$returnVar = [ $returnVar = [
'type' => 'string', 'type' => 'string',
'data' => urldecode($other), 'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
]; ];
break; break;
@ -10301,8 +10301,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1)
modules_get_type_name($agentModule['id_tipo_modulo']), modules_get_type_name($agentModule['id_tipo_modulo']),
$data $data
); );
if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$idAgentModule.'.'.$time.'.data', $xml)) {
if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$time.'.data', $xml)) {
returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config'])); returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config']));
} else { } else {
echo __('XML file was generated successfully in path: ').$config['remote_config']; echo __('XML file was generated successfully in path: ').$config['remote_config'];
@ -13132,7 +13131,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') { if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18]; $values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id
FROM tevento FROM tevento
WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";'; WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";';
@ -13147,6 +13146,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['status'] = 2; $values['status'] = 2;
$ack_utimestamp = $val['ack_utimestamp']; $ack_utimestamp = $val['ack_utimestamp'];
$values['id_usuario'] = $val['id_usuario']; $values['id_usuario'] = $val['id_usuario'];
$values['event_custom_id'] = $val['event_custom_id'];
} }
api_set_validate_event_by_id($val['id_evento']); api_set_validate_event_by_id($val['id_evento']);
@ -13177,7 +13177,8 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$custom_data, $custom_data,
$values['server_id'], $values['server_id'],
$values['id_extra'], $values['id_extra'],
$ack_utimestamp $ack_utimestamp,
$values['event_custom_id'] ?? null
); );
if ($other['data'][12] != '') { if ($other['data'][12] != '') {
@ -17787,6 +17788,48 @@ function api_token_check(string $token)
} }
/**
* Set custom field value in tevento
*
* @param mixed $id_event Event id.
* @param mixed $custom_field Custom field to set.
* @return void
*/
function api_set_event_custom_id($id, $value)
{
// Get the event
$event = events_get_event($id, false, is_metaconsole());
// If event not exists, end the execution.
if ($event === false) {
returnError(
'event_not_exists',
'Event not exists'
);
$result = false;
}
// Safe custom fields for hacks.
if (preg_match('/script/i', io_safe_output($value))) {
$result = false;
}
$result = events_event_custom_id(
$id,
$value
);
// If update results failed
if (empty($result) === true || $result === false) {
returnError(
'The event could not be updated'
);
return false;
} else {
returnData('string', ['data' => 'Event updated.']);
}
}
/** /**
* Extract info Agents for inventories ITSM. * Extract info Agents for inventories ITSM.
* *

View File

@ -249,10 +249,6 @@ function config_update_config()
$error_update[] = __('Enable Netflow'); $error_update[] = __('Enable Netflow');
} }
if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
$error_update[] = __('Enable Sflow');
}
if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) { if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) {
$error_update[] = __('Enable Feedback'); $error_update[] = __('Enable Feedback');
} }
@ -1623,6 +1619,10 @@ function config_update_config()
if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) { if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) {
$error_update[] = __('Name resolution for IP address'); $error_update[] = __('Name resolution for IP address');
} }
if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
$error_update[] = __('Enable Sflow');
}
break; break;
case 'sflow': case 'sflow':

View File

@ -459,17 +459,17 @@ function cron_task_start_gotty(bool $restart_mode=true)
// Check prev process running and kill it (only if port changed in setup params). // Check prev process running and kill it (only if port changed in setup params).
if (empty($config['restart_gotty_next_cron_port']) === false) { if (empty($config['restart_gotty_next_cron_port']) === false) {
config_update_value('restart_gotty_next_cron_port', ''); $prevProcessRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."' | grep -v 'pgrep'");
$prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'");
if (empty($prevProcessRunning) === false) { if (empty($prevProcessRunning) === false) {
shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'");
} }
config_update_value('restart_gotty_next_cron_port', '');
} }
// Check if gotty is running on the configured port. // Check if gotty is running on the configured port.
$processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); $processRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['gotty_port']."' | grep -v 'pgrep'");
$start_proc = true; $start_proc = true;

View File

@ -194,11 +194,11 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
function custom_graphs_search($id_group, $search) function custom_graphs_search($id_group, $search)
{ {
if ($id_group != '' && $search != '') { if ($id_group != '' && $search != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (name LIKE "%'.$search.'%" OR description LIKE "'.$search.'")'); $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (REPLACE(name, "&#x20;", " ") LIKE "%'.$search.'%" OR REPLACE(description, "&#x20;", " ") LIKE "'.$search.'")');
} else if ($id_group != '') { } else if ($id_group != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.''); $all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.'');
} else { } else {
$all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%" OR description LIKE "'.$search.'"'); $all_graphs = db_get_all_rows_sql('select * from tgraph where REPLACE(name, "&#x20;", " ") LIKE "%'.$search.'%" OR REPLACE(description, "&#x20;", " ") LIKE "'.$search.'"');
} }
if ($all_graphs === false) { if ($all_graphs === false) {

View File

@ -127,6 +127,58 @@ function events_translate_event_type($event_type)
} }
/**
* Module status event_type into descriptive text.
*
* @param integer $event_type Event type.
*
* @return string Module status.
*/
function events_status_module_event_type($event_type)
{
$module_status = '';
switch ($event_type) {
case 'alert_fired':
case 'alert_recovered':
case 'alert_ceased':
case 'alert_manual_validation':
$module_status = AGENT_MODULE_STATUS_CRITICAL_ALERT;
break;
case 'going_down_normal':
case 'going_up_normal':
$module_status = AGENT_MODULE_STATUS_NORMAL;
break;
case 'going_unknown':
case 'unknown':
$module_status = AGENT_MODULE_STATUS_UNKNOWN;
break;
case 'going_up_warning':
case 'going_down_warning':
$module_status = AGENT_MODULE_STATUS_WARNING;
break;
case 'going_up_critical':
case 'going_down_critical':
$module_status = AGENT_MODULE_STATUS_CRITICAL_BAD;
break;
case 'recon_host_detected':
case 'system':
case 'error':
case 'new_agent':
case 'configuration_change':
default:
$module_status = AGENT_MODULE_STATUS_NOT_INIT;
break;
}
return $module_status;
}
/** /**
* Translates a numeric value event_status into descriptive text. * Translates a numeric value event_status into descriptive text.
* *
@ -219,6 +271,7 @@ function events_get_all_fields()
$columns['module_status'] = __('Module status'); $columns['module_status'] = __('Module status');
$columns['module_custom_id'] = __('Module custom id'); $columns['module_custom_id'] = __('Module custom id');
$columns['custom_data'] = __('Custom data'); $columns['custom_data'] = __('Custom data');
$columns['event_custom_id'] = __('Event Custom ID');
return $columns; return $columns;
} }
@ -322,6 +375,9 @@ function events_get_column_name($field, $table_alias=false)
case 'custom_data': case 'custom_data':
return __('Custom data'); return __('Custom data');
case 'event_custom_id':
return __('Event Custom ID');
default: default:
return __($field); return __($field);
} }
@ -2356,7 +2412,8 @@ function events_create_event(
$custom_data='', $custom_data='',
$server_id=0, $server_id=0,
$id_extra='', $id_extra='',
$ack_utimestamp=0 $ack_utimestamp=0,
$event_custom_id=null
) { ) {
if ($source === false) { if ($source === false) {
$source = get_product_name(); $source = get_product_name();
@ -2388,6 +2445,7 @@ function events_create_event(
'custom_data' => $custom_data, 'custom_data' => $custom_data,
'data' => '', 'data' => '',
'module_status' => 0, 'module_status' => 0,
'event_custom_id' => $event_custom_id,
]; ];
return (int) db_process_sql_insert('tevento', $values); return (int) db_process_sql_insert('tevento', $values);
@ -2611,7 +2669,6 @@ function events_print_type_img(
$urlImage = ui_get_full_url(false); $urlImage = ui_get_full_url(false);
$icon = ''; $icon = '';
$style = 'main_menu_icon'; $style = 'main_menu_icon';
switch ($type) { switch ($type) {
case 'alert_recovered': case 'alert_recovered':
$icon = 'images/alert_recovered@svg.svg'; $icon = 'images/alert_recovered@svg.svg';
@ -2677,16 +2734,6 @@ function events_print_type_img(
if ($only_url) { if ($only_url) {
$output = $urlImage.'/'.$icon; $output = $urlImage.'/'.$icon;
} else { } else {
/*
$output .= html_print_div(
[
'title' => events_print_type_description($type, true),
'class' => $style,
'style' => ((empty($icon) === false) ? 'background-image: url('.$icon.'); background-repeat: no-repeat;' : ''),
],
true
);
*/
$output .= html_print_image( $output .= html_print_image(
$icon, $icon,
true, true,
@ -4658,6 +4705,30 @@ function events_page_details($event, $server_id=0)
$data[1] = '<i>'.__('N/A').'</i>'; $data[1] = '<i>'.__('N/A').'</i>';
} }
$table_details->data[] = $data;
$readonly = true;
if (check_acl($config['id_user'], 0, 'EW')) {
$readonly = false;
}
$data = [];
$data[0] = __('Event Custom ID');
$data[1] = '<div class="flex-row-center">'.html_print_input_text('event_custom_id', $event['event_custom_id'], '', false, 255, true, $readonly, false, '', 'w60p');
if ($readonly === false) {
$data[1] .= html_print_button(
__('Update'),
'update_event_custom_id',
false,
'update_event_custom_id('.$event['id_evento'].', '.$event['server_id'].');',
[
'icon' => 'next',
'mode' => 'link',
],
true
);
}
$data[1] .= '</div>';
$table_details->data[] = $data; $table_details->data[] = $data;
$details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>'; $details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>';
@ -6260,6 +6331,63 @@ function event_get_counter_extraId(array $event, ?array $filters)
} }
/**
* Update event detail custom field
*
* @param mixed $id_event Event ID or array of events.
* @param string $event_custom_id Event custom ID to be update.
*
* @return boolean Whether or not it was successful
*/
function events_event_custom_id(
$id_event,
$event_custom_id,
) {
global $config;
// Cleans up the selection for all unwanted values also casts any single
// values as an array.
if (![$id_event]) {
$id_event = (array) safe_int($id_event, 1);
}
// Check ACL.
foreach ($id_event as $k => $id) {
$event_group = events_get_group($id);
if (check_acl($config['id_user'], $event_group, 'EW') == 0) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Attempted updating event #'.$id
);
unset($id_event[$k]);
}
}
if (empty($id_event) === true) {
return false;
}
// Get the current event comments.
$first_event = $id_event;
if (is_array($id_event) === true) {
$first_event = reset($id_event);
}
// Update comment.
$ret = db_process_sql_update(
'tevento',
['event_custom_id' => $event_custom_id],
['id_evento' => $first_event]
);
if (($ret === false) || ($ret === 0)) {
return false;
}
return true;
}
function event_print_graph( function event_print_graph(
$filter, $filter,
$graph_height=100, $graph_height=100,

View File

@ -128,19 +128,18 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
$extension = pathinfo($filename, PATHINFO_EXTENSION); $extension = pathinfo($filename, PATHINFO_EXTENSION);
$umask = io_safe_output((string) get_parameter('umask')); $umask = io_safe_output((string) get_parameter('umask'));
$parse_all_queries = explode('&', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)); // $parse_all_queries = explode('&', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY));
$parse_sec2_query = explode('=', $parse_all_queries[1]); // $parse_sec2_query = explode('=', $parse_all_queries[1]);
$check_extension = true; // $check_extension = true;
if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') { // if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') {
if ((strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')) { // if ((strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')) {
$check_extension = false; // $check_extension = false;
} else { // } else {
$check_extension = true; // $check_extension = true;
} // }
} // }
// (strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip') // (strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')
if (strpos($real_directory, $default_real_directory) !== 0 || $check_extension === false) { if (strpos($real_directory, $default_real_directory) !== 0) {
// Perform security check to determine whether received upload // Perform security check to determine whether received upload
// directory is part of the default path for caller uploader and // directory is part of the default path for caller uploader and
// user is not trying to access an external path (avoid // user is not trying to access an external path (avoid
@ -152,12 +151,12 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
// Copy file to directory and change name. // Copy file to directory and change name.
$nombre_archivo = sprintf('%s/%s', $real_directory, $filename); $nombre_archivo = sprintf('%s/%s', $real_directory, $filename);
try { try {
$mimeContentType = mime_content_type($_FILES['file']['tmp_name']); $ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION));
if (empty($filterFilesType) === true || in_array($ext, $filterFilesType) === true) {
if (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true) {
$result = copy($_FILES['file']['tmp_name'], $nombre_archivo); $result = copy($_FILES['file']['tmp_name'], $nombre_archivo);
} else { } else {
$error_message = 'The uploaded file is not allowed. Only gif, png or jpg files can be uploaded.'; $types_allowed = implode(', ', $filterFilesType);
$error_message = 'The uploaded file is not allowed. Only '.$types_allowed.' files can be uploaded.';
throw new Exception(__($error_message)); throw new Exception(__($error_message));
} }
} catch (Exception $ex) { } catch (Exception $ex) {
@ -199,19 +198,29 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
$filepath = $_FILES['file']['tmp_name']; $filepath = $_FILES['file']['tmp_name'];
$real_directory = filemanager_safe_directory($destination_directory); $real_directory = filemanager_safe_directory($destination_directory);
$secure = true; $secure = true;
if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') { try {
// Security control structure. $ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION));
$zip = new \ZipArchive; if (empty($filterFilesType) === true || in_array($ext, $filterFilesType) === true) {
if ($zip->open($filepath) === true) { // Security control structure.
for ($i = 0; $i < $zip->numFiles; $i++) { $zip = new \ZipArchive;
$unzip_filename = $zip->getNameIndex($i); if ($zip->open($filepath) === true) {
$extension = pathinfo($unzip_filename, PATHINFO_EXTENSION); for ($i = 0; $i < $zip->numFiles; $i++) {
if (strtolower($extension) !== 'mib') { $unzip_filename = $zip->getNameIndex($i);
$secure = false; $extension = pathinfo($unzip_filename, PATHINFO_EXTENSION);
break; if (in_array(strtolower($extension), $filterFilesType) === false) {
$error_message = 'The uploaded file is not allowed. Only '.$types_allowed.' files can be uploaded.';
$secure = false;
throw new Exception(__($error_message));
}
} }
} }
} }
} catch (Exception $ex) {
db_pandora_audit(
AUDIT_LOG_FILE_MANAGER,
'Error Uploading files: '.$ex->getMessage()
);
$config['filemanager']['message'] = ui_print_error_message(__('Upload error').': '.$ex->getMessage());
} }
if (strpos($real_directory, $default_real_directory) !== 0 || $secure === false) { if (strpos($real_directory, $default_real_directory) !== 0 || $secure === false) {

View File

@ -1585,7 +1585,7 @@ function gis_add_conection_maps_in_form($map_connection_list)
<tr class="row_0"> <tr class="row_0">
<td>'.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).'</td> <td>'.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).'</td>
<td>'.$radioButton.'</td> <td>'.$radioButton.'</td>
<td><a id="delete_row" href="javascript: deleteConnectionMap(\''.$mapConnection['id_conection'].'\')">'.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter']).'</a></td> <td><a id="delete_row" href="javascript: deleteConnectionMap(\''.$mapConnection['id_conection'].'\')">'.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter main_menu_icon']).'</a></td>
</tr> </tr>
</tbody> </tbody>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -77,7 +77,7 @@ function inventory_get_data(
} }
if ($inventory_search_string != '') { if ($inventory_search_string != '') {
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'"); array_push($where, "REPLACE(tagent_module_inventory.data, '&#x20;', ' ') LIKE '%".$inventory_search_string."%'");
} }
$offset = (int) get_parameter('offset'); $offset = (int) get_parameter('offset');
@ -746,7 +746,7 @@ function inventory_get_datatable(
} }
if ($inventory_search_string != '') { if ($inventory_search_string != '') {
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'"); array_push($where, "REPLACE(tagente_datos_inventory.data, '&#x20;', ' ') LIKE '%".$inventory_search_string."%'");
} }
if ($utimestamp > 0) { if ($utimestamp > 0) {
@ -786,7 +786,6 @@ function inventory_get_datatable(
} }
$rows = db_get_all_rows_sql($sql); $rows = db_get_all_rows_sql($sql);
if ($order_by_agent === false) { if ($order_by_agent === false) {
$modules = []; $modules = [];
foreach ($rows as $row) { foreach ($rows as $row) {
@ -796,7 +795,13 @@ function inventory_get_datatable(
$data_rows = explode(PHP_EOL, $row['data_inventory']); $data_rows = explode(PHP_EOL, $row['data_inventory']);
foreach ($data_rows as $data_key => $data_value) { foreach ($data_rows as $data_key => $data_value) {
if (empty($data_value) === false) { if (empty($inventory_search_string) !== true) {
$search_check = strpos(str_replace('&#x20;', ' ', $data_value), $inventory_search_string);
} else {
$search_check = true;
}
if (empty($data_value) === false && $search_check !== false) {
$row['data'] = $data_value; $row['data'] = $data_value;
$modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row;
} }
@ -889,7 +894,7 @@ function get_data_basic_info_sql($params, $count=false)
if ($params['search'] > 0) { if ($params['search'] > 0) {
$where .= sprintf( $where .= sprintf(
' AND ( alias LIKE "%%%s%%" )', ' AND ( REPLACE(alias, "&#x20;", " ") LIKE "%%%s%%" )',
$params['search'] $params['search']
); );
} }

View File

@ -0,0 +1,61 @@
<?php
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ 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.
/**
* Return array with macros of agent like core.pm
*
* @param interger $id_agente Id agent to return data.
*
* @return array Array with all macros.
*/
function return_agent_macros($id_agente)
{
global $config;
$array_macros = [];
$grupo = [];
$agente = db_get_row_sql(
'SELECT * FROM tagente WHERE id_agente = '.$id_agente
);
if (isset($agente['id_grupo'])) {
$grupo = db_get_row_sql(
'SELECT * FROM tgrupo WHERE id_grupo = '.$agente['id_grupo']
);
}
if (isset($agente['server_name'])) {
$server_ip = db_get_row_sql(
'SELECT ip_address FROM tserver WHERE name = "'.$agente['server_name'].'"'
)['id_address'];
}
$array_macros = [
'_agentname_' => ($agente['nombre']) ?: '',
'_agentalias_' => ($agente['alias']) ?: '',
'_agent_' => ($agente['alias']) ?: (($agente['nombre']) ?: ''),
'_agentcustomid_' => ($agente['custom_id']) ?: '',
'_agentdescription_' => ($agente['comentarios']) ?: '',
'_agentgroup_' => ($grupo['nombre']) ?: '',
'_agentos_' => ($agente['id_os']) ?: '',
'_address_' => ($agente['direccion']) ?: '',
'_homeurl_' => ($config['public_url']) ?: '',
'_groupcontact_' => ($agente['contact']) ?: '',
'_groupcustomid_' => ($agente['custom_id']) ?: '',
'_groupother_' => ($agente['other']) ?: '',
'_server_ip_' => ($server_ip) ?: '',
'_server_name_' => ($agente['server_name']) ?: '',
];
return $array_macros;
}

View File

@ -330,7 +330,7 @@ function menu_print_menu(&$menu)
if (isset($sub['type']) && $sub['type'] == 'direct') { if (isset($sub['type']) && $sub['type'] == 'direct') {
// This is an external link. // This is an external link.
$submenu_output .= '<li title="'.$sub['id'].'" id="'.str_replace(' ', '_', $sub['id']).'" class="'.$class.'">'; $submenu_output .= '<li title="'.$sub['text'].'" id="'.str_replace(' ', '_', $sub['id']).'" class="'.$class.'">';
if (isset($sub['subtype']) && $sub['subtype'] == 'nolink') { if (isset($sub['subtype']) && $sub['subtype'] == 'nolink') {
$submenu_output .= '<div class=" SubNoLink '.$sub_tree_class.'"><span class="w70p span_has_menu_text">'.$sub['text'].'</span><div class="w21p arrow_menu_down"></div></div>'; $submenu_output .= '<div class=" SubNoLink '.$sub_tree_class.'"><span class="w70p span_has_menu_text">'.$sub['text'].'</span><div class="w21p arrow_menu_down"></div></div>';
@ -875,6 +875,7 @@ function menu_pepare_acl_select_data($pages, $sec)
if (is_ajax()) { if (is_ajax()) {
$about = (bool) get_parameter('about'); $about = (bool) get_parameter('about');
$about_operation = (bool) get_parameter('about_operation'); $about_operation = (bool) get_parameter('about_operation');
$why_enterprise = (bool) get_parameter('why_enterprise');
if ($about) { if ($about) {
global $config; global $config;
global $pandora_version; global $pandora_version;
@ -1003,7 +1004,7 @@ if (is_ajax()) {
$dialogButtons = []; $dialogButtons = [];
$dialogButtons[] = html_print_button( $dialogButtons[] = html_print_button(
__('Update manager'), __('Warp update'),
'update_manager', 'update_manager',
false, false,
'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"', 'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"',
@ -1107,10 +1108,10 @@ if (is_ajax()) {
</tr> </tr>
<tr class="about-last-tr"> <tr class="about-last-tr">
<th style="width: 50%;"> <th style="width: 50%;">
<p class="about-last-p"><span>'.$db_info->data->dbSize->name.'</span></p> <p class="about-last-p"><span>'.$db_info->data->dbVersion->name.'</span></p>
</th> </th>
<th style="width: 50%;"> <th style="width: 50%;">
<p class="about-last-p" style="font-size: 10pt;">'.$db_info->data->dbSize->value.'</p> <p class="about-last-p" style="font-size: 10pt;">'.$db_info->data->dbVersion->value.'</p>
</th> </th>
</tr> </tr>
@ -1370,4 +1371,50 @@ if (is_ajax()) {
echo $dialog; echo $dialog;
} }
if ($why_enterprise) {
global $config;
global $pandora_version;
$product_name = io_safe_output(get_product_name());
$lts_name = '';
if (empty($config['lts_name']) === false) {
$lts_name = ' <i>'.$config['lts_name'].'</i>';
}
$image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms-collapsed.svg', false, false, false);
$url_why_enterprise = 'https://pandorafms.com/en/why-enterprise/';
$lang = users_get_user_by_id($config['id_user'])['language'];
if ($lang === 'es') {
$url_why_enterprise = 'https://pandorafms.com/es/por-que-pandora-fms-enterprise/';
}
$dialog = '
<div id="about-tabs" class="overflow-hidden">
<div id="tab-general-view">
<table class="table-about">
<tbody>
<tr>
<th style="width: 40%; border: 0px;">
<a href="https://pandorafms.com/" target="_blank">
<img src="'.$image_about.'" alt="logo" width="50%">
</a>
</th>
<th style="width: 60%; text-align: left; border: 0px;">
<h1>'.$product_name.'</h1>
<p><span>'.__('Version').' '.$pandora_version.$lts_name.' - '.(enterprise_installed() ? 'Enterprise' : 'Community').'</span></p>
<p>'.__('You are using the free, OpenSource version of Pandora FMS.').'</p>
<p>'.__('This version has no official support or warranty, you can purchase the Enterprise version, which offers support, warranty and additional features to the Opensource version.').'</p>
<p><span><a href="'.$url_why_enterprise.'">'.__('Click on this link for more information.').'</a></span></p>
</th>
</tr>
</tbody>
</table>
<p class="trademark-copyright">Trademark and copyright 2004 - '.date('Y').' <a href="https://pandorafms.com/" target="_blank">Pandora FMS</a>. All rights reserved</p>
</div>
</div>
';
echo $dialog;
}
} }

View File

@ -251,6 +251,11 @@ function modules_copy_agent_module_to_agent($id_agent_module, $id_destiny_agent,
unset($new_module['id_agente_modulo']); unset($new_module['id_agente_modulo']);
unset($new_module['id_agente']); unset($new_module['id_agente']);
// Set debug content.
if (empty($new_module['debug_content']) === false) {
$new_module['debug_content'] = str_replace("'", '"', $new_module['debug_content']);
}
$id_new_module = modules_create_agent_module( $id_new_module = modules_create_agent_module(
$id_destiny_agent, $id_destiny_agent,
$new_module['nombre'], $new_module['nombre'],
@ -2619,12 +2624,26 @@ function modules_get_agentmodule_data_for_humans($module)
$salida = human_milliseconds_to_string($module['datos']); $salida = human_milliseconds_to_string($module['datos']);
} }
} else { } else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])); $salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
} }
break; break;
default: default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])); $salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
break; break;
} }
break; break;
@ -2643,12 +2662,26 @@ function modules_get_agentmodule_data_for_humans($module)
$salida = human_milliseconds_to_string($module['datos']); $salida = human_milliseconds_to_string($module['datos']);
} }
} else { } else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])); $salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
} }
break; break;
default: default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])); $salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
break; break;
} }
} }
@ -2930,7 +2963,14 @@ function modules_get_status($id_agent_module, $db_status, $data, &$status, &$tit
} }
if (is_numeric($data)) { if (is_numeric($data)) {
$title .= ': '.remove_right_zeros(number_format($data, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])); $title .= ': '.remove_right_zeros(
number_format(
$data,
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
} else { } else {
$text = io_safe_output($data); $text = io_safe_output($data);
@ -4765,7 +4805,231 @@ function export_agents_module_csv($filters)
/** /**
* Check if modules are compatible with MADE server. * Function to return Mean Time Between Failure, Mean Time To Solution (in seconds)
* and Availability of a module
*
* @param string $datetime_from Start time of the interval.
*
* @param string $datetime_to End time of the interval.
*
* @param string $id_agentmodule id_agentmodule of the module
*
* @return array Returns an array with the data
*/
function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule)
{
$data = [];
$data['mtbf'] = false;
$data['mtrs'] = false;
$data['availability'] = false;
$data['critical_events'] = false;
$data['warning_events'] = false;
$data['last_status_change'] = false;
$data['module_name'] = false;
$availability = 0;
$type = '';
if ((bool) is_metaconsole() === true) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_id = [];
$server_id['id'] = explode('|', $id_agentmodule)[0];
$id_agentmodule = explode('|', $id_agentmodule)[1];
$server_name = db_get_row_filter('tmetaconsole_setup', $server_id, 'server_name');
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
// Restore db connection.
metaconsole_restore_db();
return $data;
}
}
}
$uncompressed_data = db_uncompress_module_data(
$id_agentmodule,
$datetime_from,
$datetime_to
);
$first_utimestamp = 0;
foreach ($uncompressed_data as $data_module) {
foreach ($data_module['data'] as $subdata) {
if (!empty($subdata['datos'])) {
$first_utimestamp = $subdata['utimestamp'];
if (isset($subdata['type'])) {
$type = $subdata['type'];
}
break;
}
}
}
$interval_time = ($datetime_to - $datetime_from);
$current_time = time();
$sql = 'SELECT utimestamp, event_type FROM tevento
WHERE id_agentmodule = '.$id_agentmodule.'
AND utimestamp >= '.$datetime_from.'
AND utimestamp <= '.$datetime_to.'
ORDER BY utimestamp DESC';
$events_time = db_get_all_rows_sql($sql);
// Count events.
$sql = 'SELECT COUNT(*) as critical_events FROM tevento
WHERE id_agentmodule= '.$id_agentmodule.'
AND utimestamp >= '.$datetime_from.'
AND utimestamp <= '.$datetime_to.'
AND (event_type = "going_up_critical" OR event_type = "going_down_critical")';
$critical_events = db_get_sql($sql);
$sql = 'SELECT COUNT(*) as warning_events FROM tevento
WHERE id_agentmodule= '.$id_agentmodule.'
AND utimestamp >= '.$datetime_from.'
AND utimestamp <= '.$datetime_to.'
AND (event_type = "going_up_warning" OR event_type = "going_down_warning")';
$warning_events = db_get_sql($sql);
if ($events_time !== false && count($events_time) > 0) {
$failed_event = [];
$normal_event = [];
$events_time = array_reverse($events_time);
$mtrs_events = [];
foreach ($events_time as $key => $event) {
if ($event['event_type'] === 'going_up_critical' || $event['event_type'] === 'going_down_critical') {
$failed_event[] = $event['utimestamp'];
$mtrs_events[]['failed_event'] = $event['utimestamp'];
}
if ($event['event_type'] === 'going_up_normal'
|| $event['event_type'] === 'going_down_normal'
|| $event['event_type'] === 'going_up_warning'
|| $event['event_type'] === 'going_down_warning'
) {
$normal_event[] = $event['utimestamp'];
$mtrs_events[]['normal_event'] = $event['utimestamp'];
}
}
$process_mtrs_events = [];
if (empty($mtrs_events) === false) {
$last_event_key = '';
foreach ($mtrs_events as $key => $val) {
if (key($val) !== $last_event_key) {
$last_event_key = key($val);
$process_mtrs_events[] = $val;
}
}
}
$mtrs_array = [];
if (empty($normal_event) === true) {
$mtrs_array[] = ($current_time - $failed_event[0]);
} else if (empty($failed_event) === true) {
$mtrs_array[] = 0;
} else {
$last_value = '';
foreach ($process_mtrs_events as $key => $val) {
$current_value = $val[key($val)];
if ($last_value !== '') {
$mtrs_array[] = ($current_value - $last_value);
}
$last_value = $current_value;
}
$last_mtrs_event = key(end($process_mtrs_events));
if ($last_mtrs_event === 'failed_event') {
$mtrs_array[] = ($current_time - $last_value);
}
}
$mtbf_array = [];
if (!empty($failed_event) === true) {
if (count($failed_event) > 1) {
for ($i = 1; $i <= array_key_last($failed_event); $i++) {
$mtbf_array[] = ($failed_event[$i] - ($failed_event[($i - 1)]));
}
} else {
$mtbf_array[] = 0;
}
} else {
$mtbf_array[] = 0;
}
$total_time_failed = array_sum($mtrs_array);
$total_time_ok = ($interval_time - $total_time_failed);
if (count($events_time) === 1) {
if ((int) $first_utimestamp !== 0) {
$availability = round((($total_time_ok / $interval_time) * 100), 2);
}
} else {
$availability = round((($total_time_ok / $interval_time) * 100), 2);
}
if ($critical_events > 1) {
$mtbf = round(array_sum($mtbf_array) / count($mtbf_array));
} else {
$mtbf = false;
}
if (count($mtrs_array) === 1 && (int) $first_utimestamp !== 0) {
$mtrs = round($total_time_failed / count($mtrs_array));
} else if (count($mtrs_array) > 1 && (int) $first_utimestamp !== 0) {
$mtrs = round((array_sum($mtrs_array) / count($mtrs_array)));
} else {
$mtrs = false;
}
$data['mtbf'] = $mtbf;
$data['mtrs'] = $mtrs;
$data['availability'] = $availability;
} else {
$data['mtbf'] = false;
$data['mtrs'] = false;
$data['availability'] = false;
}
// Get last status change.
$sql = 'SELECT last_status_change FROM tagente_estado
WHERE id_agente_modulo = '.$id_agentmodule.' ';
$last_status_change = db_get_sql($sql);
// Get module name.
/*
$sql = 'SELECT nombre FROM tagente_modulo
WHERE id_agente_modulo = '.$id_agentmodule;*/
$sql = 'SELECT tagente_modulo.nombre as nombre, tagente.alias as alias
FROM tagente_modulo INNER JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
WHERE id_agente_modulo = '.$id_agentmodule.' ';
$sql_query = db_get_all_rows_sql($sql);
$data['critical_events'] = $critical_events;
$data['warning_events'] = $warning_events;
$data['last_status_change'] = $last_status_change;
$data['module_name'] = $sql_query[0]['nombre'];
if ((bool) is_metaconsole() === true) {
$data['agent_alias'] = $server_name['server_name'].' » '.$sql_query[0]['alias'];
} else {
$data['agent_alias'] = $sql_query[0]['alias'];
}
if ((bool) is_metaconsole() === true) {
metaconsole_restore_db();
}
return $data;
}
/*
Check if modules are compatible with MADE server.
* *
* @param integer $id_tipo_modulo * @param integer $id_tipo_modulo
* @retur boolean True if compatible, false otherwise. * @retur boolean True if compatible, false otherwise.

View File

@ -1066,7 +1066,7 @@ function notification_filter()
break; break;
case 'UPDATEMANAGER': case 'UPDATEMANAGER':
$type_name = 'UPDATE MANAGER'; $type_name = 'WARP UPDATE';
break; break;
case 'ALLOWOVERRIDE': case 'ALLOWOVERRIDE':

View File

@ -15986,171 +15986,174 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
return false; return false;
} }
$module_interval = modules_get_interval( if ($metaconsole_on && $server_name != '') {
$content['id_agent_module'] // Restore db connection.
); metaconsole_restore_db();
$slice = ($content['period'] / $module_interval); }
$result_sla = reporting_advanced_sla( $filter = [
$content['id_agent_module'], 'id_agentmodule' => $content['id_agent_module'],
($report['datetime'] - $content['period']), 'group_rep' => EVENT_GROUP_REP_ALL,
$report['datetime'], 'date_to' => date('Y-m-d', ($report['datetime'] - $content['period'])),
null, 'time_to' => date('H:i:s', ($report['datetime'] - $content['period'])),
null, ];
if ($metaconsole_on && $server_name != '') {
$filter['id_server'] = $connection['id'];
}
$previous_event = events_get_all(
['te.event_type, te.timestamp, te.utimestamp'],
$filter,
0, 0,
null,
null,
null,
$slice,
1, 1,
'desc',
'timestamp',
true true
); );
// Select Warning and critical values. $status = '';
$agentmodule_info = modules_get_agentmodule($content['id_agent_module']); if ($previous_event !== false) {
$min_value_critical = ($agentmodule_info['min_critical'] == 0) ? null : $agentmodule_info['min_critical']; $previous_event = end($previous_event);
$status = $previous_event['event_type'];
}
// Check if module type is string. $date_start = ($report['datetime'] - $content['period']);
$modules_is_string = modules_is_string($agentmodule_info['id_agente_modulo']); $filter = [
'id_agentmodule' => $content['id_agent_module'],
'group_rep' => EVENT_GROUP_REP_ALL,
'date_from' => date('Y-m-d', $date_start),
'date_to' => date('Y-m-d', $report['datetime']),
'time_from' => date('H:i:s', $date_start),
'time_to' => date('H:i:s', $report['datetime']),
];
if ($modules_is_string === false) { if ($metaconsole_on && $server_name != '') {
if ($agentmodule_info['max_critical'] == 0) { $filter['id_server'] = $connection['id'];
$max_value_critical = null; }
if ($agentmodule_info['min_critical'] == 0) {
if ((bool) $content['dinamic_proc'] === true) { $events = events_get_all(
$max_value_critical = 0.01; ['te.event_type, te.timestamp, te.utimestamp'],
} $filter,
null,
null,
null,
null,
true
);
// Metaconsole connection.
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
ui_print_error_message('Error connecting to '.$server_name);
}
}
$not_init_data = [];
$previous_data = [
'event_type' => $status,
'utimestamp' => $date_start,
];
if (empty($status) === true) {
// Si viene de no iniciado busco el primer dato del modulo y si es de histórico.
$first_utimestamp = false;
$search_historydb = false;
$extract_first_data = modules_get_first_date($content['id_agent_module'], 0);
if (empty($extract_first_data) === false) {
$first_utimestamp = $extract_first_data['first_utimestamp'];
$search_historydb = (isset($extract_first_data['search_historydb']) === true) ? $extract_first_data['search_historydb'] : false;
}
// Si se encuentra algun dato.
// Si no hay eventos, la fecha del primer dato no sea mayor al fin del report (seria un bloque completo de no iniciado).
// Se comprueba que si existen eventos el dato no sea previo al evento.
if ($first_utimestamp !== false
&& ((empty($events) === true && $first_utimestamp < $report['datetime']) || (empty($events) === false && $first_utimestamp < $events[0]['utimestamp']))
) {
// Tenemos en cuenta si el modulo es de tipo string.
$module = modules_get_agentmodule($content['id_agent_module']);
$module_type = $module['id_tipo_modulo'];
$module_type_str = modules_get_type_name($module_type);
$table = 'tagente_datos';
if (strstr($module_type_str, 'string') !== false) {
$table = 'tagente_datos_string';
}
$query = sprintf(
'SELECT datos,utimestamp
FROM %s
WHERE id_agente_modulo = %d
AND utimestamp = %d
',
$table,
$content['id_agent_module'],
$first_utimestamp
);
$data = db_get_all_rows_sql($query, $search_historydb);
if ($data !== false) {
$not_init_data = [
'event_type' => $status,
'utimestamp' => $date_start,
];
$previous_data = [
'event_type' => 'going_up_normal',
'utimestamp' => $data[0]['utimestamp'],
];
} }
} else {
$max_value_critical = $agentmodule_info['max_critical'];
}
} else {
if ($agentmodule_info['str_critical'] == '') {
$max_value_critical = null;
} else {
$max_value_critical = $agentmodule_info['str_critical'];
} }
} }
$inverse_critical = $agentmodule_info['critical_inverse']; $array_result = [];
$time_total = $content['period'];
$min_value_warning = ($agentmodule_info['min_warning'] == 0) ? null : $agentmodule_info['min_warning']; $check_total = 0;
$check_ok = 0;
if ($modules_is_string === false) { $time_ok = 0;
if ($agentmodule_info['max_warning'] == 0) { if (empty($events) === true) {
$max_value_warning = null; $events = [];
} else {
$max_value_warning = $agentmodule_info['max_warning'];
}
} else {
if ($agentmodule_info['str_warning'] == '') {
$max_value_warning = null;
} else {
$max_value_warning = $agentmodule_info['str_warning'];
}
} }
$inverse_warning = $agentmodule_info['warning_inverse']; // Añadimos el dato previo.
array_unshift($events, $previous_data);
if (empty($not_init_data) === false) {
// Añadimos si viene de no iniciado el no iniciado.
array_unshift($events, $not_init_data);
}
$data = []; $current_time = time();
$data['time_total'] = 0;
$data['time_ok'] = 0;
$data['time_error'] = 0;
$data['time_warning'] = 0;
$data['time_unknown'] = 0;
$data['time_not_init'] = 0;
$data['time_downtime'] = 0;
$data['checks_total'] = 0;
$data['checks_ok'] = 0;
$data['checks_error'] = 0;
$data['checks_warning'] = 0;
$data['checks_unknown'] = 0;
$data['checks_not_init'] = 0;
$array_graph = [];
$i = 0; $i = 0;
foreach ($result_sla as $value_sla) { foreach ($events as $event) {
$data['time_total'] += $value_sla['time_total']; $array_result[$i]['data'] = events_status_module_event_type($event['event_type']);
$data['time_ok'] += $value_sla['time_ok']; if (isset($events[($i + 1)]) === true) {
$data['time_error'] += $value_sla['time_error']; $period = ($events[($i + 1)]['utimestamp'] - $event['utimestamp']);
$data['time_warning'] += $value_sla['time_warning']; $array_result[$i]['utimestamp'] = $period;
$data['time_unknown'] += $value_sla['time_unknown'];
$data['time_downtime'] += $value_sla['time_downtime'];
$data['time_not_init'] += $value_sla['time_not_init'];
$data['checks_total'] += $value_sla['checks_total'];
$data['checks_ok'] += $value_sla['checks_ok'];
$data['checks_error'] += $value_sla['checks_error'];
$data['checks_warning'] += $value_sla['checks_warning'];
$data['checks_unknown'] += $value_sla['checks_unknown'];
$data['checks_not_init'] += $value_sla['checks_not_init'];
// Generate raw data for graph.
if ($value_sla['time_total'] != 0) {
if ($value_sla['time_error'] > 0) {
// ERR.
$array_graph[$i]['data'] = 3;
} else if ($value_sla['time_unknown'] > 0) {
// UNKNOWN.
$array_graph[$i]['data'] = 4;
} else if ($value_sla['time_warning'] > 0) {
// Warning.
$array_graph[$i]['data'] = 2;
} else if ($value_sla['time_not_init'] == $value_sla['time_total']) {
// NOT INIT.
$array_graph[$i]['data'] = 6;
} else {
$array_graph[$i]['data'] = 1;
}
} else { } else {
$array_graph[$i]['data'] = 7; $period = ($report['datetime'] - $event['utimestamp']);
// El ultimo evento solo lo arrastramos hasta la fecha actual.
// Si pedimos mas fecha sera desconocido.
if ($report['datetime'] > $current_time) {
$period = ($current_time - $event['utimestamp']);
}
$array_result[$i]['utimestamp'] = $period;
} }
$array_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']); if ($array_result[$i]['data'] === AGENT_MODULE_STATUS_NORMAL) {
$check_ok++;
$time_ok += $period;
}
$check_total++;
$i++; $i++;
} }
$data['sla_value'] = reporting_sla_get_compliance_from_array( // Bloque por si se pide mas fecha.
$data if ($report['datetime'] > $current_time) {
); $array_result[$i]['data'] = AGENT_MODULE_STATUS_UNKNOWN;
$array_result[$i]['utimestamp'] = ($report['datetime'] - $current_time);
$data['sla_fixed'] = sla_truncate(
$data['sla_value'],
$config['graph_precision']
);
$data_init = -1;
$acum = 0;
$sum = 0;
$array_result = [];
$i = 0;
foreach ($array_graph as $value) {
if ($data_init == -1) {
$data_init = $value['data'];
$acum = $value['utimestamp'];
} else {
if ($data_init == $value['data']) {
$acum = ($acum + $value['utimestamp']);
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
$i++;
$data_init = $value['data'];
$acum = $value['utimestamp'];
}
}
} }
if (count($array_result) == 0) {
$array_result = $array_graph;
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
}
$time_total = $data['time_total'];
// Slice graphs calculation.
$return['agent'] = modules_get_agentmodule_agent_alias( $return['agent'] = modules_get_agentmodule_agent_alias(
$content['id_agent_module'] $content['id_agent_module']
); );
@ -16158,37 +16161,21 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$content['id_agent_module'] $content['id_agent_module']
); );
$return['max_critical'] = $max_value_critical; $return['data_ok'] = $check_ok;
$return['min_critical'] = $min_value_critical; $return['data_total'] = $check_total;
$return['critical_inverse'] = $inverse_critical; if ($check_total > 0) {
$return['max_warning'] = $max_value_warning; $return['percent_ok'] = (($time_ok * 100) / $content['period']);
$return['min_warning'] = $min_value_warning;
$return['warning_inverse'] = $inverse_warning;
$return['data_not_init'] = $data['checks_not_init'];
$return['data_unknown'] = $data['checks_unknown'];
$return['data_critical'] = $data['checks_error'];
$return['data_warning'] = $data['checks_warning'];
$return['data_ok'] = $data['checks_ok'];
$return['data_total'] = $data['checks_total'];
$return['time_not_init'] = $data['time_not_init'];
$return['time_unknown'] = $data['time_unknown'];
$return['time_critical'] = $data['time_error'];
$return['time_warning'] = $data['time_warning'];
$return['time_ok'] = $data['time_ok'];
if ($data['checks_total'] > 0) {
$return['percent_ok'] = (($data['checks_ok'] * 100) / $data['checks_total']);
} else { } else {
$return['percent_ok'] = 0; $return['percent_ok'] = 0;
} }
$colors = [ $colors = [
1 => COL_NORMAL, AGENT_MODULE_STATUS_CRITICAL_ALERT => COL_ALERTFIRED,
2 => COL_WARNING, AGENT_MODULE_STATUS_NORMAL => COL_NORMAL,
3 => COL_CRITICAL, AGENT_MODULE_STATUS_UNKNOWN => COL_UNKNOWN,
4 => COL_UNKNOWN, AGENT_MODULE_STATUS_WARNING => COL_WARNING,
5 => COL_DOWNTIME, AGENT_MODULE_STATUS_CRITICAL_BAD => COL_CRITICAL,
6 => COL_NOTINIT, AGENT_MODULE_STATUS_NOT_INIT => COL_NOTINIT,
7 => COL_IGNORED,
]; ];
$width_graph = 100; $width_graph = 100;

View File

@ -1275,7 +1275,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0)
$table3->headstyle[5] = 'text-align: right'; $table3->headstyle[5] = 'text-align: right';
foreach ($item['data'] as $sla) { foreach ($item['data'] as $sla) {
if (isset($sla) === true) { if (isset($sla) === true && empty($sla['agent']) === false) {
// First_table. // First_table.
$row = []; $row = [];
$row[] = $sla['agent']; $row[] = $sla['agent'];
@ -4952,7 +4952,7 @@ function reporting_html_value(
$table2->head = [ $table2->head = [
__('Agent'), __('Agent'),
__('Module'), __('Module'),
__('Minimun'), __('Minimum'),
]; ];
break; break;
@ -5023,7 +5023,7 @@ function reporting_html_value(
case 'min_value': case 'min_value':
$table1->head = [ $table1->head = [
__('Lapse'), __('Lapse'),
__('Minimun'), __('Minimum'),
]; ];
break; break;

View File

@ -1011,12 +1011,12 @@ function reports_get_report_types($template=false, $not_editor=false)
$types['vuls_attack_complexity'] = [ $types['vuls_attack_complexity'] = [
'optgroup' => __('Vulnerabilities'), 'optgroup' => __('Vulnerabilities'),
'name' => __('Attack complexity graph donut'), 'name' => __('Attack complexity doughnut chart'),
]; ];
$types['vuls_by_packages'] = [ $types['vuls_by_packages'] = [
'optgroup' => __('Vulnerabilities'), 'optgroup' => __('Vulnerabilities'),
'name' => __('By packages in graph pie'), 'name' => __('By packages in pie chart'),
]; ];
$types['vuls_by_agent'] = [ $types['vuls_by_agent'] = [

View File

@ -1978,15 +1978,21 @@ function ui_print_help_icon(
* *
* @return boolean True if the file was added. False if the file doesn't exist. * @return boolean True if the file was added. False if the file doesn't exist.
*/ */
function ui_require_css_file($name, $path='include/styles/', $echo_tag=false) function ui_require_css_file($name, $path='include/styles/', $echo_tag=false, $return=false)
{ {
global $config; global $config;
$filename = $path.$name.'.css'; $filename = $path.$name.'.css';
if ($echo_tag === true) { if ($echo_tag === true) {
echo '<link type="text/css" rel="stylesheet" href="'.ui_get_full_url($filename, false, false, false).'">'; $filename .= '?v='.$config['current_package'];
return null; $tag_name = '<link type="text/css" rel="stylesheet" href="'.ui_get_full_url($filename, false, false, false).'">';
if ($return === false) {
echo $tag_name;
return null;
} else {
return $tag_name;
}
} }
if (! isset($config['css'])) { if (! isset($config['css'])) {
@ -2035,15 +2041,20 @@ function ui_require_css_file($name, $path='include/styles/', $echo_tag=false)
* *
* @return boolean True if the file was added. False if the file doesn't exist. * @return boolean True if the file was added. False if the file doesn't exist.
*/ */
function ui_require_javascript_file($name, $path='include/javascript/', $echo_tag=false) function ui_require_javascript_file($name, $path='include/javascript/', $echo_tag=false, $return=false)
{ {
global $config; global $config;
$filename = $path.$name.'.js'; $filename = $path.$name.'.js';
if ($echo_tag) { if ($echo_tag === true) {
echo '<script type="text/javascript" src="'.ui_get_full_url($filename, false, false, false).'"></script>'; $filename .= '?v='.$config['current_package'];
return null; $tag_name = '<script type="text/javascript" src="'.ui_get_full_url($filename, false, false, false).'"></script>';
if ($return === false) {
echo $tag_name;
return null;
} else {
return $tag_name;
}
} }
if (! isset($config['js'])) { if (! isset($config['js'])) {

View File

@ -1004,6 +1004,13 @@ function get_build_setup_charts($type, $options, $data)
} }
} }
// Set display grid true or false.
if (isset($options['grid']) === true) {
$scales = $chart->options()->getScales();
$scales->getX()->grid()->setDrawOnChartArea($options['grid']);
$scales->getY()->grid()->setDrawOnChartArea($options['grid']);
}
// Radius is null maximum possible. // Radius is null maximum possible.
if (isset($options['radius']) === true if (isset($options['radius']) === true
&& empty($options['radius']) === false && empty($options['radius']) === false

View File

@ -11,14 +11,14 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// 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.
function include_javascript_d3($return=false) function include_javascript_d3($return=false, $force=false)
{ {
global $config; global $config;
static $is_include_javascript = false; static $is_include_javascript = false;
$output = ''; $output = '';
if (!$is_include_javascript) { if (!$is_include_javascript || $force === true) {
$is_include_javascript = true; $is_include_javascript = true;
$output .= '<script type="text/javascript" src="'; $output .= '<script type="text/javascript" src="';

View File

@ -756,9 +756,8 @@ function flot_slicesbar_graph(
global $config; global $config;
if ($ttl == 2) { if ($ttl == 2) {
$tokem_config = uniqid('slicebar');
$params = [ $params = [
'tokem_config' => $tokem_config, 'graph_data' => $graph_data,
'period' => $period, 'period' => $period,
'width' => $width, 'width' => $width,
'height' => $height, 'height' => $height,
@ -781,9 +780,6 @@ function flot_slicesbar_graph(
'server_id' => $server_id, 'server_id' => $server_id,
]; ];
update_check_config_token($tokem_config, json_encode($graph_data));
$_SESSION['slicebar'] = $tokem_config;
$_SESSION['slicebar_value'] = json_encode($graph_data);
$graph = '<img src="data:image/png;base64,'; $graph = '<img src="data:image/png;base64,';
$graph .= generator_chart_to_pdf('slicebar', $params); $graph .= generator_chart_to_pdf('slicebar', $params);
$graph .= '" />'; $graph .= '" />';

View File

@ -492,6 +492,37 @@ function event_comment(current_event) {
return false; return false;
} }
// Save custom_field into an event.
function update_event_custom_id(event_id, server_id) {
var event_custom_id = $("#text-event_custom_id").val();
var params = {
page: "include/ajax/events",
update_event_custom_id: 1,
event_custom_id: event_custom_id,
event_id: event_id,
server_id: server_id
};
$("#button-update_custom_field").attr("disabled", "disabled");
$("#response_loading").show();
jQuery.ajax({
data: params,
type: "POST",
url: getUrlAjax(),
dataType: "html",
success: function(data) {
if (data === "update_error") {
alert("Event Custom ID not valid");
}
$("#button-update_custom_field").removeAttr("disabled");
$("#response_loading").hide();
$("#button-events_form_search_bt").trigger("click");
}
});
}
var processed = 0; var processed = 0;
function update_event(table, id_evento, type, event_rep, row, server_id) { function update_event(table, id_evento, type, event_rep, row, server_id) {
var inputs = $("#events_form :input"); var inputs = $("#events_form :input");
@ -1004,6 +1035,7 @@ function openSoundEventsDialog(settings, dialog_parameters, reload) {
modal: false, modal: false,
width: 600, width: 600,
height: 600, height: 600,
dialogClass: "modal-sound",
open: function() { open: function() {
$.ajax({ $.ajax({
method: "post", method: "post",
@ -1064,10 +1096,10 @@ function openSoundEventsDialog(settings, dialog_parameters, reload) {
if (reload == false && dialog_parameters != undefined) { if (reload == false && dialog_parameters != undefined) {
if ($("#button-start-search").hasClass("play")) { if ($("#button-start-search").hasClass("play")) {
$("#filter_id").val(dialog_parameters["filter_id"]); $("#filter_id").val(dialog_parameters.filter_id);
$("#interval").val(dialog_parameters["interval"]); $("#interval").val(dialog_parameters.interval);
$("#time_sound").val(dialog_parameters["time_sound"]); $("#time_sound").val(dialog_parameters.time_sound);
$("#sound_id").val(dialog_parameters["sound_id"]); $("#sound_id").val(dialog_parameters.sound_id);
$("#filter_id").trigger("change"); $("#filter_id").trigger("change");
$("#interval").trigger("change"); $("#interval").trigger("change");
@ -1124,14 +1156,15 @@ function openSoundEventsDialog(settings, dialog_parameters, reload) {
} }
function openSoundEventModal(settings) { function openSoundEventModal(settings) {
var win = "";
if ($("#hidden-metaconsole_activated").val() === "1") { if ($("#hidden-metaconsole_activated").val() === "1") {
var win = open( win = open(
"../../operation/events/sound_events.php", "../../operation/events/sound_events.php",
"day_123", "day_123",
"width=600,height=500" "width=600,height=500"
); );
} else { } else {
var win = open( win = open(
"operation/events/sound_events.php", "operation/events/sound_events.php",
"day_123", "day_123",
"width=600,height=500" "width=600,height=500"
@ -1502,11 +1535,6 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
typeof requestBody.includes === "function" && typeof requestBody.includes === "function" &&
requestBody.includes("drawConsoleSound=1") requestBody.includes("drawConsoleSound=1")
) { ) {
console.log(
"AJAX request sent with drawConsoleSound=1:",
ajaxOptions.url
);
// Find the dialog element by the aria-describedby attribute // Find the dialog element by the aria-describedby attribute
var dialog = $('[aria-describedby="modal-sound"]'); var dialog = $('[aria-describedby="modal-sound"]');
@ -1516,62 +1544,32 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
// Add the minimize button before the close button // Add the minimize button before the close button
var minimizeButton = $("<button>", { var minimizeButton = $("<button>", {
class: class:
"ui-corner-all ui-widget ui-button-icon-only ui-window-minimize ui-dialog-titlebar-minimize", "ui-corner-all ui-widget ui-button-icon-only ui-window-minimize ui-dialog-titlebar-minimize minimize-buttom-image",
type: "button", type: "button",
title: "Minimize", title: "Minimize"
style: "float: right;margin-right: 1.5em;"
}).insertBefore(closeButton); }).insertBefore(closeButton);
// Add the minimize icon to the minimize button
$("<span>", {
class: "ui-button-icon ui-icon ui-icon-minusthick",
style: "background-color: #fff;"
}).appendTo(minimizeButton);
$("<span>", {
class: "ui-button-icon-space"
})
.html(" ")
.appendTo(minimizeButton);
// Add the disengage button before the minimize button // Add the disengage button before the minimize button
var disengageButton = $("<button>", { var disengageButton = $("<button>", {
class: class:
"ui-corner-all ui-widget ui-button-icon-only ui-dialog-titlebar-disengage", "ui-corner-all ui-widget ui-button-icon-only ui-dialog-titlebar-disengage disengage-buttom-image",
type: "button", type: "button",
title: "Disengage", title: "Disengage"
style: "float: right;margin-right: 0.5em; position:relative;"
}).insertBefore(minimizeButton); }).insertBefore(minimizeButton);
// Add the disengage icon to the disengage button
$("<span>", {
class: "ui-button-icon ui-icon ui-icon-circle-triangle-n",
style: "background-color: #fff;"
}).appendTo(disengageButton);
$("<span>", {
class: "ui-button-icon-space"
})
.html(" ")
.appendTo(disengageButton);
minimizeButton.click(function(e) { minimizeButton.click(function(e) {
console.log("here");
if ($("#minimize_arrow_event_sound").hasClass("arrow_menu_up")) { if ($("#minimize_arrow_event_sound").hasClass("arrow_menu_up")) {
console.log("arrow_menu_up");
$("#minimize_arrow_event_sound").removeClass("arrow_menu_up"); $("#minimize_arrow_event_sound").removeClass("arrow_menu_up");
$("#minimize_arrow_event_sound").addClass("arrow_menu_down"); $("#minimize_arrow_event_sound").addClass("arrow_menu_down");
} else if ( } else if (
$("#minimize_arrow_event_sound").hasClass("arrow_menu_down") $("#minimize_arrow_event_sound").hasClass("arrow_menu_down")
) { ) {
console.log("arrow_menu_down");
$("#minimize_arrow_event_sound").removeClass("arrow_menu_down"); $("#minimize_arrow_event_sound").removeClass("arrow_menu_down");
$("#minimize_arrow_event_sound").addClass("arrow_menu_up"); $("#minimize_arrow_event_sound").addClass("arrow_menu_up");
} }
if (!dialog.data("isMinimized")) { if (!dialog.data("isMinimized")) {
$(".ui-widget-overlay").hide(); $(".ui-widget-overlay").hide();
console.log("Minimize Window");
dialog.data("originalPos", dialog.position()); dialog.data("originalPos", dialog.position());
dialog.data("originalSize", { dialog.data("originalSize", {
width: dialog.width(), width: dialog.width(),
@ -1582,7 +1580,6 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
dialog.animate( dialog.animate(
{ {
height: "40px", height: "40px",
top: 0,
top: $(window).height() - 100 top: $(window).height() - 100
}, },
200, 200,
@ -1597,17 +1594,13 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
}, },
5 5
); );
//dialog.find(".ui-dialog-content").hide();
} else { } else {
console.log("Restore Window");
$(".ui-widget-overlay").show(); $(".ui-widget-overlay").show();
//dialog.find(".ui-dialog-content").show();
dialog.data("isMinimized", false); dialog.data("isMinimized", false);
dialog.animate( dialog.animate(
{ {
height: "40px", height: "40px",
top: 0,
top: $(window).height() - 100 top: $(window).height() - 100
}, },
5 5

View File

@ -808,8 +808,8 @@ function loadVisualConsoleData(
getVisualConsoleItems: 1, getVisualConsoleItems: 1,
size: size, size: size,
visualConsoleId: vcId, visualConsoleId: vcId,
id_user: typeof id_user == undefined ? id_user : null, id_user: typeof id_user !== undefined ? id_user : null,
auth_hash: typeof hash == undefined ? hash : null, auth_hash: typeof hash !== undefined ? hash : null,
mode: mode, mode: mode,
widthScreen: widthScreen widthScreen: widthScreen
}, },

View File

@ -1486,6 +1486,11 @@ var TreeController = {
return 0; return 0;
}); });
//Search service criterion
const searchFilter = controller.filter.searchService;
if (searchFilter && controller.finded !== 1) {
rawTree = _filterItems(rawTree, searchFilter);
}
_.each(rawTree, function(element) { _.each(rawTree, function(element) {
element.jqObject = _processNode($group, element); element.jqObject = _processNode($group, element);
}); });
@ -1551,6 +1556,67 @@ var TreeController = {
// Add again the hover event to the 'force_callback' elements // Add again the hover event to the 'force_callback' elements
forced_title_callback(); forced_title_callback();
/**
* Filter the tree based on a search criterion
*/
function _filterItems(rawTree, searched) {
const ancestors = [];
const father = [];
const newTree = [];
const tmpTree = [];
rawTree.map((raw, index) => {
if (raw.type === "services") {
if (raw.servicesChildren.length !== 0) {
// search at parent level
let descr = raw.description.toLowerCase();
let sear = searched.toLowerCase();
let findedPadre = descr.indexOf(sear);
if (findedPadre === -1) {
father.push(raw.id);
} else if (findedPadre >= 0) {
ancestors.push(raw.id);
} else {
//we mark the father as found
controller.finded = 1;
}
} else {
let finded = raw.description.indexOf(searched);
if (finded === -1) {
delete rawTree[index];
}
}
}
});
if (ancestors.length >= 1) {
ancestors.map(ancestor => {
newTree.push(
rawTree.filter(item => item.id === parseInt(ancestor))
);
});
return newTree[0];
}
if (father.length >= 1) {
let filterfather = [...new Set(father)];
filterfather.map(father => {
tmpTree.push(rawTree.filter(raw => raw.id == father));
});
let tree = [...new Set(tmpTree)];
tree.map(item => {
let tmpItem = item[0];
newTree.push(tmpItem);
});
return newTree;
}
return rawTree.filter(item => item);
}
}, },
load: function() { load: function() {
this.reload(); this.reload();

View File

@ -458,6 +458,12 @@ class Manager implements PublicLogin
$this->publicLink $this->publicLink
); );
if ((bool) $this->dashboardFields['date_range'] === true) {
$dateFrom = $this->dashboardFields['date_from'];
$dateTo = $this->dashboardFields['date_to'];
$instance->setDateRange($dateFrom, $dateTo);
}
return $instance; return $instance;
} }
@ -1041,6 +1047,8 @@ class Manager implements PublicLogin
$id_group = \get_parameter('id_group'); $id_group = \get_parameter('id_group');
$slideshow = \get_parameter_switch('slideshow'); $slideshow = \get_parameter_switch('slideshow');
$favourite = \get_parameter_switch('favourite'); $favourite = \get_parameter_switch('favourite');
$dateRange = \get_parameter_switch('date_range');
$dateData = \get_parameter_date('range', '', 'U');
$id_user = (empty($private) === false) ? $config['id_user'] : ''; $id_user = (empty($private) === false) ? $config['id_user'] : '';
@ -1050,6 +1058,9 @@ class Manager implements PublicLogin
'id_group' => $id_group, 'id_group' => $id_group,
'cells_slideshow' => $slideshow, 'cells_slideshow' => $slideshow,
'active' => $favourite, 'active' => $favourite,
'date_range' => $dateRange,
'date_from' => $dateData['date_init'],
'date_to' => $dateData['date_end'],
]; ];
if ($this->dashboardId === 0) { if ($this->dashboardId === 0) {

View File

@ -51,6 +51,20 @@ class Widget
*/ */
private $showSelectNodeMeta; private $showSelectNodeMeta;
/**
* Date from init for filter widget.
*
* @var integer
*/
private $dateFrom;
/**
* Date from end for filter widget.
*
* @var integer
*/
private $dateTo;
/** /**
* Contructor widget. * Contructor widget.
@ -452,6 +466,10 @@ class Widget
$className .= '\HeatmapWidget'; $className .= '\HeatmapWidget';
break; break;
case 'service_level':
$className .= '\ServiceLevelWidget';
break;
case 'security_hardening': case 'security_hardening':
if (\enterprise_installed() === false) { if (\enterprise_installed() === false) {
$not_installed = true; $not_installed = true;
@ -824,4 +842,41 @@ class Widget
} }
/**
* Set the date range of parent configuration.
*
* @param integer $dateFrom Date from init for filter widget.
* @param integer $dateTo Date from end for filter widget.
*
* @return void
*/
public function setDateRange(int $dateFrom, int $dateTo)
{
$this->dateFrom = $dateFrom;
$this->dateTo = $dateTo;
}
public function getDateFrom()
{
return $this->dateFrom;
}
public function getDateTo()
{
return $this->dateTo;
}
public function getPeriod():mixed
{
if (empty($this->dateFrom) === false && empty($this->dateTo) === false) {
return ($this->dateTo - $this->dateFrom);
} else {
return null;
}
}
} }

View File

@ -637,6 +637,10 @@ class BasicChart extends Widget
$color_status = $this->values['colorValue']; $color_status = $this->values['colorValue'];
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
$params = [ $params = [
'agent_module_id' => $this->values['moduleId'], 'agent_module_id' => $this->values['moduleId'],
'period' => $this->values['period'], 'period' => $this->values['period'],

View File

@ -520,6 +520,9 @@ class BlockHistogram extends Widget
global $config; global $config;
$size = parent::getSize(); $size = parent::getSize();
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
// Desactive scroll bars only this item. // Desactive scroll bars only this item.
$id_agent = $data['agent_id']; $id_agent = $data['agent_id'];

View File

@ -473,6 +473,10 @@ class DataMatrix extends Widget
return $output; return $output;
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$modules_nodes = array_reduce( $modules_nodes = array_reduce(
$this->values['moduleDataMatrix'], $this->values['moduleDataMatrix'],

View File

@ -472,6 +472,10 @@ class CustomGraphWidget extends Widget
$size = parent::getSize(); $size = parent::getSize();
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
switch ($this->values['type']) { switch ($this->values['type']) {
case CUSTOM_GRAPH_STACKED_LINE: case CUSTOM_GRAPH_STACKED_LINE:
case CUSTOM_GRAPH_STACKED_AREA: case CUSTOM_GRAPH_STACKED_AREA:

View File

@ -581,6 +581,12 @@ class EventsListWidget extends Widget
$customFilter = \events_get_event_filter($this->values['customFilter']); $customFilter = \events_get_event_filter($this->values['customFilter']);
if ($customFilter !== false) { if ($customFilter !== false) {
$filter = $customFilter; $filter = $customFilter;
if (in_array('0', $this->values['groupId'])) {
$filter['id_group_filter'] = 0;
} else {
$filter['id_group_filter'] = (!empty($this->values['groupId'][0])) ? $this->values['groupId'] : 0;
}
$filter['tag_with'] = base64_encode( $filter['tag_with'] = base64_encode(
io_safe_output($filter['tag_with']) io_safe_output($filter['tag_with'])
); );
@ -838,6 +844,7 @@ class EventsListWidget extends Widget
'mini_severity' => __('Severity mini'), 'mini_severity' => __('Severity mini'),
'module_custom_id' => __('Module custom ID'), 'module_custom_id' => __('Module custom ID'),
'custom_data' => __('Custom data'), 'custom_data' => __('Custom data'),
'event_custom_id' => __('Event Custom ID'),
]; ];
} }

View File

@ -302,6 +302,10 @@ class GraphModuleHistogramWidget extends Widget
$values['period'] = SECONDS_1DAY; $values['period'] = SECONDS_1DAY;
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
if (isset($values['sizeLabel']) === false) { if (isset($values['sizeLabel']) === false) {
$values['sizeLabel'] = 30; $values['sizeLabel'] = 30;
} }

View File

@ -309,6 +309,12 @@ class Netflow extends Widget
$start_date = (time() - $this->values['period']); $start_date = (time() - $this->values['period']);
$end_date = time(); $end_date = time();
if (empty(parent::getPeriod()) === false) {
$start_date = parent::getDateFrom();
$end_date = parent::getDateTo();
}
if ($this->values['chart_type'] === 'usage_map') { if ($this->values['chart_type'] === 'usage_map') {
$map_data = netflow_build_map_data( $map_data = netflow_build_map_data(
$start_date, $start_date,

View File

@ -135,8 +135,6 @@ class SecurityHardening extends Widget
// Includes. // Includes.
include_once ENTERPRISE_DIR.'/include/functions_security_hardening.php'; include_once ENTERPRISE_DIR.'/include/functions_security_hardening.php';
include_once $config['homedir'].'/include/graphs/fgraph.php'; include_once $config['homedir'].'/include/graphs/fgraph.php';
include_once $config['homedir'].'/include/functions_graph.php';
// WARNING: Do not edit. This chunk must be in the constructor. // WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct( parent::__construct(
$cellId, $cellId,
@ -328,6 +326,11 @@ class SecurityHardening extends Widget
$id_groups = $this->checkAcl($values['group']); $id_groups = $this->checkAcl($values['group']);
$output .= '<b>'.$this->elements[$data_type].'</b>'; $output .= '<b>'.$this->elements[$data_type].'</b>';
if (empty(parent::getPeriod()) === false) {
$values['date_init'] = parent::getDateFrom();
$values['date_end'] = parent::getDateTo();
}
switch ($data_type) { switch ($data_type) {
case 'top_n_agents_sh': case 'top_n_agents_sh':
$output .= $this->loadTopNAgentsSh($id_groups, $values['limit']); $output .= $this->loadTopNAgentsSh($id_groups, $values['limit']);

View File

@ -0,0 +1,672 @@
<?php
/**
* Widget Service Level Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget Service Level
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ 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.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
use PandoraFMS\Agent;
use PandoraFMS\Module;
/**
* Service Level Widgets
*/
class ServiceLevelWidget extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
include_once $config['homedir'].'/include/functions_agents.php';
include_once $config['homedir'].'/include/functions_modules.php';
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Service Level Detail');
// Name.
if (empty($this->name) === true) {
$this->name = 'service_level';
}
// This forces at least a first configuration.
$this->configurationRequired = false;
if (isset($this->values['mModules']) === false) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['interval']) === true) {
$values['interval'] = $decoder['interval'];
} else {
$values['interval'] = '28800';
}
if (isset($decoder['show_agents']) === true) {
$values['show_agents'] = $decoder['show_agents'];
} else {
$values['show_agents'] = '0';
}
if (isset($decoder['mTypeShow']) === true) {
$values['mTypeShow'] = $decoder['mTypeShow'];
}
if (isset($decoder['mGroup']) === true) {
$values['mGroup'] = $decoder['mGroup'];
}
if (isset($decoder['mRecursion']) === true) {
$values['mRecursion'] = $decoder['mRecursion'];
}
if (isset($decoder['mModuleGroup']) === true) {
$values['mModuleGroup'] = $decoder['mModuleGroup'];
}
if (isset($decoder['mAgents']) === true) {
$values['mAgents'] = $decoder['mAgents'];
}
if (isset($decoder['mShowCommonModules']) === true) {
$values['mShowCommonModules'] = $decoder['mShowCommonModules'];
}
if (isset($decoder['mModules']) === true) {
$values['mModules'] = $decoder['mModules'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
$values = $this->values;
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Interval.
$fields = [
'604800' => __('1 week'),
'172800' => __('48 hours'),
'86400' => __('24 hours'),
'43200' => __('12 hours'),
'28800' => __('8 hours'),
];
$inputs[] = [
'label' => __('Interval'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'interval-'.$this->cellId,
'selected' => $values['interval'],
'return' => true,
],
];
// Show agent.
$inputs[] = [
'label' => __('Show agents'),
'arguments' => [
'type' => 'switch',
'name' => 'show_agents-'.$this->cellId,
'value' => $values['show_agents'],
'return' => true,
],
];
$return_all_group = false;
if (users_can_manage_group_all('RM') || $this->values['mGroup'] == 0) {
$return_all_group = true;
}
$mgroup = '';
if (isset($this->values['mGroup']) === false) {
$sql = sprintf(
'SELECT id_group FROM tdashboard WHERE id = %d',
$this->dashboardId
);
$group_dahsboard = db_get_value_sql($sql);
if ($group_dahsboard > 0) {
$mgroup = $group_dahsboard;
}
}
if (is_metaconsole() === true) {
$this->values['mAgents'] = $this->getIdCacheAgent($this->values['mAgents']);
}
$inputs[] = [
'class' => 'flex flex-row',
'id' => 'select_multiple_modules_filtered',
'arguments' => [
'type' => 'select_multiple_modules_filtered',
'uniqId' => $this->cellId,
'mGroup' => (isset($this->values['mGroup']) === true) ? $this->values['mGroup'] : $mgroup,
'mRecursion' => (isset($this->values['mRecursion']) === true) ? $this->values['mRecursion'] : '',
'mModuleGroup' => (isset($this->values['mModuleGroup']) === true) ? $this->values['mModuleGroup'] : '',
'mAgents' => (isset($this->values['mAgents']) === true) ? $this->values['mAgents'] : '',
'mShowCommonModules' => (isset($this->values['mShowCommonModules']) === true) ? $this->values['mShowCommonModules'] : '',
'mModules' => (isset($this->values['mModules']) === true) ? $this->values['mModules'] : '',
'mShowSelectedOtherGroups' => true,
'mReturnAllGroup' => $return_all_group,
'mMetaFields' => ((bool) is_metaconsole()),
'commonModulesSwitch' => true,
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost():array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['interval'] = \get_parameter('interval-'.$this->cellId, '28800');
$values['show_agents'] = \get_parameter('show_agents-'.$this->cellId, '0');
$values['mTypeShow'] = \get_parameter(
'filtered-type-show-'.$this->cellId
);
$values['mGroup'] = \get_parameter(
'filtered-module-group-'.$this->cellId
);
$values['mRecursion'] = \get_parameter_switch(
'filtered-module-recursion-'.$this->cellId
);
$values['mModuleGroup'] = \get_parameter(
'filtered-module-module-group-'.$this->cellId
);
$values['mAgents'] = \get_parameter(
'filtered-module-agents-'.$this->cellId
);
if (is_metaconsole() === true) {
$values['mAgents'] = $this->getRealIdAgentNode($values['mAgents']);
}
$values['mShowCommonModules'] = \get_parameter(
'filtered-module-show-common-modules-'.$this->cellId
);
$values['mModules'] = explode(
',',
\get_parameter(
'filtered-module-modules-'.$this->cellId
)
);
return $values;
}
/**
* Draw widget.
*
* @return string;
*/
public function load()
{
global $config;
$output = '';
if (check_acl($config['id_user'], 0, 'AR') === 0) {
$output .= '<div class="container-center">';
$output .= ui_print_error_message(
__('You don\'t have access'),
'',
true
);
$output .= '</div>';
return $output;
}
$interval_range = [];
$current_timestamp = time();
$interval_range['start'] = ($current_timestamp - $this->values['interval']);
$interval_range['end'] = $current_timestamp;
$reduceAllModules = array_reduce(
$this->values['mModules'],
function ($carry, $item) {
if ($item === null) {
return $carry;
}
if (is_metaconsole() === true) {
$item = explode('|', $item);
$serverId = $item[0];
$fullname = $item[1];
if ($this->values['mShowCommonModules'] !== 'on') {
$item = explode('&#x20;&raquo;&#x20;', $fullname);
$name = $item[1];
$carry['modules_selected'][$serverId][$name] = null;
$carry['modules'][$name] = null;
} else {
$carry['modules'][$fullname] = null;
}
} else {
$carry['modules'][$item] = null;
}
return $carry;
}
);
$allModules = $reduceAllModules['modules'];
$visualData = [];
// Extract info agents selected.
$target_agents = explode(',', $this->values['mAgents']);
foreach ($target_agents as $agent_id) {
try {
if (is_metaconsole() === true && str_contains($agent_id, '|') === true) {
$server_agent = explode('|', $agent_id);
} else {
$id_agente = $agent_id;
}
if ((bool) is_metaconsole() === true) {
if (isset($server_agent) === true) {
$id_agente = $server_agent[1];
$tserver = $server_agent[0];
} else {
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
[ 'id_agente' => $id_agente ]
);
$id_agente = $tmeta_agent['id_tagente'];
$tserver = $tmeta_agent['id_tmetaconsole_setup'];
}
if (metaconsole_connect(null, $tserver) !== NOERR) {
continue;
}
}
$agent = new Agent((int) $id_agente);
$visualData[$agent_id]['agent_status'] = $agent->lastStatus();
$visualData[$agent_id]['agent_name'] = $agent->name();
$visualData[$agent_id]['agent_alias'] = $agent->alias();
$visualData[$agent_id]['modules'] = [];
if (empty($allModules) === false) {
if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') {
if (isset($reduceAllModules['modules_selected'][$tserver]) === true) {
$modules = $agent->searchModules(
['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
);
} else {
$modules = null;
}
} else {
$modules = $agent->searchModules(
['nombre' => array_keys($allModules)]
);
}
}
$visualData[$agent_id]['modules'] = $allModules;
if ((bool) is_metaconsole() === true) {
metaconsole_restore_db();
}
foreach ($modules as $module) {
if ($module === null) {
continue;
}
$data_module_array = $module->toArray();
$visualData[$agent_id]['modules'][$module->name()] = [];
$last_status = $module->getStatus()->toArray();
$visualData[$agent_id]['modules'][$module->name()]['last_status_change'] = $last_status['last_status_change'];
// Mean Time Between Failure.
// Mean Time To Solution.
// Availability.
if ((bool) is_metaconsole() === true) {
$module_id = $tserver.'|'.$data_module_array['id_agente_modulo'];
} else {
$module_id = $data_module_array['id_agente_modulo'];
}
$module_data = service_level_module_data($interval_range['start'], $interval_range['end'], $module_id);
$visualData[$agent_id]['modules'][$module->name()]['mtrs'] = ($module_data['mtrs'] !== false) ? human_milliseconds_to_string(($module_data['mtrs'] * 100), 'short') : '-';
$visualData[$agent_id]['modules'][$module->name()]['mtbf'] = ($module_data['mtbf'] !== false) ? human_milliseconds_to_string(($module_data['mtbf'] * 100), 'short') : '-';
$visualData[$agent_id]['modules'][$module->name()]['availability'] = ($module_data['availability'] !== false) ? $module_data['availability'] : '100';
$visualData[$agent_id]['modules'][$module->name()]['critical_events'] = ($module_data['critical_events'] !== false) ? $module_data['critical_events'] : '';
$visualData[$agent_id]['modules'][$module->name()]['warning_events'] = ($module_data['warning_events'] !== false) ? $module_data['warning_events'] : '';
$visualData[$agent_id]['modules'][$module->name()]['last_status_change'] = ($module_data['last_status_change'] !== false) ? $module_data['last_status_change'] : '';
$visualData[$agent_id]['modules'][$module->name()]['agent_alias'] = ($module_data['agent_alias'] !== false) ? $module_data['agent_alias'] : '';
$visualData[$agent_id]['modules'][$module->name()]['module_name'] = ($module_data['module_name'] !== false) ? $module_data['module_name'] : '';
}
} catch (\Exception $e) {
echo 'Error: ['.$agent_id.']'.$e->getMessage();
}
}
$table = new \stdClass();
$table->width = '100%';
$table->class = 'databox filters filter-table-adv';
$table->head = [];
$show_agents = $this->values['show_agents'];
if ($show_agents === 'on') {
$table->head[0] = __('Agent / Modules');
} else {
$table->head[0] = __('Modules');
}
$table->head[1] = __('% Av.');
$table->head[2] = __('MTBF');
$table->head[3] = __('MTRS');
$table->head[4] = __('Crit. Events').ui_print_help_tip(__('Counted only critical events generated automatic by the module'), true);
$table->head[5] = __('Warn. Events').ui_print_help_tip(__('Counted only warning events generated automatic by the module'), true);
$table->head[6] = __('Last change');
$table->data = [];
$table->cellstyle = [];
$row = 0;
foreach ($visualData as $agent_id => $data) {
foreach ($data['modules'] as $module_name => $module_data) {
if (isset($module_data) === true) {
if ($show_agents === 'on') {
$table->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name'];
$table->cellstyle[$row][0] = 'text-align:left';
} else {
$table->data[$row][0] = $module_data['module_name'];
$table->cellstyle[$row][0] = 'text-align:left';
}
$table->data[$row][1] = $module_data['availability'].'%';
$table->data[$row][2] = $module_data['mtbf'];
$table->data[$row][3] = $module_data['mtrs'];
$table->data[$row][4] = $module_data['critical_events'];
$table->data[$row][5] = $module_data['warning_events'];
$table->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']);
}
$row++;
}
}
$height = (count($table->data) * 32);
$style = 'min-width:400px; min-height:'.$height.'px;';
$output = '<div class="container-top" style="'.$style.'">';
$output .= html_print_table($table, true);
$output .= '</div>';
return $output;
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('Service Level Detail');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'service_level';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 800,
'height' => 270,
];
return $size;
}
/**
* Return array with the real id agent and server.
*
* @param string $id_agents_cache String with the agents cache id.
*
* @return string $agents_servers with the real id agent and server.
*/
public function getRealIdAgentNode($id_agents_cache)
{
$agents_servers = [];
$target_agents = explode(',', $id_agents_cache);
foreach ($target_agents as $agent_id) {
$id_agente = $agent_id;
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
['id_agente' => $id_agente]
);
$id_agente = $tmeta_agent['id_tagente'];
$tserver = $tmeta_agent['id_tmetaconsole_setup'];
$agents_servers[] = $tserver.'|'.$id_agente;
}
return implode(',', $agents_servers);
}
/**
* Return string with the cache id agent in metaconsole.
*
* @param string $id_agents String with the agents and server id.
*
* @return string $cache_id_agents with the cache id agent.
*/
public function getIdCacheAgent($id_agents)
{
$target_agents = explode(',', $id_agents);
$cache_id_agents = [];
foreach ($target_agents as $agent_id) {
if (str_contains($agent_id, '|') === false) {
$cache_id_agents[] = $agent_id;
continue;
}
$server_agent = explode('|', $agent_id);
$tmeta_agent = db_get_row_filter(
'tmetaconsole_agent',
[
'id_tagente' => $server_agent[1],
'id_tmetaconsole_setup' => $server_agent[0],
]
);
$cache_id_agents[] = $tmeta_agent['id_agente'];
}
return implode(',', $cache_id_agents);
}
}

View File

@ -440,6 +440,10 @@ class SingleGraphWidget extends Widget
$module_name = \modules_get_agentmodule_name($this->values['moduleId']); $module_name = \modules_get_agentmodule_name($this->values['moduleId']);
$units_name = \modules_get_unit($this->values['moduleId']); $units_name = \modules_get_unit($this->values['moduleId']);
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
$trickHight = 0; $trickHight = 0;
if ($this->values['showLegend'] === 1) { if ($this->values['showLegend'] === 1) {
// Needed for legend. // Needed for legend.

Some files were not shown because too many files have changed in this diff Show More