diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 2e40524588..c16729bca0 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -11,7 +11,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2023050901' +S_VERSION='2023062901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -285,8 +285,7 @@ console_dependencies=" \ mod_ssl \ libzstd \ openldap-clients \ - chromium \ - http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" + chromium" execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies" # Server dependencies @@ -313,7 +312,6 @@ server_dependencies=" \ bind-utils \ whois \ cpanminus \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ https://firefly.pandorafms.com/centos7/pandorawmic-1.0.0-1.x86_64.rpm" execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -341,7 +339,6 @@ execute_cmd "yum install -y $oracle_dependencies || yum reinstall -y $oracle_dep #ipam dependencies ipam_dependencies=" \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ perl(NetAddr::IP) \ perl(Sys::Syslog) \ perl(DBI) \ @@ -719,6 +716,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro systemctl enable pandora_agent_daemon &>> $LOGFILE execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" +# Enable postrix +systemctl enable postfix --now &>> "$LOGFILE" + #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index 972a094c95..3b4dde6cef 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -14,7 +14,7 @@ PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf -S_VERSION='2023050901' +S_VERSION='2023062901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" # define default variables @@ -344,8 +344,7 @@ console_dependencies=" \ http://firefly.pandorafms.com/centos8/chromium-110.0.5481.177-1.el7.x86_64.rpm \ http://firefly.pandorafms.com/centos8/chromium-common-110.0.5481.177-1.el7.x86_64.rpm \ http://firefly.pandorafms.com/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ - http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ - http://firefly.pandorafms.com/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" + http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm" execute_cmd "dnf install -y $console_dependencies" "Installing Pandora FMS Console dependencies" # Server dependencies @@ -371,7 +370,7 @@ server_dependencies=" \ java \ bind-utils \ whois \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ + libnsl \ http://firefly.pandorafms.com/centos7/wmic-1.4-1.el7.x86_64.rpm \ https://firefly.pandorafms.com/centos8/pandorawmic-1.0.0-1.x86_64.rpm" execute_cmd "dnf install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -399,7 +398,6 @@ execute_cmd "dnf install -y $oracle_dependencies" "Installing Oracle Instant cli #ipam dependencies ipam_dependencies=" \ - http://firefly.pandorafms.com/centos7/xprobe2-0.3-12.2.x86_64.rpm \ perl(NetAddr::IP) \ perl(Sys::Syslog) \ perl(DBI) \ @@ -622,8 +620,9 @@ sed -i -e "s/^upload_max_filesize.*/upload_max_filesize = 800M/g" /etc/php.ini sed -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.ini sed -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini -#adding 900s to httpd timeout +#adding 900s to httpd timeout and 300 to ProxyTimeout echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf +echo 'ProxyTimeout 300' >> /etc/httpd/conf.d/timeout.conf cat > /var/www/html/index.html << EOF_INDEX @@ -787,6 +786,9 @@ echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cro systemctl enable pandora_agent_daemon &>> "$LOGFILE" execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" +# Enable postfix +systemctl enable postfix --now &>> "$LOGFILE" + #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) diff --git a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh index 3d31ae10af..7e2ff6f532 100644 --- a/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh +++ b/extras/deploy-scripts/pandora_deploy_community_ubuntu_2204.sh @@ -17,7 +17,7 @@ PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf WORKDIR=/opt/pandora/deploy -S_VERSION='2023050901' +S_VERSION='2023062901' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" rm -f $LOGFILE &> /dev/null # remove last log before start @@ -265,7 +265,6 @@ server_dependencies=" \ openssh-client \ postfix \ unzip \ - xprobe \ coreutils \ libio-compress-perl \ libmoosex-role-timer-perl \ @@ -287,6 +286,7 @@ server_dependencies=" \ libgeo-ip-perl \ arping \ snmp-mibs-downloader \ + libnsl2 \ openjdk-8-jdk " execute_cmd "apt install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -299,17 +299,7 @@ echo -en "${cyan}Installing wmic and pandorawmic...${reset}" chmod +x pandorawmic wmic &>> "$LOGFILE" && \ cp -a wmic /usr/bin/ &>> "$LOGFILE" && \ cp -a pandorawmic /usr/bin/ &>> "$LOGFILE" -check_cmd_status "Error Installing phanromjs" - -# phantomjs -echo -en "${cyan}Installing phantomjs...${reset}" - export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" - export OPENSSL_CONF=/etc/ssl - curl -LSs -O "https://firefly.pandorafms.com/pandorafms/utils/$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \ - tar xvjf "$PHANTOM_JS.tar.bz2" &>> "$LOGFILE" && \ - mv $PHANTOM_JS/bin/phantomjs /usr/bin &>> "$LOGFILE" && \ - /usr/bin/phantomjs --version &>> "$LOGFILE" -check_cmd_status "Error Installing phanromjs" +check_cmd_status "Error Installing pandorawmic/wmic" # create symlink for fping rm -f /usr/sbin/fping &>> "$LOGFILE" @@ -370,7 +360,6 @@ source '/root/.profile' &>> "$LOGFILE" #ipam dependencies ipam_dependencies=" \ - xprobe \ libnetaddr-ip-perl \ coreutils \ libdbd-mysql-perl \ @@ -619,8 +608,9 @@ sed --follow-symlinks -i -e "s/^memory_limit.*/memory_limit = 800M/g" /etc/php.i sed --follow-symlinks -i -e "s/.*post_max_size =.*/post_max_size = 800M/" /etc/php.ini sed --follow-symlinks -i -e "s/^disable_functions/;disable_functions/" /etc/php.ini -#adding 900s to httpd timeout -#echo 'TimeOut 900' > /etc/httpd/conf.d/timeout.conf +#adding 900s to httpd timeout and 300 to ProxyTimeout +echo 'TimeOut 900' > /etc/apache2/conf-enabled/timeout.conf +echo 'ProxyTimeout 300' >> /etc/apache2/conf-enabled/timeout.conf cat > /var/www/html/index.html << EOF_INDEX @@ -792,6 +782,9 @@ systemctl enable pandora_agent_daemon &>> "$LOGFILE" #fix path phantomjs sed --follow-symlinks -i -e "s/^openssl_conf = openssl_init/#openssl_conf = openssl_init/g" /etc/ssl/openssl.cnf &>> "$LOGFILE" +# Enable postfix +systemctl enable postfix --now &>> "$LOGFILE" + #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) diff --git a/pandora_agents/pc/DEBIAN/control b/pandora_agents/pc/DEBIAN/control index cdbcc99cfe..ac23fd959f 100644 --- a/pandora_agents/pc/DEBIAN/control +++ b/pandora_agents/pc/DEBIAN/control @@ -4,7 +4,7 @@ Architecture: all Priority: optional Section: admin Installed-Size: 260 -Maintainer: ÁRTICA ST +Maintainer: Pandora FMS Homepage: https://pandorafms.org/ Depends: coreutils, perl, unzip Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/shellscript/linux/DEBIAN/control b/pandora_agents/shellscript/linux/DEBIAN/control index 55a5168f93..2ffdee57df 100755 --- a/pandora_agents/shellscript/linux/DEBIAN/control +++ b/pandora_agents/shellscript/linux/DEBIAN/control @@ -4,7 +4,7 @@ Architecture: all Priority: optional Section: admin Installed-Size: 260 -Maintainer: ÁRTICA ST +Maintainer: Pandora FMS Homepage: http://pandorafms.org/ Depends: coreutils, perl Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 44025b1aad..9c0d0f0465 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-agent-unix -Version: 7.0NG.772-230712 +Version: 7.0NG.772-230725 Architecture: all Priority: optional Section: admin Installed-Size: 260 -Maintainer: ÁRTICA ST +Maintainer: Pandora FMS Homepage: http://pandorafms.org/ Depends: coreutils, perl, unzip Description: Pandora FMS agents are based on native languages in every platform: scripts that can be written in any language. It’s possible to reproduce any agent in any programming language and can be extended without difficulty the existing ones in order to cover aspects not taken into account up to the moment. These scripts are formed by modules that each one gathers a "chunk" of information. Thus, every agent gathers several "chunks" of information; this one is organized in a data set and stored in a single file, called data file. diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index ee1f7e6dfb..02c76b2b91 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.772-230712" +pandora_version="7.0NG.772-230725" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist b/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist index 4ee8965fef..1edb91b81a 100644 --- a/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist +++ b/pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist @@ -6,7 +6,7 @@ CFBundleIdentifier com.pandorafms.pandorafms_uninstall CFBundleVersion 7.0NG.772 - CFBundleGetInfoString 7.0NG.772 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020 + CFBundleGetInfoString 7.0NG.772 Pandora FMS Agent uninstaller for MacOS by Pandora FMS on Aug 2020 CFBundleShortVersionString 7.0NG.772 NSPrincipalClassNSApplication diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 7d38d218e6..9a60bb703a 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1031,7 +1031,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.772'; -use constant AGENT_BUILD => '230712'; +use constant AGENT_BUILD => '230725'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 210a4ae78e..4020ef1af9 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.772 -%define release 230712 +%define release 230725 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index d645cee00f..b53c4fda44 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.772 -%define release 230712 +%define release 230725 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 7ef06c11e3..986aa5fb71 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.772" -PI_BUILD="230712" +PI_BUILD="230725" OS_NAME=`uname -s` FORCE=0 @@ -541,8 +541,17 @@ install () { then echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon." else - echo "Check your startup configuration to be sure Pandora FMS Agent is ready " - echo "to start automatically when system restarts": + # Enable startup service + if [ `command -v systemctl` ] + then + systemctl enable pandora_agent_daemon + elif [ `command -v chkconfig` ] + then + chkconfig pandora_agent_daemon on + else + echo "Check your startup configuration to be sure Pandora FMS Agent is ready " + echo "to start automatically when system restarts": + fi fi # Restore the daemon script diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 627e4ed361..ae716f04f7 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230712} +{230725} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 97282e95d0..cc14099dca 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.772 Build 230712") +#define PANDORA_VERSION ("7.0NG.772 Build 230725") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 1acf26ca69..3c6e52cd0f 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -6,12 +6,12 @@ BEGIN BEGIN BLOCK "080904E4" BEGIN - VALUE "CompanyName", "Artica ST" + VALUE "CompanyName", "Pandora FMS" VALUE "FileDescription", "Pandora FMS Agent for Windows Platform" - VALUE "LegalCopyright", "Artica ST" + VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.772(Build 230712))" + VALUE "ProductVersion", "(7.0NG.772(Build 230725))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index dcf9f5a0ba..c69c7f5e2e 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,10 +1,10 @@ package: pandorafms-console -Version: 7.0NG.772-230712 +Version: 7.0NG.772-230725 Architecture: all Priority: optional Section: admin Installed-Size: 42112 -Maintainer: Artica ST +Maintainer: Pandora FMS Homepage: https://pandorafms.com/ Depends: php, php-snmp, php-gd, php-mysqlnd, php-db, php-xmlrpc, php-curl, graphviz, dbconfig-common, php-ldap, mysql-client | virtual-mysql-client, php-xmlrpc, php-zip, php-mbstring Description: Pandora FMS is an Open Source monitoring tool. It monitor your systems and applications, and allows you to control the status of any element of them. The web console is the graphical user interface (GUI) to manage the pool and to generate reports and graphs from the Pandora FMS monitoring process. diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index fe453dbba0..d162aab8f8 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.772-230712" +pandora_version="7.0NG.772-230725" package_pear=0 package_pandora=1 @@ -163,7 +163,7 @@ if [ $package_pear -eq 1 ] then echo "Make the package \"php-xml-rpc\"." cd temp_package - dh-make-pear --maintainer "ÁRTICA ST " XML_RPC + dh-make-pear --maintainer "Pandora FMS " XML_RPC cd php-xml-rpc-* dpkg-buildpackage -rfakeroot cd .. diff --git a/pandora_console/composer.lock b/pandora_console/composer.lock index d7a05579a9..cf6f9f2502 100644 --- a/pandora_console/composer.lock +++ b/pandora_console/composer.lock @@ -609,7 +609,7 @@ } ], "description": "PHP library for ChartJS", - "homepage": "https://artica.es/", + "homepage": "https://pandorafms.com/", "keywords": [ "chartjs", "graph", diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 0c0e0bd7fc..5d603ac1f9 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1692,3 +1692,14 @@ enterprise/godmode/modules/manage_inventory_modules_form.php enterprise/operation/inventory/inventory.php include/test.js include/web2image.js +enterprise/meta/monitoring/wizard/wizard.agent.php +enterprise/meta/monitoring/wizard/wizard.create_agent.php +enterprise/meta/monitoring/wizard/wizard.create_module.php +enterprise/meta/monitoring/wizard/wizard.main.php +enterprise/meta/monitoring/wizard/wizard.manage_alert.php +enterprise/meta/monitoring/wizard/wizard.module.local.php +enterprise/meta/monitoring/wizard/wizard.module.network.php +enterprise/meta/monitoring/wizard/wizard.module.web.php +enterprise/meta/monitoring/wizard/wizard.php +enterprise/meta/monitoring/wizard/wizard.update_agent.php +enterprise/meta/monitoring/wizard/wizard.update_module.php \ No newline at end of file diff --git a/pandora_console/extras/mr/65.sql b/pandora_console/extras/mr/65.sql index d635c9b002..623c0a36f0 100644 --- a/pandora_console/extras/mr/65.sql +++ b/pandora_console/extras/mr/65.sql @@ -1,5 +1,23 @@ START TRANSACTION; +CREATE TABLE IF NOT EXISTS `tnetwork_explorer_filter` ( +`id` INT NOT NULL, +`filter_name` VARCHAR(45) NULL, +`top` VARCHAR(45) NULL, +`action` VARCHAR(45) NULL, +`advanced_filter` TEXT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `tnetwork_usage_filter` ( +`id` INT NOT NULL auto_increment, +`filter_name` VARCHAR(45) NULL, +`top` VARCHAR(45) NULL, +`action` VARCHAR(45) NULL, +`advanced_filter` TEXT NULL, +PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + ALTER TABLE `tlayout` ADD COLUMN `grid_color` VARCHAR(45) NOT NULL DEFAULT '#cccccc' AFTER `maintenance_mode`, ADD COLUMN `grid_size` VARCHAR(45) NOT NULL DEFAULT '10' AFTER `grid_color`; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 646e40481e..af9e16d288 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -34,6 +34,22 @@ echo sprintf('
', $menuTypeClass); $notifications_numbers['notifications'], $notifications_numbers['last_id'] ).'
'; + $header_welcome = ''; + if (check_acl($config['id_user'], $group, 'AW')) { + $header_welcome .= '
'; + $header_welcome .= html_print_image( + 'images/wizard@svg.svg', + true, + [ + 'class' => 'main_menu_icon invert_filter', + 'title' => __('Welcome dialog'), + 'id' => 'Welcome-dialog', + 'alt' => __('Welcome dialog'), + 'style' => 'cursor: pointer;', + ] + ); + $header_welcome .= '
'; + } // ======= Servers List =============================================== if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) { @@ -461,7 +477,7 @@ echo sprintf('
', $menuTypeClass); } else { echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
'.$header_searchbar.'
-
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; +
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; } ?>
@@ -904,6 +920,44 @@ echo sprintf('
', $menuTypeClass); $("#agent_access").css("display",""); }); + $("#welcome-icon-header").click(function () { + if (!$('#welcome_modal_window').length){ + $(document.body).append('
'); + $(document.body).append( $('').attr('href', 'include/styles/new_installation_welcome_window.css') ); + } + // Clean DOM. + load_modal({ + target: $('#welcome_modal_window'), + url: '', + modal: { + title: "", + cancel: '', + ok: '' + }, + onshow: { + page: 'include/ajax/welcome_window', + method: 'loadWelcomeWindow', + }, + oncancel: { + page: 'include/ajax/welcome_window', + title: "", + method: 'cancelWelcome', + confirm: function (fn) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onAccept: function() { + // Continue execution. + fn(); + } + }) + } + } + }); + }); + // Feedback. $("#feedback-header").click(function () { diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 96f9232dab..759e319dbd 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -100,21 +100,23 @@ if ($initial && users_is_admin()) { ); } -$welcome = !$initial; -try { - $welcome_window = new WelcomeWindow($welcome); - if ($welcome_window !== null) { - $welcome_window->run(); +if (check_acl($config['id_user'], 0, 'AW')) { + $welcome = !$initial; + try { + $welcome_window = new WelcomeWindow($welcome); + if ($welcome_window !== null) { + $welcome_window->run(); + } + } catch (Exception $e) { + $welcome = false; } -} catch (Exception $e) { - $welcome = false; } try { if (isset($_SESSION['showed_tips_window']) === false) { $tips_window = new TipsWindow(); if ($tips_window !== null) { - $tips_window->run(); + $tips_window->run(); } } } catch (Exception $e) { diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index b161b7ff6d..c1a14a31f5 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -212,7 +212,7 @@ $groups = users_get_groups($config['id_user'], 'AR', false); // Get modules. $modules = db_get_all_rows_sql( 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo - WHERE id_agente = '.$id_parent + WHERE id_agente = '.$id_agente ); $modules_values = []; $modules_values[0] = __('Any'); diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 163fc16af8..9c080fcf3f 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -80,7 +80,7 @@ if (isset($_POST['template_id']) === true) { $values = [ 'id_agente' => $id_agente, 'id_tipo_modulo' => $row2['type'], - 'descripcion' => __('Created by template ').$name_template.' . '.$row2['description'], + 'descripcion' => $row2['description'], 'max' => $row2['max'], 'min' => $row2['min'], 'module_interval' => $row2['module_interval'], diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c68d483eaf..b07fb5ca4f 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -460,6 +460,18 @@ if ($id_agente) { $templatetab['active'] = ($tab === 'template'); + // Policy tab. + $policyTab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=policy&id_agente='.$id_agente, + 'image' => 'images/policy@svg.svg', + 'title' => __('Manage policy'), + ], + true + ); + + $policyTab['active'] = ($tab === 'policy'); + // Inventory. $inventorytab['text'] = ''.html_print_image( 'images/hardware-software-component@svg.svg', @@ -638,6 +650,7 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, @@ -654,11 +667,11 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, 'agent_wizard' => $agent_wizard, - ]; } @@ -725,6 +738,11 @@ if ($id_agente) { $tab_name = __('Inventory'); break; + case 'policy': + $help_header = 'policy_tab'; + $tab_name = __('Policies'); + break; + case 'plugins': $help_header = 'plugins_tab'; $tab_name = __('Agent plugins'); @@ -2428,6 +2446,10 @@ switch ($tab) { include 'inventory_manager.php'; break; + case 'policy': + enterprise_include('operation/agentes/policy_manager.php'); + break; + default: if (enterprise_hook('switch_agent_tab', [$tab])) { // This will make sure that blank pages will have at least some diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 4f28d256cd..9021514178 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -1072,16 +1072,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { function () { $(".actions", this).css ("visibility", "hidden"); }); - + $("#ag_group").click ( function () { $(this).css ("width", "auto"); $(this).css ("min-width", "100px"); }); - + $("#ag_group").blur (function () { $(this).css ("width", "100px"); }); - + + var show_deploy_agent = ""; + if (show_deploy_agent !== '0'){ + $('#button-modal_deploy_agent').click(); + } }); diff --git a/pandora_console/godmode/agentes/planned_downtime.list.php b/pandora_console/godmode/agentes/planned_downtime.list.php index a9a65bc834..959db70ed6 100755 --- a/pandora_console/godmode/agentes/planned_downtime.list.php +++ b/pandora_console/godmode/agentes/planned_downtime.list.php @@ -89,7 +89,7 @@ if (is_ajax() === true) { [ 'id' => 'agent_modules_affected_planned_downtime', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'godmode/agentes/planned_downtime.list', diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index de01a947ff..de07bce961 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -40,6 +40,8 @@ $table->size = []; $table->style[0] = 'width: 50%'; $table->style[1] = 'width: 50%'; +$modules = []; + if (is_metaconsole() === true) { $params = []; $params['return'] = true; @@ -79,8 +81,6 @@ if (is_metaconsole() === true) { } } -$modules = []; - $table->data[0][1] = html_print_label_input_block( __('Module'), html_print_select( diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index 9872a002f5..46095b6efb 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -184,7 +184,7 @@ if (empty($result) === false) { ] ).'  '; $data[1] .= ''.html_print_image( - 'images/delet.svg', + 'images/delete.svg', true, [ 'title' => __('Delete'), diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 067bed45be..0b09cbc789 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -187,7 +187,7 @@ try { [ 'id' => 'list_agents_tactical', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columnNames, 'return' => true, diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 5d069a8e9b..ade7a7f69b 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -86,31 +86,39 @@ if ($do_operation) { $groups = users_get_groups(); $table = new stdClass(); -$table->class = 'databox filters'; -$table->width = '100%'; -$table->data = []; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->style[2] = 'font-weight: bold'; -$table->style[4] = 'font-weight: bold'; -$table->style[6] = 'font-weight: bold'; - -// Source selection $table->id = 'source_table'; -$table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups( - false, - 'AW', - true, - 'source_id_group', - $source_id_group, - false, - '', - '', - true +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; +$table->data = []; + +// Source selection. +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'source_id_group', + $source_id_group, + false, + '', + '', + true, + false, + false, + 'w100p', + false, + 'width:100%' + ) ); -$table->data[0][2] = __('Group recursion'); -$table->data[0][3] = html_print_checkbox('source_recursion', 1, $source_recursion, true, false); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('source_recursion', 1, $source_recursion, true, false) +); + $status_list = []; $status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); @@ -118,37 +126,52 @@ $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); -$table->data[0][4] = __('Status'); -$table->data[0][5] = html_print_select( - $status_list, - 'status_agents_source', - 'selected', - '', - __('All'), - AGENT_STATUS_ALL, - true + +$table->data[1][0] = html_print_label_input_block( + __('Status'), + html_print_select( + $status_list, + 'status_agents_source', + 'selected', + '', + __('All'), + AGENT_STATUS_ALL, + true, + false, + true, + 'w100p' + ) ); -$table->data[0][6] = __('Agent'); -$table->data[0][6] .= ' '; -// $table->data[0][7] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"), -// 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); + $agents = ( $source_id_group ? agents_get_group_agents($source_id_group, false, 'none') : agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false))) ); -$table->data[0][7] = html_print_select($agents, 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); - -echo '
'; +$table->data[1][1] = html_print_label_input_block( + __('Agent').' ', + html_print_select( + $agents, + 'source_id_agent', + $source_id_agent, + false, + __('Select'), + 0, + true + ) +); +echo ''; echo '
'; -echo ''; -echo ''.__('Source'); -echo ''; +echo ''.__('Source').''; html_print_table($table); echo '
'; -// Target selection + +unset($table); +// Target selection. +$table = new stdClass(); $table->id = 'target_table'; -$table->class = 'databox filters'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; $table->data = []; $modules = []; @@ -169,66 +192,64 @@ foreach ($agent_alerts as $alert) { } $tags = tags_get_user_tags(); -$table->data['tags'][0] = __('Tags'); -$table->data['tags'][1] = html_print_select( - $tags, - 'tags[]', - $tags_name, - false, - __('Any'), - -1, - true, - true, - true +$table->colspan[0][0] = 2; +$table->data[0][0] = html_print_label_input_block( + __('Tags'), + html_print_select( + $tags, + 'tags[]', + $tags_name, + false, + __('Any'), + -1, + true, + true, + true, + '', + false, + 'overflow-x: hidden;white-space: nowrap;max-width: 1136px;' + ) ); -$table->data['operations'][0] = __('Operations'); -$table->data['operations'][1] = ''; -$table->data['operations'][1] .= html_print_checkbox('copy_modules', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy modules'), 'checkbox-copy_modules', true); -$table->data['operations'][1] .= '
'; - -$table->data['operations'][1] .= ''; -$table->data['operations'][1] .= html_print_checkbox('copy_alerts', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true); -$table->data['operations'][1] .= ''; - -$table->data['form_modules_filter'][0] = __('Filter Modules'); -$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true); - -$table->data[1][0] = __('Modules'); -$table->data[1][1] = ''; -$table->data[1][1] .= html_print_select( - $modules, - 'target_modules[]', - 0, - false, - '', - '', - true, - true +$table->data[1][0] = html_print_label_input_block( + __('Operations'), + ''.html_print_checkbox('copy_modules', 1, true, true).html_print_label(__('Copy modules'), 'checkbox-copy_modules', true).''.html_print_checkbox('copy_alerts', 1, true, true).html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true).'' ); -$table->data[1][1] .= ''; -$table->data[1][1] .= ''; -$table->data[1][1] .= ''.__('No modules for this agent').''; -$table->data[1][1] .= ''; -$table->data[2][0] = __('Alerts'); -$table->data[2][1] = ''; -$table->data[2][1] .= html_print_select( - $alerts, - 'target_alerts[]', - 0, - false, - '', - '', - true, - true +$table->data[1][1] = html_print_label_input_block( + __('Filter Modules'), + html_print_input_text('filter_modules', '', '', 20, 255, true) +); + +$table->colspan[2][0] = 2; +$table->data[2][0] = html_print_label_input_block( + __('Modules'), + ''.html_print_select( + $modules, + 'target_modules[]', + 0, + false, + '', + '', + true, + true + ).''.__('No modules for this agent').'' +); + +$table->colspan[3][0] = 2; +$table->data[3][0] = html_print_label_input_block( + __('Alerts'), + ''.html_print_select( + $alerts, + 'target_alerts[]', + 0, + false, + '', + '', + true, + true + ).''.__('No alerts for this agent').'' ); -$table->data[2][1] .= ''; -$table->data[2][1] .= ''; -$table->data[2][1] .= ''.__('No alerts for this agent').''; -$table->data[2][1] .= ''; echo '
'; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 64fa992e76..397e533366 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -38,6 +38,9 @@ require_once $config['homedir'].'/include/db/oracle.php'; // Login check. check_login(); +// Validate enterprise. +$is_enterprise = enterprise_installed(); + if (! check_acl($config['id_user'], 0, 'RW') && ! check_acl($config['id_user'], 0, 'RM') ) { @@ -3682,25 +3685,28 @@ $class = 'databox filters'; ?> - - - - - - - - - - + + + + + + + + + + + + - - - - + } + ?> '.__('Filters').'', 'filter_form', '', - false, + true, false, '', 'white-box-content', @@ -1251,7 +1254,12 @@ switch ($action) { array_push($table->data, $data); } - html_print_table($table); + $reports_table = '
'; + $reports_table .= ''.__('Reports').''; + $reports_table .= html_print_table($table, true); + $reports_table .= '
'; + echo $reports_table; + $tablePagination = ui_pagination( $total_reports, $url, @@ -1259,7 +1267,7 @@ switch ($action) { $pagination, true, 'offset', - false, + false ); } else { ui_print_info_message( @@ -1270,6 +1278,21 @@ switch ($action) { ); } + $discovery_tasklist = new DiscoveryTaskList(); + $report_task_data = $discovery_tasklist->showListConsoleTask(true); + + if (is_array($report_task_data) === true || strpos($report_task_data, 'class="nf"') === false) { + $task_table = '
'; + $task_table .= ''.__('Report tasks'); + $task_table .= ui_print_help_tip(__('To schedule a report, do it from the editing view of each report.'), true); + $task_table .= '
'; + $task_table .= $report_task_data; + $task_table .= '
'; + echo $task_table; + } else { + ui_print_info_message($report_task_data.__('To schedule a report, do it from the editing view of each report.')); + } + if (check_acl($config['id_user'], 0, 'RW') || check_acl($config['id_user'], 0, 'RM') ) { diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 3df3342f52..0fb36b4cfb 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -161,7 +161,7 @@ if ($classname_selected === null) { $wiz_data = []; foreach ($classes as $classpath) { if (is_reporting_console_node() === true) { - if ($classpath !== '/var/www/html/pandora_console/godmode/wizards/DiscoveryTaskList.class.php') { + if ($classpath !== $config['homedir'].'/godmode/wizards/DiscoveryTaskList.class.php') { continue; } } diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index acc9ad7665..34ce122954 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -212,7 +212,7 @@ if (isset($_GET['server']) === true) { false, 'servers', true, - [], + $buttons, [ [ 'link' => '', diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 04b622e312..315702528e 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -560,7 +560,14 @@ if (empty($create) === false || empty($view) === false) { // $data[0] = html_print_div(['id' => 'command_preview', 'class' => 'mono'], true); $data[0] = html_print_label_input_block( __('Command preview'), - html_print_div(['id' => 'command_preview', 'class' => 'mono'], true) + html_print_div( + [ + 'id' => 'command_preview', + 'class' => 'mono', + 'style' => 'max-width: 1050px;overflow-wrap: break-word;', + ], + true + ) ); $table->data['plugin_preview_inputs'] = $data; $table->colspan['plugin_preview_inputs'][0] = 2; diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index cce4e1e053..35cd540e6a 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -101,6 +101,13 @@ foreach ($servers as $server) { } } +$ext = ''; + +// Check for any data-type server present in servers list. If none, enable server access for first server. +if (array_search('data', array_column($servers, 'type')) === false) { + $ext = '_server'; +} + foreach ($servers as $server) { $data = []; @@ -185,14 +192,12 @@ foreach ($servers as $server) { $data[7] = ui_print_timestamp($server['keepalive'], true); - - $ext = '_server'; - if ($server['type'] != 'data') { - $ext = ''; + if ($server['type'] === 'data') { + $ext = '_server'; } $safe_server_name = servers_get_name($server['id_server']); - if (($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { + if (($ext === '_server' || $server['type'] == 'enterprise satellite')) { if (servers_check_remote_config($safe_server_name.$ext) && enterprise_installed()) { $names_servers[$safe_server_name] = true; } else { @@ -253,7 +258,7 @@ foreach ($servers as $server) { ); $data[8] .= '
'; - if (($names_servers[$safe_server_name] === true) && ($server['type'] === 'data' || $server['type'] === 'enterprise satellite')) { + if (($names_servers[$safe_server_name] === true) && ($ext === '_server' || $server['type'] === 'enterprise satellite')) { $data[8] .= ''; $data[8] .= html_print_image( 'images/agents@svg.svg', @@ -298,6 +303,8 @@ foreach ($servers as $server) { unset($data[8]); } + $ext = ''; + array_push($table->data, $data); } diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index c8413d670e..6616cd765c 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -210,7 +210,7 @@ if (is_ajax() === true) { // Ldapsearch timeout. // Default Ldapsearch timeout. - set_when_empty($config['ldap_searh_timeout'], 5); + set_when_empty($config['ldap_search_timeout'], 5); $row = []; $row['name'] = __('Ldap search timeout (secs)'); $row['control'] = html_print_input_text( @@ -558,7 +558,13 @@ echo ''; if ($('input[type=checkbox][name=secondary_ldap_enabled]:checked').val() == 1) { $("tr[id*='ldap_'][id$='_secondary']").show(); } else { - $( "tr[id*='ldap_'][id$='_secondary']" ).hide(); + $( "tr[id*='ldap_'][id$='_secondary']" ).hide(); + } + + if ($('input[type=checkbox][name=secondary_active_directory]:checked').val() == 1) { + $("tr[id*='ad_'][id$='_secondary']").show(); + } else { + $( "tr[id*='ad_'][id$='_secondary']" ).hide(); } } $( document ).ready(function() { diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 96a01694d2..110281096e 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -681,15 +681,19 @@ $table->data[$i++][] = html_print_label_input_block( ) ); +$help_tip = ui_print_help_tip( + __('This log is recommended to be DISABLED by default due to the large amount of debug data it generates.'), + true +); $table->data[$i][] = html_print_label_input_block( - __('Enable console log'), + __('Enable console log').$help_tip, html_print_checkbox_switch( 'console_log_enabled', 1, $config['console_log_enabled'], true ).ui_print_input_placeholder( - __('Log location').': pandora_console/log/console.log', + __('Log location').': /var/log/php-fpm/error.log', true ) ); @@ -743,6 +747,16 @@ $table->data[$i][] = html_print_label_input_block( ) ); +$table->data[$i][] = html_print_label_input_block( + __('Show experimental features'), + html_print_checkbox_switch( + 'show_experimental_features', + 1, + $config['show_experimental_features'], + true + ) +); + echo '
'; echo '
'; diff --git a/pandora_console/godmode/update_manager/update_manager.history.php b/pandora_console/godmode/update_manager/update_manager.history.php index e827951e88..7caab40f8b 100644 --- a/pandora_console/godmode/update_manager/update_manager.history.php +++ b/pandora_console/godmode/update_manager/update_manager.history.php @@ -50,7 +50,7 @@ try { [ 'id' => $tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'include/ajax/update_manager', diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index c0ee9646c1..0fefe0739e 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -129,6 +129,11 @@ class DiscoveryTaskList extends HTML } $delete_console_task = (bool) get_parameter('delete_console_task'); + $report_task = (bool) get_parameter('report_task', 0); + if ($report_task === true) { + $this->url = ui_get_full_url('index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'); + } + if ($delete_console_task === true) { return $this->deleteConsoleTask(); } @@ -287,6 +292,10 @@ class DiscoveryTaskList extends HTML } $id_console_task = (int) get_parameter('id_console_task'); + $report_task = (bool) get_parameter('report_task', 0); + if ($report_task === true) { + $this->url = ui_get_full_url('index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'); + } if ($id_console_task != null) { // -------------------------------- @@ -352,6 +361,10 @@ class DiscoveryTaskList extends HTML } $id_console_task = (int) get_parameter('id_console_task'); + $report_task = (bool) get_parameter('report_task', 0); + if ($report_task === true) { + $this->url = ui_get_full_url('index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'); + } if ($id_console_task > 0) { $result = db_process_sql_update( @@ -1096,9 +1109,9 @@ class DiscoveryTaskList extends HTML * * @return boolean Success or not. */ - public function showListConsoleTask() + public function showListConsoleTask($report_task=false) { - return enterprise_hook('tasklist_showListConsoleTask', [$this]); + return enterprise_hook('tasklist_showListConsoleTask', [$this, $report_task]); } @@ -1137,6 +1150,9 @@ class DiscoveryTaskList extends HTML case DISCOVERY_CLOUD_AWS_S3: return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&sub=s3&page=0'; + case DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE: + return 'wiz=cloud&mode=gcp&ki='.$task['auth_strings'].'&sub=compute&page=0'; + default: return 'wiz=cloud'; } diff --git a/pandora_console/images/circle_title.svg b/pandora_console/images/circle_title.svg new file mode 100644 index 0000000000..23c906e4e5 --- /dev/null +++ b/pandora_console/images/circle_title.svg @@ -0,0 +1,19 @@ + + + EB094270-FB38-4A58-BE94-D40EA44EA568 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/report-task.svg b/pandora_console/images/report-task.svg new file mode 100644 index 0000000000..b16b7144da --- /dev/null +++ b/pandora_console/images/report-task.svg @@ -0,0 +1,8 @@ + + + Reportes programados@svg + + + + + \ No newline at end of file diff --git a/pandora_console/images/widgets/AgentHive.png b/pandora_console/images/widgets/AgentHive.png new file mode 100644 index 0000000000..9a3c4623e5 Binary files /dev/null and b/pandora_console/images/widgets/AgentHive.png differ diff --git a/pandora_console/images/widgets/netflow.png b/pandora_console/images/widgets/netflow.png new file mode 100644 index 0000000000..5a34c1635f Binary files /dev/null and b/pandora_console/images/widgets/netflow.png differ diff --git a/pandora_console/include/ajax/audit_log.php b/pandora_console/include/ajax/audit_log.php index c979568b21..026d8ca881 100644 --- a/pandora_console/include/ajax/audit_log.php +++ b/pandora_console/include/ajax/audit_log.php @@ -84,7 +84,7 @@ if ($save_log_filter) { if ($recover_aduit_log_select) { - echo json_encode(audit_get_audit_filter_select()); + echo json_encode(audit_get_audit_filter_select_fix_order()); } if ($update_log_filter) { @@ -190,7 +190,7 @@ function show_filter() { draggable: true, modal: false, closeOnEscape: true, - width: 380 + width: "auto" }); } @@ -207,12 +207,13 @@ function load_filter_values() { }, success: function(data) { var options = ""; + console.log(data); $.each(data,function(i,value){ if (i == 'text'){ $("#text-filter_text").val(value); } if (i == 'period'){ - $("#text-filter_period").val(value); + $("#filter_period").val(value).change(); } if (i == 'ip'){ $("#text-filter_ip").val(value); @@ -395,7 +396,7 @@ function save_new_filter() { "save_log_filter" : 1, "id_name" : $("#text-id_name").val(), "text" : $("#text-filter_text").val(), - "period" : $("#text-filter_period").val(), + "period" : $("#filter_period :selected").val(), "ip" : $('#text-filter_ip').val(), "type" : $('#filter_type :selected').val(), "user" : $('#filter_user :selected').val(), @@ -431,7 +432,7 @@ function save_update_filter() { "update_log_filter" : 1, "id" : $("#overwrite_filter :selected").val(), "text" : $("#text-filter_text").val(), - "period" : $("#text-filter_period").val(), + "period" : $("#filter_period :selected").val(), "ip" : $('#text-filter_ip').val(), "type" : $('#filter_type :selected').val(), "user" : $('#filter_user :selected').val(), diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 7b2d08970b..6ea76f373b 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -17,6 +17,8 @@ $save_custom_graph = (bool) get_parameter('save_custom_graph'); $print_custom_graph = (bool) get_parameter('print_custom_graph', false); $print_sparse_graph = (bool) get_parameter('print_sparse_graph'); $get_graphs = (bool) get_parameter('get_graphs_container'); +$width = get_parameter('width', 0); +$height = get_parameter('height', 0); if ($save_custom_graph) { $return = []; @@ -25,8 +27,6 @@ if ($save_custom_graph) { $name = get_parameter('name', ''); $description = get_parameter('description', ''); $stacked = get_parameter('stacked', CUSTOM_GRAPH_LINE); - $width = get_parameter('width', 0); - $height = get_parameter('height', 0); $events = get_parameter('events', 0); $period = get_parameter('period', 0); $fullscale = get_parameter('fullscale', 0); @@ -126,6 +126,8 @@ if ($print_sparse_graph) { 'force_interval' => '', 'time_interval' => 300, 'array_data_create' => 0, + 'height' => $height, + 'width' => $width, ]; echo grafico_modulo_sparse($params); diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index c92cee0950..8cc2eca4a5 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -97,6 +97,21 @@ if (check_login()) { return; } + $id_plugin = get_parameter('id_plugin', 0); + + if ($id_plugin !== 0) { + $id_module_plugin = db_get_value( + 'id_plugin', + 'tagente_modulo', + 'id_agente_modulo', + $get_module_macros + ); + if ($id_plugin !== $id_module_plugin) { + $get_plugin_macros = true; + $get_module_macros = 0; + } + } + if ($get_plugin_macros) { if (https_is_running()) { header('Content-type: application/json'); diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index 9461dd8ca8..7bff27da4a 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -182,6 +182,7 @@ try { if ($method == 'snmp_browser_create_modules') { // Get target ids from form. + $use_agent_ip = get_parameter('use_agent_ip', ''); $id_items = get_parameter('id_item2', null); $id_target = null; if (empty($id_items) === false) { @@ -209,7 +210,8 @@ try { $module_target, $snmp_conf_values, $id_target, - $server_to_exec + $server_to_exec, + $use_agent_ip ); // Return fail modules for error/success message. diff --git a/pandora_console/include/ajax/task_to_perform.php b/pandora_console/include/ajax/task_to_perform.php new file mode 100644 index 0000000000..a8a13e08f2 --- /dev/null +++ b/pandora_console/include/ajax/task_to_perform.php @@ -0,0 +1,190 @@ + SERVER_TYPE_WEB], 'status')['status']; + if ($status_webserver === '1') { + $name = array_keys(servers_get_names())[0]; + $id_group = get_parameter('id_group', 4); + + $array_other['data'] = [ + 'Web monitoring', + '', + 2, + $id_group, + 0, + 30, + 30, + 9, + $name, + 0, + 0, + 0, + __('Agent Web monitoring created on welcome'), + ]; + + $id_agent = api_set_new_agent(0, '', $array_other, '', true); + if ($id_agent > 0) { + $module_name = get_parameter('module_name', 'Web_monitoring_module'); + $text_to_search = get_parameter('text_to_search', ''); + $url_goliat = get_parameter('url_goliat', 'https://pandorafms.com/en/'); + $module_latency = create_module_latency_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); + $module_status = create_module_status_goliat($id_agent, $module_name, $id_group, $url_goliat, $text_to_search); + if ($module_latency > 0 && $module_status > 0) { + ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } + } else { + ui_print_error_message(__('The Name is not valid for the modules.')); + } + } else { + ui_print_error_message(__('Web server is not enabled.')); + } +} + +if ($check_connectivity) { + include_once '../functions_api.php'; + include_once '../functions_servers.php'; + + $status_newtwork = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_NETWORK], 'status')['status']; + $status_pluggin = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_PLUGIN], 'status')['status']; + if ($status_newtwork === '1' && $status_pluggin === '1') { + $name = array_keys(servers_get_names())[0]; + $id_group = get_parameter('id_group', 4); + $agent_name = get_parameter('agent_name', __('Agent check connectivity')); + + $array_other['data'] = [ + $agent_name, + '', + 2, + $id_group, + 0, + 30, + 30, + 9, + $name, + 0, + 0, + 0, + __('Basic connectivity'), + ]; + + $id_agent = api_set_new_agent(0, '', $array_other, '', true); + if ($id_agent > 0) { + $ip_target = get_parameter('ip_target', '127.0.0.1'); + $basic_network = create_module_basic_network($id_agent, $id_group, $ip_target); + $latency_network = create_module_latency_network($id_agent, $id_group, $ip_target); + $packet_lost = create_module_packet_lost($id_agent, $id_group, $ip_target); + if ($basic_network > 0 && $latency_network > 0 && $packet_lost > 0) { + ui_print_success_message(__('Your check has been created, click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } + } else { + ui_print_error_message(__('The Name is not valid for the modules.')); + } + } else { + ui_print_error_message(__('Web server is not enabled.')); + } +} + +if ($create_net_scan) { + $ip_target = get_parameter('ip_target', '192.168.10.0/24'); + $id_net_scan = create_net_scan($ip_target); + if ($id_net_scan > 0) { + $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; + ui_print_success_message(__('Basic net created and scan in progress. Click here to view the data. Please note that it may take a few seconds to see data if your server is busy')); + } else { + ui_print_error_message(__('Basic net already exists. Click here to view the data')); + } +} + +if ($create_mail_alert) { + include_once '../functions_alerts.php'; + $id_action = db_get_row_filter('talert_actions', ['name' => 'Email to '.$config['id_user']], 'id')['id']; + if (!$id_action) { + $al_action = alerts_get_alert_action($id); + $id_action = alerts_clone_alert_action(1, $al_action['id_group'], 'Email to '.$config['id_user']); + } + + $id_alert_template = get_parameter('id_condition', 0); + $id_agent_module = get_parameter('id_agent_module', 0); + + $exist = db_get_value_sql( + sprintf( + 'SELECT COUNT(id) + FROM talert_template_modules + WHERE id_agent_module = %d + AND id_alert_template = %d + AND id_policy_alerts = 0 + ', + $id_agent_module, + $id_alert_template + ) + ); + + if ($exist > 0) { + ui_print_error_message(__('Alert already exists. Click here to view the data')); + } else { + $id = alerts_create_alert_agent_module($id_agent_module, $id_alert_template); + if ($id !== false) { + $values = []; + $values['fires_min'] = (int) get_parameter('fires_min'); + $values['fires_max'] = (int) get_parameter('fires_max'); + $values['module_action_threshold'] = (int) 300; + + $alert_created = alerts_add_alert_agent_module_action($id, $id_action, $values); + } + } + + if ($alert_created === true) { + ui_print_success_message(__('Congratulations, you have already created a simple alert. You can see it. Pandora FMS alerts are very flexible, you can do many more things with them, we recommend you to read the documentation for more information. You can create advanced alerts from here.')); + } +} + +if ($create_unknown_template_alert) { + if (is_array(alerts_get_alert_templates(['name' => io_safe_input('Unknown condition')]))) { + echo 1; + } else { + echo create_template_alert_unknown(); + } +} diff --git a/pandora_console/include/ajax/welcome_window.php b/pandora_console/include/ajax/welcome_window.php index 52fdcea8d2..2ca1a5e953 100644 --- a/pandora_console/include/ajax/welcome_window.php +++ b/pandora_console/include/ajax/welcome_window.php @@ -35,6 +35,13 @@ if (is_ajax() === false) { } $ajaxPage = 'include/ajax/welcome_window'; +// Ajax controller. +$method = get_parameter('method', ''); + +if ($method === 'loadWelcomeWindow') { + unset($config['welcome_state']); +} + // Control call flow. try { @@ -44,9 +51,6 @@ try { exit; } -// Ajax controller. -$method = get_parameter('method', ''); - if (method_exists($welcome_actions, $method) === true) { if ($welcome_actions->ajaxMethod($method) === true) { $welcome_actions->{$method}(); diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 526256e260..0e6083d3e2 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -129,6 +129,14 @@ if (empty($apiPassword) === true // Compat. $config['id_user'] = 'admin'; $correctLogin = true; + // Bypass credentials if server-auth and api-pass are correct. + } else if (($config['server_unique_identifier'] === get_parameter('server_auth')) + && ($api_password === $apiPassword) + && ((bool) isInACL($ipOrigin) === true) + ) { + $config['id_usuario'] = 'admin'; + $config['id_user'] = 'admin'; + $correctLogin = true; } else if ((bool) isInACL($ipOrigin) === true) { // External access. // Token is valid. Bypass the credentials. diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 9ebeaaf167..a24769e528 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -237,8 +237,13 @@ function process_user_login_remote($login, $pass, $api=false) // Active Directory. case 'ad': - if (enterprise_hook('ad_process_user_login', [$login, $pass]) === false) { - $config['auth_error'] = 'User not found in database or incorrect password'; + $sr = enterprise_hook('ad_process_user_login', [$login, $pass]); + // Try with secondary server. + if ($sr === false && (bool) $config['secondary_active_directory'] === true) { + $sr = enterprise_hook('ad_process_user_login', [$login, $pass, true]); + } + + if ($sr === false) { return false; } break; diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index b2eb97bd1b..e8ee5f294c 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -165,6 +165,9 @@ $hack_metaconsole = (is_metaconsole() === true) ? '../../' : ''; + diff --git a/pandora_console/include/class/AuditLog.class.php b/pandora_console/include/class/AuditLog.class.php index 98bca38e43..f35f4e4e6d 100644 --- a/pandora_console/include/class/AuditLog.class.php +++ b/pandora_console/include/class/AuditLog.class.php @@ -178,7 +178,7 @@ class AuditLog extends HTML [ 'id' => $this->tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, @@ -469,7 +469,7 @@ class AuditLog extends HTML success: function(data) { var options = ""; $.each(data,function(key,value){ - options += ""; + options += ""; }); $('#overwrite_filter').html(options); $('#overwrite_filter').select2(); @@ -509,8 +509,12 @@ class AuditLog extends HTML /* Filter management */ $('#button-load-filter').click(function (){ if($('#load-filter-select').length) { - $('#load-filter-select').dialog({width: "20%", - maxWidth: "25%", + $('#load-filter-select').dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto", title: "" }); $.ajax({ @@ -523,8 +527,9 @@ class AuditLog extends HTML }, success: function(data) { var options = ""; + console.log(data) $.each(data,function(key,value){ - options += ""; + options += ""; }); $('#filter_id').html(options); $('#filter_id').select2(); diff --git a/pandora_console/include/class/CalendarManager.class.php b/pandora_console/include/class/CalendarManager.class.php index ba1761d6f9..311559c4e2 100644 --- a/pandora_console/include/class/CalendarManager.class.php +++ b/pandora_console/include/class/CalendarManager.class.php @@ -1040,7 +1040,7 @@ class CalendarManager 'id' => 'templates_alerts_special_days', 'return' => true, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'godmode/alerts/alert_special_days', diff --git a/pandora_console/include/class/ConfigPEN.class.php b/pandora_console/include/class/ConfigPEN.class.php index 2177e73a74..cea6123f08 100644 --- a/pandora_console/include/class/ConfigPEN.class.php +++ b/pandora_console/include/class/ConfigPEN.class.php @@ -612,7 +612,7 @@ class ConfigPEN extends HTML 'id' => $tableId, 'return' => true, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index cb9435b559..9142f9a692 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1807,7 +1807,8 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.PHP.SERIALIZE_PRECISION'); } - if (version_compare('8.1', PHP_VERSION) >= 0) { + // If PHP_VERSION is lower than 8.0.27 version_compare() returns 1. + if (version_compare('8.0.27', PHP_VERSION) === 1) { $url = 'https://www.php.net/supported-versions.php'; $this->notify( [ diff --git a/pandora_console/include/class/CredentialStore.class.php b/pandora_console/include/class/CredentialStore.class.php index b82a129cd1..937f505f8d 100644 --- a/pandora_console/include/class/CredentialStore.class.php +++ b/pandora_console/include/class/CredentialStore.class.php @@ -827,7 +827,7 @@ class CredentialStore extends Wizard [ 'id' => $this->tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index 7483cbca30..2c00a6b328 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -1579,7 +1579,7 @@ class Diagnostics extends Wizard [ 'id' => $tableId, 'class' => 'info_table caption_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columnNames, 'ajax_data' => [ @@ -1591,6 +1591,7 @@ class Diagnostics extends Wizard 'no_sortable_columns' => [-1], 'caption' => $title, 'print' => true, + 'mini_csv' => true, ] ); } else { diff --git a/pandora_console/include/class/EventSound.class.php b/pandora_console/include/class/EventSound.class.php index e485ac4dfb..5658b44324 100644 --- a/pandora_console/include/class/EventSound.class.php +++ b/pandora_console/include/class/EventSound.class.php @@ -320,7 +320,7 @@ class EventSound extends HTML [ 'id' => $this->tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 31cd2550d9..29fa2e3b77 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -162,7 +162,7 @@ class SatelliteAgent extends HTML [ 'id' => $this->tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, diff --git a/pandora_console/include/class/SatelliteCollection.class.php b/pandora_console/include/class/SatelliteCollection.class.php index 8af5f210c8..a1ef24393c 100644 --- a/pandora_console/include/class/SatelliteCollection.class.php +++ b/pandora_console/include/class/SatelliteCollection.class.php @@ -142,7 +142,7 @@ class SatelliteCollection extends HTML [ 'id' => $this->tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index e613ab57bf..c58a9e4619 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -326,7 +326,7 @@ class SnmpConsole extends HTML [ 'id' => $tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index cf0824f626..ae4271fba9 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -475,7 +475,7 @@ class TipsWindow [ 'id' => 'list_tips_windows', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'dom_elements' => 'lpfti', 'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar', 'columns' => $columns, diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 8d81ceee73..ea6f4fe92f 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -336,54 +336,7 @@ class WelcomeWindow extends Wizard public function loadWelcomeWindow() { global $config; - - $btn_configure_mail_class = 'pending'; - $btn_create_agent_class = 'pending'; - $btn_create_module_class = ''; - $btn_create_alert_class = ''; - $btn_create_discovery_class = 'pending'; - - $li_configure_mail_class = 'row_green'; - $li_create_agent_class = 'row_green'; - $li_create_module_class = 'row_grey'; - $li_create_alert_class = 'row_grey'; - $li_create_discovery_class = 'row_green'; - - if (empty($config['welcome_mail_configured']) === false) { - $btn_configure_mail_class = ' completed'; - } - - if (empty($config['welcome_id_agent']) === false) { - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' pending'; - $li_create_module_class = 'row_green'; - } - - if (empty($config['welcome_module']) === false) { - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' pending'; - $li_create_module_class = 'row_green'; - } - - if (empty($config['welcome_alert']) === false) { - $btn_create_alert_class = ' completed'; - $li_create_alert_class = 'row_green'; - } - - if (empty($config['welcome_task']) === false) { - $btn_create_discovery_class = ' completed'; - } - - if ((int) $config['welcome_state'] === WELCOME_FINISHED) { - // Nothing left to do. - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' completed'; - $btn_create_discovery_class = ' completed'; - $li_create_module_class = 'row_green'; - $li_create_alert_class = 'row_green'; - } + $flag_task = false; $form = [ 'action' => '#', @@ -392,207 +345,279 @@ class WelcomeWindow extends Wizard 'class' => 'modal', ]; - $logo_url = 'images/custom_logo/pandora_logo_head_white_bg.png'; - if (enterprise_installed() === true) { $logo_url = ENTERPRISE_DIR.'/'.$logo_url; } - $inputs = [ - [ - 'class' => 'white_box', - 'block_content' => [ - [ - 'class' => 'centered_full', - 'arguments' => [ - 'type' => 'image', - 'src' => $logo_url, - 'value' => 1, - 'return' => true, - ], - ], - ], - ], - [ + if (check_acl($config['id_user'], 0, 'PM')) { + $flag_um = false; + $flag_cm = false; + $flag_su = false; + $flag_lv = false; + + $btn_update_manager_class = ' fail'; + $btn_configure_mail_class = ' fail'; + $btn_servers_up_class = ' fail'; + $btn_license_valid_class = ' fail'; + + $li_update_manager_class = 'row_grey'; + $li_configure_mail_class = 'row_grey'; + $li_servers_up_class = 'row_grey'; + $li_license_valid_class = 'row_grey'; + + include_once 'include/functions_update_manager.php'; + if (update_manager_verify_registration()) { + $btn_update_manager_class = ''; + $li_update_manager_class = 'row_green'; + $flag_um = true; + } + + if (empty($config['welcome_mail_configured']) === false) { + $btn_configure_mail_class = ''; + $li_configure_mail_class = 'row_green'; + $flag_cm = true; + } + + include_once 'include/functions_servers.php'; + if (check_all_servers_up() === true) { + $btn_servers_up_class = ''; + $li_servers_up_class = 'row_green'; + $flag_su = true; + } + + if (enterprise_installed()) { + $license_valid = true; + enterprise_include_once('include/functions_license.php'); + $license = enterprise_hook('license_get_info'); + $days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24)); + if ($license === ENTERPRISE_NOT_HOOK || $days_to_expiry <= 30) { + $license_valid = false; + } + + if ($license_valid === true) { + $btn_license_valid_class = ''; + $li_license_valid_class = 'row_green'; + $flag_lv = true; + } else { + $btn_license_valid_class = 'fail'; + $li_license_valid_class = 'row_grey'; + $flag_lv = false; + } + } else { + $btn_license_valid_class = 'fail'; + $li_license_valid_class = 'row_grey'; + $flag_lv = false; + } + + $inputs[] = [ 'wrapper' => 'div', - 'block_id' => 'div_configure_mail', - 'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class, + 'block_id' => 'div_diagnosis', + 'class' => 'flex-row flex-items-center w98p ', 'direct' => 1, 'block_content' => [ [ - 'label' => __('Please ensure mail configuration matches your needs'), + 'label' => __('Post-installation status diagnostic'), 'arguments' => [ 'class' => 'first_lbl', - 'name' => 'lbl_create_agent', - 'id' => 'lbl_create_agent', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important', - 'mode' => 'onlyIcon', - ], - 'name' => 'btn_email_conf', - 'id' => 'btn_email_conf', + 'name' => 'lbl_diagnosis', + 'id' => 'lbl_diagnosis', ], ], ], - ], - [ - 'label' => 'Learn to monitor', - 'class' => 'extra', - 'arguments' => [ - 'class' => 'class="lbl_learn"', - 'name' => 'lbl_learn', - 'id' => 'lbl_learn', - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_create_agent', - 'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_agent_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create an agent'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_create_agent', - 'id' => 'lbl_create_agent', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_agent_class) === false) ? $btn_create_agent_class : 'invisible_important', - 'mode' => 'onlyIcon', + ]; + + if ($flag_um === false || $flag_cm === false || $flag_su === false || $flag_lv === false) { + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_update_manager', + 'class' => 'hole flex-row flex-items-center w98p '.$li_update_manager_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Warp Update registration'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_update_manager', + 'id' => 'lbl_update_manager', ], - 'name' => 'btn_create_agent', - 'id' => 'btn_create_agent', ], - ], - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_monitor_actions', - 'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_module_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Create a module to check if an agent is online'), - 'arguments' => [ - 'class' => 'second_lbl', - 'name' => 'lbl_check_agent', - 'id' => 'lbl_check_agent', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_module_class) === false) ? $btn_create_module_class : 'invisible_important', - 'mode' => 'onlyIcon', + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_update_manager_class) === false) ? $btn_update_manager_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_update_manager_conf', + 'id' => 'btn_update_manager_conf', ], - 'name' => 'btn_create_module', - 'id' => 'btn_create_module', ], ], - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_monitor_actions', - 'class' => 'hole learn_content_indented flex-row flex-items-center w98p '.$li_create_alert_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Be warned if something is wrong, create an alert on the module'), - 'arguments' => [ - 'class' => 'second_lbl', - 'name' => 'lbl_create_alert', - 'id' => 'lbl_create_alert', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_alert_class) === false) ? $btn_create_alert_class : 'invisible_important', - 'mode' => 'onlyIcon', + ]; + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_configure_mail', + 'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Default mail to send alerts'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_create_agent', + 'id' => 'lbl_create_agent', ], - 'name' => 'btn_create_alert', - 'id' => 'btn_create_alert', ], - ], - ], - ], - [ - 'wrapper' => 'div', - 'block_id' => 'div_discover', - 'class' => 'hole flex-row flex-items-center w98p '.$li_create_discovery_class, - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Discover hosts and devices in your network'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_discover_devices', - 'id' => 'lbl_discover_devices', - ], - ], - [ - 'arguments' => [ - 'label' => '', - 'type' => 'button', - 'attributes' => [ - 'class' => (empty($btn_create_discovery_class) === false) ? $btn_create_discovery_class : 'invisible_important', - 'mode' => 'onlyIcon', + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_email_conf', + 'id' => 'btn_email_conf', ], - 'name' => 'btn_discover_devices', - 'id' => 'btn_discover_devices', ], ], + ]; + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_servers_up', + 'class' => 'hole flex-row flex-items-center w98p '.$li_servers_up_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('All servers running'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_servers_up', + 'id' => 'lbl_servers_up', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_servers_up_class) === false) ? $btn_servers_up_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_servers_up_conf', + 'id' => 'btn_servers_up_conf', + ], + ], + ], + ]; + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_license_valid', + 'class' => 'hole flex-row flex-items-center w98p '.$li_license_valid_class, + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Enterprise licence valid'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_license_valid', + 'id' => 'lbl_license_valid', + ], + ], + [ + 'arguments' => [ + 'label' => '', + 'type' => 'button', + 'attributes' => [ + 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], + 'name' => 'btn_license_valid_conf', + 'id' => 'btn_license_valid_conf', + ], + ], + ], + ]; + } else { + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_all_correct', + 'class' => 'hole flex-row flex-items-center w98p', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('It seems that your Pandora FMS is working correctly and registered with ID:
#'.$config['pandora_uid'].'.
For more information use the self-diagnosis tool.'), + 'arguments' => [ + 'class' => 'first_lbl w98p', + 'name' => 'lbl_all_correct', + 'id' => 'lbl_all_correct', + ], + ], + ], + ]; + } + + if ($flag_um === false || $flag_cm === false || $flag_su === false || $flag_lv === false) { + $flag_task = true; + } + } + + // Task to do. + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_task_todo', + 'class' => 'flex-row flex-items-center w98p', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Task to perform'), + 'arguments' => [ + 'class' => 'first_lbl', + 'name' => 'lbl_task_todo', + 'id' => 'lbl_task_todo', + ], ], ], ]; - if (enterprise_installed() === true) { - $inputs[] = [ - 'wrapper' => 'div', - 'block_id' => 'div_not_working', - 'class' => 'hole flex-row flex-items-center w98p', - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('If something is not working as expected, look for this icon and report!'), - 'arguments' => [ - 'class' => 'first_lbl', - 'name' => 'lbl_not_working', - 'id' => 'lbl_not_working', - ], - ], - [ - 'label' => html_print_image( - 'images/feedback-header.png', - true, - [ - 'onclick' => '$(\'#feedback-header\').click()', - 'style' => 'cursor: pointer;', - ] - ), + $fields['wizard_agent'] = __('Agent installation wizard'); + $fields['check_web'] = __('Create WEB monitoring'); + $fields['check_connectivity'] = __('Create network monitoring'); + $fields['check_net'] = __('Discover my network'); + $fields['check_mail_alert'] = __('Create email alert'); + $inputs[] = [ + 'wrapper' => 'div', + 'block_id' => 'div_wizard_agent', + 'class' => 'flex space-between w98p', + 'direct' => 1, + 'block_content' => [ + [ + 'arguments' => [ + 'type' => 'select', + 'fields' => $fields, + 'name' => 'task_to_perform', + 'selected' => '', + 'return' => true, + 'nothing' => \__('Please select one'), + 'nothing_value' => '', ], ], - ]; - } + [ + 'arguments' => [ + 'label' => __("Let's do it!"), + 'type' => 'button', + 'attributes' => [ + 'class' => 'secondary', + 'icon' => 'next', + ], + 'name' => 'go_wizard', + 'id' => 'go_wizard', + ], + ], + ], + ]; $output = $this->printForm( [ @@ -602,9 +627,235 @@ class WelcomeWindow extends Wizard true ); - $output .= $this->loadJS(); + $output .= $this->loadJS($flag_task); echo $output; + ?> + + + + + setHtml($response); + /* + //For debug url with parameters. + $navigation = $page->navigate($url.'?data='.urlencode(json_encode($data))); + $navigation->waitForNavigation(Page::DOM_CONTENT_LOADED); + */ // Dynamic. $dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue(); diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2c09fda820..940e9e3e7f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2770,6 +2770,69 @@ function agents_delete_agent($id_agents, $disableACL=false) enterprise_include_once('include/functions_agents.php'); enterprise_hook('agent_delete_from_cache', [$id_agent]); + // Delete agent from visual console. + db_process_sql_delete( + 'tlayout_data', + ['id_agent' => $id_agent] + ); + + // Delete agent from visual dashboards. + db_process_sql( + 'UPDATE twidget_dashboard + SET options = NULL + WHERE options LIKE ("%\"agentid\":\"'.$id_agent.'\"%")' + ); + + // Delete agent from treport. + db_process_sql_delete( + 'treport_content', + ['id_agent' => $id_agent] + ); + + // Delete rules from tevent alerts (correlative alerts) + db_process_sql_delete( + 'tevent_rule', + [ + 'agent' => $id_agent, + 'operator_agent' => '==', + ] + ); + + db_process_sql_delete( + 'tevent_rule', + [ + 'log_agent' => $id_agent, + 'operator_log_agent' => '==', + ] + ); + + // Delete from gis maps history + db_process_sql_delete( + 'tgis_data_history', + ['tagente_id_agente' => $id_agent] + ); + + // Delete from policies. + db_process_sql_delete( + 'tpolicy_agents', + ['id_agent' => $id_agent] + ); + + // Delete from tnetwork maps + db_process_sql_delete( + 'titem', + ['source_data' => $id_agent] + ); + + db_process_sql_delete( + 'trel_item', + [ + 'id_parent_source_data' => $id_agent, + 'id_child_source_data' => $id_agent, + ], + 'OR' + ); + // Delete agent from fav menu. db_process_sql_delete( 'tfavmenu_user', diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index eec1ba849e..8d51a3b536 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -455,7 +455,7 @@ function alerts_delete_alert_action($id_alert_action) * * @return mixed Id of the cloned action or false in case of fail. */ -function alerts_clone_alert_action($id_alert_action, $id_group) +function alerts_clone_alert_action($id_alert_action, $id_group, $copy_name='') { $id_alert_action = safe_int($id_alert_action, 1); if (empty($id_alert_action)) { @@ -474,7 +474,13 @@ function alerts_clone_alert_action($id_alert_action, $id_group) unset($action['id']); - return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action); + if ($copy_name !== '') { + $copy_name = $copy_name; + } else { + $copy_name = $action['name'].' '.__('copy'); + } + + return alerts_create_alert_action($copy_name, $action['id_alert_command'], $action); } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 095b71f61b..16b0372f74 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1916,7 +1916,7 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params) * * @param $thrash3 Don't use. */ -function api_set_new_agent($id_node, $thrash2, $other, $trhash3) +function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false) { global $config; @@ -2038,13 +2038,17 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3) } } - returnData( - 'string', - [ - 'type' => 'string', - 'data' => $id_agente, - ] - ); + if ($return === false) { + returnData( + 'string', + [ + 'type' => 'string', + 'data' => $id_agente, + ] + ); + } else { + return $id_agente; + } } catch (\Exception $e) { returnError($e->getMessage()); return; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 7a82254cf8..0fac943076 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -378,6 +378,10 @@ function config_update_config() $error_update[] = __('keep_in_process_status_extra_id'); } + if (config_update_value('show_experimental_features', get_parameter('show_experimental_features'), true) === false) { + $error_update[] = __('show_experimental_features'); + } + if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) { $error_update[] = __('Console log enabled'); } @@ -627,6 +631,30 @@ function config_update_config() $error_update[] = __('Domain'); } + if (config_update_value('secondary_active_directory', get_parameter('secondary_active_directory'), true) === false) { + $error_update[] = __('Secondary active directory'); + } + + if (config_update_value('ad_server_secondary', get_parameter('ad_server_secondary'), true) === false) { + $error_update[] = __('Secondary active directory server'); + } + + if (config_update_value('ad_port_secondary', get_parameter('ad_port_secondary'), true) === false) { + $error_update[] = __('Secondary active directory port'); + } + + if (config_update_value('ad_start_tls_secondary', get_parameter('ad_start_tls_secondary'), true) === false) { + $error_update[] = __('Secondary start TLS'); + } + + if (config_update_value('ad_search_timeout', get_parameter('ad_search_timeout'), true) === false) { + $error_update[] = __('AD search timeout'); + } + + if (config_update_value('ad_domain_secondary', get_parameter('ad_domain_secondary'), true) === false) { + $error_update[] = __('Secondary domain'); + } + if (config_update_value('ad_adv_perms', get_parameter('ad_adv_perms'), true) === false) { $error_update[] = __('Advanced Permisions AD'); } @@ -2377,6 +2405,10 @@ function config_process_config() config_update_value('keep_in_process_status_extra_id', 0); } + if (!isset($config['show_experimental_features'])) { + config_update_value('show_experimental_features', 0); + } + if (!isset($config['console_log_enabled'])) { config_update_value('console_log_enabled', 0); } @@ -3100,6 +3132,14 @@ function config_process_config() config_update_value('ad_port', 389); } + if (!isset($config['ad_server_secondary'])) { + config_update_value('ad_server_secondary', 'localhost'); + } + + if (!isset($config['ad_port_secondary'])) { + config_update_value('ad_port_secondary', 389); + } + if (!isset($config['ad_start_tls'])) { config_update_value('ad_start_tls', 0); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 116deea959..c35e553235 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4624,7 +4624,10 @@ function graph_netflow_circular_mesh($data) include_once $config['homedir'].'/include/graphs/functions_d3.php'; - return d3_relationship_graph($data['elements'], $data['matrix'], 900, true); + $width = (empty($data['width']) === false) ? $data['width'] : 900; + $height = (empty($data['height']) === false) ? $data['height'] : 900; + + return d3_relationship_graph($data['elements'], $data['matrix'], $width, true, $height); } @@ -4983,19 +4986,18 @@ function graph_monitor_wheel($width=550, $height=600, $filter=false) $filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false; if ($filter['group'] != 0) { - $filter_subgroups = ''; - if (!$filter['dont_show_subgroups']) { - $filter_subgroups = ' || parent IN ('.$filter['group'].')'; + if ($filter['dont_show_subgroups'] === false) { + $groups = groups_get_children($filter['group']); + $groups_ax = []; + foreach ($groups as $g) { + $groups_ax[$g['id_grupo']] = $g; + } + + $groups = $groups_ax; + } else { + $groups = groups_get_group_by_id($filter['group']); + $groups[$group['id_grupo']] = $group; } - - $groups = db_get_all_rows_sql('SELECT * FROM tgrupo where id_grupo IN ('.$filter['group'].') '.$filter_subgroups); - - $groups_ax = []; - foreach ($groups as $g) { - $groups_ax[$g['id_grupo']] = $g; - } - - $groups = $groups_ax; } else { $groups = users_get_groups(false, 'AR', false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 100e85b610..6563c78eb6 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -671,6 +671,7 @@ function html_print_select_groups( step: params.page || 1, strict: "", not_condition: $('#not_condition_switch').prop('checked'), + returnAllGroup: } return query; @@ -5503,7 +5504,10 @@ function html_print_input($data, $wrapper='div', $input_only=false) ($data['attributes'] ?? null), ((isset($data['return']) === true) ? $data['return'] : false), ((isset($data['password']) === true) ? $data['password'] : false), - ((isset($data['function']) === true) ? $data['function'] : '') + ((isset($data['function']) === true) ? $data['function'] : ''), + ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : 'off'), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['hide_div_eye']) === true) ? $data['hide_div_eye'] : false), ); break; @@ -7194,3 +7198,44 @@ function html_print_code_picker( echo $output; } } + + +function html_print_wizard_diagnosis( + $title, + $id_button, + $description='', + $status=true, + $return=false, +) { + $button = ''; + if ($status === true) { + $status = 'Connected'; + $img = '/images/configuration@svg.svg'; + } else { + $status = 'Disconnected'; + $img = '/images/change-active.svg'; + } + + $button = html_print_image( + $img, + true, + [ + 'class' => 'main_menu_icon invert_filter float-right mrgn_right_10px', + 'id' => $id_button, + ] + ); + + $output = '
+ '.__($status).$button.' +
'.html_print_image('/images/circle_title.svg', true, ['class' => 'invert_filter']).''.$title.'
+
+ '.$description.' +
+
'; + + if ($return === true) { + return $output; + } else { + echo $output; + } +} \ No newline at end of file diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 4878333071..ff18544586 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -324,6 +324,8 @@ function menu_print_menu(&$menu) if (isset($sub['subtype']) && $sub['subtype'] == 'nolink') { $submenu_output .= ''; + } else if (isset($sub['subtype']) && $sub['subtype'] == 'nolink_no_arrow') { + $submenu_output .= ''; } else if (isset($sub['subtype']) && $sub['subtype'] == 'new_blank') { $submenu_output .= '
'.$sub['text'].'
'; } else { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index b670088f85..a039fcbc07 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -743,7 +743,8 @@ function modules_create_agent_module( string $name, array $values=[], bool $disableACL=false, - $tags=false + $tags=false, + $use_agent_ip=false, ) { global $config; @@ -785,6 +786,10 @@ function modules_create_agent_module( return ERR_EXIST; } + if ($use_agent_ip === true) { + $values['ip_target'] = agents_get_address($id_agent); + } + // Encrypt passwords. if (isset($values['plugin_pass']) === true) { // Avoid two times encryption. diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 59d02ccb4f..79fcd9a0db 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1233,7 +1233,9 @@ function netflow_draw_item( $max_aggregates, $connection_name='', $output='HTML', - $address_resolution=false + $address_resolution=false, + $width_content=false, + $height_content=false ) { $aggregate = $filter['aggregate']; $interval = ($end_date - $start_date); @@ -1432,6 +1434,9 @@ function netflow_draw_item( netflow_aggregate_is_ip($aggregate) ); + $data_circular['width'] = $width_content; + $data_circular['height'] = $height_content; + $html = '
'; $html .= graph_netflow_circular_mesh($data_circular); $html .= '
'; @@ -1734,7 +1739,12 @@ function netflow_get_top_summary( switch ($top_action) { case 'listeners': if (empty(!$filter)) { - $netflow_filter['ip_src'] = $filter; + if (!is_array($filter)) { + $netflow_filter['ip_src'] = $filter; + } else { + $netflow_filter['ip_src'] = $filter['ip']; + $netflow_filter['advanced_filter'] = $filter['advanced_filter']; + } } $sort = 'dstip'; @@ -1742,7 +1752,12 @@ function netflow_get_top_summary( case 'talkers': if (empty(!$filter)) { - $netflow_filter['ip_dst'] = $filter; + if (!is_array($filter)) { + $netflow_filter['ip_dst'] = $filter; + } else { + $netflow_filter['ip_dst'] = $filter['ip']; + $netflow_filter['advanced_filter'] = $filter['advanced_filter']; + } } $sort = 'srcip'; @@ -2069,7 +2084,7 @@ function netflow_aggregate_is_ip($aggregate) * * @return array With map structure. */ -function netflow_build_map_data($start_date, $end_date, $top, $aggregate) +function netflow_build_map_data($start_date, $end_date, $top, $aggregate, $advanced_filter='') { // Pass an empty filter data structure. $data = netflow_get_relationships_raw_data( @@ -2083,7 +2098,7 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate) 'ip_src' => '', 'dst_port' => '', 'src_port' => '', - 'advanced_filter' => '', + 'advanced_filter' => $advanced_filter, 'router_ip' => '', ], $top, diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index f42b791e8f..ebc2bb414d 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1411,3 +1411,24 @@ function servers_get_master() return $result; } + + +/** + * Return true if all servers are up. + * + * @return boolean + */ +function check_all_servers_up() +{ + $status = true; + + $servers = servers_get_info(); + + foreach ($servers as $server) { + if ($server['status'] !== '1') { + return false; + } + } + + return $status; +} diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 745d61ef51..38ecabb0e0 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -1291,7 +1291,8 @@ function snmp_browser_create_modules_snmp( string $module_target, array $snmp_values, ?array $id_target, - ?string $server_to_exec=null + ?string $server_to_exec=null, + ?string $use_agent_ip='' ) { $target_ip = null; $target_port = null; @@ -1350,6 +1351,12 @@ function snmp_browser_create_modules_snmp( } } + if (empty($use_agent_ip) === false) { + $use_agent_ip = true; + } else { + $use_agent_ip = false; + } + $fail_modules = []; foreach ($targets_oids as $key => $target_oid) { @@ -1514,7 +1521,7 @@ function snmp_browser_create_modules_snmp( 'history_data' => 1, ]; foreach ($id_target as $agent) { - $ids[] = modules_create_agent_module($agent, $oid['oid'], $values); + $ids[] = modules_create_agent_module($agent, $oid['oid'], $values, false, false, $use_agent_ip); } } else if ($module_target == 'policy') { // Policies only in enterprise version. @@ -1803,6 +1810,16 @@ function snmp_browser_print_create_module_massive( true ); + $table->data[4][0] = html_print_label_input_block( + __('Use agent IP'), + html_print_checkbox( + 'use_agent_ip', + 1, + false, + true + ) + ); + $output .= html_print_table($table, true); // SNMP extradata. diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index b2341ff6c9..90213d96dd 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -795,8 +795,14 @@ function tags_get_acl_tags( $acltags = []; foreach ($raw_acltags as $group => $taglist) { - if (empty($id_group) === false && array_key_exists($group, $id_group) === false) { - continue; + if ($return_mode === 'module_condition') { + if (!empty($id_group) && !in_array($group, $id_group)) { + continue; + } + } else { + if (empty($id_group) === false && array_key_exists($group, $id_group) === false) { + continue; + } } if (!empty($taglist)) { diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 33b164a330..b408567aeb 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -650,16 +650,28 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) // Agent name. $row = []; $row['title'] = __('Agent name'); - $row['data'] = html_print_anchor( - [ - 'href' => 'javascript:void(0)', - 'title' => __('Click here for view this agent'), - 'class' => 'font_11', - 'content' => $cellName, - 'onClick' => "sendHash('".$urlAgent."')", - ], - true - ); + if (is_metaconsole() === true) { + $row['data'] = html_print_anchor( + [ + 'href' => 'javascript:void(0)', + 'title' => __('Click here for view this agent'), + 'class' => 'font_11', + 'content' => $cellName, + 'onClick' => "sendHash('".$urlAgent."')", + ], + true + ); + } else { + $row['data'] = html_print_anchor( + [ + 'href' => $urlAgent, + 'title' => __('Click here for view this agent'), + 'class' => 'font_11', + 'content' => $cellName, + ], + true + ); + } $table->data['name'] = $row; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 80837ec422..6c1b7c6905 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3324,6 +3324,32 @@ function ui_print_module_status( } +/** + * Returns html code to print a shape for a module. + * + * @param integer $color Hex color. + * @param boolean $return True or false. + * @param string $class Custom class or use defined. + * @param string $div_content Content. + * + * @return string HTML code for shape. + */ +function ui_print_diagnosis_status( + $color, + $return=false, + $class='status_rounded_rectangles', + $div_content='' +) { + $output = '
'.$div_content.'
'; + + if ($return === false) { + echo $output; + } + + return $output; +} + + /** * Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status. * @@ -3716,28 +3742,71 @@ function ui_progress_extend( * Generate needed code to print a datatables jquery plugin. * * @param array $parameters All desired data using following format: - * [ - * 'print' => true (by default printed) - * 'id' => datatable id. - * 'class' => datatable class. - * 'style' => datatable style. - * 'order' => [ - * 'field' => column name - * 'direction' => asc or desc - * ], - * 'default_pagination' => integer, default pagination is set to block_size - * 'ajax_url' => 'include/ajax.php' ajax_url. - * 'ajax_data' => [ operation => 1 ] extra info to be sent. - * 'ajax_postprocess' => a javscript function to postprocess data received - * by ajax call. It is applied foreach row and must - * use following format: - * * [code] - * * function (item) { - * * // Process received item, for instance, name: - * * tmp = '' + item.name + ''; - * * item.name = tmp; - * * } - * * [/code] + * + * ```php + * $parameters = [ + * // JS Parameters + * 'serverside' => true, + * 'paging' => true, + * 'default_pagination' => $config['block_size'], + * 'searching' => false, + * 'dom_elements' => "plfrtiB", + * 'pagination_options' => [default_pagination, 5, 10, 20, 100, 200, 500, 1000, "All"], + * 'ordering' => true, + * 'order' => [[0, "asc"]], //['field' => 'column_name', 'direction' => 'asc/desc'] + * 'zeroRecords' => "No matching records found", + * 'emptyTable' => "No data available in table", + * 'no_sortable_columns' => [], //Allows the column name (db) from "columns" parameter + * 'csv_field_separator' => ",", + * 'csv_header' => true, + * 'mini_csv' => false, + * 'mini_pagination' => false, + * 'mini_search' => false, + * 'drawCallback' => undefined, //'console.log(123),' + * 'data_element' => undefined, //Rows processed + * 'ajax_postprocess' => undefined, //'process_datatables_item(item)' + * 'ajax_data' => undefined, //Extra data to be sent ['field1' => 1, 'field2 => 0] + * 'ajax_url' => undefined, + * 'caption' => undefined, + * + * // PHP Parameters + * 'id' => undefined, //Used for table and form id, + * 'columns' =>, + * 'column_names' =>, + * 'filter_main_class' =>, + * 'toggle_collapsed' =>true, + * 'search_button_class' => 'sub filter', + * 'csv' =>=1, + * 'form' => + * ..[ + * ....'id' => $form_id, + * ....'class' => 'flex-row', + * ....'style' => 'width: 100%,', + * ....'js' => '', + * ....'html' => $filter, + * ....'inputs' => [], + * ....'extra_buttons' => $buttons, + * ..], + * 'no_toggle' => false, + * 'form_html' => undefined, + * 'toggle_collapsed' => true, + * 'class' => "", //Datatable class. + * 'style' => "" ,//Datatable style. + * 'return' => false, + * 'print' => true, + * ] + * + * ``` + * + * ```php + * ajax_postprocess => a javscript function to postprocess data received + * by ajax call. It is applied foreach row and must + * use following format: + * function (item) { + * // Process received item, for instance, name: + * tmp = '' + item.name + ''; + * item.name = tmp; + * } * 'columns_names' => [ * 'column1' :: Used as th text. Direct text entry. It could be array: * OR @@ -3754,7 +3823,6 @@ function ui_progress_extend( * 'column2', * ... * ], - * 'no_sortable_columns' => [ indexes ] 1,2... -1 etc. Avoid sorting. * 'form' => [ * 'html' => 'html code' a directly defined inputs in HTML. * 'extra_buttons' => [ @@ -3786,12 +3854,7 @@ function ui_progress_extend( * ] * ], * 'extra_html' => HTML content to be placed after 'filter' section. - * 'drawCallback' => function to be called after draw. Sample in: - * https://datatables.net/examples/advanced_init/row_grouping.html - * ] - * 'zeroRecords' => Message when zero records obtained from filter.(Leave blank for default). - * 'emptyTable' => Message when table data empty.(Leave blank for default). - * End. + * ``` * * @return string HTML code with datatable. * @throws Exception On error. @@ -3808,6 +3871,9 @@ function ui_print_datatable(array $parameters) $form_id = uniqid('datatable_filter_'); } + $parameters['table_id'] = $table_id; + $parameters['form_id'] = $form_id; + if (!isset($parameters['columns']) || !is_array($parameters['columns'])) { throw new Exception('[ui_print_datatable]: You must define columns for datatable'); } @@ -3827,10 +3893,6 @@ function ui_print_datatable(array $parameters) $parameters['default_pagination'] = $config['block_size']; } - if (!isset($parameters['paging'])) { - $parameters['paging'] = true; - } - if (!isset($parameters['filter_main_class'])) { $parameters['filter_main_class'] = ''; } @@ -3839,13 +3901,9 @@ function ui_print_datatable(array $parameters) $parameters['toggle_collapsed'] = true; } - $no_sortable_columns = json_encode([]); - if (isset($parameters['no_sortable_columns'])) { - $no_sortable_columns = json_encode($parameters['no_sortable_columns']); - } - if (!is_array($parameters['order'])) { - $order = '0, "asc"'; + $order = 0; + $direction = 'asc'; } else { if (!isset($parameters['order']['direction'])) { $direction = 'asc'; @@ -3864,47 +3922,35 @@ function ui_print_datatable(array $parameters) } } - $order .= ', "'.$parameters['order']['direction'].'"'; + $direction = $parameters['order']['direction']; } - if (!isset($parameters['ajax_data'])) { - $parameters['ajax_data'] = ''; + $parameters['order']['order'] = $order; + $parameters['order']['direction'] = $direction; + + foreach ($parameters['no_sortable_columns'] as $key => $find) { + $found = array_search( + $parameters['no_sortable_columns'][$key], + $parameters['columns'] + ); + + if ($found !== false) { + unset($parameters['no_sortable_columns'][$key]); + array_push($parameters['no_sortable_columns'], $found); + } + + if (is_int($parameters['no_sortable_columns'][$key]) === false) { + unset($parameters['no_sortable_columns'][$key]); + } } - $search_button_class = 'sub filter'; + $parameters['csvTextInfo'] = __('Export current page to CSV'); + $parameters['csvFileTitle'] = sprintf(__('export_%s_current_page_%s'), $table_id, date('Y-m-d')); + if (isset($parameters['search_button_class'])) { $search_button_class = $parameters['search_button_class']; - } - - if (isset($parameters['pagination_options'])) { - $pagination_options = $parameters['pagination_options']; } else { - $pagination_options = [ - [ - // There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows. - // -1 Retun error or only 1 row. - $parameters['default_pagination'], - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - 18446744073709551615, - ], - [ - $parameters['default_pagination'], - 5, - 10, - 25, - 100, - 200, - 500, - 1000, - 'All', - ], - ]; + $search_button_class = 'sub filter'; } if (isset($parameters['datacolumns']) === false @@ -3917,16 +3963,12 @@ function ui_print_datatable(array $parameters) $parameters['csv'] = 1; } - $dom_elements = '"plfrtiB"'; - if (isset($parameters['dom_elements'])) { - $dom_elements = '"'.$parameters['dom_elements'].'"'; - } - $filter = ''; // Datatable filter. if (isset($parameters['form']) && is_array($parameters['form'])) { if (isset($parameters['form']['id'])) { $form_id = $parameters['form']['id']; + $parameters['form_id'] = $form_id; } if (isset($parameters['form']['class'])) { @@ -4044,10 +4086,13 @@ function ui_print_datatable(array $parameters) ) ); $processing .= '
'; + $parameters['processing'] = $processing; $zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found'); $emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table'); + $parameters['zeroRecords'] = $zeroRecords; + $parameters['emptyTable'] = $emptyTable; // Extra html. $extra = ''; if (isset($parameters['extra_html']) && !empty($parameters['extra_html'])) { @@ -4056,8 +4101,8 @@ function ui_print_datatable(array $parameters) // Base table. $table = ''; + $table .= 'class="'.$parameters['class'].'"'; + $table .= 'style="box-sizing: border-box;'.$parameters['style'].'">'; $table .= ''; if (isset($parameters['column_names']) @@ -4084,335 +4129,60 @@ function ui_print_datatable(array $parameters) } $table .= ''; - - if (isset($parameters['data_element']) === true) { - $table .= ''; - foreach ($parameters['data_element'] as $row) { - $table .= ''; - foreach ($row as $td_data) { - $table .= ''; - } - - $table .= ''; - } - - $table .= ''; - - $js = ''; - } - $table .= '
'.$td_data.'
'; - $pagination_class = 'pandora_pagination'; - if (!empty($parameters['pagination_class'])) { - $pagination_class = $parameters['pagination_class']; + $parameters['ajax_url_full'] = ui_get_full_url('ajax.php', false, false, false); + + $parameters['spinnerLoading'] = html_print_image( + 'images/spinner.gif', + true, + [ + 'id' => $form_id.'_loading', + 'class' => 'loading-search-datatables-button', + ] + ); + + $language = substr(get_user_language(), 0, 2); + if (is_metaconsole() === false) { + $parameters['language'] = 'include/javascript/i18n/dataTables.'.$language.'.json'; + } else { + $parameters['language'] = '../../include/javascript/i18n/dataTables.'.$language.'.json'; } - $columns = ''; - for ($i = 1; $i <= (count($parameters['columns']) - 3); $i++) { - if ($i != (count($parameters['columns']) - 3)) { - $columns .= $i.','; - } else { - $columns .= $i; - } + $parameters['phpDate'] = date('Y-m-d'); + $parameters['dataElements'] = json_encode($parameters['data_element']); + + // * START JAVASCRIPT. + if (is_metaconsole() === false) { + $file_path = ui_get_full_url('include/javascript/datatablesFunction.js'); + } else { + $file_path = ui_get_full_url('../../include/javascript/datatablesFunction.js'); } - $export_columns = ''; - if (isset($parameters['csv_exclude_latest']) === true - && $parameters['csv_exclude_latest'] === true - ) { - $export_columns = ',columns: \'th:not(:last-child)\''; - } + $file_content = file_get_contents($file_path); + $json_data = json_encode($parameters); + $json_config = json_encode($config); - if (isset($parameters['data_element']) === false || isset($parameters['print_pagination_search_csv'])) { - if (isset($parameters['ajax_url'])) { - $type_data = 'ajax: { - url: "'.ui_get_full_url('ajax.php', false, false, false).'", - type: "POST", - dataSrc: function (json) { - if($("#'.$form_id.'_search_bt") != undefined) { - $("#'.$form_id.'_loading").remove(); - } + $js = ''; - if (json.error) { - console.error(json.error); - $("#error-'.$table_id.'").html(json.error); - $("#error-'.$table_id.'").dialog({ - title: "Filter failed", - width: 630, - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - buttons: { - "Ok" : function () { - $(this).dialog("close"); - } - } - }).parent().addClass("ui-state-error"); - } else {'; - - if (isset($parameters['ajax_return_operation']) === true - && empty($parameters['ajax_return_operation']) === false - && isset($parameters['ajax_return_operation_function']) === true - && empty($parameters['ajax_return_operation_function']) === false - ) { - $type_data .= ' - if (json.'.$parameters['ajax_return_operation'].' !== undefined) { - '.$parameters['ajax_return_operation_function'].'(json.'.$parameters['ajax_return_operation'].'); - } - '; - } - - if (isset($parameters['ajax_postprocess'])) { - $type_data .= ' - if (json.data) { - json.data.forEach(function(item) { - '.$parameters['ajax_postprocess'].' - }); - } else { - json.data = {}; - }'; - } - - $type_data .= ' - return json.data; - } - }, - data: function (data) { - if($("#button-'.$form_id.'_search_bt") != undefined) { - var loading = \''.html_print_image( - 'images/spinner.gif', - true, - [ - 'id' => $form_id.'_loading', - 'class' => 'loading-search-datatables-button', - ] - ).'\'; - $("#button-'.$form_id.'_search_bt").parent().append(loading); - } - - inputs = $("#'.$form_id.' :input"); - - values = {}; - inputs.each(function() { - values[this.name] = $(this).val(); - }) - - $.extend(data, { - filter: values,'."\n"; - - if (is_array($parameters['ajax_data'])) { - foreach ($parameters['ajax_data'] as $k => $v) { - $type_data .= $k.':'.json_encode($v).",\n"; - } - } - - $type_data .= 'page: "'.$parameters['ajax_url'].'" - }); - - return data; - } - },'; - } else { - $type_data = 'data: '.json_encode($parameters['data_element']).','; - } - - $serverside = 'true'; - if (isset($parameters['data_element'])) { - $serverside = 'false'; - } - - // Javascript controller. - $js = ''; - } - - // Order. + $js .= ''; + // * END JAVASCRIPT. $info_msg_arr = []; $info_msg_arr['message'] = $emptyTable; $info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id; - $spinner = '
'; + $spinner = '
'; $info_msg = '
'.ui_print_info_message($info_msg_arr).'
'; + $err_msg = '
'; $output = $info_msg.$err_msg.$filter.$extra.$spinner.$table.$js; if (is_ajax() === false) { @@ -4436,7 +4206,7 @@ function ui_print_datatable(array $parameters) false, false ); - $output .= '?v='.$config['current_package'].'"/>'; + $output .= '"/>'; // Load tables.css. $output .= ' 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, $module_name.'_latency', $array_values); +} + + +/** + * Create_module_status_goliat and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $module_name Module name. + * @param mixed $id_group Id group. + * @param mixed $url_search Url to search. + * @param mixed $string_search Text to search. + * + * @return interger Module id. + */ +function create_module_status_goliat($id_agent, $module_name, $id_group, $url_search, $string_search='') +{ + if ($string_search !== '') { + $str_search = 'check_string '.$string_search.' '; + } + + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '31', + 'descripcion' => '', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => 'task_begin +get '.$url_search.' +resource 1 +'.$str_search.' +task_end', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '7', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, $module_name.'_status', $array_values); +} + + +/** + * Create module basic network and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_basic_network($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '6', + 'descripcion' => 'Basic network check (ping)', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => $ip_target, + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '2', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '0', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Check', $array_values); +} + + +/** + * Create module latency network and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_latency_network($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '7', + 'descripcion' => 'Basic network connectivity check to measure network latency in miliseconds', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => $ip_target, + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '0', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '2', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '1', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Latency', $array_values); +} + + +/** + * Create module packet lost and return module id. + * + * @param mixed $id_agent Id agent. + * @param mixed $id_group Id group. + * @param mixed $ip_target Ip target. + * + * @return interger Module id. + */ +function create_module_packet_lost($id_agent, $id_group, $ip_target) +{ + include_once 'include/functions_modules.php'; + + $array_values = [ + 'id_tipo_modulo' => '1', + 'descripcion' => 'Basic network connectivity check to measure packet loss in %', + 'max' => '0', + 'min' => '0', + 'snmp_oid' => '', + 'snmp_community' => 'public', + 'id_module_group' => $id_group, + 'module_interval' => '300', + 'module_ff_interval' => '0', + 'ip_target' => '', + 'tcp_port' => '0', + 'tcp_rcv' => '', + 'tcp_send' => '', + 'id_export' => '0', + 'plugin_user' => '', + 'plugin_pass' => '0', + 'plugin_parameter' => '', + 'id_plugin' => '9', + 'post_process' => '0', + 'prediction_module' => '0', + 'max_timeout' => '0', + 'max_retries' => '0', + 'disabled' => '', + 'id_modulo' => '4', + 'custom_id' => '', + 'history_data' => '1', + 'dynamic_interval' => '0', + 'dynamic_max' => '0', + 'dynamic_min' => '0', + 'dynamic_two_tailed' => '1', + 'parent_module_id' => '0', + 'min_warning' => '0', + 'max_warning' => '0', + 'str_warning' => '', + 'min_critical' => '0', + 'max_critical' => '0', + 'str_critical' => '', + 'custom_string_1' => '', + 'custom_string_2' => '', + 'custom_string_3' => '', + 'custom_integer_1' => '0', + 'custom_integer_2' => '0', + 'min_ff_event' => '0', + 'min_ff_event_normal' => '0', + 'min_ff_event_warning' => '0', + 'min_ff_event_critical' => '0', + 'ff_type' => '0', + 'each_ff' => '0', + 'ff_timeout' => '0', + 'unit' => '', + 'macros' => '{"1":{"macro":"_field1_","desc":"Test time","help":"","value":"8","hide":""},"2":{"macro":"_field2_","desc":"Target IP","help":"","value":"'.$ip_target.'","hide":""}}', + 'quiet' => '0', + 'cps' => '0', + 'critical_instructions' => '', + 'warning_instructions' => '', + 'unknown_instructions' => '', + 'critical_inverse' => '0', + 'warning_inverse' => '0', + 'percentage_critical' => '0', + 'percentage_warning' => '0', + 'cron_interval' => '* * * * *', + 'id_category' => '0', + 'disabled_types_event' => '{\"going_unknown\":0}', + 'module_macros' => 'W10=', + 'warning_time' => '0', + ]; + return modules_create_agent_module($id_agent, 'Basic_Network_Packetloss', $array_values); +} + + +/** + * Create module packet lost and return module id. + * + * @param string $ip_target Ip and red mask. + * + * @return interger Module id. + */ +function create_net_scan($ip_target) +{ + global $config; + include_once $config['homedir'].'/godmode/wizards/HostDevices.class.php'; + $HostDevices = new HostDevices(1); + $id_recon_server = db_get_row_filter('tserver', ['server_type' => SERVER_TYPE_DISCOVERY], 'id_server')['id_server']; + + $_POST = [ + 'page' => '1', + 'interval_manual_defined' => '1', + 'interval_select' => '-1', + 'interval_text' => '0', + 'interval' => '0', + 'interval_units' => '1', + 'taskname' => __('Basic network'), + 'id_recon_server' => $id_recon_server, + 'network' => $ip_target, + 'id_group' => '8', + 'comment' => __('Created on welcome'), + ]; + $task_created = $HostDevices->parseNetScan(); + if ($task_created === true) { + $HostDevicesFinal = new HostDevices(2); + $_POST = [ + 'task' => $HostDevices->task['id_rt'], + 'page' => '2', + 'recon_ports' => '', + 'auto_monitor' => 'on', + 'id_network_profile' => ['0' => '2'], + 'review_results' => 'on', + 'review_limited' => '0', + 'snmp_enabled' => 'on', + 'snmp_version' => '1', + 'snmp_skip_non_enabled_ifs' => 'on', + 'community' => '', + 'snmp_context' => '', + 'snmp_auth_user' => '', + 'snmp_security_level' => 'authNoPriv', + 'snmp_auth_method' => 'MD5', + 'snmp_auth_pass' => '', + 'snmp_privacy_method' => 'AES', + 'snmp_privacy_pass' => '', + 'os_detect' => 'on', + 'resolve_names' => 'on', + 'parent_detection' => 'on', + 'parent_recursion' => 'on', + 'vlan_enabled' => 'on', + ]; + + $task_final_created = $HostDevicesFinal->parseNetScan(); + if ($task_final_created === true) { + $net_scan_id = $HostDevices->task['id_rt']; + unset($HostDevices, $HostDevicesFinal); + return $net_scan_id; + } + } else { + return 0; + } +} + + +/** + * Create new template unknown. + * + * @return boolean 1 correct create 0 bad create. + */ +function create_template_alert_unknown() +{ + $name = io_safe_input(__('Unknown condition')); + $type = 'critical'; + $values = [ + 'description' => __('This is a generic alert template to fire on UNKNOWN condition'), + 'max_value' => 0, + 'min_value' => 0, + 'id_group' => 0, + 'priority' => 4, + 'wizard_level' => 'nowizard', + 'time_threshold' => '300', + 'min_alerts_reset_counter' => 1, + 'schedule' => '{"monday":[{"start":"00:00:00","end":"00:00:00"}],"tuesday":[{"start":"00:00:00","end":"00:00:00"}],"wednesday":[{"start":"00:00:00","end":"00:00:00"}],"thursday":[{"start":"00:00:00","end":"00:00:00"}],"friday":[{"start":"00:00:00","end":"00:00:00"}],"saturday":[{"start":"00:00:00","end":"00:00:00"}],"sunday":[{"start":"00:00:00","end":"00:00:00"}]}', + 'recovery_notify' => true, + 'field2' => '[PANDORA] Alert for UNKNOWN status on _agent_ / _module_', + 'field2_recovery' => '[PANDORA] Alert RECOVERED for UNKNOWN status on _agent_ / _module_', + 'field3' => '

Automatic alert system


We have bad news for you, something is on UNKNOWN status!

Monitoring details

Data: _data_ (warning)

Agent: _agent_ _address_

Module: _module_ _moduledescription_

Timestamp: _timestamp_

This is a graph of latest 24hr data for this module

_modulegraph_24h_

Contact Us  |  Support  |  Docs

', + 'field3_recovery' => '

Automatic alert system


We have good news for you, alert has been recovered

Monitoring details

Data: _data_ (normal)

Agent: _agent_ _address_

Module: _module_ _moduledescription_

Timestamp: _timestamp_

This is a graph of latest 24hr data for this module

_modulegraph_24h_

Contact Us  |  Support  |  Docs

', + ]; + + $result = alerts_create_alert_template($name, $type, $values); + return $result; +} diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 4e3206840b..498602a1d1 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -57,7 +57,7 @@ function include_javascript_d3($return=false) } -function d3_relationship_graph($elements, $matrix, $width=700, $return=false) +function d3_relationship_graph($elements, $matrix, $width=700, $return=false, $height=700) { global $config; @@ -72,7 +72,7 @@ function d3_relationship_graph($elements, $matrix, $width=700, $return=false) $output = '
'; $output .= include_javascript_d3(true); $output .= ""; if (!$return) { @@ -150,7 +150,7 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false) } -function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true) +function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true, $id_container=false) { global $config; @@ -158,6 +158,8 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $toolt $data = json_encode($data); } + $id_container = ($id_container === false) ? '#sunburst' : $id_container; + $output = "
"; $output .= include_javascript_d3(true); $output .= ''; $output .= ""; if (!$return) { diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index bce475ad4f..6b64cae989 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -259,7 +259,7 @@ function flot_area_graph( $return .= html_print_input_hidden( 'line_width_graph', - $config['custom_graph_width'], + (empty($params['line_width']) === true) ? $config['custom_graph_width'] : $params['line_width'], true ); $return .= "
a, a => b, a => c] // [5, 0, 1], // b[b => a, b => b, b => c] // [2, 3, 0]]; // c[c => a, c => b, c => c] -function chordDiagram(recipient, elements, matrix, width) { +function chordDiagram(recipient, elements, matrix, width, height) { d3.chart = d3.chart || {}; d3.chart.chordWheel = function(options) { // Default values @@ -59,10 +59,13 @@ function chordDiagram(recipient, elements, matrix, width) { .enter() .append("svg:svg") .attr("width", width) - .attr("height", width) + .attr("height", height) .attr("class", "dependencyWheel") .append("g") - .attr("transform", "translate(" + width / 2 + "," + width / 2 + ")"); + .attr( + "transform", + "translate(" + width / 2 + "," + height / 2 + ") scale(1.2)" + ); var arc = d3.svg .arc() @@ -206,8 +209,8 @@ function chordDiagram(recipient, elements, matrix, width) { .on("mousemove", move_tooltip); function move_tooltip(d) { - x = d3.event.pageX + 10; - y = d3.event.pageY + 10; + x = d3.event.layerX + 10; + y = d3.event.layerY + 10; $("#tooltip").css("left", x + "px"); $("#tooltip").css("top", y + "px"); diff --git a/pandora_console/include/javascript/datatablesFunction.js b/pandora_console/include/javascript/datatablesFunction.js new file mode 100644 index 0000000000..41f0bbf1e2 --- /dev/null +++ b/pandora_console/include/javascript/datatablesFunction.js @@ -0,0 +1,378 @@ +var dt = dt; +var config = config; + +var datacolumns = []; +var datacolumnsTemp = []; +dt.datacolumns.forEach(column => { + if (column === null) return; + if (typeof column !== "string") { + datacolumnsTemp = { data: column.text, className: column.class }; + datacolumns.push(datacolumnsTemp); + } else { + datacolumnsTemp = { data: column, className: "no-class" }; + datacolumns.push(datacolumnsTemp); + } +}); + +var paginationClass = "pandora_pagination"; +if (typeof dt.pagination_class !== "undefined") { + paginationClass = dt.pagination_class; +} + +var processing = ""; +if (typeof dt.processing === "undefined") { + processing = dt.processing; +} + +var ajaxReturn = ""; +var ajaxReturnFunction = ""; +if ( + typeof dt.ajax_return_operation !== "undefined" && + dt.ajax_return_operation !== "" && + typeof dt.ajax_return_operation_function !== "undefined" && + dt.ajax_return_operation_function !== "" +) { + ajaxReturn = dt.ajax_return_operation; + ajaxReturnFunction = dt.ajax_return_operation_function; +} + +var serverSide = true; +if (typeof dt.data_element !== "undefined") { + serverSide = false; +} + +var paging = true; +if (typeof dt.paging !== "undefined") { + paging = dt.paging; +} + +var pageLength = parseInt(dt.default_pagination); + +var searching = false; +if (typeof dt.searching !== "undefined" && dt.searching === true) { + searching = dt.searching; +} + +var dom = "plfrtiB"; +if (typeof dt.dom_elements !== "undefined") { + dom = dt.dom_elements; +} + +var lengthMenu = [ + [pageLength, 5, 10, 20, 100, 200, 500, 1000, -1], + [pageLength, 5, 10, 20, 100, 200, 500, 1000, "All"] +]; +if (typeof dt.pagination_options !== "undefined") { + lengthMenu = dt.pagination_options; +} + +var ordering = true; +if (typeof dt.ordering !== "undefined" && dt.ordering === false) { + ordering = dt.ordering; +} + +var order = [[0, "asc"]]; +if (typeof dt.order !== "undefined") { + order = [[dt.order.order, dt.order.direction]]; +} + +var zeroRecords = ""; +if (typeof dt.zeroRecords !== "undefined") { + zeroRecords = `${dt.zeroRecords}`; +} + +var emptyTable = ""; +if (typeof dt.emptyTable !== "undefined") { + emptyTable = `${dt.emptyTable}`; +} + +var no_sortable_columns = []; +if (typeof dt.no_sortable_columns !== "undefined") { + no_sortable_columns = Object.values(dt.no_sortable_columns); +} + +var columnDefs = []; +if (typeof dt.columnDefs === "undefined") { + columnDefs = [ + { className: "no-class", targets: "_all" }, + { bSortable: false, targets: no_sortable_columns } + ]; +} else { + columnDefs = dt.columnDefs; +} + +var csvClassName = "csv-button"; +if (dt.mini_csv === true) { + csvClassName = "mini-csv-button"; +} + +var csvFieldSeparator = ";"; +if (typeof dt.csv_field_separator !== "undefined") { + csvFieldSeparator = dt.csv_field_separator; +} + +var csvHeader = true; +if (dt.csv_header === false) { + csvHeader = false; +} + +var csvExcludeLast = ""; +if (dt.csv_exclude_latest === true) { + csvExcludeLast = "th:not(:last-child)"; +} + +var ajaxData = ""; +if (typeof dt.ajax_data !== "undefined") { + ajaxData = dt.ajax_data; +} + +$(document).ready(function() { + function checkPages() { + if (dt_table.page.info().pages > 1) { + $( + "div.pagination-child-div > .dataTables_paginate.paging_simple_numbers" + ).show(); + $(`#${dt.id}_paginate`).show(); + } else { + $( + "div.pagination-child-div > .dataTables_paginate.paging_simple_numbers" + ).hide(); + $(`#${dt.id}_paginate`).hide(); + } + } + + function moveElementsToActionButtons() { + $(".action_buttons_right_content").html( + '
' + ); + $(".pagination-child-div").append( + $(`#${dt.id}_wrapper > .dataTables_paginate.paging_simple_numbers`).attr( + "style", + "margin-right: 10px;" + ) + ); + $(".pagination-child-div").append( + $(`#${dt.id}_wrapper > .dataTables_length`) + ); + $(".pagination-child-div").append($(`#${dt.id}_wrapper > .dt-buttons`)); + $(".pagination-child-div").append( + $(`#${dt.id}_wrapper > .dataTables_filter`) + ); + } + + $.fn.dataTable.ext.errMode = "none"; + $.fn.dataTable.ext.classes.sPageButton = paginationClass; + + if (dt.mini_pagination === true) { + $.fn.dataTable.ext.classes.sPageButton = `${paginationClass} mini-pandora-pagination`; + } + + var settings_datatable = { + processing: true, + responsive: true, + serverSide, + paging, + pageLength, + searching, + dom, + lengthMenu, + ordering, + order, + columns: eval(datacolumns), + columnDefs, + language: { + url: dt.language, + processing, + zeroRecords, + emptyTable + }, + buttons: + dt.csv == 1 + ? [ + { + extend: "csv", + className: csvClassName, + text: dt.csvTextInfo, + titleAttr: dt.csvTextInfo, + title: dt.csvFileTitle, + fieldSeparator: csvFieldSeparator, + header: csvHeader, + action: function(e, dt, node, config) { + blockResubmit(node); + // Call the default csvHtml5 action method to create the CSV file + $.fn.dataTable.ext.buttons.csvHtml5.action.call( + this, + e, + dt, + node, + config + ); + }, + exportOptions: { + modifier: { + // DataTables core + order: "current", + page: "All", + search: "applied" + }, + columns: csvExcludeLast + } + } + ] + : [], + initComplete: function(settings, json) { + moveElementsToActionButtons(); + + checkPages(); + + $(`div#${dt.id}-spinner`).hide(); + }, + drawCallback: function(settings) { + if ($(`#${dt.id} tr td`).length == 1) { + $(`.datatable-msg-info-${dt.id}`) + .removeClass("invisible_important") + .show(); + $(`table#${dt.id}`).hide(); + $("div.pagination-child-div").hide(); + $("div.dataTables_info").hide(); + $(`#${dt.id}_wrapper`).hide(); + $(`.action_buttons_right_content .pagination-child-div`).hide(); + } else { + $(`.datatable-msg-info-${dt.id}`).hide(); + $(`table#${dt.id}`).show(); + $("div.pagination-child-div").show(); + $("div.dataTables_info").show(); + $(`#${dt.id}_wrapper`).show(); + + if (typeof dt.drawCallback !== "undefined") { + eval(dt.drawCallback); + } + } + + $(`div#${dt.id}-spinner`).hide(); + + checkPages(); + } + }; + + var ajaxOrData = {}; + if (typeof dt.data_element == "undefined") { + ajaxOrData = { + ajax: { + url: dt.ajax_url_full, + type: "POST", + dataSrc: function(json) { + if ($(`#${dt.form_id}_search_bt`) != undefined) { + $(`#${dt.form_id}_loading`).remove(); + } + + if (json.error) { + console.error(json.error); + $(`#error-${dt.id}`).html(json.error); + $(`#error-${dt.id}`) + .dialog({ + title: "Filter failed", + width: 630, + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }) + .parent() + .addClass("ui-state-error"); + } else { + if (json.ajaxReturn !== "undefined") { + eval(`${ajaxReturnFunction}(${json.ajaxReturn})`); + } + + if (typeof dt.ajax_postprocess !== "undefined") { + if (json.data) { + json.data.forEach(function(item) { + eval(dt.ajax_postprocess); + }); + } else { + json.data = {}; + } + } + + return json.data; + } + }, + data: function(data) { + $(`div#${dt.id}-spinner`).show(); + if ($(`#button-${dt.form_id}_search_bt`) != undefined) { + var loading = ``; + $(`#button-${dt.form_id}_search_bt`) + .parent() + .append(loading); + } + + var inputs = $(`#${dt.form_id} :input`); + + var values = {}; + inputs.each(function() { + values[this.name] = $(this).val(); + }); + + $.extend(data, ajaxData); + + $.extend(data, { + filter: values, + page: dt.ajax_url + }); + + return data; + } + } + }; + } else { + ajaxOrData = { data: dt.data_element }; + } + + $.extend(settings_datatable, ajaxOrData); + var dt_table = $(`#${dt.table_id}`).DataTable(settings_datatable); + + $(`#button-${dt.form_id}_search_bt`).click(function() { + dt_table.draw().page(0); + }); + + if (typeof dt.caption !== "undefined" && dt.caption !== "") { + $(`#${dt.table_id}`).append(`${dt.caption}`); + $(".datatables_thead_tr").css("height", 0); + } + + $(function() { + $(document).on("init.dt", function(ev, settings) { + if (dt.mini_search === true) { + $(`#${dt.id}_filter > label > input`).addClass("mini-search-input"); + } + + $("div.dataTables_length").show(); + $("div.dataTables_filter").show(); + $("div.dt-buttons").show(); + + if (dt_table.page.info().pages === 0) { + $(`.action_buttons_right_content .pagination-child-div`).hide(); + } + + if (dt_table.page.info().pages === 1) { + $(`div.pagination-child-div > #${dt.table_id}_paginate`).hide(); + } else { + $(`div.pagination-child-div > #${dt.table_id}_paginate`).show(); + } + }); + }); +}); + +$(function() { + $(document).on("preInit.dt", function(ev, settings) { + $(`#${dt.id}_wrapper div.dataTables_length`).hide(); + $(`#${dt.id}_wrapper div.dataTables_filter`).hide(); + $(`#${dt.id}_wrapper div.dt-buttons`).hide(); + }); +}); diff --git a/pandora_console/include/javascript/i18n/dataTables.en.json b/pandora_console/include/javascript/i18n/dataTables.en.json index 9ccd76c4ad..d80bbe6e75 100644 --- a/pandora_console/include/javascript/i18n/dataTables.en.json +++ b/pandora_console/include/javascript/i18n/dataTables.en.json @@ -6,7 +6,6 @@ "infoThousands": ",", "lengthMenu": "Show _MENU_ entries", "loadingRecords": "Loading...", - "processing": "Processing...", "search": "Search:", "zeroRecords": "No matching records found", "thousands": ",", diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 245c9f0481..14712eee27 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -416,6 +416,10 @@ class Widget $className .= '\OsQuickReportWidget'; break; + case 'netflow': + $className .= '\Netflow'; + break; + case 'GroupedMeterGraphs': case 'ColorModuleTabs': case 'BlockHistogram': @@ -424,6 +428,7 @@ class Widget case 'ModulesByStatus': case 'AvgSumMaxMinModule': case 'BasicChart': + case 'AgentHive': $className .= '\\'.$name; break; diff --git a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php new file mode 100644 index 0000000000..3b881ca344 --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php @@ -0,0 +1,519 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Cell Id. + $this->cellId = $cellId; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Agent hive'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'AgentHive'; + } + + // This forces at least a first configuration. + $this->configurationRequired = false; + if (empty($this->values['groups']) === true) { + $this->configurationRequired = true; + } + } + + + /** + * 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['groups']) === true) { + $values['groups'] = $decoder['groups']; + } + + 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(); + + // Filters. + $inputs[] = [ + 'label' => __('Groups'), + 'id' => 'li_groups', + 'arguments' => [ + 'type' => 'select_groups', + 'name' => 'groups[]', + 'returnAllGroup' => false, + 'privilege' => 'AR', + 'selected' => explode(',', $values['groups'][0]), + 'return' => true, + 'multiple' => true, + 'required' => true, + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost(): array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['groups'] = \get_parameter('groups', 0); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + $groups = $this->values['groups']; + $groups = explode(',', $groups[0]); + + $user_groups = array_keys( + users_get_groups( + false, + 'AR', + false, + false, + $groups + ) + ); + + foreach ($groups as $key => $group) { + if (in_array($group, $user_groups) === false) { + unset($groups[$key]); + } + } + + $table = 'tagente'; + if (is_metaconsole()) { + $table = 'tmetaconsole_agent'; + } + + $sql = sprintf( + 'SELECT * FROM %s WHERE id_grupo IN('.implode(',', $groups).')', + $table + ); + $all_agents = db_get_all_rows_sql($sql); + + $output = ''; + $output .= '
'; + foreach ($all_agents as $agent) { + $output .= $this->drawSquare($agent); + } + + $output .= '
'; + + $output .= ''; + + return $output; + } + + + /** + * Draw square agent. + * + * @param array $data Info agent. + * + * @return string Output. + */ + private function drawSquare(array $data): string + { + global $config; + + $id = (is_metaconsole() === true) + ? $data['id_tagente'] + : $data['id_agente']; + + $status = agents_get_status_from_counts($data); + switch ($status) { + case 1: + case 4: + case 100: + // Critical (BAD or ALERT). + $color = '#e63c52'; + break; + + case 0: + case 300: + // Normal (OK). + $color = '#82b92e'; + break; + + case 2: + case 200: + // Warning. + $color = '#f3b200'; + break; + + case 5: + // Not init. + $color = '#4a83f3'; + break; + + default: + // Default is Grey (Other). + $color = '#b2b2b2'; + break; + } + + $style_contact = 'flex-grow: 9; font-size: 8pt; display: flex; + justify-content: start;align-items: start; color: #9FA5B1; font-weight: 600;'; + // Last contact. + $lastContactDate = ui_print_timestamp( + $data['ultimo_contacto'], + true, + ['style' => $style_contact] + ); + + // Url. + $console_url = ui_get_full_url('/'); + if (is_metaconsole()) { + $server = metaconsole_get_servers($data['id_tmetaconsole_setup']); + $console_url = $server['server_url'].'/'; + } + + $url_view = $console_url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id; + $url_manage = $console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id; + + $output = '
'; + $output .= ''; + $output .= '
'; + $output .= '
'; + // Last contact and img. + $output .= ''; + + // OS and alias. + $output .= '
'; + $icon = (string) db_get_value( + 'icon_name', + 'tconfig_os', + 'id_os', + (int) $data['id_os'] + ); + $output .= '
'; + $output .= file_get_contents( + ui_get_full_url('images/'.$icon, false, false, false) + ); + $output .= '
'; + $output .= ui_print_truncate_text( + ucfirst(io_safe_output($data['alias'])), + 12, + false, + true, + true, + '…', + 'font-size: 11pt;color: #14524f;white-space: nowrap; + font-weight: 600;text-align: left;width: 80%; + overflow: hidden;', + ); + + $output .= '
'; + + // OS description. + $output .= html_print_div( + [ + 'content' => (empty($data['os_version']) === true) + ? get_os_name((int) $data['id_os']) + : $data['os_version'], + 'style' => 'font-size: 6pt; display: + flex;justify-content: start;align-items: start; + color: #9FA5B1; font-weight: 600;margin-bottom: 5px', + ], + true + ); + + // Description. + $output .= html_print_div( + [ + 'content' => ui_print_truncate_text( + io_safe_output($data['comentarios']), + 38, + false, + true, + true, + '…', + ), + 'style' => 'text-align: left;min-height: 42px; + font-size: 8pt;max-height: 42px; margin-bottom: 10px', + ], + true + ); + + // IP. + $output .= html_print_div( + [ + 'content' => $data['direccion'], + 'style' => 'font-size: 10pt;color: #14524f; + font-weight: 600; text-align: left', + ], + true + ); + $output .= '
'; + $output .= '
'; + + return $output; + + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('Agents hive'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'AgentHive'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => (is_metaconsole() === true) ? 700 : 600, + 'height' => 610, + ]; + + return $size; + } + + +} diff --git a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php index ff5d22a539..85665e7e4c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php +++ b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php @@ -297,6 +297,14 @@ class BasicChart extends Widget $values['label'] = $decoder['label']; } + if (isset($decoder['type_graph']) === true) { + $values['type_graph'] = $decoder['type_graph']; + } + + if (isset($decoder['line_width']) === true) { + $values['line_width'] = $decoder['line_width']; + } + return $values; } @@ -477,6 +485,22 @@ class BasicChart extends Widget ], ]; + $types_graph = [ + 'area' => __('Area'), + 'line' => __('Wire'), + ]; + + $inputs['inputs']['row1'][] = [ + 'label' => __('Type graph'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $types_graph, + 'name' => 'type_graph', + 'selected' => $values['type_graph'], + 'return' => true, + ], + ]; + $inputs['inputs']['row2'][] = [ 'label' => __('Show Value'), 'arguments' => [ @@ -520,6 +544,18 @@ class BasicChart extends Widget ], ]; + $inputs['inputs']['row2'][] = [ + 'label' => __('Graph line size'), + 'arguments' => [ + 'name' => 'line_width', + 'type' => 'number', + 'value' => (empty($values['line_width']) === true) ? 3 : $values['line_width'], + 'return' => true, + 'min' => 2, + 'max' => 10, + ], + ]; + return $inputs; } @@ -546,6 +582,8 @@ class BasicChart extends Widget $values['colorChart'] = \get_parameter('colorChart'); $values['formatData'] = \get_parameter_switch('formatData'); $values['label'] = \get_parameter('label'); + $values['type_graph'] = \get_parameter('type_graph'); + $values['line_width'] = \get_parameter('line_width'); return $values; } @@ -606,6 +644,8 @@ class BasicChart extends Widget 'title' => $module_name, 'unit' => $units_name, 'only_image' => false, + 'type_graph' => $this->values['type_graph'], + 'line_width' => (empty($this->values['line_width']) === true) ? 3 : $this->values['line_width'], 'menu' => false, 'vconsole' => true, 'return_img_base_64' => false, diff --git a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php index b00c3ae421..10ddd2bc9c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php +++ b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php @@ -520,7 +520,7 @@ class DataMatrix extends Widget [ 'id' => $tableId, 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'include/ajax/module', diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index 86a50eefef..351d78ffec 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -438,7 +438,7 @@ class ModulesByStatus extends Widget [ 'id' => $tableId, 'class' => 'info_table align-left-important', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'include/ajax/module', diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php index 24d1c7e207..e5c68eab11 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php @@ -540,12 +540,6 @@ class ModuleIconWidget extends Widget $output = ''; - $id_group = \agents_get_agent_group($this->values['agentId']); - - $modulesAgent = \modules_get_agentmodule_agent( - $this->values['moduleId'] - ); - $data_module = \modules_get_last_value( $this->values['moduleId'] ); @@ -574,33 +568,37 @@ class ModuleIconWidget extends Widget // General div. $output .= '
'; - $sql = 'SELECT min_warning, - max_warning, - min_critical, - max_critical, - str_warning, - str_critical - FROM tagente_modulo - WHERE id_agente_modulo = '.(int) $this->values['moduleId']; - $sql_data = db_get_row_sql($sql); + $status = \modules_get_agentmodule_status($this->values['moduleId']); - $last = modules_get_last_value($this->values['moduleId']); + switch ($status) { + case 1: + case 4: + // Critical or critical alert (BAD). + $color_icon .= '_bad.png'; + break; - $color_icon = '_ok'; - if (($last >= $sql_data['min_warning']) && ($last < $sql_data['max_warning'])) { - $color_icon = '_warning'; + case 0: + // Normal (OK). + $color_icon .= '_ok.png'; + break; + + case 2: + case 10: + // Warning or warning alert. + $color_icon .= '_warning.png'; + break; + + case 3: + // Unknown. + default: + $color_icon .= '.png'; + // Default is Grey (Other). + break; } - if ($last >= $sql_data['max_warning']) { - $color_icon = '_bad'; - } - - // Div image. - $style_icon = 'flex: 0 1 '.$sizeIcon.'px;'; - - $output .= '
'; + $output .= '
'; $output .= html_print_image( - 'images/console/icons/'.$icon.$color_icon.'.png', + 'images/console/icons/'.$icon.$color_icon, true, ['width' => $sizeIcon] ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/netflow.php b/pandora_console/include/lib/Dashboard/Widgets/netflow.php new file mode 100644 index 0000000000..be603e452b --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/netflow.php @@ -0,0 +1,465 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Options. + $this->values = $this->getOptionsWidget(); + + // Positions. + $this->position = $this->getPositionWidget(); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Netflow'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'netflow'; + } + } + + + /** + * 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(); + + // Default values. + if (isset($values['quantity']) === false) { + $values['quantity'] = 5; + } + + // Default values. + if (isset($values['period']) === false) { + $values['period'] = SECONDS_1WEEK; + } + + // Default values. + if (isset($values['max_values']) === false) { + $values['max_values'] = 10; + } + + // Period. + $inputs[] = [ + 'label' => __('Interval'), + 'arguments' => [ + 'name' => 'period', + 'type' => 'interval', + 'value' => $values['period'], + 'nothing' => __('None'), + 'nothing_value' => 0, + 'style_icon' => 'flex-grow: 0', + ], + ]; + $chart_types = netflow_get_chart_types(); + $chart_types['usage_map'] = __('Usage map'); + $inputs[] = [ + 'label' => __('Type graph'), + 'arguments' => [ + 'name' => 'chart_type', + 'type' => 'select', + 'fields' => $chart_types, + 'selected' => $values['chart_type'], + ], + ]; + + $aggregate_list = [ + 'srcip' => __('Src Ip Address'), + 'dstip' => __('Dst Ip Address'), + 'srcport' => __('Src Port'), + 'dstport' => __('Dst Port'), + ]; + $inputs[] = [ + 'label' => __('Aggregated by'), + 'id' => 'aggregated', + 'arguments' => [ + 'name' => 'aggregate', + 'type' => 'select', + 'fields' => $aggregate_list, + 'selected' => $values['aggregate'], + ], + ]; + + $inputs[] = [ + 'label' => __('Data to show'), + 'id' => 'data_to_show', + 'arguments' => [ + 'name' => 'action', + 'type' => 'select', + 'fields' => network_get_report_actions(), + 'selected' => $values['action'], + ], + ]; + + $max_values = [ + '2' => '2', + '5' => '5', + '10' => '10', + '15' => '15', + '20' => '20', + '25' => '25', + '50' => '50', + ]; + + $inputs[] = [ + 'label' => __('Max values'), + 'arguments' => [ + 'name' => 'max_values', + 'type' => 'select', + 'fields' => $max_values, + 'selected' => $values['max_values'], + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost():array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['period'] = \get_parameter('period', 0); + $values['chart_type'] = \get_parameter('chart_type', ''); + $values['aggregate'] = \get_parameter('aggregate'); + $values['max_values'] = \get_parameter('max_values', 10); + $values['action'] = \get_parameter('action', 'srcip'); + + return $values; + } + + + /** + * Draw widget. + * + * @return string + */ + public function load() + { + ui_require_css_file('netflow_widget', 'include/styles/', true); + global $config; + + $output = ''; + + $size = parent::getSize(); + + $start_date = (time() - $this->values['period']); + $end_date = time(); + if ($this->values['chart_type'] === 'usage_map') { + $map_data = netflow_build_map_data( + $start_date, + $end_date, + $this->values['max_values'], + ($this->values['action'] === 'talkers') ? 'srcip' : 'dstip' + ); + $has_data = !empty($map_data['nodes']); + + if ($has_data === true) { + $map_manager = new \NetworkMap($map_data); + $map_manager->printMap(); + } else { + ui_print_info_message(__('No data to show')); + } + } else { + $netflowContainerClass = ($this->values['chart_type'] === 'netflow_data' || $this->values['chart_type'] === 'netflow_summary' || $this->values['chart_type'] === 'netflow_top_N') ? '' : 'white_box'; + $filter = [ + 'aggregate' => $this->values['aggregate'], + 'netflow_monitoring_interval' => 300, + ]; + + $output .= html_print_input_hidden( + 'selected_style_theme', + $config['style'], + true + ); + $style = 'width:100%; height: 100%; border: none;'; + if ($this->values['chart_type'] !== 'netflow_area') { + $style .= ' width: 95%;'; + } + + if ($size['width'] > $size['height']) { + $size['width'] = $size['height']; + } + + // Draw the netflow chart. + $output .= html_print_div( + [ + 'class' => $netflowContainerClass, + 'style' => $style, + 'content' => netflow_draw_item( + $start_date, + $end_date, + 12, + $this->values['chart_type'], + $filter, + $this->values['max_values'], + '', + 'HTML', + 0, + ($size['width'] - 50), + ($size['height'] - 20), + ), + ], + true + ); + } + + return $output; + + } + + + /** + * Return aux javascript code for forms. + * + * @return string + */ + public function getFormJS() + { + return ' + $(document).ready(function(){ + //Limit 1 week + $("#period_select option").each(function(key, element){ + if(element.value > 604800){ + $(element).remove(); + } + }) + $("#period_manual option").each(function(key, element){ + if(element.value > 604800){ + $(element).remove(); + } + }); + $("#period_manual input").on("change", function(e){ + if($("#hidden-period").val() > 604800) { + $(this).val(1); + $("#hidden-period").val(604800); + $("#period_manual select option").removeAttr("selected"); + setTimeout(() => { + $("#period_default select option[value=\'604800\']").attr("selected", "selected"); + $("#period_manual select option[value=\'604800\']").attr("selected", "selected"); + $("#period_manual select").val(604800); + }, 500); + } + }); + if($("#chart_type").val() === "usage_map") { + $("#data_to_show").show(); + $("#aggregated").hide(); + } else { + $("#data_to_show").hide(); + $("#aggregated").show(); + } + $("#chart_type").on("change", function(e){ + if(this.value === "usage_map") { + $("#data_to_show").show(); + $("#aggregated").hide(); + } else { + $("#data_to_show").hide(); + $("#aggregated").show(); + } + }); + }); + '; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('Netflow'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'netflow'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 400, + 'height' => 530, + ]; + + return $size; + } + + +} diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index 1957cf1c0a..5353ed79a9 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -433,7 +433,14 @@ class ServiceMapWidget extends Widget ); } else { include_once $config['homedir'].'/include/graphs/functions_d3.php'; - servicemap_print_sunburst($this->values['serviceId'], $size['width'], $size['height'], false); + $id_container = '#container_servicemap_'.$this->values['serviceId'].'_'.$this->cellId.' #sunburst'; + servicemap_print_sunburst( + $this->values['serviceId'], + $size['width'], + $size['height'], + false, + $id_container + ); } $output .= ob_get_clean(); diff --git a/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php b/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php index 7d00c43715..b026ffcd9e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php @@ -395,7 +395,9 @@ class SystemGroupStatusWidget extends Widget $user_groups = users_get_groups(false, 'AR', $return_all_group); $selected_groups = explode(',', $this->values['groupId'][0]); + $all_group_selected = false; if (in_array(0, $selected_groups) === true) { + $all_group_selected = true; $selected_groups = []; foreach (groups_get_all() as $key => $name_group) { $selected_groups[] = groups_get_id($name_group); @@ -480,7 +482,12 @@ class SystemGroupStatusWidget extends Widget } } - $this->values['groupId'] = $selected_groups; + if ($all_group_selected === true && $this->values['groupRecursion'] === true) { + $this->values['groupId'] = array_keys($result_groups); + } else { + $this->values['groupId'] = $selected_groups; + } + $this->values['status'] = explode(',', $this->values['status'][0]); $style = 'font-size: 1.5em; font-weight: bolder;text-align: center;'; diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 908f673997..285e8fa481 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -654,6 +654,59 @@ form.modal-dashboard font-style: italic; } +.widget-agent-hive-square { + flex: 1; + display: flex; + flex-direction: row; + justify-content: center; + align-items: start; + min-width: 150px; + max-width: 150px; + min-height: 150px; + max-height: 150px; + margin: 8px; + padding: 5px; + border: 1px solid #eceef2; + border-radius: 5px; + cursor: pointer; +} + +.widget-agent-hive-square-status { + width: 3%; + height: 100%; + margin-left: 3%; + border-radius: 15px; +} + +.widget-agent-hive-square-info { + width: 87%; + height: 100%; + display: flex; + flex-direction: column; + margin-left: 6%; +} + +.widget-agent-hive-square-info-header { + width: 100%; + display: flex; + flex-direction: row; + margin-bottom: 10px; +} + +.widget-agent-hive-square-info-body { + width: 100%; + display: flex; + flex-direction: row; +} + +.span-alias { + font-size: 13pt; + justify-content: start; + align-items: start; + color: #14524f; + font-weight: 600; +} + .container-histograms { min-width: 400px; } diff --git a/pandora_console/include/styles/form.css b/pandora_console/include/styles/form.css index fd7e496aac..a0e5957358 100644 --- a/pandora_console/include/styles/form.css +++ b/pandora_console/include/styles/form.css @@ -365,3 +365,7 @@ form#modal_form_feedback > ul > li > textarea { form#modal_form_feedback > ul > li:not(:first-child) > label { margin-top: 20px !important; } + +table.dataTable { + box-sizing: border-box !important; +} diff --git a/pandora_console/include/styles/login.css b/pandora_console/include/styles/login.css index 4314296d15..30d29c584c 100644 --- a/pandora_console/include/styles/login.css +++ b/pandora_console/include/styles/login.css @@ -351,6 +351,7 @@ span.span1 { font-family: "lato-bolder"; color: #fff; margin-right: 30px; + text-shadow: 2px 2px #000; } span.span2 { @@ -361,6 +362,7 @@ span.span2 { font-family: "lato-bolder"; color: #fff; margin-right: 30px; + text-shadow: 2px 2px #000; } div.img_banner_login img { diff --git a/pandora_console/include/styles/netflow_widget.css b/pandora_console/include/styles/netflow_widget.css new file mode 100644 index 0000000000..c7be7fe90d --- /dev/null +++ b/pandora_console/include/styles/netflow_widget.css @@ -0,0 +1,13 @@ +.menu_graph { + display: none; +} +.parent_graph { + width: 97% !important; +} +#image_hide_show_labels { + display: none !important; +} + +.select2-search--dropdown .select2-search__field { + padding: 0px !important; +} diff --git a/pandora_console/include/styles/new_installation_welcome_window.css b/pandora_console/include/styles/new_installation_welcome_window.css index 90f96a5445..6d354b0c33 100644 --- a/pandora_console/include/styles/new_installation_welcome_window.css +++ b/pandora_console/include/styles/new_installation_welcome_window.css @@ -86,3 +86,29 @@ #welcome_form li.extra { padding-bottom: 2.5em; } + +#li-div_diagnosis, +#li-div_task_todo, +#li-div_wizard_agent { + border-left: unset !important; +} + +#div_diagnosis > label, +#div_task_todo > label { + font-weight: bold; +} + +button.buttonButton.onlyIcon.fail, +button.submitButton.onlyIcon.fail { + mask: url(../../images/fail@svg.svg) no-repeat center / contain; + -webkit-mask: url(../../images/fail@svg.svg) no-repeat center / contain; +} + +.select2-container .select2-container--default .select2-container--open { + z-index: 2000; +} + +#div_wizard_agent > .select2 { + width: 75% !important; + max-width: 75% !important; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 84700d62a9..598f100a83 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -7628,6 +7628,10 @@ div.graph div.legend table { padding-bottom: 10px !important; } +.pdd_b_15px_important { + padding-bottom: 15px !important; +} + .pdd_b_20px { padding-bottom: 20px; } @@ -7706,6 +7710,10 @@ div.graph div.legend table { padding-top: 15px; } +.pdd_t_15px_important { + padding-top: 15px !important; +} + .pdd_t_20px { padding-top: 20px; } @@ -10809,6 +10817,10 @@ button.ui-button.ui-widget.submit-cancel:active { border-color: #96a2bf; } +.cursor-default { + cursor: default; +} + .hasColorPicker { z-index: 10; } @@ -11667,14 +11679,14 @@ p.trademark-copyright { } .show-hide-pass { - position: relative; - right: 40px; + position: absolute; + right: 9px; top: 4px; border: 0; outline: none; margin: 0; height: 30px; - width: 30px; + width: 40px; cursor: pointer; display: inline-block; } @@ -11915,10 +11927,6 @@ span.help_icon_15px > img { height: 15px !important; } -.select2-dropdown { - z-index: 1116 !important; -} - .icon_connection_check { width: 65px !important; height: 65px !important; @@ -11954,7 +11962,7 @@ span.help_icon_15px > img { /* ==== Spinner ==== */ .spinner-fixed { position: absolute; - left: 40%; + left: 45%; top: 40%; z-index: 1; width: 100px; @@ -11964,6 +11972,7 @@ span.help_icon_15px > img { animation: animate 1.2s linear infinite; margin: auto; margin-bottom: 40px; + text-align: initial; } .spinner-fixed span { position: absolute; diff --git a/pandora_console/include/styles/select2.min.css b/pandora_console/include/styles/select2.min.css index ad21d16958..9d81e83c30 100644 --- a/pandora_console/include/styles/select2.min.css +++ b/pandora_console/include/styles/select2.min.css @@ -71,7 +71,7 @@ position: absolute; left: -100000px; width: 100%; - z-index: 1115; + z-index: 1118; } .select2-results { display: block; diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index 562ffc3c80..bc6c504529 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -381,15 +381,35 @@ a.pandora_pagination.current:hover { cursor: pointer; } +.dt-button.buttons-csv.buttons-html5.mini-csv-button { + background-image: url(../../images/file-csv.svg); + background-position: 4px center; + height: 26px; + width: 31px; + margin-left: 10px; + box-shadow: 0px 0px 0px #00000000; + border: 0px; + border-radius: 0px; +} + .dt-button.buttons-csv.buttons-html5:hover { color: #1d7873 !important; border: 2px solid #1d7873 !important; } +.dt-button.buttons-csv.buttons-html5.mini-csv-button:hover { + color: #00000000 !important; + border: 0px !important; +} + .dt-button.buttons-csv.buttons-html5:before { content: "csv"; } +.dt-button.buttons-csv.buttons-html5.mini-csv-button:before { + content: ""; +} + .dt-button.buttons-csv.buttons-html5 span { font-size: 0; } diff --git a/pandora_console/index.php b/pandora_console/index.php index 96be49a6af..75c00af9b1 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -712,7 +712,6 @@ if (isset($config['id_user']) === false) { login_check_failed($nick); } - $config['auth_error'] = __('User is blocked'); $login_failed = true; } diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 4db865990f..07974af99e 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -258,7 +258,8 @@ if ((bool) check_acl($config['id_user'], $id_group, 'LW') === true || (bool) che ); } - if ($print_agent === true) { + /* + if ($print_agent === true) { array_push( $column_names, ['text' => 'Agent'] @@ -268,11 +269,12 @@ if ((bool) check_acl($config['id_user'], $id_group, 'LW') === true || (bool) che $columns, ['agent_name'] ); - } + }*/ } array_push( $column_names, + ['text' => 'Agent'], ['text' => 'Module'], ['text' => 'Template'], [ @@ -286,6 +288,7 @@ array_push( $columns = array_merge( $columns, + ['agent_name'], ['agent_module_name'], ['template_name'], ['action'], @@ -359,7 +362,7 @@ if ($agent_view_page === true) { [ 'id' => 'alerts_status_datatable', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'no_sortable_columns' => $no_sortable_columns, diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index 3ba04acf7e..14b13c6893 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -45,7 +45,7 @@ if ((bool) check_acl($config['id_user'], $id_grupo, 'AR') === false && (bool) ch require_once $config['homedir'].'/include/functions_graph.php'; $draw_alerts = get_parameter('draw_alerts', 0); -$period = get_parameter('period', SECONDS_1HOUR); +$period = (string) get_parameter('period', SECONDS_2HOUR); $width = get_parameter('width', 555); $height = get_parameter('height', 245); $label = get_parameter('label', ''); @@ -53,8 +53,8 @@ $start_date = get_parameter('start_date', date('Y-m-d')); $draw_events = get_parameter('draw_events', 0); $modules = get_parameter('modules', []); $filter = get_parameter('filter', 0); -$combined = get_parameter('combined', 1); -$option_type = get_parameter('option_type', 0); +$combined = get_parameter('combined', 0); +$option_type = get_parameter('option_type', 2); // ---------------------------------------------------------------------- // Get modules of agent sorted as: @@ -176,11 +176,12 @@ foreach ($modules_boolean as $i => $m) { $list_modules = ($modules_networkmap_no_proc + $modules_others + $modules_boolean); +asort($list_modules); // ---------------------------------------------------------------------- if (empty($modules)) { // Selected the first 6 modules. $module_ids = array_keys($list_modules); - $module_ids = array_slice($module_ids, 0, 6); + $module_ids = array_slice($module_ids, 0, 12); $modules = $module_ids; } @@ -301,7 +302,7 @@ $htmlForm .= html_print_div( $htmlForm .= ''; -ui_toggle($htmlForm, __('Filter graphs'), __('Toggle filter(s)'), '', false); +ui_toggle($htmlForm, __('Filter graphs'), __('Toggle filter(s)'), '', true); $utime = get_system_time(); $current = date('Y-m-d', $utime); @@ -316,13 +317,17 @@ if ($combined) { // Pass the $modules before the ajax call. echo '
'.html_print_image('images/spinner.gif', true).'
'; } else { + echo '
'; foreach ($modules as $id_module) { $title = modules_get_agentmodule_name($id_module); $unit = modules_get_unit($id_module); - + echo '
'; echo '

'.$title.'

'; - echo '
'.html_print_image('images/spinner.gif', true).'
'; + echo '
'.html_print_image('images/spinner.gif', true).'
'; + echo '
'; } + + echo '
'; } echo "
"; diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index ac73c474aa..3dea327116 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -205,9 +205,15 @@ if ($edit_networkmap) { $button = []; if ($edit_networkmap === true) { + if (empty($method) === false && $method === 'radial_dinamic') { + $url = 'index.php?sec=network&sec2=operation/agentes/networkmap.dinamic&activeTab=radial_dynamic&id_networkmap='.$id; + } else { + $url = 'index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap='.$id; + } + $button['map'] = [ 'active' => false, - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/network@svg.svg', true, [ diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 540cd8c173..be4837ea65 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -256,152 +256,165 @@ if ($new_networkmap || $save_networkmap) { $name = (string) get_parameter('name'); - // Default size values. - $width = $config['networkmap_max_width']; - $height = $config['networkmap_max_width']; - - $method = (string) get_parameter('method', 'fdp'); - - $recon_task_id = (int) get_parameter( - 'recon_task_id', - 0 + $exist = db_get_row_filter( + 'tmap', + [ + 'name' => $name, + 'id_group_map' => $id_group_map, + ], ); - $ip_mask = get_parameter( - 'ip_mask', - '' - ); - $source = (string) get_parameter('source', 'group'); - $dont_show_subgroups = (int) get_parameter_checkbox( - 'dont_show_subgroups', - 0 - ); - $node_radius = (int) get_parameter('node_radius', 40); - $description = get_parameter('description', ''); + hd('Entraaaa', true); + hd($exist, true); + if ($exist !== false) { + $result_txt = ui_print_error_message(__('Another network map already exists with this name and group.')); + } else { + // Default size values. + $width = $config['networkmap_max_width']; + $height = $config['networkmap_max_width']; - $offset_x = get_parameter('pos_x', 0); - $offset_y = get_parameter('pos_y', 0); - $scale_z = get_parameter('scale_z', 0.5); + $method = (string) get_parameter('method', 'fdp'); - $node_sep = get_parameter('node_sep', '0.25'); - $rank_sep = get_parameter('rank_sep', ($method === 'twopi') ? '1.0' : '0.5'); - - $mindist = get_parameter('mindist', '1.0'); - $kval = get_parameter('kval', '0.3'); - - $refresh_time = get_parameter('refresh_time', '300'); - - $values = []; - $values['name'] = $name; - $values['id_group'] = implode(',', $id_group); - $values['source_period'] = 60; - $values['width'] = $width; - $values['height'] = $height; - $values['id_user'] = $config['id_user']; - $values['description'] = $description; - $values['id_group_map'] = $id_group_map; - $values['refresh_time'] = $refresh_time; - - switch ($method) { - case 'twopi': - $values['generation_method'] = LAYOUT_RADIAL; - break; - - case 'dot': - $values['generation_method'] = LAYOUT_FLAT; - break; - - case 'circo': - $values['generation_method'] = LAYOUT_CIRCULAR; - break; - - case 'neato': - $values['generation_method'] = LAYOUT_SPRING1; - break; - - case 'fdp': - $values['generation_method'] = LAYOUT_SPRING2; - break; - - case 'radial_dinamic': - $values['generation_method'] = LAYOUT_RADIAL_DYNAMIC; - break; - - default: - $values['generation_method'] = LAYOUT_RADIAL; - break; - } - - if ($source == 'group') { - $values['source'] = 0; - $values['source_data'] = implode(',', $id_group); - } else if ($source == 'recon_task') { - $values['source'] = 1; - $values['source_data'] = $recon_task_id; - } else if ($source == 'ip_mask') { - $values['source'] = 2; - $values['source_data'] = $ip_mask; - } - - if ($networkmap_write === false && $networkmap_manage === false) { - db_pandora_audit( - AUDIT_LOG_ACL_VIOLATION, - 'Trying to access networkmap' + $recon_task_id = (int) get_parameter( + 'recon_task_id', + 0 ); - include 'general/noaccess.php'; - return; - } - - $filter = []; - $filter['dont_show_subgroups'] = $dont_show_subgroups; - $filter['node_radius'] = $node_radius; - $filter['x_offs'] = $offset_x; - $filter['y_offs'] = $offset_y; - $filter['z_dash'] = $scale_z; - $filter['node_sep'] = $node_sep; - $filter['rank_sep'] = $rank_sep; - $filter['mindist'] = $mindist; - $filter['kval'] = $kval; - - $values['filter'] = json_encode($filter); - - $result = false; - if (!empty($name)) { - $result = db_process_sql_insert( - 'tmap', - $values + $ip_mask = get_parameter( + 'ip_mask', + '' ); - } + $source = (string) get_parameter('source', 'group'); + $dont_show_subgroups = (int) get_parameter_checkbox( + 'dont_show_subgroups', + 0 + ); + $node_radius = (int) get_parameter('node_radius', 40); + $description = get_parameter('description', ''); - $result_txt = ui_print_result_message( - $result, - __('Succesfully created'), - __('Could not be created'), - '', - true - ); + $offset_x = get_parameter('pos_x', 0); + $offset_y = get_parameter('pos_y', 0); + $scale_z = get_parameter('scale_z', 0.5); - $id = $result; - define('_id_', $id); + $node_sep = get_parameter('node_sep', '0.25'); + $rank_sep = get_parameter('rank_sep', ($method === 'twopi') ? '1.0' : '0.5'); - if ($result !== false) { - $tab = 'view'; - if ($values['generation_method'] == LAYOUT_RADIAL_DYNAMIC) { - $tab = 'r_dinamic'; - define('_activeTab_', 'radial_dynamic'); - $url = 'index.php?sec=network&sec2=operation/agentes/networkmap.dinamic&activeTab=radial_dynamic'; - header( - 'Location: '.ui_get_full_url( - $url.'&id_networkmap='.$id - ) + $mindist = get_parameter('mindist', '1.0'); + $kval = get_parameter('kval', '0.3'); + + $refresh_time = get_parameter('refresh_time', '300'); + + $values = []; + $values['name'] = $name; + $values['id_group'] = implode(',', $id_group); + $values['source_period'] = 60; + $values['width'] = $width; + $values['height'] = $height; + $values['id_user'] = $config['id_user']; + $values['description'] = $description; + $values['id_group_map'] = $id_group_map; + $values['refresh_time'] = $refresh_time; + + switch ($method) { + case 'twopi': + $values['generation_method'] = LAYOUT_RADIAL; + break; + + case 'dot': + $values['generation_method'] = LAYOUT_FLAT; + break; + + case 'circo': + $values['generation_method'] = LAYOUT_CIRCULAR; + break; + + case 'neato': + $values['generation_method'] = LAYOUT_SPRING1; + break; + + case 'fdp': + $values['generation_method'] = LAYOUT_SPRING2; + break; + + case 'radial_dinamic': + $values['generation_method'] = LAYOUT_RADIAL_DYNAMIC; + break; + + default: + $values['generation_method'] = LAYOUT_RADIAL; + break; + } + + if ($source == 'group') { + $values['source'] = 0; + $values['source_data'] = implode(',', $id_group); + } else if ($source == 'recon_task') { + $values['source'] = 1; + $values['source_data'] = $recon_task_id; + } else if ($source == 'ip_mask') { + $values['source'] = 2; + $values['source_data'] = $ip_mask; + } + + if ($networkmap_write === false && $networkmap_manage === false) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access networkmap' ); - } else { - $url = 'index.php?sec=network&sec2=operation/agentes/pandora_networkmap'; - header( - 'Location: '.ui_get_full_url( - $url.'&tab='.$tab.'&id_networkmap='.$id - ) + include 'general/noaccess.php'; + return; + } + + $filter = []; + $filter['dont_show_subgroups'] = $dont_show_subgroups; + $filter['node_radius'] = $node_radius; + $filter['x_offs'] = $offset_x; + $filter['y_offs'] = $offset_y; + $filter['z_dash'] = $scale_z; + $filter['node_sep'] = $node_sep; + $filter['rank_sep'] = $rank_sep; + $filter['mindist'] = $mindist; + $filter['kval'] = $kval; + + $values['filter'] = json_encode($filter); + + $result = false; + if (!empty($name)) { + $result = db_process_sql_insert( + 'tmap', + $values ); } + + $result_txt = ui_print_result_message( + $result, + __('Succesfully created'), + __('Could not be created'), + '', + true + ); + + $id = $result; + define('_id_', $id); + + if ($result !== false) { + $tab = 'view'; + if ($values['generation_method'] == LAYOUT_RADIAL_DYNAMIC) { + $tab = 'r_dinamic'; + define('_activeTab_', 'radial_dynamic'); + $url = 'index.php?sec=network&sec2=operation/agentes/networkmap.dinamic&activeTab=radial_dynamic'; + header( + 'Location: '.ui_get_full_url( + $url.'&id_networkmap='.$id + ) + ); + } else { + $url = 'index.php?sec=network&sec2=operation/agentes/pandora_networkmap'; + header( + 'Location: '.ui_get_full_url( + $url.'&tab='.$tab.'&id_networkmap='.$id + ) + ); + } + } } } } @@ -464,70 +477,81 @@ else if ($update_networkmap || $copy_networkmap || $delete) { } $name = (string) get_parameter('name', ''); - - $recon_task_id = (int) get_parameter( - 'recon_task_id', - 0 + $exist = db_get_row_filter( + 'tmap', + [ + 'name' => $name, + 'id_group_map' => $id_group_map, + ], ); - $source = (string) get_parameter('source', 'group'); - - $offset_x = get_parameter('pos_x', 0); - $offset_y = get_parameter('pos_y', 0); - $scale_z = get_parameter('scale_z', 0.5); - - $refresh_time = get_parameter('refresh_time', '300'); - - $values = []; - $values['name'] = $name; - $values['id_group'] = implode(',', $id_group); - $values['id_group_map'] = $id_group_map; - - $description = get_parameter('description', ''); - $values['description'] = $description; - - $values['refresh_time'] = $refresh_time; - - $dont_show_subgroups = (int) get_parameter('dont_show_subgroups', 0); - $node_radius = (int) get_parameter('node_radius', 40); - $row = db_get_row('tmap', 'id', $id); - $filter = json_decode($row['filter'], true); - $filter['dont_show_subgroups'] = $dont_show_subgroups; - $filter['node_radius'] = $node_radius; - $filter['x_offs'] = $offset_x; - $filter['y_offs'] = $offset_y; - $filter['z_dash'] = $scale_z; - - $values['filter'] = json_encode($filter); - - $result = false; - if (empty($name) === false) { - $result = db_process_sql_update( - 'tmap', - $values, - ['id' => $id] + if ($exist !== false) { + $result_txt = ui_print_error_message(__('Another network map already exists with this name and group.')); + } else { + $recon_task_id = (int) get_parameter( + 'recon_task_id', + 0 ); - ui_update_name_fav_element($id, 'Network_map', $name); - } - $result_txt = ui_print_result_message( - $result, - __('Succesfully updated'), - __('Could not be updated'), - '', - true - ); + $source = (string) get_parameter('source', 'group'); - if ($result) { - // If change the group, the map must be regenerated - if ($id_group != $id_group_old) { - networkmap_delete_nodes($id); - // Delete relations. - networkmap_delete_relations($id); + $offset_x = get_parameter('pos_x', 0); + $offset_y = get_parameter('pos_y', 0); + $scale_z = get_parameter('scale_z', 0.5); + + $refresh_time = get_parameter('refresh_time', '300'); + + $values = []; + $values['name'] = $name; + $values['id_group'] = implode(',', $id_group); + $values['id_group_map'] = $id_group_map; + + $description = get_parameter('description', ''); + $values['description'] = $description; + + $values['refresh_time'] = $refresh_time; + + $dont_show_subgroups = (int) get_parameter('dont_show_subgroups', 0); + $node_radius = (int) get_parameter('node_radius', 40); + $row = db_get_row('tmap', 'id', $id); + $filter = json_decode($row['filter'], true); + $filter['dont_show_subgroups'] = $dont_show_subgroups; + $filter['node_radius'] = $node_radius; + $filter['x_offs'] = $offset_x; + $filter['y_offs'] = $offset_y; + $filter['z_dash'] = $scale_z; + + $values['filter'] = json_encode($filter); + + $result = false; + if (empty($name) === false) { + $result = db_process_sql_update( + 'tmap', + $values, + ['id' => $id] + ); + ui_update_name_fav_element($id, 'Network_map', $name); } - $networkmap_write = $networkmap_write_new; - $networkmap_manage = $networkmap_manage_new; + $result_txt = ui_print_result_message( + $result, + __('Succesfully updated'), + __('Could not be updated'), + '', + true + ); + + if ($result) { + // If change the group, the map must be regenerated + if ($id_group != $id_group_old) { + networkmap_delete_nodes($id); + // Delete relations. + networkmap_delete_relations($id); + } + + $networkmap_write = $networkmap_write_new; + $networkmap_manage = $networkmap_manage_new; + } } } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 92f1875513..04a51cb88a 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2560,7 +2560,7 @@ try { [ 'id' => $table_id, 'class' => 'info_table events', - 'style' => 'width: 99%;', + 'style' => 'width: 100%;', 'ajax_url' => 'operation/events/events', 'ajax_data' => [ 'get_events' => 1, diff --git a/pandora_console/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php index 63b302062c..536f470fe6 100755 --- a/pandora_console/operation/inventory/inventory.php +++ b/pandora_console/operation/inventory/inventory.php @@ -804,7 +804,7 @@ if ($inventory_module !== 'basic') { [ 'id' => $id_table, 'class' => 'info_table w100p', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columns, 'no_sortable_columns' => [], @@ -919,7 +919,7 @@ if ($inventory_module !== 'basic') { [ 'id' => $id_table, 'class' => 'info_table w100p', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columns, 'no_sortable_columns' => [], @@ -1083,7 +1083,7 @@ if ($inventory_module !== 'basic') { [ 'id' => $id_table, 'class' => 'info_table w100p', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columns, 'no_sortable_columns' => [], @@ -1173,7 +1173,7 @@ if ($inventory_module !== 'basic') { [ 'id' => $id_table, 'class' => 'info_table w100p', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columns, 'no_sortable_columns' => [], @@ -1188,6 +1188,8 @@ if ($inventory_module !== 'basic') { 'emptyTable' => __('No inventory found'), 'return' => true, 'no_sortable_columns' => [], + 'mini_search' => true, + 'mini_pagination' => true, ] ); @@ -1204,7 +1206,7 @@ if ($inventory_module !== 'basic') { [ 'id' => $id_table, 'class' => 'info_table w100p', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columns, 'no_sortable_columns' => [], @@ -1233,7 +1235,7 @@ if ($inventory_module !== 'basic') { $agentes = []; $data = []; $class = 'info_table'; - $style = 'width: 99%'; + $style = 'width: 100%'; $ordering = true; $searching = false; diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 15716e653c..5d402a5793 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -39,10 +39,26 @@ if (! check_acl($config['id_user'], 0, 'AR')) { exit; } +// Ajax callbacks. +if (is_ajax() === true) { + $get_filter_values = get_parameter('get_filter_values', 0); + // Get values of the current network filter. + if ($get_filter_values) { + $id = get_parameter('id'); + $filter_values = db_get_row_filter('tnetwork_explorer_filter', ['id' => $id]); + // Decode HTML entities. + $filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']); + echo json_encode($filter_values); + } + + return; +} + // Include JS timepicker. ui_include_time_picker(); // Query params and other initializations. +$filter_id = (int) get_parameter('filter_id', 0); $time_greater = get_parameter('time_greater', date(TIME_FORMAT)); $date_greater = get_parameter('date_greater', date(DATE_FORMAT)); $utimestamp_greater = strtotime($date_greater.' '.$time_greater); @@ -59,6 +75,13 @@ $top = (int) get_parameter('top', 10); $main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', ''); if (is_numeric($main_value) && !in_array($action, ['udp', 'tcp'])) { $main_value = ''; +} else { + $filter['ip'] = $main_value; +} + +$advanced_filter = get_parameter('advanced_filter', ''); +if ($advanced_filter !== '') { + $filter['advanced_filter'] = $advanced_filter; } $order_by = get_parameter('order_by', 'bytes'); @@ -66,30 +89,143 @@ if (!in_array($order_by, ['bytes', 'pkts', 'flows'])) { $order_by = 'bytes'; } -$style_end = ($is_period) ? 'display: none;' : ''; -$style_period = ($is_period) ? '' : 'display: none;'; +$save = get_parameter('save_button', ''); +$update = get_parameter('update_button', ''); + +// Save user defined filter. +if ($save != '' && check_acl($config['id_user'], 0, 'AW')) { + // Save filter args. + $data['filter_name'] = get_parameter('filter_name'); + $data['top'] = $top; + $data['action'] = $action; + $data['advanced_filter'] = $advanced_filter; + + + $filter_id = db_process_sql_insert('tnetwork_explorer_filter', $data); + if ($filter_id === false) { + $filter_id = 0; + ui_print_error_message(__('Error creating filter')); + } else { + ui_print_success_message(__('Filter created successfully')); + } +} else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) { + // Update current filter. + // Do not update the filter name and group. + $data['top'] = $top; + $data['action'] = $action; + $data['advanced_filter'] = $advanced_filter; + + $result = db_process_sql_update( + 'tnetwork_explorer_filter', + $data, + ['id' => $filter_id] + ); + ui_print_result_message( + $result, + __('Filter updated successfully'), + __('Error updating filter') + ); +} // Build the table. -$table = new stdClass(); -$table->class = 'filter-table-adv'; -$table->width = '100%'; -$table->data = []; +$filterTable = new stdClass(); +$filterTable->id = ''; +$filterTable->class = 'filter-table-adv'; +$filterTable->size = []; +$filterTable->size[0] = '33%'; +$filterTable->size[1] = '33%'; +$filterTable->size[2] = '33%'; +$filterTable->data = []; -$table->data[0][] = html_print_label_input_block( - __('Data to show'), - html_print_select( - network_get_report_actions(false), - 'action', - $action, +$filterTable->data[0][0] = html_print_label_input_block( + __('Interval'), + html_print_extended_select_for_time( + 'period', + $period, '', '', 0, + false, + true + ), + [ 'div_id' => 'period_container' ] +); + +$filterTable->data[0][0] .= html_print_label_input_block( + __('Start date'), + html_print_div( + [ + 'class' => '', + 'content' => html_print_input_text( + 'date_lower', + $date_lower, + false, + 13, + 10, + true + ).html_print_image( + 'images/calendar_view_day.png', + true, + [ + 'alt' => 'calendar', + 'class' => 'main_menu_icon invert_filter', + ] + ).html_print_input_text( + 'time_lower', + $time_lower, + false, + 10, + 8, + true + ), + ], + true + ), + [ 'div_id' => 'end_date_container' ] +); + +$filterTable->data[0][1] = html_print_label_input_block( + __('End date'), + html_print_div( + [ + 'content' => html_print_input_text( + 'date', + $date_greater, + false, + 13, + 10, + true + ).html_print_image( + 'images/calendar_view_day.png', + true, + ['alt' => 'calendar'] + ).html_print_input_text( + 'time', + $time_greater, + false, + 10, + 8, + true + ), + ], true ) ); -$table->data[0][] = html_print_label_input_block( - __('Number of result to show'), +$filterTable->data[0][2] = html_print_label_input_block( + __('Defined period'), + html_print_checkbox_switch( + 'is_period', + 1, + ($is_period === true) ? 1 : 0, + true, + false, + 'nf_view_click_period()' + ) +); + +$filterTable->data[1][] = html_print_label_input_block( + __('Results to show'), html_print_select( [ '5' => 5, @@ -110,95 +246,62 @@ $table->data[0][] = html_print_label_input_block( ) ); -$table->data[1][] = html_print_label_input_block( - __('Start date'), - html_print_div( - [ - 'id' => 'end_date_container', - 'content' => html_print_input_text( - 'date_lower', - $date_lower, - '', - 10, - 10, - true - ).html_print_input_text( - 'time_lower', - $time_lower, - '', - 7, - 8, - true - ), - ], - true - ).html_print_div( - [ - 'id' => 'period_container', - 'style' => 'display: none;', - 'content' => html_print_label_input_block( - '', - html_print_extended_select_for_time( - 'period', - $period, - '', - '', - 0, - false, - true - ), - ), - ], +$filterTable->data[1][] = html_print_label_input_block( + __('Data to show'), + html_print_select( + network_get_report_actions(), + 'action', + $action, + '', + '', + 0, true ) ); -$table->data[1][] = html_print_label_input_block( - __('End date'), - html_print_div( - [ - 'id' => '', - 'class' => '', - 'content' => html_print_input_text( - 'date_greater', - $date_greater, - '', - 10, - 10, - true - ).html_print_input_text( - 'time_greater', - $time_greater, - '', - 7, - 8, - true - ), - ], - true - ) +$advanced_toggle = new stdClass(); +$advanced_toggle->class = 'filter-table-adv'; +$advanced_toggle->size = []; +$advanced_toggle->size[0] = '50%'; +$advanced_toggle->size[1] = '50%'; +$advanced_toggle->width = '100%'; +$user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true); +$user_groups[0] = 0; +// Add all groups. +$sql = 'SELECT * FROM tnetwork_explorer_filter'; +$advanced_toggle->data[0][0] = html_print_label_input_block( + __('Load Filter'), + html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true, false, true, false, 'width:100%;') ); - -$table->data[2][] = html_print_label_input_block( - __('Defined period'), - html_print_checkbox_switch( - 'is_period', - 1, - ($is_period === true) ? 1 : 0, +$advanced_toggle->data[0][1] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('filter_name', '', false, 40, 45, true, false, false, '', 'w100p') +); +$advanced_toggle->colspan[1][0] = 2; +$advanced_toggle->data[1][0] = html_print_label_input_block( + __('Filter').ui_print_help_icon('pcap_filter', true), + html_print_textarea('advanced_filter', 4, 10, $advanced_filter, 'style="width:100%"', true) +); +$filterTable->colspan[2][0] = 3; +$filterTable->data[2][0] = html_print_label_input_block( + '', + ui_toggle( + html_print_table($advanced_toggle, true), + __('Advanced'), + '', + '', true, - false, - 'network_report_click_period(event)' + true, + '', + 'white-box-content', + 'box-flat white_table_graph' ) ); -echo '
'; -html_print_input_hidden('order_by', $order_by); -if (empty($main_value) === false) { - html_print_input_hidden('main_value', $main_value); -} - -$outputTable = html_print_table($table, true); -$outputTable .= html_print_div( +$filterInputTable = ''; +$filterInputTable .= html_print_input_hidden('order_by', $order_by); +$filterInputTable .= html_print_table($filterTable, true); +$filterInputTable .= html_print_div( [ 'class' => 'action-buttons-right-forced', 'content' => html_print_submit_button( @@ -210,19 +313,48 @@ $outputTable .= html_print_div( 'mode' => 'mini', ], true + ).html_print_submit_button( + __('Save as new filter'), + 'save_button', + false, + [ + 'icon' => 'load', + 'onClick' => 'return defineFilterName();', + 'mode' => 'mini secondary', + 'class' => 'mrgn_right_10px', + ], + true + ).html_print_submit_button( + __('Update current filter'), + 'update_button', + false, + [ + 'icon' => 'load', + 'mode' => 'mini secondary', + 'class' => 'mrgn_right_10px', + ], + true ), ], true ); +$filterInputTable .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => $netflow_button, + ], + true +); +$filterInputTable .= '
'; ui_toggle( - $outputTable, - ''.__('Filters').'', - __('Filters'), - '', + $filterInputTable, + ''.__('Filter').'', + __('Filter'), + 'search', true, false, '', - 'white-box-content', + 'white-box-content no_border', 'box-flat white_table_graph fixed_filter_bar' ); html_print_action_buttons( @@ -246,7 +378,7 @@ $data = netflow_get_top_summary( $action, $utimestamp_lower, $utimestamp_greater, - $main_value, + $filter, $order_by ); @@ -450,6 +582,26 @@ if (empty($data)) { ?> diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index e3919e90b9..ff2c99869d 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -34,6 +34,21 @@ global $config; check_login(); +// Ajax callbacks. +if (is_ajax() === true) { + $get_filter_values = get_parameter('get_filter_values', 0); + // Get values of the current network filter. + if ($get_filter_values) { + $id = get_parameter('id'); + $filter_values = db_get_row_filter('tnetwork_usage_filter', ['id' => $id]); + // Decode HTML entities. + $filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']); + echo json_encode($filter_values); + } + + return; +} + // Header. ui_print_standard_header( __('Network usage map'), @@ -76,6 +91,7 @@ $is_period = (bool) get_parameter('is_period', false); $period = (int) get_parameter('period', SECONDS_1HOUR); $time_lower = get_parameter('time_lower', date(TIME_FORMAT, ($utimestamp_greater - $period))); $date_lower = get_parameter('date_lower', date(DATE_FORMAT, ($utimestamp_greater - $period))); +$advanced_filter = get_parameter('advanced_filter', ''); $utimestamp_lower = ($is_period) ? ($utimestamp_greater - $period) : strtotime($date_lower.' '.$time_lower); if (!$is_period) { $period = ($utimestamp_greater - $utimestamp_lower); @@ -88,6 +104,44 @@ if (in_array($order_by, ['bytes', 'pkts', 'flows']) === false) { $order_by = 'bytes'; } +$save = get_parameter('save_button', ''); +$update = get_parameter('update_button', ''); + +// Save user defined filter. +if ($save != '' && check_acl($config['id_user'], 0, 'AW')) { + // Save filter args. + $data['filter_name'] = get_parameter('filter_name'); + $data['top'] = $top; + $data['action'] = $action; + $data['advanced_filter'] = $advanced_filter; + + + $filter_id = db_process_sql_insert('tnetwork_usage_filter', $data); + if ($filter_id === false) { + $filter_id = 0; + ui_print_error_message(__('Error creating filter')); + } else { + ui_print_success_message(__('Filter created successfully')); + } +} else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) { + // Update current filter. + // Do not update the filter name and group. + $data['top'] = $top; + $data['action'] = $action; + $data['advanced_filter'] = $advanced_filter; + + $result = db_process_sql_update( + 'tnetwork_usage_filter', + $data, + ['id' => $filter_id] + ); + ui_print_result_message( + $result, + __('Filter updated successfully'), + __('Error updating filter') + ); +} + if ((bool) $config['activate_netflow'] === true) { $netflow_button = html_print_submit_button( __('Show netflow map'), @@ -95,6 +149,27 @@ if ((bool) $config['activate_netflow'] === true) { false, ['icon' => 'update'], true + ).html_print_submit_button( + __('Save as new filter'), + 'save_button', + false, + [ + 'icon' => 'load', + 'onClick' => 'return defineFilterName();', + 'mode' => 'mini secondary', + 'class' => 'mrgn_right_10px', + ], + true + ).html_print_submit_button( + __('Update current filter'), + 'update_button', + false, + [ + 'icon' => 'load', + 'mode' => 'mini secondary', + 'class' => 'mrgn_right_10px', + ], + true ); } else { $netflow_button = ''; @@ -232,6 +307,44 @@ $filterTable->data[1][] = html_print_label_input_block( ) ); +$advanced_toggle = new stdClass(); +$advanced_toggle->class = 'filter-table-adv'; +$advanced_toggle->size = []; +$advanced_toggle->size[0] = '50%'; +$advanced_toggle->size[1] = '50%'; +$advanced_toggle->width = '100%'; +$user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true); +$user_groups[0] = 0; +$sql = 'SELECT * FROM tnetwork_usage_filter'; +$advanced_toggle->data[0][0] = html_print_label_input_block( + __('Load Filter'), + html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true, false, true, false, 'width:100%;') +); +$advanced_toggle->data[0][1] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('filter_name', '', false, 40, 45, true, false, false, '', 'w100p') +); +$advanced_toggle->colspan[1][0] = 2; +$advanced_toggle->data[1][0] = html_print_label_input_block( + __('Filter').ui_print_help_icon('pcap_filter', true), + html_print_textarea('advanced_filter', 4, 10, $advanced_filter, 'style="width:100%"', true) +); +$filterTable->colspan[2][0] = 3; +$filterTable->data[2][0] = html_print_label_input_block( + '', + ui_toggle( + html_print_table($advanced_toggle, true), + __('Advanced'), + '', + '', + true, + true, + '', + 'white-box-content', + 'box-flat white_table_graph' + ) +); + $filterInputTable = '
'; $filterInputTable .= html_print_input_hidden('order_by', $order_by); $filterInputTable .= html_print_table($filterTable, true); @@ -263,7 +376,8 @@ if ((bool) get_parameter('update_netflow') === true) { $utimestamp_lower, $utimestamp_greater, $top, - ($action === 'talkers') ? 'srcip' : 'dstip' + ($action === 'talkers') ? 'srcip' : 'dstip', + $advanced_filter ); $has_data = !empty($map_data['nodes']); } @@ -283,10 +397,26 @@ if ($has_data === true) {