diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 9880d55476..eb17d47c21 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, AIX version +# Version 7.0NG.745, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 5f18593278..51972f7e78 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, FreeBSD Version +# Version 7.0NG.745, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 8c09c2e1db..f562ee4053 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, HP-UX Version +# Version 7.0NG.745, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index b2989b95e8..4c1178a025 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, GNU/Linux +# Version 7.0NG.745, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index a708087446..c254df3ed4 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, GNU/Linux +# Version 7.0NG.745, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 6ae2ae474f..46e3c5c0db 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, Solaris Version +# Version 7.0NG.745, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 4d2b4dc5c4..f1a79ad265 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.744 +# Version 7.0NG.745 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index f0bf132498..b2eac4399a 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.744, AIX version +# Version 7.0NG.745, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 3a79c9f3dc..094c2f850b 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.744 +# Version 7.0NG.745 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index dbb5c3e79f..6b1779741e 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.744, HPUX Version +# Version 7.0NG.745, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 0351cb9fea..cb94b50604 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744 +# Version 7.0NG.745 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 660a616e40..779da4af44 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744 +# Version 7.0NG.745 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 6303271947..fd9a754f23 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744 +# Version 7.0NG.745 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index fd40952a8e..934e8092c8 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.744, Solaris version +# Version 7.0NG.745, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 2860d5f0bc..59dfa821b8 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, AIX version +# Version 7.0NG.745, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 41729be605..5f9d720497 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.744-200415 +Version: 7.0NG.745-200519 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 109cb398bf..ddfb8b8732 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.744-200415" +pandora_version="7.0NG.745-200519" 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/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 3477cb8ff2..9f1321be59 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, GNU/Linux +# Version 7.0NG.745, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 1c38ab4504..ef101119e1 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, FreeBSD Version +# Version 7.0NG.745, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 7ec21a8215..ac1d967039 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, HP-UX Version +# Version 7.0NG.745, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 52ca10f17b..7cb462f7e1 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, GNU/Linux +# Version 7.0NG.745, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 36216608dc..7c614a4d94 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, GNU/Linux +# Version 7.0NG.745, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index db64cb1514..e1fe45e718 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, NetBSD Version +# Version 7.0NG.745, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 0f34c6623e..5855922016 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.744, Solaris Version +# Version 7.0NG.745, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 4a71ee35b9..d073cb4579 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -54,8 +54,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.744'; -use constant AGENT_BUILD => '200415'; +use constant AGENT_VERSION => '7.0NG.745'; +use constant AGENT_BUILD => '200519'; # 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 22bca871b1..7644b9583e 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 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 4bbbce0199..f7fb42fb27 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 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 5ebb27d919..315e1e5ad9 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,8 +9,8 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.744" -PI_BUILD="200415" +PI_VERSION="7.0NG.745" +PI_BUILD="200519" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_plugins/Autodiscover services/autodiscover.py b/pandora_agents/unix/plugins/autodiscover similarity index 100% rename from pandora_plugins/Autodiscover services/autodiscover.py rename to pandora_agents/unix/plugins/autodiscover diff --git a/pandora_agents/unix/plugins/pandora_mem b/pandora_agents/unix/plugins/pandora_mem index 998438d5b6..43883744d8 100755 --- a/pandora_agents/unix/plugins/pandora_mem +++ b/pandora_agents/unix/plugins/pandora_mem @@ -33,9 +33,16 @@ my $freemem=`cat /proc/meminfo | grep 'MemFree' | awk '{ print \$2 } '`; my $cached=`cat /proc/meminfo | grep '^Cached:' | awk '{ print \$2 } '`; my $cachedswap=`cat /proc/meminfo | grep '^SwapCached:' | awk '{ print \$2 }'`; my $total_meminfo=`cat /proc/meminfo | grep 'MemTotal:' | awk '{ print \$2 }'`; -my $available=$freemem+$cached+$cachedswap; +my $available_new=`cat /proc/meminfo | grep 'MemAvailable:' | awk '{ print \$2 }'`; +my $available; +if ($available_new == 0){ + $available=$freemem+$cached+$cachedswap; +}else{ + $available=$available_new; +} my $available_percent = floor(($available / $total_meminfo)*100); +my $USED = 100 - $available_percent; print "\n"; print "\n"; diff --git a/pandora_agents/unix/plugins/pandora_mem_used b/pandora_agents/unix/plugins/pandora_mem_used index 3ba2034d80..4bca3f3c2f 100755 --- a/pandora_agents/unix/plugins/pandora_mem_used +++ b/pandora_agents/unix/plugins/pandora_mem_used @@ -23,7 +23,13 @@ my $freemem=`cat /proc/meminfo | grep 'MemFree' | awk '{ print \$2 } '`; my $cached=`cat /proc/meminfo | grep '^Cached:' | awk '{ print \$2 } '`; my $cachedswap=`cat /proc/meminfo | grep '^SwapCached:' | awk '{ print \$2 }'`; my $total_meminfo=`cat /proc/meminfo | grep 'MemTotal:' | awk '{ print \$2 }'`; -my $available=$freemem+$cached+$cachedswap; +my $available_new=`cat /proc/meminfo | grep 'MemAvailable:' | awk '{ print \$2 }'`; +my $available; +if ($available_new == 0){ + $available=$freemem+$cached+$cachedswap; +}else{ + $available=$available_new; +} my $available_percent = floor(($available / $total_meminfo)*100); my $USED = 100 - $available_percent; diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 774797aa4b..02d730f2dc 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.744 +# Version 7.0NG.745 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/build.sh b/pandora_agents/win32/build.sh index 2759a6b9cb..ae9f4cf6e8 100755 --- a/pandora_agents/win32/build.sh +++ b/pandora_agents/win32/build.sh @@ -3,13 +3,18 @@ # The installer will be placed in ./installer/output/. # InstallJammer must be installed and in the PATH. -ARCH=`uname -m` +# ARCH may be set by other build scripts. +if [ "$ARCH" == "" ]; then + ARCH=`uname -m` +fi + +# Set the target host. if [ "$ARCH" == "x86_64" ]; then HOST="x86_64-w64-mingw32" else HOST="i686-w64-mingw32" fi -#./autogen.sh && ./configure --host=$HOST && make clean && make && cp PandoraAgent.exe bin/ && installjammer --build installer/pandora.mpi +# Compile and update the Pandora FMS Agent binary. ./autogen.sh && ./configure --host=$HOST && make clean && make && cp PandoraAgent.exe bin/ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 7cd5115d61..20df2e4b95 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.744} +{Pandora FMS Windows Agent v7.0NG.745} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200415} +{200519} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f87f3ff562..f2ffece35b 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.744(Build 200415)") +#define PANDORA_VERSION ("7.0NG.745(Build 200519)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 75104f3f81..3f86b9faae 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.744(Build 200415))" + VALUE "ProductVersion", "(7.0NG.745(Build 200519))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index af277c616a..75aea2426d 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.744-200415 +Version: 7.0NG.745-200519 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 7a1abea1ab..6e1dd718b2 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.744-200415" +pandora_version="7.0NG.745-200519" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 6b70ae21e8..644e9aa564 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -188,9 +188,10 @@ function quickShell() } else if ($method == 'telnet') { // Telnet. $port = $config['gotty_telnet_port']; + $username = preg_replace('/[^a-zA-Z0-9\-\.]/', '', $username); $command_arguments = "var args = '?arg=-l ".$username; $command_arguments .= '&arg='.$address; - $command_arguments .= '&arg='.$method_port."';"; + $command_arguments .= '&arg='.$method_port."&arg=-E';"; } else { ui_print_error_message(__('Please use SSH or Telnet.')); return; diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index c0d8f0a9db..b18abb678d 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1 +1,6 @@ -operation/servers/recon_view.php \ No newline at end of file +operation/servers/recon_view.php +operation/users/webchat.php +include/javascript/webchat.js +attachment/pandora_chat.log.json.txt +attachment/pandora_chat.user_list.json.txt +attachment/pandora_chat.global_counter.txt \ No newline at end of file diff --git a/pandora_console/extras/mr/38.sql b/pandora_console/extras/mr/38.sql index 248c1aeb52..901e0f89dc 100644 --- a/pandora_console/extras/mr/38.sql +++ b/pandora_console/extras/mr/38.sql @@ -1,5 +1,6 @@ START TRANSACTION; INSERT INTO `ttipo_modulo` VALUES (38,'web_server_status_code_string',9,'Remote HTTP module to check server status code','mod_web_data.png'); +ALTER TABLE trecon_task add column `rcmd_enabled` TINYINT(1) UNSIGNED DEFAULT 0 AFTER `wmi_enabled`; COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 895ba45a8a..ca4c9f02e0 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1674,6 +1674,7 @@ ALTER TABLE trecon_task ADD `alias_as_name` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; +ALTER TABLE trecon_task ADD `rcmd_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; ALTER TABLE trecon_task ADD `summary` text; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index b443926a63..753406cc66 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -81,13 +81,6 @@ if ($config['menu_type'] == 'classic') { } - // Chat messages. - $header_chat = "
'; - - // Search. $acl_head_search = true; if ($config['acl_enterprise'] == 1 && !users_is_admin()) { @@ -417,7 +410,7 @@ if ($config['menu_type'] == 'classic') { echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
'.$header_searchbar.'
-
'.$header_chat, $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, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; ?> @@ -530,15 +523,34 @@ if ($config['menu_type'] == 'classic') { }); } - function print_toast(title, subtitle, severity, url, id, onclick) { + function closeToast(event) { + var match = /notification-(.*)-id-([0-9]+)/.exec(event.target.id); + var div_id = document.getElementById(match.input); + $(div_id).attr("hidden",true); + } + + function print_toast(title, subtitle, severity, url, id, onclick, closeToast) { // TODO severity. severity = ''; - // Start the toast. + + var parent_div = document.createElement('div'); + + // Print close image + var img = document.createElement('img'); + img.setAttribute('id', id); + img.setAttribute("src", './images/close_button_dialog.png'); + img.setAttribute('onclick', closeToast); + img.setAttribute('style', 'margin-left: 95%;'); + parent_div.appendChild(img); + + // Print a element var toast = document.createElement('a'); - toast.setAttribute('onclick', onclick); - toast.setAttribute('href', url); toast.setAttribute('target', '_blank'); + toast.setAttribute('href', url); + toast.setAttribute('onclick', onclick); + + var link_div = document.createElement('div'); // Fill toast. var toast_div = document.createElement('div'); @@ -548,9 +560,13 @@ if ($config['menu_type'] == 'classic') { var toast_text = document.createElement('p'); toast_title.innerHTML = title; toast_text.innerHTML = subtitle; - toast_div.appendChild(toast_title); + + // Append Elements + toast_div.appendChild(img); + link_div.appendChild(toast_title); + toast.appendChild(link_div); + toast_div.appendChild(toast); toast_div.appendChild(toast_text); - toast.appendChild(toast_div); // Show and program the hide event. toast_div.className = toast_div.className + ' show'; @@ -558,9 +574,11 @@ if ($config['menu_type'] == 'classic') { toast_div.className = toast_div.className.replace("show", ""); }, 8000); - return toast; - } + toast_div.appendChild(parent_div); + return toast_div; + } + function check_new_notifications() { var last_id = document.getElementById('notification-ball-header') .getAttribute('last_id'); @@ -617,9 +635,11 @@ if ($config['menu_type'] == 'classic') { ele.criticity, ele.full_url, 'notification-toast-id-' + ele.id_mensaje, - 'click_on_notification_toast(event)' + 'click_on_notification_toast(event)', + 'closeToast(event)' ) ); + }); } }, @@ -640,8 +660,6 @@ if ($config['menu_type'] == 'classic') { var fixed_header = ; - var new_chat = ; - function showinterpreter(){ document.onclick = function(e) { @@ -789,9 +807,7 @@ if ($config['menu_type'] == 'classic') { $('div#head').addClass('fixed_header'); $('div#main').css('padding-top', $('div#head').innerHeight() + 'px'); } - - check_new_chats_icon('icon_new_messages_chat'); - + /* Temporal fix to hide graphics when ui_dialog are displayed */ $("#yougotalert").click(function () { $("#agent_access").css("display", "none"); diff --git a/pandora_console/general/noaccess.php b/pandora_console/general/noaccess.php index 8f70661296..c091215829 100644 --- a/pandora_console/general/noaccess.php +++ b/pandora_console/general/noaccess.php @@ -136,8 +136,11 @@ font-size:10pt;

'; - echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name()); + echo '

'; + echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name()); + if ($config['logged'] == false) { + session_destroy(); + } ?>
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index b48590074c..e68a74bcf1 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1901,12 +1901,6 @@ if ($enable_module) { 'Fail to enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias'] ); } - - ui_print_result_message( - $result, - __('Successfully enabled'), - __('Could not be enabled') - ); } if ($disable_module) { @@ -1942,12 +1936,6 @@ if ($disable_module) { 'Fail to disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias'] ); } - - ui_print_result_message( - $result, - __('Successfully disabled'), - __('Could not be disabled') - ); } // Fix to stop the module from being added to the agent's conf diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index c026015cc7..f4134a27e2 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -16,7 +16,7 @@ global $config; check_login(); -require 'vendor/autoload.php'; +require_once $config['homedir'].'/vendor/autoload.php'; use PandoraFMS\Dashboard\Manager; @@ -46,6 +46,54 @@ if ($enterprise_include) { enterprise_include_once('meta/include/functions_users_meta.php'); } + +if (!is_metaconsole()) { + date_default_timezone_set('UTC'); + include 'include/javascript/timezonepicker/includes/parser.inc'; + + // Read in options for map builder. + $bases = [ + 'gray' => 'Gray', + 'blue-marble' => 'Blue marble', + 'night-electric' => 'Night Electric', + 'living' => 'Living Earth', + ]; + + $local_file = 'include/javascript/timezonepicker/images/gray-400.png'; + + // Dimensions must always be exact since the imagemap does not scale. + $array_size = getimagesize($local_file); + + $map_width = $array_size[0]; + $map_height = $array_size[1]; + + $timezones = timezone_picker_parse_files( + $map_width, + $map_height, + 'include/javascript/timezonepicker/tz_world.txt', + 'include/javascript/timezonepicker/tz_islands.txt' + ); + + + foreach ($timezones as $timezone_name => $tz) { + if ($timezone_name == 'America/Montreal') { + $timezone_name = 'America/Toronto'; + } else if ($timezone_name == 'Asia/Chongqing') { + $timezone_name = 'Asia/Shanghai'; + } + + $area_data_timezone_polys .= ''; + foreach ($tz['polys'] as $coords) { + $area_data_timezone_polys .= ''; + } + + $area_data_timezone_rects .= ''; + foreach ($tz['rects'] as $coords) { + $area_data_timezone_rects .= ''; + } + } +} + // This defines the working user. Beware with this, old code get confusses // and operates with current logged user (dangerous). $id = get_parameter('id', get_parameter('id_user', '')); @@ -75,6 +123,12 @@ if (! check_acl($config['id_user'], 0, 'UM')) { $tab = get_parameter('tab', 'user'); +if ($id) { + $header_title = ' » '.__('Update user'); +} else { + $header_title = ' » '.__('Create user'); +} + // Header if ($meta) { user_meta_print_header(); @@ -94,7 +148,7 @@ if ($meta) { $buttons[$tab]['active'] = true; ui_print_page_header( - __('User detail editor'), + __('User detail editor').$header_title, 'images/gm_users.png', false, 'profile_tab', @@ -625,59 +679,61 @@ if ($values) { $user_info = $values; } -$table = new stdClass(); -$table->id = 'user_configuration_table'; -$table->width = '100%'; -$table->class = 'databox filters'; if (defined('METACONSOLE')) { if ($id) { - $table->head[0] = __('Update User'); + echo '
'.__('Update User').'
'; } else { - $table->head[0] = __('Create User'); + echo '
'.__('Create User').'
'; } - - $table->head_colspan[0] = 5; - $table->headstyle[0] = 'text-align: center'; } -$table->data = []; -$table->colspan = []; -$table->size = []; -$table->size[0] = '35%'; -$table->size[1] = '65%'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; +if (!$new_user) { + $user_id = '

'.__('User ID').':

'; + $user_id .= ''.$id.''; + $user_id .= html_print_input_hidden('id_user', $id, true); + $user_id .= '
'; +} else { + $user_id = '
'.html_print_input_text_extended( + 'id_user', + $id, + '', + '', + 20, + 100, + !$new_user || $view_mode, + '', + [ + 'class' => 'input_line user_icon_input', + 'placeholder' => __('User ID'), + ], + true + ).'
'; +} -$table->data[0][0] = __('User ID'); -$table->data[0][1] = html_print_input_text_extended( - 'id_user', - $id, - '', - '', - 20, - 60, - !$new_user || $view_mode, - '', - '', - true -); +if (is_user_admin($id)) { + $avatar = html_print_image('images/people_1.png', true, ['class' => 'user_avatar']); +} else { + $avatar = html_print_image('images/people_2.png', true, ['class' => 'user_avatar']); +} -$table->data[1][0] = __('Full (display) name'); -$table->data[1][1] = html_print_input_text_extended( +$full_name = '
'.html_print_input_text_extended( 'fullname', $user_info['fullname'], + 'fullname', '', - '', - 30, - 125, + 20, + 100, $view_mode, '', - '', + [ + 'class' => 'input', + 'placeholder' => __('Full (display) name'), + ], true -); +).'
'; -$table->data[2][0] = __('Language'); -$table->data[2][1] = html_print_select_from_sql( +$language = '

'.__('Language').':

'; +$language .= html_print_select_from_sql( 'SELECT id_language, name FROM tlanguage', 'language', $user_info['language'], @@ -685,88 +741,112 @@ $table->data[2][1] = html_print_select_from_sql( __('Default'), 'default', true -); +).'
'; -$table->data[3][0] = __('Timezone'); -$table->data[3][1] = html_print_timezone_select('timezone', $user_info['timezone']); + +$timezone = '

'.__('Timezone').':

'; +$timezone .= html_print_timezone_select('timezone', $user_info['timezone']).'
'; if ($config['user_can_update_password']) { - $table->data[4][0] = __('Password'); - $table->data[4][1] = html_print_input_text_extended( + $new_pass = '
'.html_print_input_text_extended( 'password_new', '', + 'password_new', '', - '', - 15, - 45, + '25', + '45', $view_mode, '', - '', + [ + 'class' => 'input', + 'placeholder' => __('Password'), + ], true, true - ); - $table->data[5][0] = __('Password confirmation'); - $table->data[5][1] = html_print_input_text_extended( + ).'
'; + $new_pass_confirm = '
'.html_print_input_text_extended( 'password_confirm', '', + 'password_conf', '', - '', - 15, - 45, + '20', + '45', $view_mode, '', - '', + [ + 'class' => 'input', + 'placeholder' => __('Password confirmation'), + ], true, true - ); + ).'
'; } $own_info = get_user_info($config['id_user']); -if ($config['admin_can_make_admin']) { - $table->data[6][0] = __('Global Profile'); - $table->data[6][1] = ''; - if ($own_info['is_admin'] || $user_info['is_admin']) { - $table->data[6][1] = html_print_radio_button('is_admin', 1, '', $user_info['is_admin'], true); - $table->data[6][1] .= __('Administrator'); - $table->data[6][1] .= ui_print_help_tip(__('This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL.'), true); - $table->data[6][1] .= '
'; - } +$global_profile = '
'.__('Global Profile').': '; +$global_profile .= '
'; +$global_profile .= html_print_radio_button_extended( + 'is_admin', + 1, + [ + 'label' => __('Administrator'), + 'help_tip' => __('This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL.'), + ], + $user_info['is_admin'], + false, + '', + '', + true +); +$global_profile .= html_print_radio_button_extended( + 'is_admin', + 0, + [ + 'label' => __('Standard User'), + 'help_tip' => __('This user has separated permissions to view data in his group agents, create incidents belong to his groups, add notes in another incidents, create personal assignments or reviews and other tasks, on different profiles'), + ], + $user_info['is_admin'], + false, + '', + '', + true +); +$global_profile .= '
'; - $table->data[6][1] .= html_print_radio_button('is_admin', 0, '', $user_info['is_admin'], true); - $table->data[6][1] .= __('Standard User'); - $table->data[6][1] .= ui_print_help_tip(__('This user has separated permissions to view data in his group agents, create incidents belong to his groups, add notes in another incidents, create personal assignments or reviews and other tasks, on different profiles'), true); -} - -$table->data[7][0] = __('E-mail'); -$table->data[7][1] = html_print_input_text_extended( +$email = '
'.html_print_input_text_extended( 'email', $user_info['email'], + 'email', '', - '', - 20, - 100, + '25', + '100', $view_mode, '', - '', + [ + 'class' => 'input input_line email_icon_input', + 'placeholder' => __('E-mail'), + ], true -); +).'
'; -$table->data[8][0] = __('Phone number'); -$table->data[8][1] = html_print_input_text_extended( +$phone = '
'.html_print_input_text_extended( 'phone', $user_info['phone'], + 'phone', '', - '', - 10, - 30, + '20', + '30', $view_mode, '', - '', + [ + 'class' => 'input input_line phone_icon_input', + 'placeholder' => __('Phone number'), + ], true -); +).'
'; -$table->data[9][0] = __('Comments'); -$table->data[9][1] = html_print_textarea( +$comments = '

'.__('Comments').':

'; +$comments .= html_print_textarea( 'comments', 2, 65, @@ -795,16 +875,17 @@ if (!$meta) { // User only can change skins if has more than one group if (count($usr_groups) > 1) { if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { - $table->data[10][0] = __('Skin'); - $table->data[10][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true); + $skin = '

'.__('Skin').':

'; + $skin .= skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true).'
'; } } } if ($meta) { $array_filters = get_filters_custom_fields_view(0, true); - $table->data[11][0] = __('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true); - $table->data[11][1] = html_print_select( + + $search_custom_fields_view = '

'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'

'; + $search_custom_fields_view .= html_print_select( $array_filters, 'default_custom_view', $user_info['default_custom_view'], @@ -816,7 +897,7 @@ if ($meta) { true, '', false - ); + ).'
'; } $values = [ @@ -825,7 +906,8 @@ $values = [ 0 => __('No'), ]; -$table->data[12][0] = __('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true); +$home_screen = '

'.__('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true).'

'; +; $values = [ 'Default' => __('Default'), 'Visual console' => __('Visual console'), @@ -841,7 +923,7 @@ if (!is_metaconsole()) { } -$table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false); +$home_screen .= html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false).'
'; $dashboards = Manager::getDashboards(-1, -1); @@ -854,7 +936,7 @@ if ($dashboards === false) { } } -$table->data[12][1] .= html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true); +$home_screen .= html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true); $layouts = visual_map_get_user_layouts($config['id_user'], true); @@ -867,14 +949,14 @@ if ($layouts === false) { } } -$table->data[12][1] .= html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true); -$table->data[12][1] .= html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true, false); +$home_screen .= html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true); +$home_screen .= html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true, false); -$table->data[13][0] = __('Block size for pagination'); -$table->data[13][1] = html_print_input_text('block_size', $user_info['block_size'], '', 5, 5, true); +$size_pagination = '

'.__('Block size for pagination').'

'; +$size_pagination .= html_print_input_text('block_size', $user_info['block_size'], '', 5, 5, true).'
'; if ($id == $config['id_user']) { - $table->data[13][1] .= html_print_input_hidden('quick_language_change', 1, true); + $language .= html_print_input_hidden('quick_language_change', 1, true); } if (enterprise_installed() && defined('METACONSOLE')) { @@ -883,12 +965,12 @@ if (enterprise_installed() && defined('METACONSOLE')) { $user_info_metaconsole_access = $user_info['metaconsole_access']; } - $table->data[13][0] = __('Metaconsole access').' '.ui_print_help_icon('meta_access', true); + $meta_access = '

'.__('Metaconsole access').' '.ui_print_help_icon('meta_access', true).'

'; $metaconsole_accesses = [ 'basic' => __('Basic'), 'advanced' => __('Advanced'), ]; - $table->data[13][1] = html_print_select( + $meta_access .= html_print_select( $metaconsole_accesses, 'metaconsole_access', $user_info_metaconsole_access, @@ -898,16 +980,16 @@ if (enterprise_installed() && defined('METACONSOLE')) { true, false, false - ); + ).'
'; } -$table->data[14][0] = __('Not Login'); -$table->data[14][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); -$table->data[14][1] = html_print_checkbox('not_login', 1, $user_info['not_login'], true); +$not_login = '

'.__('Not Login').'

'; +$not_login .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); +$not_login .= html_print_checkbox_switch('not_login', 1, $user_info['not_login'], true).'
'; -$table->data[15][0] = __('Session Time'); -$table->data[15][0] .= ui_print_help_tip(__('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), true); -$table->data[15][1] = html_print_input_text('session_time', $user_info['session_time'], '', 5, 5, true); +$session_time = '

'.__('Session Time'); +$session_time .= ui_print_help_tip(__('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), true).'

'; +$session_time .= html_print_input_text('session_time', $user_info['session_time'], '', 5, 5, true.false, false, '', 'class="input_line_small"').'
'; $event_filter_data = db_get_all_rows_sql('SELECT id_name, id_filter FROM tevent_filter'); if ($event_filter_data === false) { @@ -920,69 +1002,104 @@ foreach ($event_filter_data as $filter) { $event_filter[$filter['id_filter']] = $filter['id_name']; } -$table->data[16][0] = __('Default event filter'); -$table->data[16][1] = html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false); +$default_event_filter = '

'.__('Default event filter').'

'; +$default_event_filter .= html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false).'
'; -$table->data[17][0] = __('Disabled newsletter'); +$newsletter = '

'.__('Disabled newsletter').'

'; if ($user_info['middlename'] >= 0) { $middlename = false; } else { $middlename = true; } -$table->data[17][1] = html_print_checkbox( +$newsletter .= html_print_checkbox_switch( 'middlename', -1, $middlename, true -); +).'
'; if ($config['ehorus_user_level_conf']) { - $table->data[18][0] = __('eHorus user acces enabled'); - $table->data[18][1] = html_print_checkbox('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true); - $table->data[19][0] = __('eHorus user'); - $table->data[20][0] = __('eHorus password'); - $table->data[19][1] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true); - $table->data[20][1] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true); + $ehorus = '

'.__('eHorus user access enabled').'

'; + $ehorus .= html_print_checkbox_switch('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true).'
'; + $ehorus .= '
'; + $ehorus .= '

'.__('eHorus user').'

'; + $ehorus .= html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true).'
'; + $ehorus .= '

'.__('eHorus password').'

'; + $ehorus .= html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true).'
'; + $ehorus .= '
'; } if ($meta) { enterprise_include_once('include/functions_metaconsole.php'); - $data = []; - $data[0] = __('Enable agents managment'); - $data[1] = html_print_checkbox('metaconsole_agents_manager', 1, $user_info['metaconsole_agents_manager'], true); - $table->rowclass[] = ''; - $table->rowstyle[] = 'font-weight: bold;'; - $table->data['metaconsole_agents_manager'] = $data; + $metaconsole_agents_manager = '

'.__('Enable agents managment').'

'; + $metaconsole_agents_manager .= html_print_checkbox_switch('metaconsole_agents_manager', 1, $user_info['metaconsole_agents_manager'], true).'
'; - $data = []; - $data[0] = __('Assigned node').ui_print_help_tip(__('Server where the agents created of this user will be placed'), true); + $metaconsole_assigned_server = '

'.__('Assigned node').ui_print_help_tip(__('Server where the agents created of this user will be placed'), true).'

'; $servers = metaconsole_get_servers(); $servers_for_select = []; foreach ($servers as $server) { $servers_for_select[$server['id']] = $server['server_name']; } - $data[1] = html_print_select($servers_for_select, 'metaconsole_assigned_server', $user_info['metaconsole_assigned_server'], '', '', -1, true, false, false); - $table->rowclass[] = ''; - $table->rowstyle[] = 'font-weight: bold;'; - $table->data['metaconsole_assigned_server'] = $data; + $metaconsole_assigned_server .= html_print_select($servers_for_select, 'metaconsole_assigned_server', $user_info['metaconsole_assigned_server'], '', '', -1, true, false, false).'
'; - $data = []; - $data[0] = __('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true); - $data[2] = html_print_checkbox('metaconsole_access_node', 1, $user_info['metaconsole_access_node'], true); - $table->rowclass[] = ''; - $table->rowstyle[] = ''; - $table->data['metaconsole_access_node'] = $data; + $metaconsole_access_node = '

'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'

'; + $metaconsole_access_node .= html_print_checkbox('metaconsole_access_node', 1, $user_info['metaconsole_access_node'], true).'
'; } echo '
'; -html_print_table($table); -echo '
'; +if (!$id) { + $user_id_update_view = $user_id; + $user_id_create = ''; +} else { + $user_id_update_view = ''; + $user_id_create = $user_id; +} + +if (is_metaconsole()) { + $access_or_pagination = $meta_access; +} else { + $access_or_pagination = $size_pagination; +} + + +echo '
+
+ +

Extra info:

'.$email.$phone.$not_login.$session_time.'
+
+
+
'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$newsletter.'
+ +
'.$timezone; +if (!is_metaconsole()) { + echo '
+ + + '.$area_data_timezone_polys.$area_data_timezone_rects.' +
'; +} else { + echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_assigned_server.$metaconsole_access_node; +} + + echo '
+
+ +
+
'.$comments.'
+
+
'.$ehorus.'
+
'; + +echo '
'; if ($config['admin_can_add_user']) { html_print_csrf_hidden(); if ($new_user) { @@ -1005,32 +1122,62 @@ if (!empty($id) && !$new_user) { enterprise_hook('close_meta_frame'); +if (!is_metaconsole()) { + ?> + + + + + '."\n\t"; + echo ''."\n\t"; + // Closes no meta condition. +} + ?> - $module) { - if ($module == $name) { - $modules_by_name[($cont - 1)]['id'][] = $key; - } else { - $name = $module; - $modules_by_name[$cont]['name'] = $name; - $modules_by_name[$cont]['id'][] = $key; - $cont ++; - } - } - - foreach ($agents as $agent) { - if (!users_access_to_agent($agent['id_agente'])) { - continue; - } - - $row = []; - $row['agent_status'] = agents_get_status($agent['id_agente'], true); - $row['agent_name'] = $agent['nombre']; - $row['agent_alias'] = $agent['alias']; - $agent_modules = agents_get_modules($agent['id_agente']); - - $row['modules'] = []; - foreach ($modules_by_name as $module) { - $row['modules'][$module['name']] = null; - foreach ($module['id'] as $module_id) { - if (array_key_exists($module_id, $agent_modules)) { - $row['modules'][$module['name']] = modules_get_agentmodule_status($module_id); - break; - } - } - } - - $return[] = $row; - } - - return $return; - } - - - public function generate_view_agent_module($visual_data) - { - $table_data = '
'; - $table_data .= ''; - - if (!empty($visual_data)) { - $table_data .= ''; - - $array_names = []; - - foreach ($visual_data as $data) { - foreach ($data['modules'] as $module_name => $module) { - if ($module === null || in_array($module_name, $array_names)) { - continue; - } else { - $array_names[] = $module_name; - } - } - } - - natcasesort($array_names); - foreach ($array_names as $module_name) { - $file_name = ui_print_truncate_text( - $module_name, - 'module_small', - false, - true, - false, - '...' - ); - $table_data .= ''; - } - - foreach ($visual_data as $row) { - $table_data .= ""; - switch ($row['agent_status']) { - case AGENT_STATUS_ALERT_FIRED: - $rowcolor = COL_ALERTFIRED; - $textcolor = '#000'; - break; - - case AGENT_STATUS_CRITICAL: - $rowcolor = COL_CRITICAL; - $textcolor = '#FFF'; - break; - - case AGENT_STATUS_WARNING: - $rowcolor = COL_WARNING; - $textcolor = '#000'; - break; - - case AGENT_STATUS_NORMAL: - $rowcolor = COL_NORMAL; - $textcolor = '#FFF'; - break; - - case AGENT_STATUS_UNKNOWN: - case AGENT_STATUS_ALL: - default: - $rowcolor = COL_UNKNOWN; - $textcolor = '#FFF'; - break; - } - - $file_name = ui_print_truncate_text( - $row['agent_alias'], - 'agent_small', - false, - true, - false, - '...' - ); - $table_data .= "'; - - foreach ($row['modules'] as $module_name => $module) { - if ($module === null) { - if (in_array($module_name, $array_names)) { - $table_data .= ""; - } else { - continue; - } - } else { - $table_data .= "'; - } - } - - $table_data .= ''; - } - } else { - $table_data .= ''; - } - - $table_data .= '
'.__('Agents').' / '.__('Modules').''.$file_name.'
".$file_name.'"; - switch ($module) { - case AGENT_STATUS_NORMAL: - $table_data .= ui_print_status_image( - 'module_ok.png', - __( - '%s in %s : NORMAL', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_CRITICAL: - $table_data .= ui_print_status_image( - 'module_critical.png', - __( - '%s in %s : CRITICAL', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_WARNING: - $table_data .= ui_print_status_image( - 'module_warning.png', - __( - '%s in %s : WARNING', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_UNKNOWN: - $table_data .= ui_print_status_image( - 'module_unknown.png', - __( - '%s in %s : UNKNOWN', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case 4: - $table_data .= ui_print_status_image( - 'module_no_data.png', - __( - '%s in %s : Not initialize', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_ALERT_FIRED: - default: - $table_data .= ui_print_status_image( - 'module_alertsfired.png', - __( - '%s in %s : ALERTS FIRED', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - } - - $table_data .= '
'.__('Please configure this widget before usage').'
'; - $table_data .= '
'; - - return $table_data; - } - - /** * Generates inputs for form (specific). * @@ -666,38 +188,12 @@ class AgentModuleWidget extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); - // Autocomplete agents. $inputs[] = [ - 'label' => __('Agent'), - 'arguments' => [ - 'type' => 'autocomplete_agent', - 'name' => 'agentAlias', - 'id_agent_hidden' => $values['agentId'], - 'name_agent_hidden' => 'agentId', - 'server_id_hidden' => $values['metaconsoleId'], - 'name_server_hidden' => 'metaconsoleId', - 'return' => true, - 'module_input' => true, - 'module_name' => 'moduleId', - 'module_none' => false, - 'size' => 0, - ], - ]; - - // Autocomplete module. - $inputs[] = [ - 'label' => __('Module'), - 'arguments' => [ - 'type' => 'autocomplete_module', - 'fields' => $fields, - 'name' => 'moduleId', - 'selected' => $values['moduleId'], - 'return' => true, - 'sort' => false, - 'agent_id' => $values['agentId'], - 'metaconsole_id' => $values['metaconsoleId'], - 'style' => 'width: inherit;', - ], + 'label' => \ui_print_error_message( + __('This widget has been removed'), + '', + true + ), ]; return $inputs; @@ -714,12 +210,6 @@ class AgentModuleWidget extends Widget // Retrieve global - common inputs. $values = parent::getPost(); - $values['agentId'] = \get_parameter('agentId', 0); - $values['metaconsoleId'] = \get_parameter('metaconsoleId', 0); - $values['moduleId'] = \get_parameter('moduleId', 0); - $values['period'] = \get_parameter('period', 0); - $values['showLegend'] = \get_parameter_switch('showLegend'); - return $values; } @@ -733,45 +223,14 @@ class AgentModuleWidget extends Widget { global $config; - // TODO:XXX WIP. - return 'WIP in this widget'; - /* - $this->body = ''; - $id_agent = $this->options['id_agent_'.$this->getId()]; - if (! check_acl($config['id_user'], 0, 'AR')) { - $this->body = __('You don\'t have access'); - return; - } - - $id_module = $this->options['id_module_'.$this->getId()]; - if ($id_agent) { - $sql = 'SELECT id_agente,nombre,alias - FROM tagente - WHERE id_agente IN ('.implode(',', $id_agent).') - ORDER BY id_agente'; - $agents = db_get_all_rows_sql($sql); - if ($agents === false) { - $agents = []; - } - - $sql = 'SELECT id_agente_modulo,nombre - FROM tagente_modulo - WHERE id_agente IN ('.implode(',', $id_agent).") - AND nombre IN ('".implode("','", $id_module)."') - AND delete_pending = 0 ORDER BY nombre"; - $modules = index_array(db_get_all_rows_sql($sql), 'id_agente_modulo', 'nombre'); - if ($modules === false) { - $modules = []; - } - } else { - $agents = []; - $modules = []; - } - - $visual_data = $this->generate_data_agent_module($agents, $modules); - - $this->body .= $this->generate_view_agent_module($visual_data); - */ + $output .= '
'; + $output .= \ui_print_error_message( + __('This widget has been removed'), + '', + true + ); + $output .= '
'; + return $output; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php b/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php index de76b7a744..4aadb73dae 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php +++ b/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php @@ -146,7 +146,7 @@ class AlertsFiredWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -176,6 +176,31 @@ class AlertsFiredWidget extends Widget } + /** + * 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['group']) === true) { + $values['groupId'] = $decoder['group']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -234,7 +259,7 @@ class AlertsFiredWidget extends Widget $output = ''; - if ($this->values['groupId'] === 0) { + if ((int) $this->values['groupId'] === 0) { $groups = users_get_groups(false, 'AR', false); } else { $groups = [$this->values['groupId'] => '']; @@ -254,7 +279,7 @@ class AlertsFiredWidget extends Widget $flag = false; foreach ($groups as $id_group => $name) { - $alerts_group = get_group_alerts($id_group); + $alerts_group = get_group_alerts([$id_group]); if (isset($alerts_group['simple']) === true) { $alerts_group = $alerts_group['simple']; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/clock.php b/pandora_console/include/lib/Dashboard/Widgets/clock.php index 5c7b793b9e..8ad514e023 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/clock.php +++ b/pandora_console/include/lib/Dashboard/Widgets/clock.php @@ -142,7 +142,7 @@ class ClockWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class ClockWidget extends Widget } + /** + * 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['clock_type']) === true) { + $values['clockType'] = $decoder['clock_type']; + } + + if (isset($decoder['clockType']) === true) { + $values['clockType'] = $decoder['clockType']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php index 61d5a49904..b35ce233a1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php @@ -104,6 +104,13 @@ class CustomGraphWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -141,8 +148,11 @@ class CustomGraphWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -173,6 +183,43 @@ class CustomGraphWidget extends Widget } + /** + * 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['id_graph']) === true) { + $values['id_graph'] = $decoder['id_graph']; + } + + if (isset($decoder['stacked']) === true) { + $values['type'] = $decoder['stacked']; + } + + if (isset($decoder['type']) === true) { + $values['type'] = $decoder['type']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + if (isset($decoder['showLegend']) === true) { + $values['showLegend'] = $decoder['showLegend']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index 1d0d4a3563..90c863472e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -147,7 +147,7 @@ class EventsListWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +177,71 @@ class EventsListWidget extends Widget } + /** + * 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['type']) === true) { + $values['eventType'] = $decoder['type']; + } + + if (isset($decoder['eventType']) === true) { + $values['eventType'] = $decoder['eventType']; + } + + if (isset($decoder['event_view_hr']) === true) { + $values['maxHours'] = $decoder['event_view_hr']; + } + + if (isset($decoder['maxHours']) === true) { + $values['maxHours'] = $decoder['maxHours']; + } + + if (isset($decoder['limit']) === true) { + $values['limit'] = $decoder['limit']; + } + + if (isset($decoder['status']) === true) { + $values['eventStatus'] = $decoder['status']; + } + + if (isset($decoder['eventStatus']) === true) { + $values['eventStatus'] = $decoder['eventStatus']; + } + + if (isset($decoder['severity']) === true) { + $values['severity'] = $decoder['severity']; + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $decoder['id_groups'][0] = implode(',', $decoder['id_groups']); + } + + $values['groupId'] = $decoder['id_groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['tagsId']) === true) { + $values['tagsId'] = $decoder['tagsId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -416,13 +481,15 @@ class EventsListWidget extends Widget $filter['limit'] = $this->values['limit']; $filter['order'] = '`utimestamp` DESC'; - if ((int) $this->values['severity'] === 20) { - $filter['criticity'] = [ - EVENT_CRIT_WARNING, - EVENT_CRIT_CRITICAL, - ]; - } else if ((int) $this->values['severity'] !== -1) { - $filter['criticity'] = $this->values['severity']; + if (isset($this->values['severity']) === true) { + if ((int) $this->values['severity'] === 20) { + $filter['criticity'] = [ + EVENT_CRIT_WARNING, + EVENT_CRIT_CRITICAL, + ]; + } else if ((int) $this->values['severity'] !== -1) { + $filter['criticity'] = $this->values['severity']; + } } if (empty($this->values['tagsId']) === false) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/example.php b/pandora_console/include/lib/Dashboard/Widgets/example.php index e7d431cd5a..8c0664464c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/example.php +++ b/pandora_console/include/lib/Dashboard/Widgets/example.php @@ -142,7 +142,7 @@ class WelcomeWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -168,6 +168,23 @@ class WelcomeWidget extends Widget } + /** + * 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); + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php index 067bbef1fd..948b20acc7 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php @@ -106,6 +106,13 @@ class GraphModuleHistogramWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -148,8 +155,11 @@ class GraphModuleHistogramWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -179,6 +189,63 @@ class GraphModuleHistogramWidget extends Widget } + /** + * 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['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status.php index 7e2c449bbd..5b7fa16395 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/groups_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status.php @@ -142,7 +142,7 @@ class GroupsStatusWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class GroupsStatusWidget extends Widget } + /** + * 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['groupId'] = $decoder['groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php index f285abdc08..f480c45389 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php @@ -158,7 +158,7 @@ class MapsMadeByUser extends Widget $this->cellId = $cellId; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -188,6 +188,31 @@ class MapsMadeByUser extends Widget } + /** + * 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['id_layout']) === true) { + $values['vcId'] = $decoder['id_layout']; + } + + if (isset($decoder['vcId']) === true) { + $values['vcId'] = $decoder['vcId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php index 083a3bd2b3..783cca2b0c 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php @@ -142,7 +142,7 @@ class MapsStatusWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class MapsStatusWidget extends Widget } + /** + * 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['maps']) === true) { + if (is_array($decoder['maps']) === true) { + $decoder['maps'][0] = implode(',', $decoder['maps']); + } + + $values['maps'] = $decoder['maps']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php index 10ed9f8948..e8335e4661 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php @@ -114,6 +114,13 @@ class ModuleIconWidget extends Widget */ protected $dashboardId; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -151,8 +158,11 @@ class ModuleIconWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -183,6 +193,83 @@ class ModuleIconWidget extends Widget } + /** + * 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['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['size_icon_'.$this->cellId]) === true) { + $values['sizeIcon'] = $decoder['size_icon_'.$this->cellId]; + } + + if (isset($decoder['sizeIcon']) === true) { + $values['sizeIcon'] = $decoder['sizeIcon']; + } + + if (isset($decoder['icon_module_'.$this->cellId]) === true) { + $values['imageSrc'] = $decoder['icon_module_'.$this->cellId]; + } + + if (isset($decoder['imageSrc']) === true) { + $values['imageSrc'] = $decoder['imageSrc']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_status.php b/pandora_console/include/lib/Dashboard/Widgets/module_status.php index 06fd65afd3..e4dc1c65f6 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_status.php @@ -106,6 +106,13 @@ class ModuleStatusWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -146,8 +153,11 @@ class ModuleStatusWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +187,83 @@ class ModuleStatusWidget extends Widget } + /** + * 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['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['size_icon_'.$this->cellId]) === true) { + $values['sizeIcon'] = $decoder['size_icon_'.$this->cellId]; + } + + if (isset($decoder['sizeIcon']) === true) { + $values['sizeIcon'] = $decoder['sizeIcon']; + } + + if (isset($decoder['icon_module_'.$this->cellId]) === true) { + $values['imageSrc'] = $decoder['icon_module_'.$this->cellId]; + } + + if (isset($decoder['imageSrc']) === true) { + $values['imageSrc'] = $decoder['imageSrc']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php index a817ffce8b..fc07f1c2a7 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php @@ -107,6 +107,13 @@ class ModuleTableValueWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -148,8 +155,11 @@ class ModuleTableValueWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -179,6 +189,59 @@ class ModuleTableValueWidget extends Widget } + /** + * 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['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_text_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_text_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['separator_data_'.$this->cellId]) === true) { + $values['separator'] = $decoder['separator_data_'.$this->cellId]; + } + + if (isset($decoder['separator']) === true) { + $values['separator'] = $decoder['separator']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_value.php index b1606be21b..b862cc4d71 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_value.php @@ -109,6 +109,13 @@ class ModuleValueWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -146,8 +153,11 @@ class ModuleValueWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +187,67 @@ class ModuleValueWidget extends Widget } + /** + * 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['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php b/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php index 0d364de6ee..476bf327e9 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php +++ b/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php @@ -142,7 +142,7 @@ class MonitorHealthWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -164,14 +164,28 @@ class MonitorHealthWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (isset($this->values['title']) === false) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -234,8 +248,11 @@ class MonitorHealthWidget extends Widget $data['mW'] = (int) $all_data['_monitors_warning_']; $data['mC'] = (int) $all_data['_monitors_critical_']; $data['mNN'] = (int) $all_data['_monitor_not_normal_']; + $data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_']; + $data['monitor_not_init'] = (int) $all_data['_monitors_not_init_']; $data['monitor_alerts'] = (int) $all_data['_monitors_alerts_']; $data['mAFired'] = (int) $all_data['_monitors_alerts_fired_']; + $data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_']; $data['total_agents'] = (int) $all_data['_total_agents_']; diff --git a/pandora_console/include/lib/Dashboard/Widgets/network_map.php b/pandora_console/include/lib/Dashboard/Widgets/network_map.php index c873bbbec1..27880e71cb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/network_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/network_map.php @@ -154,7 +154,7 @@ class NetworkMapWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -184,6 +184,55 @@ class NetworkMapWidget extends Widget } + /** + * 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['networkmaps']) === true) { + $values['networkmapId'] = $decoder['networkmaps']; + } + + if (isset($decoder['networkmapId']) === true) { + $values['networkmapId'] = $decoder['networkmapId']; + } + + if (isset($decoder['map_translate_x']) === true) { + $values['xOffset'] = $decoder['map_translate_x']; + } + + if (isset($decoder['xOffset']) === true) { + $values['xOffset'] = $decoder['xOffset']; + } + + if (isset($decoder['map_translate_y']) === true) { + $values['yOffset'] = $decoder['map_translate_y']; + } + + if (isset($decoder['yOffset']) === true) { + $values['yOffset'] = $decoder['yOffset']; + } + + if (isset($decoder['zoom_level_dash']) === true) { + $values['zoomLevel'] = $decoder['zoom_level_dash']; + } + + if (isset($decoder['zoomLevel']) === true) { + $values['zoomLevel'] = $decoder['zoomLevel']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/post.php b/pandora_console/include/lib/Dashboard/Widgets/post.php index be8bdd9193..6844a3de7a 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/post.php +++ b/pandora_console/include/lib/Dashboard/Widgets/post.php @@ -142,7 +142,7 @@ class PostWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class PostWidget extends Widget } + /** + * 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['textit']) === true) { + $values['text'] = $decoder['textit']; + } + + if (isset($decoder['text']) === true) { + $values['text'] = $decoder['text']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/reports.php b/pandora_console/include/lib/Dashboard/Widgets/reports.php index 5ae3a5c70d..b042877ed2 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/reports.php +++ b/pandora_console/include/lib/Dashboard/Widgets/reports.php @@ -148,7 +148,7 @@ class ReportsWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -178,6 +178,31 @@ class ReportsWidget extends Widget } + /** + * 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['id_report']) === true) { + $values['reportId'] = $decoder['id_report']; + } + + if (isset($decoder['reportId']) === true) { + $values['reportId'] = $decoder['reportId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index 401852b070..92209fcf93 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -146,7 +146,7 @@ class ServiceMapWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -176,6 +176,39 @@ class ServiceMapWidget extends Widget } + /** + * 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['service_id']) === true) { + $values['serviceId'] = $decoder['service_id']; + } + + if (isset($decoder['serviceId']) === true) { + $values['serviceId'] = $decoder['serviceId']; + } + + if (isset($decoder['show_legend']) === true) { + $values['showLegend'] = (int) $decoder['show_legend']; + } + + if (isset($decoder['showLegend']) === true) { + $values['showLegend'] = $decoder['showLegend']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php index bd7969dc72..e4e3462024 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php @@ -106,6 +106,13 @@ class SingleGraphWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -143,8 +150,11 @@ class SingleGraphWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -174,6 +184,55 @@ class SingleGraphWidget extends Widget } + /** + * 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['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + if (isset($decoder['show_full_legend']) === true) { + $values['showLegend'] = $decoder['show_full_legend']; + } + + if (isset($decoder['showLegend']) === true) { + $values['showLegend'] = $decoder['showLegend']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php index 3cd1e72fc4..df88cb28fa 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php +++ b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php @@ -110,6 +110,13 @@ class SLAPercentWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -147,8 +154,11 @@ class SLAPercentWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -178,6 +188,71 @@ class SLAPercentWidget extends Widget } + /** + * 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['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -387,7 +462,7 @@ class SLAPercentWidget extends Widget if (empty($label) === false) { // Div Label. - $output .= '
'.$label.'
'; + $output .= '
'.$label.'
'; } $output .= '
'; 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 65df0b83d4..8f0bbc00bb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php @@ -142,7 +142,7 @@ class SystemGroupStatusWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -164,14 +164,80 @@ class SystemGroupStatusWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (empty($this->values['groupId']) === true) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['status']) === true) { + if (is_array($decoder['status']) === true) { + $compatibilityStatus = []; + foreach ($decoder['status'] as $key => $value) { + switch ((int) $value) { + case 2: + $compatibilityStatus[] = AGENT_STATUS_WARNING; + break; + + case 3: + $compatibilityStatus[] = AGENT_STATUS_CRITICAL; + break; + + case 4: + $compatibilityStatus[] = 4; + break; + + default: + case 1: + $compatibilityStatus[] = AGENT_STATUS_NORMAL; + break; + } + } + + $decoder['status'][0] = implode(',', $compatibilityStatus); + } + + $values['status'] = $decoder['status']; + } else { + $values['status'][0] = implode( + ',', + [ + AGENT_STATUS_NORMAL, + AGENT_STATUS_WARNING, + AGENT_STATUS_CRITICAL, + 4, + ] + ); + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $decoder['id_groups'][0] = implode(',', $decoder['id_groups']); + } + + $values['groupId'] = $decoder['id_groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -186,6 +252,19 @@ class SystemGroupStatusWidget extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); + // Default values. + if (isset($values['status']) === false) { + $values['status'][0] = implode( + ',', + [ + AGENT_STATUS_NORMAL, + AGENT_STATUS_WARNING, + AGENT_STATUS_CRITICAL, + 4, + ] + ); + } + // Restrict access to group. $inputs[] = [ 'label' => __('Groups'), @@ -439,7 +518,7 @@ class SystemGroupStatusWidget extends Widget } } - $height = (count($table->data) * 30); + $height = (count($table->data) * 32); $style = 'min-width:200px; min-height:'.$height.'px;'; $output = '
'; if ($flag_groups === true) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/tactical.php b/pandora_console/include/lib/Dashboard/Widgets/tactical.php index bee5f4164c..2003a6facb 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/tactical.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tactical.php @@ -160,7 +160,7 @@ class TacticalWidget extends Widget $this->pmAccess = \users_can_manage_group_all('PM'); // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -193,6 +193,43 @@ class TacticalWidget extends Widget } + /** + * 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['statusmonitors']) === true) { + $values['statusMonitor'] = $decoder['statusmonitors']; + } + + if (isset($decoder['statusMonitor']) === true) { + $values['statusMonitor'] = $decoder['statusMonitor']; + } + + if (isset($decoder['serverperf']) === true) { + $values['serverPerformance'] = $decoder['serverperf']; + } + + if (isset($decoder['serverPerformance']) === true) { + $values['serverPerformance'] = $decoder['serverPerformance']; + } + + if (isset($decoder['summary']) === true) { + $values['summary'] = $decoder['summary']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -366,7 +403,7 @@ class TacticalWidget extends Widget ); } - if ($this->values['statusMonitor'] === 1) { + if ((int) $this->values['statusMonitor'] === 1) { $table = new \stdClass(); $table->width = '100%'; @@ -396,7 +433,7 @@ class TacticalWidget extends Widget $output .= \html_print_table($table, true); } - if ($this->values['serverPerformance'] === 1 + if ((int) $this->values['serverPerformance'] === 1 && $this->pmAccess === true ) { $table = new \stdClass(); @@ -414,7 +451,7 @@ class TacticalWidget extends Widget $output .= \html_print_table($table, true); } - if ($this->values['summary'] === 1) { + if ((int) $this->values['summary'] === 1) { $table = new \stdClass(); $table->width = '100%'; $table->class = ''; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index a7b8198546..7029b07bad 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -375,7 +375,7 @@ class TopNWidget extends Widget } // This function check ACL. - $agents = agents_get_group_agents(0, ['aliasRegex' => $agentRegex]); + $agents = @agents_get_group_agents(0, ['aliasRegex' => $agentRegex]); $agentsId = \array_keys($agents); $agentsIdString = \implode(',', $agentsId); @@ -414,7 +414,7 @@ class TopNWidget extends Widget $quantity ); - $modules = \db_get_all_rows_sql( + $modules = @db_get_all_rows_sql( $sql, $search_in_history_db ); @@ -422,7 +422,7 @@ class TopNWidget extends Widget if (empty($modules) === true) { $output .= '
'; $output .= \ui_print_info_message( - __('There are no Agent/Modules defined'), + __('There are no agents/modules found matching filter set'), '', true ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php index 10ddfb881a..2acd7f32fa 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php @@ -147,7 +147,7 @@ class TopNEventByGroupWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +177,59 @@ class TopNEventByGroupWidget extends Widget } + /** + * 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['amount']) === true) { + $values['amountShow'] = $decoder['amount']; + } + + if (isset($decoder['amountShow']) === true) { + $values['amountShow'] = $decoder['amountShow']; + } + + if (isset($decoder['event_view_hr']) === true) { + $values['maxHours'] = $decoder['event_view_hr']; + } + + if (isset($decoder['maxHours']) === true) { + $values['maxHours'] = $decoder['maxHours']; + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $implode = implode(',', $decoder['id_groups']); + $values['groupId'] = []; + $values['groupId'][0] = $implode; + } + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['legend_position']) === true) { + $values['legendPosition'] = $decoder['legend_position']; + } + + if (isset($decoder['legendPosition']) === true) { + $values['legendPosition'] = $decoder['legendPosition']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -320,8 +373,8 @@ class TopNEventByGroupWidget extends Widget GROUP BY id_agente ORDER BY count DESC LIMIT %d', - implode(',', $this->values['groupId']), $timestamp, + implode(',', $this->values['groupId']), $this->values['amountShow'] ); } else { diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php index 4d9187bf80..4bbaee22a8 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php @@ -147,7 +147,7 @@ class TopNEventByModuleWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +177,59 @@ class TopNEventByModuleWidget extends Widget } + /** + * 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['amount']) === true) { + $values['amountShow'] = $decoder['amount']; + } + + if (isset($decoder['amountShow']) === true) { + $values['amountShow'] = $decoder['amountShow']; + } + + if (isset($decoder['event_view_hr']) === true) { + $values['maxHours'] = $decoder['event_view_hr']; + } + + if (isset($decoder['maxHours']) === true) { + $values['maxHours'] = $decoder['maxHours']; + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $decoder['id_groups'][0] = implode(',', $decoder['id_groups']); + } + + $values['groupId'] = $decoder['id_groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['legend_position']) === true) { + $values['legendPosition'] = $decoder['legend_position']; + } + + if (isset($decoder['legendPosition']) === true) { + $values['legendPosition'] = $decoder['legendPosition']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -311,20 +364,26 @@ class TopNEventByModuleWidget extends Widget if ($all_group === false) { $sql = sprintf( - 'SELECT id_agentmodule, COUNT(*) AS count + 'SELECT id_agente, + id_agentmodule, + event_type, + COUNT(*) AS count FROM tevento WHERE utimestamp >= %d AND id_grupo IN (%s) GROUP BY id_agentmodule, event_type ORDER BY count DESC LIMIT %d', - implode(',', $this->values['groupId']), $timestamp, + implode(',', $this->values['groupId']), $this->values['amountShow'] ); } else { $sql = sprintf( - 'SELECT id_agentmodule, COUNT(*) AS count + 'SELECT id_agente, + id_agentmodule, + event_type, + COUNT(*) AS count FROM tevento WHERE utimestamp >= %d GROUP BY id_agentmodule, event_type @@ -353,8 +412,9 @@ class TopNEventByModuleWidget extends Widget $name = __('System'); } else { $name_agent = io_safe_output( - agents_get_alias($row['id_agentmodule']) + agents_get_alias($row['id_agente']) ); + $name_module = io_safe_output( modules_get_agentmodule_name($row['id_agentmodule']) ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php index 9176bec9ef..994cceac73 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php @@ -155,7 +155,7 @@ class TreeViewWidget extends Widget $this->cellId = $cellId; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,14 +177,136 @@ class TreeViewWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (isset($this->values['groupId']) === false) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['tab']) === true) { + $values['typeTree'] = $decoder['tab']; + } + + if (isset($decoder['typeTree']) === true) { + $values['typeTree'] = $decoder['typeTree']; + } + + if (isset($decoder['search_group']) === true) { + $values['groupId'] = $decoder['search_group']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['open_all_nodes']) === true) { + $values['openAllGroups'] = $decoder['open_all_nodes']; + } + + if (isset($decoder['openAllGroups']) === true) { + $values['openAllGroups'] = $decoder['openAllGroups']; + } + + if (isset($decoder['status_agent']) === true) { + switch ((int) $decoder['status_agent']) { + case 0: + $values['agentStatus'] = AGENT_STATUS_NORMAL; + break; + + case 1: + $values['agentStatus'] = AGENT_STATUS_CRITICAL; + break; + + case 2: + $values['agentStatus'] = AGENT_STATUS_WARNING; + break; + + case 3: + $values['agentStatus'] = AGENT_STATUS_UNKNOWN; + break; + + case 5: + $values['agentStatus'] = AGENT_STATUS_NOT_INIT; + break; + + default: + case -1: + $values['agentStatus'] = AGENT_STATUS_ALL; + break; + } + } + + if (isset($decoder['agentStatus']) === true) { + $values['agentStatus'] = $decoder['agentStatus']; + } + + if (isset($decoder['search_agent']) === true) { + $values['filterAgent'] = $decoder['search_agent']; + } + + if (isset($decoder['filterAgent']) === true) { + $values['filterAgent'] = $decoder['filterAgent']; + } + + if (isset($decoder['status_module']) === true) { + switch ((int) $decoder['status_module']) { + case 0: + $values['moduleStatus'] = AGENT_MODULE_STATUS_NORMAL; + break; + + case 1: + $values['moduleStatus'] = AGENT_MODULE_STATUS_CRITICAL_BAD; + break; + + case 2: + $values['moduleStatus'] = AGENT_MODULE_STATUS_WARNING; + break; + + case 3: + $values['moduleStatus'] = AGENT_MODULE_STATUS_UNKNOWN; + break; + + case 5: + $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT; + break; + + default: + case -1: + $values['moduleStatus'] = -1; + break; + } + + $values['moduleStatus'] = $decoder['status_module']; + } + + if (isset($decoder['moduleStatus']) === true) { + $values['moduleStatus'] = $decoder['moduleStatus']; + } + + if (isset($decoder['search_module']) === true) { + $values['filterModule'] = $decoder['search_module']; + } + + if (isset($decoder['filterModule']) === true) { + $values['filterModule'] = $decoder['filterModule']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/url.php b/pandora_console/include/lib/Dashboard/Widgets/url.php index 70a841a9fd..4259f1abb1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/url.php +++ b/pandora_console/include/lib/Dashboard/Widgets/url.php @@ -142,7 +142,7 @@ class UrlWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class UrlWidget extends Widget } + /** + * 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['url']) === true) { + $values['urlText'] = $decoder['url']; + } + + if (isset($decoder['urlText']) === true) { + $values['urlText'] = $decoder['urlText']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php index 92de8445e2..47c002f2ad 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php +++ b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php @@ -106,6 +106,13 @@ class WuxWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -142,8 +149,11 @@ class WuxWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -173,6 +183,43 @@ class WuxWidget extends Widget } + /** + * 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['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['wux_transaction_'.$this->cellId]) === true) { + $values['transactionId'] = $decoder['wux_transaction_'.$this->cellId]; + } + + if (isset($decoder['transactionId']) === true) { + $values['transactionId'] = $decoder['transactionId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php index 25b4270715..49187dcb05 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php +++ b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php @@ -154,7 +154,7 @@ class WuxStatsWidget extends Widget $this->cellId = $cellId; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -184,6 +184,51 @@ class WuxStatsWidget extends Widget } + /** + * 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['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['wux_transaction_'.$this->cellId]) === true) { + $values['transactionId'] = $decoder['wux_transaction_'.$this->cellId]; + } + + if (isset($decoder['transactionId']) === true) { + $values['transactionId'] = $decoder['transactionId']; + } + + if (isset($decoder['view_all_stats']) === true) { + $values['allStats'] = $decoder['view_all_stats']; + } + + if (isset($decoder['allStats']) === true) { + $values['allStats'] = $decoder['allStats']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 0db5cd6cb3..e89e282d6f 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -477,13 +477,17 @@ div#main_pure { margin-top: 30px; } -.info_box { +.content-widget .info_box { border-radius: 5px; width: 90%; } -.info_box tbody tr td { +.content-widget .info_box tbody tr td { padding: 10px; } -.info_box tbody tr td.icon { +.content-widget .info_box tbody tr td.icon { padding-right: 10px !important; } + +.content-widget .databox.filters > tbody > tr > td { + padding-right: 30px; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index b9f3b2a1ed..3ab99bb7e6 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -588,9 +588,18 @@ select:-internal-list-box { .padding-6 { padding: 6em; } +.margin-right-1 { + margin-right: 1em; +} +.margin-left-1 { + margin-left: 1em; +} .margin-right-2 { margin-right: 2em; } +.margin-left-2 { + margin-left: 2em; +} .no-border { border: none; } @@ -4779,7 +4788,8 @@ input:checked + .p-slider:before { width: 75%; } -.edit_user_info_right input { +.edit_user_info_right input, +.input_line { background-color: transparent; border: none; border-radius: 0; @@ -4796,15 +4806,18 @@ input:checked + .p-slider:before { font-weight: bold; } -.edit_user_info_right #fullname { +.edit_user_info_right #fullname, +.user_icon_input { background-image: url("../../images/user_name.png"); } -.edit_user_info_right #email { +.edit_user_info_right #email, +.email_icon_input { background-image: url("../../images/user_email.png"); } -.edit_user_info_right #phone { +.edit_user_info_right #phone, +.phone_icon_input { background-image: url("../../images/user_phone.png"); } @@ -4822,7 +4835,8 @@ input:checked + .p-slider:before { padding-right: 50px; } -.edit_user_options #text-block_size { +.edit_user_options #text-block_size, +.input_line_small { background-color: transparent; border: none; border-radius: 0; @@ -4866,12 +4880,14 @@ input:checked + .p-slider:before { display: inline; } -.edit_user_options .label_select_simple { +.edit_user_options .label_select_simple, +.edit_user_autorefresh .label_select_simple { display: flex; align-items: center; } -.edit_user_options .label_select_simple .p-switch { +.edit_user_options .label_select_simple .p-switch, +.edit_user_autorefresh .label_select_simple .p-switch { margin-right: 5px; margin-left: 10px; } @@ -4927,6 +4943,24 @@ input:checked + .p-slider:before { width: 100%; } +@media screen and (min-width: 1200px) { + .user_global_profile { + display: flex; + align-items: center; + } +} + +.user_edit_ehorus_outer { + display: flex; + flex-direction: column; + width: 280px; +} + +.user_edit_ehorus_inner { + display: flex; + justify-content: space-between; +} + .edit_user_button { margin-top: 20px; width: 100%; @@ -5396,7 +5430,7 @@ table.info_table.policy_sub_table { .switch_radio_button input:checked + label { background-color: #82b92e; box-shadow: none; - color: #fff; + color: #fff !important; } .switch_radio_button label:last-child { diff --git a/pandora_console/include/styles/task_list.css b/pandora_console/include/styles/task_list.css index e1184b5da2..c8a6f42aa8 100644 --- a/pandora_console/include/styles/task_list.css +++ b/pandora_console/include/styles/task_list.css @@ -115,3 +115,7 @@ span.link.review { border-color: #eee; background-color: #ddd; } + +#task_review { + width: 100% !important; +} diff --git a/pandora_console/include/styles/tree.css b/pandora_console/include/styles/tree.css index 42649bd048..1a479ac3cf 100644 --- a/pandora_console/include/styles/tree.css +++ b/pandora_console/include/styles/tree.css @@ -4,7 +4,7 @@ } .tree-group { - margin-left: 19px; + margin-left: 24px; padding-top: 1px; } @@ -18,12 +18,24 @@ min-height: 26px; } +div.tree-node { + background: 0 0; +} + +div.tree-node span { + font-size: 1.2em; +} + .tree-node:last-child { background: 0 0; } .node-content { height: 26px; font-size: 1.2em; + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: center; } .node-content > img { @@ -106,6 +118,30 @@ padding-right: 3px; } +.tree-node > .node-content > .agent-status.status_balls, +.tree-node > .node-content > .status_small_balls { + width: 0.6em; + height: 1.5em; + margin-bottom: -0.4em; + border-radius: 0; +} +.tree-node > .node-content > .module-status.status_small_balls { + width: 0.4em; +} + +.tree-node > .node-content > .module-name { + margin: 0 0 0 1em; + width: 250px; + display: inline-block; +} + +.tree-node > .node-content > .module-value { + width: 120px; + display: inline-block; + text-align: right; + margin: 0 1em; +} + .tree-node > .node-content > img.module-server-type, .tree-node > .node-content > img.agent-status, .tree-node > .node-content > img.agent-alerts-fired, @@ -121,6 +157,7 @@ } .tree-node > .node-content > .tree-node-counters { + font-size: 1.2em; } .tree-node > .node-content > img { @@ -129,7 +166,7 @@ .tree-node > .node-content > .tree-node-counters > .tree-node-counter { font-weight: bold; - font-size: 1.2em; + font-size: 0.9em; cursor: default; } diff --git a/pandora_console/index.php b/pandora_console/index.php index cc79382b82..4d643de5ae 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1002,60 +1002,9 @@ if ($process_login) { } } - // Set the initial global counter for chat. - users_get_last_global_counter('session'); - $config['logged'] = true; } -// ---------------------------------------------------------------------- -// Get old parameters before navigation. -$old_sec = ''; -$old_sec2 = ''; -$old_page = ''; -if (isset($_SERVER['HTTP_REFERER'])) { - $old_page = $_SERVER['HTTP_REFERER']; -} - -$chunks = explode('?', $old_page); -if (count($chunks) == 2) { - $chunks = explode('&', $chunks[1]); - - foreach ($chunks as $chunk) { - if (strstr($chunk, 'sec=') !== false) { - $old_sec = str_replace('sec=', '', $chunk); - } - - if (strstr($chunk, 'sec2=') !== false) { - $old_sec = str_replace('sec2=', '', $chunk); - } - } -} - -$_SESSION['new_chat'] = false; -if ($old_sec2 == 'operation/users/webchat') { - users_get_last_global_counter('session'); -} - -if ($page == 'operation/users/webchat') { - // Reload the global counter. - users_get_last_global_counter('session'); -} - -if (isset($_SESSION['global_counter_chat'])) { - $old_global_counter_chat = $_SESSION['global_counter_chat']; -} else { - $old_global_counter_chat = users_get_last_global_counter('return'); -} - -$now_global_counter_chat = users_get_last_global_counter('return'); - -if ($old_global_counter_chat != $now_global_counter_chat) { - if (!users_is_last_system_message()) { - $_SESSION['new_chat'] = true; - } -} - require_once 'general/register.php'; if (get_parameter('login', 0) !== 0) { diff --git a/pandora_console/install.php b/pandora_console/install.php index 89ebb7e7a2..efabb80044 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -128,8 +128,8 @@
'; + if(item.meta === true) { + evn += ''; + } item.mini_severity = '
'; item.mini_severity += output; diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 6b22d71c28..11fb477380 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -482,12 +482,6 @@ $sub['operation/users/user_edit_notifications']['text'] = __('Configure user not $sub['operation/users/user_edit_notifications']['id'] = 'Configure user notifications'; $sub['operation/users/user_edit_notifications']['refr'] = 0; -// ANY user can chat with other user and dogs. -// Users. -$sub['operation/users/webchat']['text'] = __('WebChat'); -$sub['operation/users/webchat']['id'] = 'WebChat'; -$sub['operation/users/webchat']['refr'] = 0; - // Incidents. if (check_acl($config['id_user'], 0, 'IR') diff --git a/pandora_console/operation/search_agents.getdata.php b/pandora_console/operation/search_agents.getdata.php index c754628731..aad2835a36 100644 --- a/pandora_console/operation/search_agents.getdata.php +++ b/pandora_console/operation/search_agents.getdata.php @@ -20,6 +20,8 @@ $searchAgents = check_acl($config['id_user'], 0, 'AR'); $selectNameUp = ''; $selectNameDown = ''; +$selectDescriptionUp = ''; +$selectDescriptionDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectIntervalUp = ''; @@ -50,6 +52,26 @@ switch ($sortField) { } break; + case 'comentarios': + switch ($sort) { + case 'up': + $selectDescriptionUp = $selected; + $order = [ + 'field' => 'comentarios', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectDescriptionDown = $selected; + $order = [ + 'field' => 'comentarios', + 'order' => 'DESC', + ]; + break; + } + break; + case 'os': switch ($sort) { case 'up': @@ -133,6 +155,8 @@ switch ($sortField) { default: $selectNameUp = $selected; $selectNameDown = ''; + $selectDescriptionUp = ''; + $selectDescriptionDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectIntervalUp = ''; @@ -165,7 +189,8 @@ if ($searchAgents) { $aux = $id[0]['id_agent']; $search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%cd ".$stringSearchSQL."%%' OR t2.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR - t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR + t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR + t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR t1.id_agente = $aux"; if (count($id) >= 2) { @@ -177,7 +202,8 @@ if ($searchAgents) { } else { $search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR t2.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR - t1.direccion COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR + t1.direccion COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR + t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%'"; } @@ -211,7 +237,7 @@ if ($searchAgents) { ) '; - $select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet'; + $select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.comentarios, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet'; if ($only_count) { $limit = ' ORDER BY '.$order['field'].' '.$order['order'].' LIMIT '.$config['block_size'].' OFFSET 0'; } else { diff --git a/pandora_console/operation/search_agents.php b/pandora_console/operation/search_agents.php index 05383df31a..5dd83871eb 100755 --- a/pandora_console/operation/search_agents.php +++ b/pandora_console/operation/search_agents.php @@ -39,21 +39,23 @@ if (!$agents || !$searchAgents) { $table->head = []; if ($only_count) { $table->head[0] = __('Agent'); - $table->head[1] = __('OS'); - $table->head[2] = __('Interval'); - $table->head[3] = __('Group'); + $table->head[1] = __('Description'); + $table->head[2] = __('OS'); + $table->head[3] = __('Interval'); + $table->head[4] = __('Group'); } else { $table->head[0] = __('Agent').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectNameUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectNameDown]).''; - $table->head[1] = __('OS').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectOsUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectOsDown]).''; - $table->head[2] = __('Interval').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown]).''; - $table->head[3] = __('Group').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectGroupUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectGroupDown]).''; + $table->head[1] = __('Description').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectDescriptionUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectDescriptionDown]).''; + $table->head[2] = __('OS').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectOsUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectOsDown]).''; + $table->head[3] = __('Interval').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown]).''; + $table->head[4] = __('Group').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectGroupUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectGroupDown]).''; } - $table->head[4] = __('Modules'); - $table->head[5] = __('Status'); - $table->head[6] = __('Alerts'); - $table->head[7] = __('Last contact').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectLastContactUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectLastContactDown]).''; - $table->head[8] = ''; + $table->head[5] = __('Modules'); + $table->head[6] = __('Status'); + $table->head[7] = __('Alerts'); + $table->head[8] = __('Last contact').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectLastContactUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectLastContactDown]).''; + $table->head[9] = ''; $table->align = []; $table->align[0] = 'left'; @@ -64,7 +66,8 @@ if (!$agents || !$searchAgents) { $table->align[5] = 'left'; $table->align[6] = 'left'; $table->align[7] = 'left'; - $table->align[8] = 'center'; + $table->align[8] = 'left'; + $table->align[9] = 'center'; $table->data = []; @@ -116,6 +119,7 @@ if (!$agents || !$searchAgents) { $table->data, [ $cellName, + ui_print_truncate_text($agent['comentarios'], 'comentarios', false, true, true, '[…]'), ui_print_os_icon($agent['id_os'], false, true), human_time_description_raw($agent['intervalo'], false, 'tiny'), ui_print_group_icon($agent['id_grupo'], true), diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 41a6b9c5d2..91c23d164f 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -345,7 +345,7 @@ enterprise_hook('close_meta_frame'); detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }), page: parameters['page'], emptyMessage: "", - foundMessage: "", + foundMessage: "", tree: data.tree, baseURL: "", ajaxURL: "", diff --git a/pandora_console/operation/users/webchat.php b/pandora_console/operation/users/webchat.php deleted file mode 100644 index 809ccaa000..0000000000 --- a/pandora_console/operation/users/webchat.php +++ /dev/null @@ -1,335 +0,0 @@ - false]); - } - - return; -} - -global $config; - -check_login(); - -ui_print_page_header(__('Webchat'), 'images/comments.png', false, '', false, ''); - -$table = new stdClass(); - -$table->width = '100%'; -$table->class = 'databox filters'; -$table->style[0][1] = 'text-align: right; vertical-align: top;'; - -$table->data[0][0] = '
'; -$table->data[0][1] = '

'.__('Users Online').'

'.'
'; -$table->data[1][0] = ''.__('Message').'   '.html_print_input_text( - 'message_box', - '', - '', - 100, - 150, - true -); -html_print_table($table); - -echo "
".html_print_button( - __('Send message'), - 'send', - false, - 'send_message()', - 'class="sub next" style="float:right"', - true -).'
'; - -?> - diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 53fd72a7a6..32dff9dc34 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 96d2bed8e5..68cc8f7fbd 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 1a587a8970..7718ae09cd 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install index 9f1f21632e..26e3b7ae15 100644 --- a/pandora_console/pandora_console_install +++ b/pandora_console/pandora_console_install @@ -9,7 +9,7 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.744" +PI_VERSION="7.0NG.745" FORCE=0 DESTDIR="" LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c698f0d6a9..a00b796864 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -805,6 +805,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `snmp_privacy_pass` varchar(255) NOT NULL default '', `snmp_security_level` varchar(25) NOT NULL default '', `wmi_enabled` tinyint(1) unsigned DEFAULT 0, + `rcmd_enabled` tinyint(1) unsigned DEFAULT 0, `auth_strings` text, `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1, `autoconfiguration_enabled` tinyint(1) unsigned default 0, diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index ab7a9c4457..bdba1fffe9 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -34,6 +34,7 @@ if ($redraw === false) { $output .= '
'; $output .= '
'; + if ((int) $cellData['id_widget'] !== 0) { $options = json_decode($cellData['options'], true); $output .= $options['title']; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 3673c722e5..3110b2ffa2 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.744-200415 +Version: 7.0NG.745-200519 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index a0efb7c79e..c908e74321 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.744-200415" +pandora_version="7.0NG.745-200519" package_cpan=0 package_pandora=1 diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 0fb91d0bfd..557b9f3a7d 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -1,7 +1,7 @@ ############################################################################# # Pandora FMS Server Parameters # Pandora FMS, the Flexible Monitoring System. -# Version 7.0NG.744 +# Version 7.0NG.745 # Licensed under GPL license v2, # (c) 2003-2017 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 23226249bf..0dd80c9e0a 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -44,8 +44,8 @@ our @EXPORT = qw( ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.744"; -my $pandora_build = "200415"; +my $pandora_version = "7.0NG.745"; +my $pandora_build = "200519"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index b395ec9574..00eabac6b3 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -289,23 +289,23 @@ my $Master :shared = 0; # Return the agent given the agent name or alias or address. ########################################################################## sub locate_agent { - my ($pa_config, $dbh, $field) = @_; + my ($pa_config, $dbh, $field, $relative) = @_; if (is_metaconsole($pa_config)) { # Locate agent first in tmetaconsole_agent return undef if (! defined ($field) || $field eq ''); - my $rs = enterprise_hook('get_metaconsole_agent_from_alias', [$dbh, $field]); + my $rs = enterprise_hook('get_metaconsole_agent_from_alias', [$dbh, $field, $relative]); return $rs if defined($rs) && (ref($rs)); # defined and not a scalar - $rs = enterprise_hook('get_metaconsole_agent_from_addr', [$dbh, $field]); + $rs = enterprise_hook('get_metaconsole_agent_from_addr', [$dbh, $field, $relative]); return $rs if defined($rs) && (ref($rs)); # defined and not a scalar - $rs = enterprise_hook('get_metaconsole_agent_from_name', [$dbh, $field]); + $rs = enterprise_hook('get_metaconsole_agent_from_name', [$dbh, $field, $relative]); return $rs if defined($rs) && (ref($rs)); # defined and not a scalar } else { - return get_agent($dbh, $field); + return get_agent($dbh, $field, $relative); } return undef; @@ -316,17 +316,17 @@ sub locate_agent { # Return the agent given the agent name or alias or address. ########################################################################## sub get_agent { - my ($dbh, $field) = @_; + my ($dbh, $field, $relative) = @_; return undef if (! defined ($field) || $field eq ''); - my $rs = get_agent_from_alias($dbh, $field); + my $rs = get_agent_from_alias($dbh, $field, $relative); return $rs if defined($rs) && (ref($rs)); # defined and not a scalar $rs = get_agent_from_addr($dbh, $field); return $rs if defined($rs) && (ref($rs)); # defined and not a scalar - $rs = get_agent_from_name($dbh, $field); + $rs = get_agent_from_name($dbh, $field, $relative); return $rs if defined($rs) && (ref($rs)); # defined and not a scalar return undef; @@ -335,10 +335,13 @@ sub get_agent { ########################################################################## # Return the agent given the agent name. ########################################################################## -sub get_agent_from_alias ($$) { - my ($dbh, $alias) = @_; +sub get_agent_from_alias ($$;$) { + my ($dbh, $alias, $relative) = @_; return undef if (! defined ($alias) || $alias eq ''); + if ($relative) { + return get_db_single_row($dbh, 'SELECT * FROM tagente WHERE tagente.alias like ?', safe_input($alias)); + } return get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE tagente.alias = ?', safe_input($alias)); } @@ -361,10 +364,14 @@ sub get_agent_from_addr ($$) { ########################################################################## # Return the agent given the agent name. ########################################################################## -sub get_agent_from_name ($$) { - my ($dbh, $name) = @_; +sub get_agent_from_name ($$;$) { + my ($dbh, $name, $relative) = @_; return undef if (! defined ($name) || $name eq ''); + + if ($relative) { + return get_db_single_row($dbh, 'SELECT * FROM tagente WHERE tagente.nombre like ?', safe_input($name)); + } return get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE tagente.nombre = ?', safe_input($name)); } @@ -931,10 +938,12 @@ sub pandora_execute_alert ($$$$$$$$$;$$) { $pa_config, "$text (" . safe_output($alert->{'name'}) . ") " . (defined ($module) ? 'assigned to ('. safe_output($module->{'nombre'}) . ")" : ""), (defined ($agent) ? $agent->{'id_grupo'} : 0), - (defined ($agent) ? $agent->{'id_agente'} : 0), + # id agent. + 0, $severity, (defined ($alert->{'id_template_module'}) ? $alert->{'id_template_module'} : 0), - (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), + # id agent module. + 0, $event, 0, $dbh, @@ -4206,7 +4215,9 @@ sub on_demand_macro($$$$$$;$) { my $unit_mod = get_db_value ($dbh, 'SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ?', $id_mod); my $field_value = ""; - if ($type_mod eq 3 || $type_mod eq 23|| $type_mod eq 17 || $type_mod eq 10 || $type_mod eq 33 ){ + if (defined($type_mod) + && ($type_mod eq 3 || $type_mod eq 23|| $type_mod eq 17 || $type_mod eq 10 || $type_mod eq 33 ) + ) { $field_value = get_db_value($dbh, 'SELECT datos FROM tagente_datos_string where id_agente_modulo = ? order by utimestamp desc limit 1', $id_mod); } else{ diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 903a9014c3..cbb21d42fb 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -26,7 +26,7 @@ use Thread::Semaphore; use IO::Socket::INET; use POSIX qw(strftime ceil); -use JSON qw(decode_json encode_json); +use JSON; use Encode qw(encode_utf8); use MIME::Base64; @@ -105,7 +105,7 @@ sub new ($$$$$$) { get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER)); # Reset (but do not restart) manual recon tasks. - db_do ($dbh, 'UPDATE trecon_task SET status = -1 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep = 0', + db_do ($dbh, 'UPDATE trecon_task SET status = -1, summary = "cancelled" WHERE id_recon_server = ? AND status <> -1 AND interval_sweep = 0', get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER)); # Call the constructor of the parent class @@ -250,6 +250,13 @@ sub data_consumer ($$) { } } + if (!is_empty($task->{'recon_ports'})) { + # Accept only valid symbols. + if ($task->{'recon_ports'} !~ /[\d\-\,\ ]+/) { + $task->{'recon_ports'} = ''; + } + } + my $recon = new PandoraFMS::Recon::Base( communities => \@communities, dbh => $dbh, @@ -276,6 +283,9 @@ sub data_consumer ($$) { task_id => $task->{'id_rt'}, vlan_cache_enabled => $task->{'vlan_enabled'}, wmi_enabled => $task->{'wmi_enabled'}, + rcmd_enabled => $task->{'rcmd_enabled'}, + rcmd_timeout => $pa_config->{'rcmd_timeout'}, + rcmd_timeout_bin => $pa_config->{'rcmd_timeout_bin'}, auth_strings_array => \@auth_strings, autoconfiguration_enabled => $task->{'autoconfiguration_enabled'}, main_event_id => $main_event, @@ -336,14 +346,14 @@ sub exec_recon_script ($$$) { my $macros = safe_output($task->{'macros'}); - # \r and \n should be escaped for decode_json(). + # \r and \n should be escaped for p_decode_json(). $macros =~ s/\n/\\n/g; $macros =~ s/\r/\\r/g; my $decoded_macros; if ($macros) { eval { - $decoded_macros = decode_json(encode_utf8($macros)); + $decoded_macros = p_decode_json($pa_config, $macros); }; } @@ -399,8 +409,10 @@ sub exec_recon_script ($$$) { ################################################################################ # Guess the OS using xprobe2 or nmap. ################################################################################ -sub PandoraFMS::Recon::Base::guess_os($$) { - my ($self, $device) = @_; +sub PandoraFMS::Recon::Base::guess_os($$;$) { + my ($self, $device, $string_flag) = @_; + + return $self->{'os_id'}{$device} if defined($self->{'os_id'}{$device}); $DEVNULL = '/dev/null' if (!defined($DEVNULL)); $DEVNULL = '/NUL' if ($^O =~ /win/i && !defined($DEVNULL)); @@ -420,7 +432,9 @@ sub PandoraFMS::Recon::Base::guess_os($$) { my $return = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL`; if ($? == 0) { if($return =~ /Running OS:(.*)/) { - return pandora_get_os($self->{'dbh'}, $1); + my $str_os = $1; + return $str_os if is_enabled($string_flag); + return pandora_get_os($self->{'dbh'}, $str_os); } } } @@ -431,7 +445,9 @@ sub PandoraFMS::Recon::Base::guess_os($$) { return OS_OTHER if ($? != 0); if ($return =~ /Aggressive OS guesses:\s*(.*)/) { - return pandora_get_os($self->{'dbh'}, $1); + my $str_os = $1; + return $str_os if is_enabled($string_flag); + return pandora_get_os($self->{'dbh'}, $str_os); } } @@ -444,6 +460,9 @@ sub PandoraFMS::Recon::Base::guess_os($$) { sub PandoraFMS::Recon::Base::tcp_scan ($$) { my ($self, $host) = @_; + return if is_empty($host); + return if is_empty($self->{'recon_ports'}); + my $r = `"$self->{pa_config}->{nmap}" -p$self->{recon_ports} $host`; # Same as ""| grep open | wc -l" but multi-OS; @@ -510,6 +529,9 @@ sub PandoraFMS::Recon::Base::test_module($$) { ) { # Generic, plugins. (21-23 ASYNC) if ($test->{'id_modulo'} == 6) { + + return 0 unless $self->wmi_responds($addr); + # WMI commands. $value = $self->call( 'wmi_get_value', @@ -527,9 +549,39 @@ sub PandoraFMS::Recon::Base::test_module($$) { } elsif ($test->{'id_tipo_modulo'} >= 34 && $test->{'id_tipo_modulo'} <= 37) { # Remote command. - # XXX TODO: Test remote commands. - # Disabled until we can ensure result. - return 0; + return 0 unless $self->rcmd_responds($addr); + + my $target_os; + if ($test->{'custom_string_2'} =~ /inherited/i) { + $target_os = pandora_get_os( + $self->{'dbh'}, + $self->{'os_cache'}{$test->{'ip_target'}} + ); + } else { + $target_os = pandora_get_os($self->{'dbh'}, $test->{'custom_string_2'}); + } + + $value = enterprise_hook( + 'remote_execution_module', + [ + # pa_config, + $self->{'pa_config'}, + # dbh, + $self->{'dbh'}, + # module, + $test, + # target_os, + $target_os, + # ip_target, + $test->{'ip_target'}, + # tcp_port + $test->{'tcp_port'} + ] + ); + + chomp($value); + + return 0 unless defined($value); } elsif ($test->{'id_tipo_modulo'} >= 8 && $test->{'id_tipo_modulo'} <= 11) { # TCP @@ -905,6 +957,16 @@ sub PandoraFMS::Recon::Base::create_network_profile_modules($$) { $np_component->{'id_nc'} ); + # Tag cleanup. + if (!is_empty($component->{'tags'})) { + my @tags = map { + if ($_ > 0) { $_ } + else {} + } split ',', $component->{'tags'}; + + $component->{'tags'} = join ',', @tags; + } + $component->{'name'} = safe_output($component->{'name'}); if ($component->{'type'} >= 15 && $component->{'type'} <= 18) { $component->{'snmp_community'} = safe_output($self->get_community($device)); @@ -917,6 +979,15 @@ sub PandoraFMS::Recon::Base::create_network_profile_modules($$) { $component->{'plugin_pass'} = $self->{'snmp_auth_pass'}; } + if ($component->{'type'} >= 34 && $component->{'type'} <= 37) { + # Update module credentials. + $component->{'custom_string_1'} = $self->rcmd_credentials_key($device); + $component->{'custom_string_2'} = pandora_get_os_by_id( + $self->{'dbh'}, + $self->guess_os($device) + ); + } + $component->{'__module_component'} = 1; # 3. Try to register module into monitoring list. @@ -980,7 +1051,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { my $data; eval { local $SIG{__DIE__}; - $data = decode_json(decode_base64($row->{'data'})); + $data = p_decode_json($self->{'pa_config'}, decode_base64($row->{'data'})); }; if ($@) { $self->call('message', "ERROR JSON: $@", 3); @@ -1012,42 +1083,73 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { || $force_creation ) { my $parent_id; - my $os_id = $self->guess_os($data->{'agent'}{'direccion'}); + my $os_id = $data->{'agent'}{'id_os'}; + if (is_empty($os_id)) { + $os_id = $self->guess_os($data->{'agent'}{'direccion'}); + } $self->call('message', "Agent accepted: ".$data->{'agent'}{'nombre'}, 5); # Agent creation. my $agent_id = $data->{'agent'}{'agent_id'}; my $agent_learning; + my $agent_data; if (defined($agent_id) && $agent_id > 0) { - $agent_learning = get_db_value( + $agent_data = get_db_single_row( $self->{'dbh'}, - 'SELECT modo FROM tagente WHERE id_agente = ?', + 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id ); + $agent_learning = $agent_data->{'modo'} if ref($agent_data) eq 'HASH'; } if (!defined($agent_learning)) { # Agent id does not exists or is invalid. - # Check if has been created by another process. - $agent_id = get_db_value( - $self->{'dbh'}, - 'SELECT id_agente FROM tagente WHERE nombre = ?', - safe_input($data->{'agent'}{'nombre'}) - ); + # Check if has been created by another process, if not found. + $agent_data = PandoraFMS::Core::locate_agent( + $self->{'pa_config'}, $self->{'dbh'}, $data->{'agent'}{'direccion'} + ) if ref($agent_data) ne 'HASH'; - if (!defined($agent_id) || $agent_id <= 0) { + $agent_id = $agent_data->{'id_agente'} if ref($agent_data) eq 'HASH'; + if (ref($agent_data) eq 'HASH' && $agent_data->{'modo'} != 1) { + # Agent previously exists, but is not in learning mode, so skip + # modules scan and jump directly to parent analysis. + $data->{'agent'}{'agent_id'} = $agent_id; + push @agents, $data->{'agent'}; + next; + } + + if (!defined($agent_id) || $agent_id <= 0 || !defined($agent_data)) { # Agent creation. $agent_id = pandora_create_agent( $self->{'pa_config'}, $self->{'servername'}, $data->{'agent'}{'nombre'}, $data->{'agent'}{'direccion'}, $self->{'task_data'}{'id_group'}, $parent_id, $os_id, $data->{'agent'}->{'description'}, $data->{'agent'}{'interval'}, $self->{'dbh'}, - $data->{'agent'}{'timezone_offset'} + $data->{'agent'}{'timezone_offset'}, undef, undef, undef, undef, + undef, undef, 1, $data->{'agent'}{'alias'} ); + # Add found IP addresses to the agent. + if (ref($data->{'other_ips'}) eq 'ARRAY') { + foreach my $ip_addr (@{$data->{'other_ips'}}) { + my $addr_id = get_addr_id($self->{'dbh'}, $ip_addr); + $addr_id = add_address($self->{'dbh'}, $ip_addr) unless ($addr_id > 0); + next unless ($addr_id > 0); + + # Assign the new address to the agent + my $agent_addr_id = get_agent_addr_id($self->{'dbh'}, $addr_id, $agent_id); + if ($agent_addr_id <= 0) { + db_do( + $self->{'dbh'}, 'INSERT INTO taddress_agent (`id_a`, `id_agent`) + VALUES (?, ?)', $addr_id, $agent_id + ); + } + } + } + # Agent autoconfiguration. if (is_enabled($self->{'autoconfiguration_enabled'})) { my $agent_data = PandoraFMS::DB::get_db_single_row( @@ -1093,6 +1195,25 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { 'SELECT modo FROM tagente WHERE id_agente = ?', $agent_id ); + + # Update new IPs. + # Add found IP addresses to the agent. + if (ref($data->{'other_ips'}) eq 'ARRAY') { + foreach my $ip_addr (@{$data->{'other_ips'}}) { + my $addr_id = get_addr_id($self->{'dbh'}, $ip_addr); + $addr_id = add_address($self->{'dbh'}, $ip_addr) unless ($addr_id > 0); + next unless ($addr_id > 0); + + # Assign the new address to the agent + my $agent_addr_id = get_agent_addr_id($self->{'dbh'}, $addr_id, $agent_id); + if ($agent_addr_id <= 0) { + db_do( + $self->{'dbh'}, 'INSERT INTO taddress_agent (`id_a`, `id_agent`) + VALUES (?, ?)', $addr_id, $agent_id + ); + } + } + } } $data->{'agent'}{'agent_id'} = $agent_id; @@ -1198,7 +1319,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { eval { local $SIG{__DIE__}; $encoded = encode_base64( - encode_json($data) + p_encode_json($self->{'pa_config'}, $data) ); }; @@ -1215,12 +1336,10 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { ); } - } # Update parent relationships. foreach my $agent (@agents) { - # Avoid processing if does not exist. next unless (defined($agent->{'agent_id'})); @@ -1228,10 +1347,10 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { next unless defined($agent->{'parent'}); # Get parent id. - my $parent = get_agent_from_addr($self->{'dbh'}, $agent->{'parent'}); - if (!defined($parent)) { - $parent = get_agent_from_name($self->{'dbh'}, $agent->{'parent'}); - } + my $parent = PandoraFMS::Core::locate_agent( + $self->{'pa_config'}, $self->{'dbh'}, $agent->{'parent'} + ); + next unless defined($parent); # Is the agent in learning mode? @@ -1286,15 +1405,24 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { my @hosts = keys %{$self->{'agents_found'}}; $self->{'step'} = STEP_PROCESSING; my ($progress, $step) = (90, 10.0 / scalar(@hosts)); # From 90% to 100%. - foreach my $label (keys %{$self->{'agents_found'}}) { + + foreach my $addr (keys %{$self->{'agents_found'}}) { + my $label = $self->{'agents_found'}->{$addr}{'agent'}{'nombre'}; + + next if is_empty($label); + + # Retrieve target agent OS version. + $self->{'agents_found'}->{$addr}{'agent'}{'id_os'} = $self->guess_os($addr); + $self->call('update_progress', $progress); $progress += $step; # Store temporally. Wait user approval. my $encoded; + eval { local $SIG{__DIE__}; $encoded = encode_base64( - encode_json($self->{'agents_found'}->{$label}) + p_encode_json($self->{'pa_config'}, $self->{'agents_found'}->{$addr}) ); }; @@ -1307,7 +1435,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { if (defined($id)) { # Already defined. - $self->{'agents_found'}{$label}{'id'} = $id; + $self->{'agents_found'}{$addr}{'id'} = $id; db_do( $self->{'dbh'}, @@ -1321,7 +1449,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { } # Insert. - $self->{'agents_found'}{$label}{'id'} = db_insert( + $self->{'agents_found'}{$addr}{'id'} = db_insert( $self->{'dbh'}, 'id', 'INSERT INTO tdiscovery_tmp_agents (`id_rt`,`label`,`data`,`created`) ' @@ -1386,28 +1514,33 @@ sub PandoraFMS::Recon::Base::apply_monitoring($) { my @hosts = keys %{$self->{'agents_found'}}; - $self->{'step'} = STEP_MONITORING; - # From 80% to 90%. - my ($progress, $step) = (80, 10.0 / scalar(@hosts)); - my ($partial, $sub_step) = (0, 100 / scalar(@hosts)); + my $progress = 80; - foreach my $label (keys %{$self->{'agents_found'}}) { - $self->{'c_network_percent'} = $partial; - $self->{'c_network_name'} = $label; - $self->call('update_progress', $progress); - $progress += $step; - $partial += $sub_step; - $self->call('message', "Checking modules for $label", 5); + if (scalar @hosts > 0) { + $self->{'step'} = STEP_MONITORING; + # From 80% to 90%. + my ($progress, $step) = (80, 10.0 / scalar(@hosts)); + my ($partial, $sub_step) = (0, 100 / scalar(@hosts)); - # Monitorization selected. - $self->call('create_network_profile_modules', $label); + foreach my $label (keys %{$self->{'agents_found'}}) { + $self->{'c_network_percent'} = $partial; + $self->{'c_network_name'} = $label; + $self->call('update_progress', $progress); + $progress += $step; + $partial += $sub_step; + $self->call('message', "Checking modules for $label", 5); - # Monitorization - interfaces - $self->call('create_interface_modules', $label); + # Monitorization selected. + $self->call('create_network_profile_modules', $label); - # Monitorization - WMI modules. - $self->call('create_wmi_modules', $label); + # Monitorization - interfaces + $self->call('create_interface_modules', $label); + # Monitorization - WMI modules. + $self->call('create_wmi_modules', $label); + + } + } $self->{'c_network_percent'} = 100; @@ -1615,6 +1748,16 @@ sub PandoraFMS::Recon::Base::set_parent($$$) { $self->{'agents_found'}{$host}{'agent'}{'parent'} = $parent; + # Add host alive module for parent. + $self->add_module($parent, + { + 'ip_target' => $parent, + 'name' => "Host Alive", + 'description' => '', + 'type' => 'remote_icmp_proc', + 'id_modulo' => 2, + } + ); } ################################################################################ @@ -1624,17 +1767,25 @@ sub PandoraFMS::Recon::Base::update_progress ($$) { my ($self, $progress) = @_; my $stats = {}; - if (defined($self->{'summary'}) && $self->{'summary'} ne '') { - $stats->{'summary'} = $self->{'summary'}; + eval { + local $SIG{__DIE__}; + if (defined($self->{'summary'}) && $self->{'summary'} ne '') { + $stats->{'summary'} = $self->{'summary'}; + } + + $stats->{'step'} = $self->{'step'}; + $stats->{'c_network_name'} = $self->{'c_network_name'}; + $stats->{'c_network_percent'} = $self->{'c_network_percent'}; + + # Store progress, last contact and overall status. + db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', + time (), $progress, p_encode_json($self->{'pa_config'}, $stats), $self->{'task_id'}); + }; + if ($@) { + $self->call('message', "Problems updating progress $@", 5); + db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', + time (), $progress, "{}", $self->{'task_id'}); } - - $stats->{'step'} = $self->{'step'}; - $stats->{'c_network_name'} = $self->{'c_network_name'}; - $stats->{'c_network_percent'} = $self->{'c_network_percent'}; - - # Store progress, last contact and overall status. - db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', - time (), $progress, encode_json($stats), $self->{'task_id'}); } 1; diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 36d9e34b3e..57a95502da 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -32,8 +32,8 @@ use base 'Exporter'; our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.744"; -my $pandora_build = "200415"; +my $pandora_version = "7.0NG.745"; +my $pandora_build = "200519"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index 01f8e824b8..2e54650f7c 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -8,6 +8,7 @@ use warnings; # Default lib dir for RPM and DEB packages use NetAddr::IP; +use IO::Socket::INET; use POSIX qw/ceil/; use Socket qw/inet_aton/; @@ -159,6 +160,12 @@ sub new { # Globally enable/disable WMI scans. wmi_enabled => 0, + + # Globally enable/disable RCMD scans. + rcmd_enabled => 0, + rcmd_timeout => 4, + rcmd_timeout_bin => '/usr/bin/timeout', + auth_strings_array => [], wmi_timeout => 3, timeout_cmd => '', @@ -171,6 +178,9 @@ sub new { # Visited devices (initially empty). visited_devices => {}, + # Inverse relationship for visited devices (initially empty). + addresses => {}, + # Per device VLAN cache. vlan_cache => {}, vlan_cache_enabled => 1, # User configuration. Globally disables the VLAN cache. @@ -308,6 +318,26 @@ sub add_addresses($$$) { my ($self, $device, $ip_address) = @_; $self->{'visited_devices'}->{$device}->{'addr'}->{$ip_address} = ''; + + # Inverse relationship. + $self->{'addresses'}{$ip_address} = $device; + + # Update IP references. + if (ref($self->{'agents_found'}{$device}) eq 'HASH') { + my @addresses = $self->get_addresses($device); + $self->{'agents_found'}{$device}{'other_ips'} = \@addresses; + $self->call('message', 'New IP detected for '.$device.': '.$ip_address, 5); + } + +} + +################################################################################ +# Get main address from given address (multi addressed devices). +################################################################################ +sub get_main_address($$) { + my ($self, $addr) = @_; + + return $self->{'addresses'}{$addr}; } ################################################################################ @@ -408,11 +438,11 @@ sub are_connected($$$$$) { sub icmp_discovery($$) { my ($self, $addr) = @_; - # Create an agent for the device and add it to the list of known hosts. - push(@{$self->{'hosts'}}, $addr); + # Create an agent for the device and add it to the list of known hosts. + push(@{$self->{'hosts'}}, $addr); - # Create an agent for the device and add it to the list of known hosts. - $self->add_agent($addr); + # Create an agent for the device and add it to the list of known hosts. + $self->add_agent($addr); $self->add_module($addr, { @@ -1320,17 +1350,30 @@ sub remote_arp($$) { ################################################################################ sub prepare_agent($$) { my ($self, $addr) = @_; + + # Avoid multi-ip agent. No reference, is first encounter. + my $main_address = $self->get_main_address($addr); + return unless is_empty($main_address); + + # Resolve hostnames. + my $host_name = (($self->{'resolve_names'} == 1) ? gethostbyaddr(inet_aton($addr), AF_INET) : $addr); + + # Fallback to device IP if host name could not be resolved. + $host_name = $addr if (!defined($host_name) || $host_name eq ''); + $self->{'agents_found'} = {} if ref($self->{'agents_found'}) ne 'HASH'; # Already initialized. return if ref($self->{'agents_found'}->{$addr}) eq 'HASH'; + my @addresses = $self->get_addresses($addr); $self->{'agents_found'}->{$addr} = { 'agent' => { - 'nombre' => $addr, + 'nombre' => $host_name, 'direccion' => $addr, - 'alias' => $addr, + 'alias' => $host_name, }, + 'other_ips' => \@addresses, 'pen' => $self->{'pen'}{$addr}, 'modules' => [], }; @@ -1392,6 +1435,12 @@ sub test_capabilities($$) { # Add wmi scan if enabled. $self->wmi_discovery($addr); } + + # RCMD discovery. + if (is_enabled($self->{'rcmd_enabled'})) { + # Add wmi scan if enabled. + $self->rcmd_discovery($addr); + } } ################################################################################ @@ -1500,6 +1549,11 @@ sub scan_subnet($) { # Populate. $self->call('update_progress', ceil($progress)); + # Filter by port (if enabled). + if (!is_empty($self->{'recon_ports'})) { + next unless $self->call("tcp_scan", $addr) > 0; + } + # Enable/ disable capabilities. $self->test_capabilities($addr); } @@ -1924,10 +1978,10 @@ sub scan($) { } } - # Apply monitoring templates - $self->call('message', "[5/6] Applying monitoring.", 3); + # Apply monitoring templates + $self->call('message', "[5/6] Applying monitoring.", 3); $self->{'step'} = STEP_MONITORING; - $self->call('apply_monitoring', $self); + $self->call('apply_monitoring', $self); # Print debug information on found devices. $self->call('message', "[Summary]", 3); @@ -1945,8 +1999,8 @@ sub scan($) { $self->call('message', $dev_info, 3); } - # Apply monitoring templates - $self->call('message', "[6/6] Processing results.", 3); + # Apply monitoring templates + $self->call('message', "[6/6] Processing results.", 3); $self->{'step'} = STEP_PROCESSING; # Send agent information to Database (Discovery) or XML (satellite.). $self->call('report_scanned_agents'); @@ -2072,16 +2126,16 @@ sub snmp_get_value($$$) { my ($self, $device, $oid) = @_; my $effective_oid = $oid; - if (is_enabled($self->{'translate_snmp'})) { + if (is_enabled($self->{'translate_snmp'}) && $oid !~ /^[\.\d]+$/) { $effective_oid = `snmptranslate $oid -On 2>$DEVNULL`; - chomp($effective_oid); + $effective_oid =~ s/[\r\n]//g; } my @output = $self->snmp_get($device, $effective_oid); - + foreach my $line (@output) { - chomp($line); - return $1 if ($line =~ /^$effective_oid\s+=\s+\S+:\s+(.*)$/); + $line =~ s/[\r\n]//g; + return $1 if ($line =~ /^$effective_oid\s+=\s+\S+:\s+(.*)/); } return undef; @@ -2172,8 +2226,8 @@ sub wmi_credentials { # undef if it does not respond to WMI. ################################################################################ sub wmi_credentials_key { - my ($self, $target) = @_; - return $self->{'wmi_auth_key'}{$target}; + my ($self, $target) = @_; + return $self->{'wmi_auth_key'}{$target}; } ################################################################################ @@ -2231,6 +2285,110 @@ sub wmi_credentials_calculation { return undef; } +################################################################################ +# Returns the credentials with which the host responds to WMI queries or +# undef if it does not respond to WMI. +################################################################################ +sub rcmd_credentials { + my ($self, $target) = @_; + return $self->{'rcmd_auth'}{$target}; +} + +################################################################################ +# Returns the credentials KEY with which the host responds to WMI queries or +# undef if it does not respond to WMI. +################################################################################ +sub rcmd_credentials_key { + my ($self, $target) = @_; + return $self->{'rcmd_auth_key'}{$target}; +} + +################################################################################ +# Calculate WMI credentials for target, 1 if calculated, undef if cannot +# connect to target. Credentials could be empty (-N) +################################################################################ +sub rcmd_credentials_calculation { + my ($self, $target) = @_; + + my $rcmd = PandoraFMS::Recon::Util::enterprise_new( + 'PandoraFMS::RemoteCmd',[{ + 'psexec' => $self->{'parent'}->{'pa_config'}->{'psexec'}, + 'winexe' => $self->{'parent'}->{'pa_config'}->{'winexe'}, + 'plink' => $self->{'parent'}->{'pa_config'}->{'plink'} + }] + ); + + if (!$rcmd) { + # Library not available. + $self->call('message', "PandoraFMS::RemoteCmd library not available", 10); + return undef; + } + + my $os = $self->{'os_cache'}{$target}; + $os = $self->call('guess_os', $target, 1) if is_empty($os); + $rcmd->set_host($target); + $rcmd->set_os($os); + + $self->{'os_cache'}{$target} = $os; + + # Test all credentials selected. + foreach my $key_index (@{$self->{'auth_strings_array'}}) { + my $cred = $self->call('get_credentials', $key_index); + next if ref($cred) ne 'HASH'; + $rcmd->clean_ssh_lib(); + + my $username; + my $domain; + + if($cred->{'username'} =~ /^(.*?)\\(.*)$/) { + $domain = $1; + $username = $2; + } else { + $username = $cred->{'username'}; + } + + $rcmd->set_credentials( + { + 'user' => $username, + 'pass' => $cred->{'password'}, + 'domain' => $domain + } + ); + + $rcmd->set_timeout( + $self->{'rcmd_timeout_bin'}, + $self->{'rcmd_timeout'} + ); + + my $result; + eval { + $result = $rcmd->rcmd('echo 1'); + chomp($result); + my $out = ''; + $out = $result if !is_empty($result); + $self->call('message', "Trying [".$key_index."] in [". $target."] [".$os."]: [$out]", 10); + }; + if ($@) { + $self->call('message', "Failed while trying [".$key_index."] in [". $target."] [".$os."]:" . @_, 10); + } + + if (!is_empty($result) && $result == "1") { + $self->{'rcmd_auth'}{$target} = $cred; + $self->{'rcmd_auth_key'}{$target} = $key_index; + $self->{'rcmd'}{$target} = 1; + $self->{'summary'}->{'RCMD'} += 1; + $self->call('message', "RCMD available for $target", 10); + return 1; + } else { + $self->call('message', "Last error ($target|$os|$result) was [".$rcmd->get_last_error()."]", 10); + } + + } + + # Not found. + return 0; +} + ################################################################################ # Tests wmi capability for addr. ################################################################################ @@ -2245,6 +2403,20 @@ sub wmi_discovery { } +################################################################################ +# Tests credentials against addr. +################################################################################ +sub rcmd_discovery { + my ($self, $addr) = @_; + + # Initialization. + $self->{'rcmd'} = {} unless ref($self->{'rcmd'}) eq 'HASH'; + + # Calculate credentials. + $self->rcmd_credentials_calculation($addr); + +} + ################################################################################ # Extra: WMI imported methods. DO NOT EXPORT TO AVOID DOUBLE DEF. ################################################################################ @@ -2329,9 +2501,18 @@ sub wmi_get_command { # Checks if target is reachable using wmi. ################################################################################ sub wmi_responds { - my ($self, $target) = @_; - return 1 if is_enabled($self->{'wmi'}{$target}); - return 0; + my ($self, $target) = @_; + return 1 if is_enabled($self->{'wmi'}{$target}); + return 0; +} + +################################################################################ +# Checks if target is reachable using rcmd. +################################################################################ +sub rcmd_responds { + my ($self, $target) = @_; + return 1 if is_enabled($self->{'rcmd'}{$target}); + return 0; } ################################################################################ diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 10f57b1e15..cf9f01f5e1 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -31,6 +31,9 @@ use LWP::UserAgent; use threads; use threads::shared; +use JSON; +use Encode qw/decode_utf8 encode_utf8/; + use lib '/usr/lib/perl5'; use PandoraFMS::Sendmail; @@ -152,6 +155,8 @@ our @EXPORT = qw( dateTimeToTimestamp get_user_agent ui_get_full_url + p_encode_json + p_decode_json ); # ID of the different servers @@ -1458,7 +1463,7 @@ sub pandora_block_ping($@) { if (-x $pa_config->{'fping'}) { # fping timeout in milliseconds - $cmd = $pa_config->{'fping'} . " -a -q -t " . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts)); + $cmd = '"'.$pa_config->{'fping'} . '" -a -q -t ' . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts)); @output = `$cmd 2>$DEVNULL`; } else { # Ping scan @@ -2353,6 +2358,52 @@ sub ui_get_full_url { } +################################################################################ +# Encodes a json. +################################################################################ +sub p_encode_json { + my ($pa_config, $data) = @_; + + # Initialize JSON manager. + my $json = JSON->new->allow_nonref; + my $encoded_data; + + eval { + local $SIG{__DIE__}; + if ($JSON::VERSION > 2.90) { + $encoded_data = $json->encode($data); + } else { + $encoded_data = encode_utf8($json->encode($data)); + } + }; + if ($@){ + if (defined($data)) { + logger($pa_config, 'Failed to encode data: '.$@, 5); + } + } + + return $encoded_data; +} + +################################################################################ +# Dencodes a json. +################################################################################ +sub p_decode_json { + my ($pa_config, $data) = @_; + my $decoded_data; + + if ($JSON::VERSION > 2.90) { + # Initialize JSON manager. + my $json = JSON->new->allow_nonref; + $decoded_data = $json->decode($data); + } else { + $decoded_data = decode_json($data); + } + + return $decoded_data; +} + + 1; __END__ diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 59af01f729..f3036203bb 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 88f07557e7..b393316483 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.744 -%define release 200415 +%define version 7.0NG.745 +%define release 200519 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 22d69f90c2..ac8ff62b40 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -8,8 +8,8 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.744" -PI_BUILD="200415" +PI_VERSION="7.0NG.745" +PI_BUILD="200519" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_backup.sh b/pandora_server/util/pandora_backup.sh index 777c8666fc..cd0ae285b9 100755 --- a/pandora_server/util/pandora_backup.sh +++ b/pandora_server/util/pandora_backup.sh @@ -32,6 +32,7 @@ QUIET=0 RESTOREFILES=0 DATABASE=1 TIMESTAMP=`date +"%Y-%m-%d-%H-%M-%S"` +MDE=1 # Main parsing code @@ -70,6 +71,15 @@ done # Execution +which mysqldump &>/dev/null +[ $? -eq 0 ] || MDE=0 + +if [ $MDE == 0 ] +then + echo -e "Command Mysqldump not found. \nIn order to make backups it is necessary to have mysqldump on your console.\nAborting..." + exit 1 +fi + if [ ! -e "$PANDORAPATH/include/config.php" ] then echo "Cannot read config file at $PANDORAPATH/include/config.php. Aborting" diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl old mode 100644 new mode 100755 index bb343ef78f..58fcfdd203 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.744 PS200415"; +my $version = "7.0NG.745 PS200519"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ca987efd80..b4de5ace47 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.744 PS200415"; +my $version = "7.0NG.745 PS200519"; # save program name for logging my $progname = basename($0); diff --git a/tests/.gitignore b/tests/.gitignore index 0d20b6487c..82b9d47a72 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1 +1,3 @@ *.pyc +geckodriver.log +wmic diff --git a/tests/Dockerfile b/tests/Dockerfile index e09f39c301..2a1fb9f667 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,109 +1,86 @@ -FROM centos:centos6 -MAINTAINER Pandora FMS Team +FROM centos:7 RUN { \ - echo '[EPEL]'; \ - echo 'name = CentOS Epel'; \ - echo 'baseurl = http://dl.fedoraproject.org/pub/epel/6/x86_64'; \ - echo 'enabled=1'; \ + echo '[artica_pandorafms]'; \ + echo 'name=CentOS7 - PandoraFMS official repo'; \ + echo 'baseurl=http://firefly.artica.es/centos7'; \ echo 'gpgcheck=0'; \ - echo ''; \ - echo '[remi-php72]'; \ - echo 'name=Remi php72'; \ - echo 'baseurl=http://rpms.remirepo.net/enterprise/6/php72/x86_64/'; \ echo 'enabled=1'; \ - echo 'gpgcheck=0'; \ - echo ''; \ - echo '[remi-safe]'; \ - echo 'name=Safe Remis RPM repository'; \ - echo 'mirrorlist=http://cdn.remirepo.net/enterprise/$releasever/safe/mirror'; \ - echo 'enabled=1'; \ - echo 'gpgcheck=0'; \ - echo ''; \ -} > /etc/yum.repos.d/extra_repos.repo + } > /etc/yum.repos.d/pandorafms.repo -RUN { \ - echo '[artica_pandorafms]'; \ - echo 'name=CentOS6 - PandoraFMS official repo'; \ - echo 'baseurl=http://artica.es/centos6'; \ - echo 'gpgcheck=0'; \ - echo 'enabled=1'; \ -} > /etc/yum.repos.d/pandorafms.repo - -RUN yum -y update; yum clean all; - -RUN yum --disablerepo=updates install -y firefox - -# Generic dependencies -RUN yum install -y \ +# Pandora FMS dependencies. +RUN yum install -y epel-release vim wget bzip2 curl && \ + yum install -y yum-utils && \ + yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm && \ + yum-config-manager --disable mysql80-community && \ + yum-config-manager --enable mysql57-community && \ + yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm && \ + yum-config-manager --enable remi-php72 && \ + yum install -y gtk3 python-pip \ python-pip \ - xorg-x11-server-Xvfb; yum clean all; -RUN pip install pyvirtualdisplay -RUN pip install 'selenium==2.53.0' -RUN pip install unittest2 -RUN pip install testtools - -# Pandora FMS Console dependencies -RUN yum install -y \ - git \ + firefox \ + xorg-x11-server-Xvfb \ + x11vnc && \ + wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz && \ + tar xvzf geckodriver-v0.26.0-linux64.tar.gz && \ + mv geckodriver /usr/bin/ && rm geckodriver-v0.26.0-linux64.tar.gz && \ + pip install pyvirtualdisplay && \ + pip install "selenium==3.141" && \ + pip install unittest2 && \ + pip install testtools && \ + yum install -y git \ httpd \ cronie \ ntp \ openldap \ nfdump \ - wget \ - curl \ openldap \ plymouth \ xterm \ - php \ - php-gd \ - graphviz \ - php-mysql \ - php-pear-DB \ + php \ + php-gd \ + graphviz \ + php-mysqlnd \ + php-pear-DB \ php-pear \ php-pdo \ - php-mbstring \ - php-ldap \ - php-snmp \ - php-ldap \ - php-common \ - php-zip \ - php-xmlrpc \ + php-mbstring \ + php-ldap \ + php-snmp \ + php-ldap \ + php-common \ + php-zip \ + php-xmlrpc \ nmap \ xprobe2 \ mysql-server \ - mysql; yum clean all; - -# Pandora FMS Server dependencies -RUN yum install -y \ + mysql \ ntp \ - vim \ htop \ nano \ postfix \ - wmic \ - perl-HTML-Tree \ - perl-DBI \ - perl-DBD-mysql \ - perl-libwww-perl \ - perl-XML-Simple \ - perl-XML-SAX \ - perl-NetAddr-IP \ + perl-HTML-Tree \ + perl-DBI \ + perl-DBD-mysql \ + perl-libwww-perl \ + perl-XML-Simple \ + perl-XML-SAX \ + perl-NetAddr-IP \ perl-Scope-Guard \ - net-snmp \ - net-tools \ - perl-IO-Socket-INET6 \ - perl-Socket6 \ - nmap \ - sudo \ - xprobe2 \ - make \ - perl-CPAN \ - perl-JSON \ - net-snmp-perl \ - perl-Time-HiRes \ - perl-XML-Twig \ + net-snmp \ + net-tools \ + perl-IO-Socket-INET6 \ + perl-Socket6 \ + perl-Sys-Syslog \ + nmap \ + sudo \ + xprobe2 \ + make \ + perl-CPAN \ + perl-JSON \ + net-snmp-perl \ + perl-Time-HiRes \ + perl-XML-Twig \ perl-Encode-Locale \ net-snmp-utils \ fontconfig \ @@ -111,20 +88,19 @@ RUN yum install -y \ freetype-devel \ fontconfig-devel \ libstdc++ \ - perl-Test-Simple; yum clean all; + gettext \ + cpanminus && \ + cpanm Geo::IP && \ + mkdir -p /opt/phantomjs/bin && cd /opt/phantomjs/bin && \ + wget https://netcologne.dl.sourceforge.net/project/pandora/Tools%20and%20dependencies%20%28All%20versions%29/DEB%20Debian%2C%20Ubuntu/phantomjs && \ + chmod +x phantomjs && \ + ln -s /opt/phantomjs/bin/phantomjs /usr/bin/ && \ + yum update -y && \ + echo -e '#!/bin/bash\nhttpd -k $1\n' > /etc/init.d/httpd && \ + chmod +x /etc/init.d/httpd && \ + yum clean all -RUN wget http://rpmfind.net/linux/centos/6.9/os/i386/Packages/gettext-0.17-18.el6.i686.rpm; \ - yum localinstall -y gettext-0.17-18.el6.i686.rpm; \ - rm -rf gettext-0.17-18.el6.i686.rpm; \ - wget http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/perl-Geo-IP-1.38-1.el6.rf.x86_64.rpm; \ - yum localinstall -y perl-Geo-IP-1.38-1.el6.rf.x86_64.rpm; \ - rm -rf perl-Geo-IP-1.38-1.el6.rf.x86_64.rpm; - -#Install phantomjs required for export graph pdf. -RUN mkdir -p /opt/phantomjs/bin && cd /opt/phantomjs/bin; \ - wget https://netcologne.dl.sourceforge.net/project/pandora/Tools%20and%20dependencies%20%28All%20versions%29/DEB%20Debian%2C%20Ubuntu/phantomjs; \ - chmod +x phantomjs; \ - ln -s /opt/phantomjs/bin/phantomjs /usr/bin/; +ADD wmic /usr/bin/ # Install debugg dependencies. RUN yum install -y \ @@ -133,6 +109,7 @@ RUN yum install -y \ gcc \ gcc-c++ \ autoconf \ + file \ automake && \ pecl install Xdebug && \ git clone https://github.com/tideways/php-xhprof-extension && \ @@ -142,7 +119,8 @@ RUN yum install -y \ make && \ make install && \ cd .. && \ - rm -rf php-xhprof-extension + rm -rf php-xhprof-extension && \ + yum clean all #Exposing ports for: HTTP, SNMP Traps, Tentacle protocol EXPOSE 80 162/udp 41121 diff --git a/tests/install_console.py b/tests/install_console.py index 54ab91e518..ca594bf17e 100755 --- a/tests/install_console.py +++ b/tests/install_console.py @@ -10,7 +10,7 @@ if ('DISPLAY' not in os.environ): display.start() # Go to the installation page. -browser = webdriver.Firefox() +browser = webdriver.Firefox(timeout=15) browser.implicitly_wait(5) browser.get('http://localhost/pandora_console/install.php') assert("Pandora FMS - Installation Wizard" in browser.title)