diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index c4a017d5df..173b2e8aac 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.715, AIX version +# Version 7.0NG.716, 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 66ed797d78..5964b8c23b 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.715, FreeBSD Version +# Version 7.0NG.716, 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 876222a5eb..c32ca457de 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.715, HP-UX Version +# Version 7.0NG.716, 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 1ab6555ce5..fdea3a3700 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.715, GNU/Linux +# Version 7.0NG.716, 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 d308a01e8e..fc457d1358 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.715, GNU/Linux +# Version 7.0NG.716, 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 514782e164..ca431a8917 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.715, Solaris Version +# Version 7.0NG.716, 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 8479b4515f..c17122f997 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.715 +# Version 7.0NG.716 # 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 53c491e3c4..e9929e30ee 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.715, AIX version +# Version 7.0NG.716, 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 e5c7738542..3688e15492 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.715 +# Version 7.0NG.716 # 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 8f8c2febdf..1a2d1075d7 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.715, HPUX Version +# Version 7.0NG.716, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 25712c4d7c..cf9c6d54b7 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.715 +# Version 7.0NG.716 # 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 7a8f736c41..107aeacbc5 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.715 +# Version 7.0NG.716 # 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 8a33853ae5..9189faa142 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.715 +# Version 7.0NG.716 # 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 ba1d866ed2..1cf52d41cf 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.715, Solaris version +# Version 7.0NG.716, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index bb75e5f95b..625fca365d 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.715, AIX version +# Version 7.0NG.716, 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 48192919a2..f07a12ded5 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.715-171110 +Version: 7.0NG.716-171130 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 1b335438a9..097ef3b63f 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.715-171110" +pandora_version="7.0NG.716-171130" 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 aaf29acb8f..d7647191a4 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.715, GNU/Linux +# Version 7.0NG.716, 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 817432efa6..2625ca7542 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.715, FreeBSD Version +# Version 7.0NG.716, 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 d0f28e9943..2387412e15 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.715, HP-UX Version +# Version 7.0NG.716, 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 d9876734df..da5c2b2c18 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.715, GNU/Linux +# Version 7.0NG.716, 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 c4665aaa94..a0717d889e 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.715, GNU/Linux +# Version 7.0NG.716, 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 8100e76026..0cc5dc41cc 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.715, NetBSD Version +# Version 7.0NG.716, 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 9a5432057a..ac8ece9b0c 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.715, Solaris Version +# Version 7.0NG.716, 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 a5743df259..7c1cbe610c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -40,8 +40,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.715'; -use constant AGENT_BUILD => '171110'; +use constant AGENT_VERSION => '7.0NG.716'; +use constant AGENT_BUILD => '171130'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -1244,7 +1244,11 @@ sub check_collections () { # Delete old collections if there are no broker agents if ($BrokerEnabled == 0) { - opendir (DIR, "$ConfDir/collections") || return; + if(!opendir (DIR, "$ConfDir/collections")){ + log_message ('Collection', "Could not open dir $ConfDir/collections"); + return; + } + while (defined (my $file_name = readdir(DIR))) { next if ($file_name eq '.' || $file_name eq '..'); @@ -1252,8 +1256,14 @@ sub check_collections () { $file_name =~ s/\.md5$//; if (! defined ($Collections{$file_name})) { - rmrf ("$ConfDir/collections/$file_name"); - unlink ("$ConfDir/collections/$file_name.md5"); + if(opendir (DIR_check, "$ConfDir/collections/$file_name")){ + closedir (DIR_check); + rmrf ("$ConfDir/collections/$file_name"); + unlink ("$ConfDir/collections/$file_name.md5"); + } + else { + log_message ('Collection', "Could not open dir $ConfDir/collections/$file_name"); + } } } closedir (DIR); @@ -1272,7 +1282,11 @@ sub check_collections () { # Get remote md5 error ("File '$Conf{'temporal'}/$collection_md5_file' already exists as a symlink and could not be removed: $!.") if (-l "$Conf{'temporal'}/$collection_md5_file" && !unlink("$Conf{'temporal'}/$collection_md5_file")); - next unless (recv_file ($collection_md5_file, $Conf{'server_path_md5'}) == 0); + if(recv_file ($collection_md5_file, $Conf{'server_path_md5'}) != 0){ + log_message ('Collection', "Could not write $collection_md5_file on " . $Conf{'server_path_md5'}); + next; + } + open (MD5_FILE, "< $Conf{'temporal'}/$collection_md5_file") || error ("Could not open file '$Conf{'temporal'}/$collection_md5_file' for reading: $!."); my $remote_collection_md5 = ; close (MD5_FILE); @@ -1284,13 +1298,20 @@ sub check_collections () { $local_collection_md5 = ; close MD5_FILE; } + else{ + log_message ('Collection', "Could not open dir $ConfDir/collections/$collection_md5_file"); + next; + } # Check for changes $local_collection_md5 = $remote_collection_md5 unless defined ($local_collection_md5); next if ($local_collection_md5 eq $remote_collection_md5); # Download and unzip - next unless (recv_file ($collection_file, $Conf{'server_path_zip'}) == 0); + if(recv_file ($collection_md5_file, $Conf{'server_path_md5'}) != 0){ + log_message ('Collection', "Could not write $collection_file on " . $Conf{'server_path_zip'}); + next; + } rmrf ("$ConfDir/collections/$collection"); `unzip -d "$ConfDir/collections/$collection" "$Conf{'temporal'}/$collection_file" 2>$DevNull`; unlink ("$Conf{'temporal'}/$collection_file"); diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 7071e4655d..582cba7a4c 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.715 -%define release 171110 +%define version 7.0NG.716 +%define release 171130 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 a3ce74230c..1e91878da6 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.715 -%define release 171110 +%define version 7.0NG.716 +%define release 171130 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 e75fffdc2b..696fa280a0 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.715" -PI_BUILD="171110" +PI_VERSION="7.0NG.716" +PI_BUILD="171130" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 90626fedbc..5cbf2b0876 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-2014 Artica Soluciones Tecnologicas -# Version 7.0NG.715 +# (c) 2006-2017 Artica Soluciones Tecnologicas +# Version 7.0NG.716 # 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 @@ -21,6 +21,13 @@ server_ip $ServerIP$ server_path /var/spool/pandora/data_in temporal "%ProgramFiles%\pandora_agent\temp" +# Group assigned for this agent (descriptive, p.e: Servers) +group $GroupName$ + +# If set to 1 allows the agent to be configured via the web console +# (only works on enterprise version). Set to 0 to disable it +remote_config 0 + #include "C:\Archivos de programa\pandora_agent\pandora_agent_alt.conf" #broker_agent name_agent @@ -43,15 +50,10 @@ agent_name_cmd __rand__ # address: Enforce to server a ip address to this agent # You can also try to detect the first IP using "auto", for example - address auto - # or setting a fixed IP address, like for example: #address 192.168.36.73 -# Group assigned for this agent (descriptive, p.e: Servers) -group Servers - # This limits operation if temporal dir has not enough free disk. #temporal_min_size 1024 @@ -80,10 +82,6 @@ server_port 41121 # Debug mode renames XML in the temp folder and continues running # debug 1 -# If set to 1 allows the agent to be configured via the web console -# (only works on enterprise version). Set to 0 to disable it -remote_config 0 - # XML encoding (ISO-8859-1 by default). Most windows servers experience problems when you set to UTF-8. Other special codepages may be specified here. #encoding ISO-8859-1 @@ -102,6 +100,10 @@ xml_buffer 1 # Agent mode: Learn (default), No-learn, Autodisable # agent_mode autodisable +# EHorus configuration file default full path. +#It try to find the EKID and set it like a custom field. +ehorus_conf "C:\Program Files\ehorus_agent\ehorus_agent.conf" + # Secondary server configuration # ============================== @@ -127,74 +129,166 @@ xml_buffer 1 #process_firefox_stop killall firefox #service_messenger 1 +############################################### # Module Definition # Check online documentation and module library at http://pandorafms.org # ================= -# Get Network information using Agent plugin -module_plugin cscript //B "%ProgramFiles%\Pandora_Agent\util\nettraffic.vbs" - -# Get disk occupation (percent) -module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent.vbs" - -# External inventory plugin -module_begin -module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\software_installed.vbs" -module_interval 288 -# 288 x 5min = 24 hr, one execution per day, using module_interval -module_end - -# CPU Load - +# CPU Load using WMI module_begin module_name CPU Load module_type generic_data -#module_wmiquery SELECT LoadPercentage FROM Win32_Processor -#module_wmicolumn LoadPercentage -module_cpuusage all -module_description CPU Load (%) -module_unit % -module_min_warning 80 +module_wmiquery SELECT LoadPercentage FROM Win32_Processor +module_wmicolumn LoadPercentage +module_max 100 +module_min 0 +module_description User CPU Usage (%) +module_min_warning 70 module_max_warning 90 module_min_critical 91 module_max_critical 100 +module_unit % +module_group System module_end -# Number processes +# Basic info about TCP Connection module_begin -module_name Number processes -module_type generic_data -module_exec tasklist | gawk "NR > 3 {print$0}" | wc -l -module_description Number of processes running -module_min_warning 175 -module_max_warning 249 -module_min_critical 250 -module_max_critical 300 +module_name TCP_Connections +module_type generic_data +module_exec netstat -an | find /c /v "estab" +module_description Total number of TCP connections active +module_group Networking module_end +# Example plugin to retrieve drive usage +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs" + +# Example plugin to retrieve memory usage +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\mem_percent_used.vbs" + +# Example plugin to retrieve network usage +module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\network.vbs" + +## Windows inventory module (This information will be displayed only in enterprise version) +## Please check the WMI is healthy before activate this functionality + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +#module_begin +#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs" +#module_crontab * 12-15 * * 1 +#module_end + +######################################### +# EXAMPLES # +######################################### + +# Example: get Network information using Agent plugin +#module_plugin cscript //B "%ProgramFiles%\Pandora_Agent\util\nettraffic.vbs" + +# External inventory plugin +#module_begin +#module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\software_installed.vbs" +#module_interval 288 +## 288 x 5min = 24 hr, one execution per day, using module_interval +#module_end + # Free Memory -module_begin -module_name FreeMemory -module_type generic_data -module_freepercentmemory -module_unit % -module_description Free memory (%). -module_min_warning 21 -module_max_warning 30 -module_min_critical 0 -module_max_critical 20 -module_end +#module_begin +#module_name FreeMemory +#module_type generic_data +#module_freepercentmemory +#module_description Free memory (%). +#module_min_warning 21 +#module_max_warning 30 +#module_min_critical 0 +#module_max_critical 20 +#module_end # Log events +#module_begin +#module_name System Events (TermService) +#module_type async_string +#module_logevent +#module_description Log Events coming from Terminal Service +#module_source System +#module_application TermService +#module_end -module_begin -module_name Security Events (Invalid Login) -module_type async_string -module_description Security log events for invalid login attempt -module_logevent -module_source Security -module_eventcode 529 -module_end +#module_begin +#module_name Security Events (Invalid Login) +#module_type async_string +#module_description Security log events for invalid login attempt +#module_logevent +#module_source Security +#module_eventcode 529 +#module_end + +# Check if Dhcp service is enabled +#module_begin +#module_name DHCP Enabled +#module_type generic_proc +#module_service Dhcp +#module_description Check DCHP service enabled +#module_end #Antivirus monitoring #This modules checks the antivirus is running on your system, if there is and antivirus @@ -207,72 +301,51 @@ module_end #module_description Last update for Antivirus Signature file #module_end -## Windows inventory module (This information will be displayed only in enterprise version) -## Please check the WMI is healthy before activate this functionality +# Number processes +#module_begin +#module_name Number processes +#module_type generic_data +#module_exec tasklist | gawk "NR > 3 {print$0}" | wc -l +#module_description Number of processes running +#module_min_warning 175 +#module_max_warning 249 +#module_min_critical 250 +#module_max_critical 300 +#module_end -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end +# Example plugin to retrieve drive usage +#module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs" -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end +# Free space on disk C: (%) +#module_begin +#module_name FreeDiskC +#module_type generic_data +#module_freepercentdisk C: +#module_description Free space on drive C: (%) +#module_min_warning 31 +#module_max_warning 40 +#module_min_critical 0 +#module_max_critical 30 +#module_end -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs" -# module_crontab * 12-15 * * 1 -# module_end +# CPU usage percentage +#module_begin +#module_name CPUUse +#module_type generic_data +#module_cpuusage all +#module_description CPU# usage +#module_min_warning 70 +#module_max_warning 90 +#module_min_critical 91 +#module_max_critical 100 +#module_end +# Free space on disk D: (%) # module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs" -# module_crontab * 12-15 * * 1 -# module_end - -# module_begin -# module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs" -# module_crontab * 12-15 * * 1 +# module_name FreeDiskD +# module_type generic_data +# module_freepercentdisk D: +# module_description Free space on drive D: (%) # module_end ## Plugin example for custom fields (version, architecture, IP, IPv6, MAC) @@ -281,10 +354,9 @@ module_end # module_crontab * 12-15 * * 1 # module_end -# ---------------------------------------------------------------------------------------------------- -# This samples below need to be reconfigured and uncommented. Please read documentation -# on how to setup pandora fms windows agent at http://wiki.pandorafms.com -# ---------------------------------------------------------------------------------------------------- +# Example plugin to retrieve last 5 min events in log4x format +# module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\logevent_log4x.vbs" Aplicacion System 300 + # Sample on how to get a value from registry # This returns the last time user launch microsoft Windows update #module_begin @@ -391,11 +463,11 @@ module_end #module_description Postcondition test module #module_end -#Example of when module_native_encoding is necessary -#Dont uncomment module_native_encoding tag to see the difference +# Example of native encoding. #module_begin -#module_name Accent_example +#module_name Written Accent #module_type generic_data_string #module_exec echo Bordón #module_native_encoding OEM #module_end + diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 1269e3108d..d3ca83843f 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.715} +{Pandora FMS Windows Agent v7.0NG.716} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{171110} +{171130} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 80142ca894..7b1eb275ba 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.715(Build 171110)") +#define PANDORA_VERSION ("7.0NG.716(Build 171130)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5d9e664a8f..9bc83625c4 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.715(Build 171110))" + VALUE "ProductVersion", "(7.0NG.716(Build 171130))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fe0cfc6bdc..b9efaf31e9 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.715-171110 +Version: 7.0NG.716-171130 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 b80b89eccd..43009ec1fd 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.715-171110" +pandora_version="7.0NG.716-171130" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 2b0e281993..d184850a34 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -259,80 +259,60 @@ function extension_db_check_tables_differences($connection_test, $field_system = $fields_system[$name_field]; $diff = array_diff($field_test, $field_system); + if (!empty($diff)) { - foreach ($diff as $config_field => $value) { - switch ($config_field) { - case 'type': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set the type with %s.', - $name_field, $table, $value)); - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-										"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $value . ";" .
-									'
' - ); - break; - case 'null': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be null: (%s).', - $name_field, $table, $value)); + $info_message = ""; + $error_message = ""; + if($diff['type']){ + $error_message .= "Unsuccessful the field ".$name_field." in the table ".$table." must be set the type with ".$diff['type']."
"; + } + + if($diff['null']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be null: (".$diff['null'].").
"; + } + + if($diff['default']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be set ".$diff['default']." as default value.
"; + } + + if($field_test['null'] == "YES" || !isset($field_test['null']) || $field_test['null'] == ""){ + $null_defect = " NULL"; + } + else{ + $null_defect = " NOT NULL"; + } + + if(!isset($field_test['default']) || $field_test['default'] == ""){ + $default_value = ""; + } + else{ + $default_value = " DEFAULT ".$field_test['default']; + } + + if($diff['type'] || $diff['null'] || $diff['default']){ + $info_message .= "ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $field_test['type'] . $null_defect . $default_value.";"; + } + + if($diff['key']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be set the key as defined in the SQL file.
"; + $info_message .= "

Please check the SQL file for to know the kind of key needed."; + } + + if($diff['extra']){ + $error_message .= "Unsuccessful the field $name_field in the table $table must be set as defined in the SQL file.
"; + $info_message .= "

Please check the SQL file for to know the kind of extra config needed."; + } + + ui_print_error_message( + __($error_message)); - if ($value == "YES") { - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " "  . $field_test['type'] . " NULL;" .
-										'
' - ); - } - else { - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $field_test['type'] . " NOT NULL;" .
-										'
' - ); - } + ui_print_info_message( + __($info_message)); - break; - case 'key': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set the key as defined in the SQL file.', - $name_field, $table)); - ui_print_info_message( - __('Please check the SQL file for to know the kind of key needed.')); - break; - case 'default': - if($field_test['null'] == "YES" || !isset($field_test['null']) || $field_test['null'] == ""){ - $null_defect = " NULL"; - } - else{ - $null_defect = " NOT NULL"; - } - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set %s as default value.', - $name_field, $table, $value)); - ui_print_info_message( - __('You can execute this SQL query for to fix.') . "
" . - '
' .
-											"ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " "  . $field_test['type'] . $null_defect . " DEFAULT " . $value . ";" .
-										'
' - ); - break; - case 'extra': - ui_print_error_message( - __('Unsuccessful the field %s in the table %s must be set as defined in the SQL file.', - $name_field, $table)); - ui_print_info_message( - __('Please check the SQL file for to know the kind of extra config needed.')); - break; } } } } - } - } if ($correct_fields) { ui_print_success_message( @@ -366,4 +346,4 @@ function extension_db_status_execute_sql_file($url, $connection) { extensions_add_godmode_function('extension_db_status'); extensions_add_godmode_menu_option(__('DB Schema check'), 'DM', 'gextensions', null, "v1r1", 'gdbman'); -?> \ No newline at end of file +?> diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index f20bcab720..4241018a16 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -69,9 +69,9 @@ function pandoralogs_extension_main () { ui_print_page_header (__("System logfile viewer"), "images/extensions.png", false, "", true, "" ); - echo "

" . __('This tool is used just to view your Pandora FMS system logfiles directly from console') . "

"; + echo "

" . __('Use this tool to view your Pandora FMS logfiles directly on the console') . "

"; - echo "

" . __('You can control the size information to show in general setup (Log size limit in view extension), actually ') . $config['max_log_size'] * 1000 . "B" . "

"; + echo "

" . __('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), ' . $config['max_log_size'] * 1000 . 'B at the moment') . "

"; $logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora"; diff --git a/pandora_console/extras/mr/10.sql b/pandora_console/extras/mr/10.sql new file mode 100644 index 0000000000..2b58ce08c4 --- /dev/null +++ b/pandora_console/extras/mr/10.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +ALTER TABLE tsnmp_filter ADD unified_filters_id int(10) NOT NULL DEFAULT 0; +ALTER TABLE treport_content_template ADD COLUMN hide_no_data tinyint(1) DEFAULT 0; +ALTER TABLE tgraph_source ADD COLUMN `order` int(10) NOT NULL default 0; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/mr/9.sql b/pandora_console/extras/mr/9.sql new file mode 100644 index 0000000000..dbf0456323 --- /dev/null +++ b/pandora_console/extras/mr/9.sql @@ -0,0 +1,24 @@ +START TRANSACTION; + +SET @st_oum708 = (SELECT IF( + (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled') > 0, + "ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL", + "SELECT 1" +)); + +PREPARE pr_oum708 FROM @st_oum708; +EXECUTE pr_oum708; +DEALLOCATE PREPARE pr_oum708; + +ALTER TABLE tagente ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; +ALTER TABLE tmetaconsole_agent ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; + +alter table tlayout_data add column element_group int(10) not null default 0; + +alter table tlayout_data add column id_layout_linked_weight int(10) not null default 0; + +ALTER TABLE tlayout_data ADD COLUMN show_on_top tinyint(1) default 0; + +ALTER TABLE `tdashboard` ADD COLUMN `cells_slideshow` TINYINT(1) NOT NULL default 0; + +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 159eb466f9..3a2e2b49a4 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 @@ -1157,10 +1157,10 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 7); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 9); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '714'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '716'); -- --------------------------------------------------------------------- -- Table `tplanned_downtime_agents` @@ -1226,6 +1226,7 @@ ALTER TABLE tagente ADD `remote` tinyint(1) NOT NULL default 0; ALTER TABLE tagente ADD COLUMN `cascade_protection_module` int(10) unsigned NOT NULL default '0'; ALTER TABLE tagente ADD COLUMN (alias varchar(600) not null default ''); ALTER TABLE tagente ADD `alias_as_name` int(2) unsigned default '0'; +ALTER TABLE tagente ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; UPDATE tagente SET tagente.alias = tagente.nombre; -- --------------------------------------------------------------------- @@ -1239,6 +1240,9 @@ ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF'; ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area'; ALTER TABLE tlayout_data ADD `label_position` varchar(50) NOT NULL default 'down'; ALTER TABLE tlayout_data ADD COLUMN `show_statistics` tinyint(2) NOT NULL default '0'; +ALTER TABLE tlayout_data ADD COLUMN `element_group` int(10) NOT NULL default '0'; +ALTER TABLE tlayout_data ADD COLUMN `id_layout_linked_weight` int(10) NOT NULL default '0'; +ALTER TABLE tlayout_data ADD COLUMN `show_on_top` tinyint(1) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `tagent_custom_fields` @@ -1308,6 +1312,7 @@ ALTER TABLE tmetaconsole_agent ADD COLUMN `cascade_protection_module` int(10) de ALTER TABLE tmetaconsole_agent ADD COLUMN `transactional_agent` tinyint(1) NOT NULL default '0'; ALTER TABLE tmetaconsole_agent ADD COLUMN `alias` VARCHAR(600) not null DEFAULT ''; ALTER TABLE tmetaconsole_agent ADD COLUMN `alias_as_name` int(2) unsigned default '0'; +ALTER TABLE tmetaconsole_agent ADD COLUMN `safe_mode_module` int(10) unsigned NOT NULL default '0'; UPDATE `tmetaconsole_agent` SET tmetaconsole_agent.alias = tmetaconsole_agent.nombre; -- --------------------------------------------------------------------- @@ -1339,6 +1344,10 @@ SET @vv1 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = IF @vv1>0 THEN ALTER TABLE tbackup ADD COLUMN `filepath` varchar(512) NOT NULL DEFAULT ""; END IF; +SET @vv2 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled'); +IF @vv2>0 THEN + ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL; +END IF; END; // delimiter ; @@ -1424,6 +1433,7 @@ ALTER TABLE tserver_export MODIFY `name` varchar(600) BINARY NOT NULL default '' -- --------------------------------------------------------------------- ALTER TABLE tgraph_source ADD COLUMN id_server int(11) UNSIGNED NOT NULL default 0; +ALTER TABLE tgraph_source ADD COLUMN `order` int(10) NOT NULL default 0; -- --------------------------------------------------------------------- -- Table `tserver_export_data` @@ -1453,3 +1463,7 @@ INSERT INTO tmodule VALUES (8, 'Wux module'); INSERT INTO ttipo_modulo VALUES (25,'web_analysis', 8, 'Web analysis data', 'module-wux.png'); +-- --------------------------------------------------------------------- +-- Table `tdashboard` +-- --------------------------------------------------------------------- +ALTER TABLE `tdashboard` ADD COLUMN `cells_slideshow` TINYINT(1) NOT NULL default 0; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e228c1eca4..2ac1e34df4 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -388,6 +388,12 @@ config_check(); $do_refresh = false; } } + + $new_dashboard = get_parameter('new_dashboard',0); + + if ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard' && $new_dashboard) { + $do_refresh = false; + } if ($do_refresh) { ?> diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index efee6dc435..42e71093ab 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -252,25 +252,6 @@ foreach ($modules as $m) { $modules_values[$m['id_module']] = $m['name']; } -$table->data[3][0] = __('Parent'); -$params = array(); -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'id_parent'; -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_name'] = 'id_agent_parent'; -$params['hidden_input_idagent_value'] = $id_parent; -$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent); -$params['selectbox_id'] = 'cascade_protection_module'; -$params['javascript_is_function_select'] = true; -$params['cascade_protection'] = true; - -$table->data[3][1] = ui_print_agent_autocomplete_input($params); - -$table->data[3][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). " " . ui_print_help_icon("cascade_protection", true); - -$table->data[3][1] .= "  " . __('Module') . " " . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true); - $table->data[4][0] = __('Group'); $table->data[4][1] = html_print_select_groups(false, "AR", false, 'grupo', $grupo, '', '', 0, true); $table->data[4][1] .= ' '; @@ -320,52 +301,87 @@ $table->class = "databox filters"; $table->head = array (); $table->style = array (); $table->style[0] = 'font-weight: bold; '; -$table->style[2] = 'font-weight: bold;'; +$table->style[4] = 'font-weight: bold;'; $table->data = array (); // Custom ID $table->data[0][0] = __('Custom ID'); $table->data[0][1] = html_print_input_text ('custom_id', $custom_id, '', 16, 255, true); +$table->data[1][0] = __('Parent'); +$params = array(); +$params['return'] = true; +$params['show_helptip'] = true; +$params['input_name'] = 'id_parent'; +$params['print_hidden_input_idagent'] = true; +$params['hidden_input_idagent_name'] = 'id_agent_parent'; +$params['hidden_input_idagent_value'] = $id_parent; +$params['value'] = db_get_value ("alias","tagente","id_agente",$id_parent); +$params['selectbox_id'] = 'cascade_protection_module'; +$params['javascript_is_function_select'] = true; +$params['cascade_protection'] = true; + +$table->data[1][1] = ui_print_agent_autocomplete_input($params); +$table->data[1][1] .= html_print_checkbox ("cascade_protection", 1, $cascade_protection, true).__('Cascade protection'). " " . ui_print_help_icon("cascade_protection", true); +$table->data[1][1] .= "  " . __('Module') . " " . html_print_select ($modules_values, "cascade_protection_module", $cascade_protection_module, "", "", 0, true); + +//safe operation mode +if($id_agente){ + $sql_modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = " . $id_agente); + $safe_mode_modules = array(); + $safe_mode_modules[0] = __('Any'); + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } + + $table->data[2][0] = __('Safe operation mode') + . ui_print_help_tip(__('This mode allow Pandora FMS to disable all modules + of this agent while the selected module is on CRITICAL status'), true); + $table->data[2][1] = html_print_checkbox('safe_mode', 1, $safe_mode, true); + $table->data[2][1] .= "  " . __('Module') . " " . html_print_select ($safe_mode_modules, "safe_mode_module", $safe_mode_module, "", "", 0, true); +} + + // Learn mode / Normal mode -$table->data[1][0] = __('Module definition') . +$table->data[3][0] = __('Module definition') . ui_print_help_icon("module_definition", true); -$table->data[1][1] = __('Learning mode') . ' ' . +$table->data[3][1] = __('Learning mode') . ' ' . html_print_radio_button_extended ("modo", 1, '', $modo, false, 'show_modules_not_learning_mode_context_help();', 'style="margin-right: 40px;"', true); -$table->data[1][1] .= __('Normal mode') . ' ' . +$table->data[3][1] .= __('Normal mode') . ' ' . html_print_radio_button_extended ("modo", 0, '', $modo, false, 'show_modules_not_learning_mode_context_help();', 'style="margin-right: 40px;"', true); -$table->data[1][1] .= __('Autodisable mode') . ' ' . +$table->data[3][1] .= __('Autodisable mode') . ' ' . html_print_radio_button_extended ("modo", 2, '', $modo, false, 'show_modules_not_learning_mode_context_help();', 'style="margin-right: 40px;"', true); // Status (Disabled / Enabled) -$table->data[2][0] = __('Status'); -$table->data[2][1] = __('Disabled') . ' ' . +$table->data[4][0] = __('Status'); +$table->data[4][1] = __('Disabled') . ' ' . html_print_radio_button_extended ("disabled", 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); -$table->data[2][1] .= __('Active') . ' ' . +$table->data[4][1] .= __('Active') . ' ' . html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); // Remote configuration -$table->data[3][0] = __('Remote configuration'); +$table->data[5][0] = __('Remote configuration'); if (!$new_agent) { - $table->data[3][1] = '' . __('Not available') . ''; + $table->data[5][1] = '' . __('Not available') . ''; if (isset($filename)) { if (file_exists ($filename['md5'])) { - $table->data[3][1] = date ("F d Y H:i:s", fileatime ($filename['md5'])); + $table->data[5][1] = date ("F d Y H:i:s", fileatime ($filename['md5'])); // Delete remote configuration - $table->data[3][1] .= ''; - $table->data[3][1] .= html_print_image( + $table->data[5][1] .= html_print_image( "images/cross.png", true, array ('title' => __('Delete remote configuration file'), 'style' => 'vertical-align: middle;')).''; - $table->data[3][1] .= '' . + $table->data[5][1] .= '' . ui_print_help_tip( __('Delete this conf file implies that for restore you must reactive remote config in the local agent.'), true); @@ -373,7 +389,7 @@ if (!$new_agent) { } } else - $table->data[3][1] = '' . __('Not available') . ''; + $table->data[5][1] = '' . __('Not available') . ''; $listIcons = gis_get_array_list_icons(); @@ -411,23 +427,23 @@ $table->data[0][3] = html_print_select($arraySelectIcon, "icon_path", array("id" => "icon_warning", "style" => "display:".$display_icons.";")); if ($config['activate_gis']) { - $table->data[1][2] = __('Ignore new GIS data:'); - $table->data[1][3] = __('Yes') . ' ' . + $table->data[3][2] = __('Ignore new GIS data:'); + $table->data[3][3] = __('Yes') . ' ' . html_print_radio_button_extended ("update_gis_data", 0, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true); - $table->data[1][3] .= __('No') . ' ' . + $table->data[3][3] .= __('No') . ' ' . html_print_radio_button_extended ("update_gis_data", 1, '', $update_gis_data, false, '', 'style="margin-right: 40px;"', true); } -$table->data[2][2] = __('Url address'); -$table->data[2][3] = html_print_input_text ('url_description', +$table->data[4][2] = __('Url address'); +$table->data[4][3] = html_print_input_text ('url_description', $url_description, '', 45, 255, true); -$table->data[3][2] = __('Quiet'); -$table->data[3][3] = ui_print_help_tip( +$table->data[5][2] = __('Quiet'); +$table->data[5][3] = ui_print_help_tip( __('The agent still runs but the alerts and events will be stop'), true); -$table->data[3][3] .= html_print_checkbox('quiet', 1, $quiet, true); +$table->data[5][3] .= html_print_checkbox('quiet', 1, $quiet, true); ui_toggle(html_print_table ($table, true), __('Advanced options')); unset($table); @@ -582,6 +598,26 @@ ui_require_jquery_file('bgiframe'); $("#cascade_protection_module").attr("disabled", 'disabled'); } }); + + var safe_mode_checked = $("#checkbox-safe_mode").is(":checked"); + if (safe_mode_checked) { + $("#safe_mode_module").removeAttr("disabled"); + } + else { + $("#safe_mode_module").attr("disabled", 'disabled'); + } + + $("#checkbox-safe_mode").change(function () { + var safe_mode_checked = $("#checkbox-safe_mode").is(":checked"); + + if (safe_mode_checked) { + $("#safe_mode_module").removeAttr("disabled"); + } + else { + $("#safe_mode_module").val(0); + $("#safe_mode_module").attr("disabled", 'disabled'); + } + }); paint_qrcode( "data[0][1] = ''; $table->data[0][2] = ''.__('Modules').''; - $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:200px;'); + $table->data[1][0] = html_print_select ($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:500px;'); $table->data[1][1] = html_print_image('images/darrowright.png', true); $table->data[1][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;'); $table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index e2a264e6e0..1311620c34 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -135,6 +135,8 @@ $id_os = 9; // Windows $custom_id = ""; $cascade_protection = 0; $cascade_protection_modules = 0; +$safe_mode = 0; +$safe_mode_module = 0; $icon_path = ''; $update_gis_data = 0; $unit = ""; @@ -166,6 +168,8 @@ if ($create_agent) { $custom_id = (string) get_parameter_post ("custom_id",''); $cascade_protection = (int) get_parameter_post ("cascade_protection", 0); $cascade_protection_module = (int) get_parameter_post("cascade_protection_module", 0); + $safe_mode = (int) get_parameter_post ("safe_mode", 0); + $safe_mode_module = (int) get_parameter_post ("safe_mode_module", 0); $icon_path = (string) get_parameter_post ("icon_path",''); $update_gis_data = (int) get_parameter_post("update_gis_data", 0); $url_description = (string) get_parameter("url_description"); @@ -228,7 +232,7 @@ if ($create_agent) { if ($id_agente !== false) { // Create custom fields for this agent foreach ($field_values as $key => $value) { - db_process_sql_insert ('tagent_custom_data', + $update_custom = db_process_sql_insert ('tagent_custom_data', array('id_field' => $key, 'id_agent' => $id_agente, 'description' => $value)); } @@ -707,6 +711,7 @@ if ($update_agent) { // if modified some agent paramenter $custom_id = (string) get_parameter_post ("custom_id", ""); $cascade_protection = (int) get_parameter_post ("cascade_protection", 0); $cascade_protection_module = (int) get_parameter ("cascade_protection_module", 0); + $safe_mode_module = (int) get_parameter ("safe_mode_module", 0); $icon_path = (string) get_parameter_post ("icon_path",''); $update_gis_data = (int) get_parameter_post("update_gis_data", 0); $url_description = (string) get_parameter("url_description"); @@ -730,13 +735,17 @@ if ($update_agent) { // if modified some agent paramenter if ($old_value === false) { // Create custom field if not exist - db_process_sql_insert ('tagent_custom_data', + $update_custom = db_process_sql_insert ('tagent_custom_data', array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value)); } else { - db_process_sql_update ('tagent_custom_data', + $update_custom = db_process_sql_update ('tagent_custom_data', array('description' => $value), array('id_field' => $key,'id_agent' => $id_agente)); + + if($update_custom == 1){ + $update_custom_result = 1; + } } } @@ -782,7 +791,8 @@ if ($update_agent) { // if modified some agent paramenter 'update_gis_data' => $update_gis_data, 'url_address' => $url_description, 'url_address' => $url_description, - 'quiet' => $quiet); + 'quiet' => $quiet, + 'safe_mode_module' => $safe_mode_module); if ($config['metaconsole_agent_cache'] == 1) { $values['update_module_count'] = 1; // Force an update of the agent cache. @@ -793,7 +803,9 @@ if ($update_agent) { // if modified some agent paramenter WHERE id_group = ".$group_old); $result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agente)); - if ($result == false) { + + + if ($result == false && $update_custom_result == false) { ui_print_error_message( __('There was a problem updating the agent')); } @@ -900,6 +912,8 @@ if ($id_agente) { $update_gis_data = $agent["update_gis_data"]; $url_description = $agent["url_address"]; $quiet = $agent["quiet"]; + $safe_mode_module = $agent["safe_mode_module"]; + $safe_mode = ($safe_mode_module) ? 1 : 0; } $update_module = (bool) get_parameter ('update_module'); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index cc5349182e..1f8afb37f4 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -24,6 +24,7 @@ $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $recursion = (bool) get_parameter('recursion',false); $disabled = get_parameter('disabled', 0); +$os = get_parameter('os', 0); if ($ag_group == -1 ) $ag_group = (int) get_parameter ("ag_group", -1); @@ -163,6 +164,20 @@ html_print_select($fields,"disabled",$disabled,'this.form.submit()'); echo ""; +echo ""; +echo __('Operative System') . ' '; + +$pre_fields = db_get_all_rows_sql('select distinct(tagente.id_os),tconfig_os.description from tagente,tconfig_os where tagente.id_os = tconfig_os.id_os'); +$fields = array(); + +foreach ($pre_fields as $key => $value) { + $fields[$value['id_os']] = $value['description']; +} + +html_print_select($fields,"os",$os,'this.form.submit()','All',0); + +echo ""; + echo ""; echo __('Recursion') . ' '; html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()'); @@ -171,6 +186,8 @@ echo ""; echo __('Search') . ' '; html_print_input_text ("search", $search, '', 12); +echo ui_print_help_tip(__('Search filter by alias, name, description, IP address or custom fields content'), true); + echo ""; echo ""; echo ""; @@ -296,20 +313,26 @@ if ($search != "") { }else{ $search_sql = " AND ( nombre " . $order_collation . " LIKE LOWER('%$search%') OR alias " . $order_collation . " - LIKE LOWER('%$search%')) "; + LIKE LOWER('%$search%') OR comentarios " . $order_collation . " LIKE LOWER('%$search%') + OR EXISTS (SELECT * FROM tagent_custom_data + WHERE id_agent = id_agente AND description LIKE '%$search%'))"; } } if ($disabled == 1) { - $search_sql = " AND disabled = ". $disabled . $search_sql; + $search_sql .= " AND disabled = ". $disabled . $search_sql; } else { if ($disabled == 0) { - $search_sql = " AND disabled = 0" . $search_sql; + $search_sql .= " AND disabled = 0" . $search_sql; } } +if($os != 0){ + $search_sql .= " AND id_os = " . $os; +} + // Show only selected groups if ($ag_group > 0) { diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 9b9b96ffaf..473e36dfdc 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -590,8 +590,7 @@ $table_advanced->colspan[10][1] = 6; if (isset($id_agente) && $moduletype == MODULE_DATA) { $has_remote_conf = enterprise_hook('config_agents_has_remote_configuration',array($agent["id_agente"])); if ($has_remote_conf) { - $table_advanced->data[11][0] = __('Cron from') . - ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true); + $table_advanced->data[11][0] = __('Cron from') . ui_print_help_icon ('cron', true); $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); $table_advanced->colspan[11][1] = 6; @@ -600,8 +599,7 @@ if (isset($id_agente) && $moduletype == MODULE_DATA) { $table_advanced->colspan[12][1] = 6; } else { - $table_advanced->data[11][0] = __('Cron from') . - ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true); + $table_advanced->data[11][0] = __('Cron from') . ui_print_help_icon ('cron', true); $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, true); $table_advanced->colspan[11][1] = 6; @@ -611,8 +609,7 @@ if (isset($id_agente) && $moduletype == MODULE_DATA) { } } else { - $table_advanced->data[11][0] = __('Cron from') . - ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true); + $table_advanced->data[11][0] = __('Cron from') . ui_print_help_icon ('cron', true); $table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); $table_advanced->colspan[11][1] = 6; diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 4b57931a2c..8a2a7c6702 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -132,8 +132,8 @@ $form_filter .= ""; $form_filter .= ""; $form_filter .= "".__('Enabled / Disabled').""; $ed_list = array (); -$ed_list[0] = __('Enable'); -$ed_list[1] = __('Disable'); +$ed_list[0] = __('Enabled'); +$ed_list[1] = __('Disabled'); $form_filter .= html_print_select ($ed_list, 'enabledisable', $enabledisable, '', __('All'), -1, true); $form_filter .= "".__('Standby').""; $sb_list = array (); diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index 94e834bbf5..f60ba4e5a6 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -30,15 +30,15 @@ $default = (int) get_parameter('default', 0); if ($default != 0) { - $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); - $fields_selected = explode (',', $event_fields); + //$event_fields = io_safe_input('evento,id_agente,estado,timestamp'); + $fields_selected = explode (',', $config['event_fields']); } else if ($update != '') { $fields_selected = (array)get_parameter('fields_selected'); if ($fields_selected[0] == '') { - $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); - $fields_selected = explode (',', $event_fields); + //$event_fields = io_safe_input('evento,id_agente,estado,timestamp'); + $fields_selected = explode (',', $config['event_fields']); } else { $event_fields = implode (',', $fields_selected); @@ -130,7 +130,7 @@ $event = array(); echo '

'.__('Show event fields'); echo ' '; -html_print_image ('images/clean.png', false, array ('title' => __('Load default event fields'), 'onclick' => "if (! confirm ('" . __('Default event fields will be loaded. Do you want to continue?') ."')) return false")); +html_print_image ('images/clean.png', false, array ('title' => __('Load the fields from previous events'), 'onclick' => "if (! confirm ('" . __('Event fields will be loaded. Do you want to continue?') ."')) return false")); echo '

'; $table = new stdClass(); diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index a89a9422ba..4daaf0c18d 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -32,6 +32,7 @@ require_once($config['homedir'] . "/include/functions_modules.php"); require_once($config['homedir'] . "/include/functions_groups.php"); $editGraph = (bool) get_parameter('edit_graph', 0); +$action = get_parameter('action', ''); if (isset ($_GET["get_agent"])) { $id_agent = $_POST["id_agent"]; @@ -39,6 +40,122 @@ if (isset ($_GET["get_agent"])) { $chunkdata = $_POST["chunk"]; } +switch ($action) { + case 'sort_items': + $resultOperationDB = null; + $position_to_sort = (int)get_parameter('position_to_sort', 1); + $ids_serialize = (string)get_parameter('ids_items_to_sort', ''); + $move_to = (string)get_parameter('move_to', 'after'); + + $countItems = db_get_sql(' + SELECT COUNT(id_gs) + FROM tgraph_source + WHERE id_graph = ' . $id_graph); + + if (($countItems < $position_to_sort) || ($position_to_sort < 1)) { + $resultOperationDB = false; + } + else if (!empty($ids_serialize)) { + $ids = explode('|', $ids_serialize); + + switch ($config["dbtype"]) { + case "mysql": + $items = db_get_all_rows_sql(' + SELECT id_gs, `order` + FROM tgraph_source + WHERE id_graph = ' . $id_graph . ' + ORDER BY `order`'); + break; + } + + if ($items === false) $items = array(); + + + // Clean the repeated order values + $order_temp = 1; + foreach ($items as $item) { + switch ($config["dbtype"]) { + case "mysql": + db_process_sql_update('tgraph_source', + array('`order`' => $order_temp), + array('id_gs' => $item['id_rc'])); + break; + } + + $order_temp++; + } + + + switch ($config["dbtype"]) { + case "mysql": + $items = db_get_all_rows_sql(' + SELECT id_gs, `order` + FROM tgraph_source + WHERE id_graph = ' . $id_graph . ' + ORDER BY `order`'); + break; + } + + if ($items === false) $items = array(); + + + + $temp = array(); + + $temp = array(); + foreach ($items as $item) { + //Remove the contents from the block to sort + if (array_search($item['id_gs'], $ids) === false) { + $temp[$item['order']] = $item['id_gs']; + } + } + $items = $temp; + + + + $sorted_items = array(); + foreach ($items as $pos => $id_unsort) { + if ($pos == $position_to_sort) { + if ($move_to == 'after') { + $sorted_items[] = $id_unsort; + } + + foreach ($ids as $id) { + $sorted_items[] = $id; + } + + if ($move_to != 'after') { + $sorted_items[] = $id_unsort; + } + } + else { + $sorted_items[] = $id_unsort; + } + } + + $items = $sorted_items; + + + + foreach ($items as $order => $id) { + switch ($config["dbtype"]) { + case "mysql": + + db_process_sql_update('tgraph_source', + array('`order`' => ($order + 1)), + array('id_gs' => $id)); + break; + } + } + + $resultOperationDB = true; + } + else { + $resultOperationDB = false; + } + break; + } + if ($editGraph) { $graphRows = db_get_all_rows_sql("SELECT t1.*, (SELECT t3.alias @@ -49,7 +166,8 @@ if ($editGraph) { WHERE t2.id_agente_modulo = t1.id_agent_module)) AS agent_name FROM tgraph_source t1 - WHERE t1.id_graph = " . $id_graph); + WHERE t1.id_graph = " . $id_graph . " order by `order`"); + $position_array = array(); $module_array = array(); $weight_array = array(); $agent_array = array(); @@ -65,6 +183,7 @@ if ($editGraph) { $weight_array[] = $graphRow['weight']; $label_array[] = $graphRow['label']; $agent_array[] = $graphRow['agent_name']; + $position_array[] = $graphRow['order']; } $graphInTgraph = db_get_row_sql("SELECT * FROM tgraph WHERE id_graph = " . $id_graph); @@ -81,11 +200,13 @@ if ($editGraph) { if (count($module_array) > 0) { echo ""; echo " + - "; + + "; $color = 0; for ($a = 0; $a < count($module_array); $a++) { // Calculate table line color @@ -98,7 +219,8 @@ if (count($module_array) > 0) { $color = 1; } - echo ""; + echo ""; + echo ""; echo ""; @@ -126,11 +248,55 @@ if (count($module_array) > 0) { echo ""; + echo ""; + + echo ""; + + + echo ""; } echo "
".__('P.')." ".__('Agent')." ".__('Module')." ".__('Label')." ".__('Weight')."".__('Delete')."".__('Delete')."".__('Sort')."
" . $agent_array[$a] . "
$position_array[$a]" . $agent_array[$a] . ""; echo modules_get_agentmodule_name ($module_array[$a]).""; echo "".html_print_image('images/cross.png', true, array ('title' => __('Delete'))).""; - echo "
"; + + echo html_print_checkbox_extended('sorted_items[]', $idgs_array[$a], false, false, '', 'class="selected_check"', true); + + echo "
"; } + +$table = new stdClass(); +$table->width = '100%'; +$table->colspan[0][0] = 3; +$table->size = array(); +$table->size[0] = '25%'; +$table->size[1] = '25%'; +$table->size[2] = '25%'; +$table->size[3] = '25%'; +if (defined("METACONSOLE")) { + $table->class = "databox data"; + $table->head[0] = __("Sort items"); + $table->head_colspan[0] = 4; + $table->headstyle[0] = 'text-align: center'; +} +else { + $table->data[0][0] = "". __("Sort items") . ""; +} +$table->data[1][0] = __('Sort selected items from position: '); +$table->data[1][1] = html_print_select_style( + array('before' => __('Move before to'), 'after' => __('Move after to')), 'move_to', + '', '', '', '', 0, true); +$table->data[1][2] = html_print_input_text_extended('position_to_sort', 1, + 'text-position_to_sort', '', 3, 10, false, "only_numbers('position_to_sort');", '', true); +$table->data[1][2] .= html_print_input_hidden('ids_items_to_sort', '', true); +$table->data[1][3] = html_print_submit_button(__('Sort'), 'sort_submit', false, 'class="sub upd"', true); +$table->data[1][4] = html_print_input_hidden('action', 'sort_items', true); + +echo "
"; +html_print_table($table); +echo "
"; + +echo "
"; + + //Configuration form echo ''; echo "
"; @@ -217,4 +383,28 @@ function filterByGroup(idGroup) { "json" ); } + +function added_ids_sorted_items_to_hidden_input() { + var ids = ''; + var first = true; + + $("input.selected_check:checked").each(function(i, val) { + if (!first) + ids = ids + '|'; + first = false; + + ids = ids + $(val).val(); + }); + + $("input[name='ids_items_to_sort']").val(ids); + + if (ids == '') { + alert(""); + + return false; + } + else { + return true; + } +} diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 53f8d47835..9c95f2263b 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -66,8 +66,6 @@ if ($edit_graph) { $height = $graphInTgraph['height']; $check = false; $percentil = $graphInTgraph['percentil']; - $summatory_series = $graphInTgraph['summatory_series']; - $average_series = $graphInTgraph['average_series']; if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ $stacked = CUSTOM_GRAPH_BULLET_CHART; @@ -86,8 +84,6 @@ else { $stacked = 4; $check = false; $percentil = 0; - $summatory_series = 0; - $average_series = 0; } @@ -178,15 +174,6 @@ echo ""; echo ""; -echo "".__('Add summatory series')."" . - ui_print_help_tip (__("This will add a synthetic series to the graph, - using all series to give a SUM or an average of all present series values - in each interval. This feature could be used instead synthetic modules - if you only want to see a graph"), true).""; -echo "" . html_print_checkbox ("summatory_series", 1, $summatory_series, true) . " -".__('Add average series').""; -echo "" . html_print_checkbox ("average_series", 1, $average_series, true) . ""; - echo "".__('Percentil').""; echo "" . html_print_checkbox ("percentil", 1, $percentil, true) . ""; diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 0d4cdcc2f9..317f562e6f 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -87,8 +87,6 @@ if ($add_graph) { $period = get_parameter_post ("period"); $threshold = get_parameter('threshold'); $percentil = get_parameter ("percentil", 0); - $summatory_series = get_parameter ("summatory_series", 0); - $average_series = get_parameter ("average_series", 0); if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ $stacked = $threshold; @@ -105,9 +103,7 @@ if ($add_graph) { 'private' => 0, 'id_group' => $idGroup, 'stacked' => $stacked, - 'percentil' => $percentil, - 'summatory_series' => $summatory_series, - 'average_series' => $average_series + 'percentil' => $percentil ); if (trim($name) != "") { @@ -135,8 +131,6 @@ if ($update_graph) { $period = get_parameter('period'); $stacked = get_parameter('stacked'); $percentil = get_parameter('percentil'); - $summatory_series = get_parameter ("summatory_series"); - $average_series = get_parameter ("average_series"); $alerts = get_parameter('alerts'); $threshold = get_parameter('threshold'); @@ -147,9 +141,7 @@ if ($update_graph) { if (trim($name) != "") { $success = db_process_sql_update('tgraph', - array('name' => $name, 'id_group' => $id_group, 'description' => $description, - 'width' => $width, 'height' => $height, 'period' => $period, 'stacked' => $stacked, - 'percentil' => $percentil, 'summatory_series' => $summatory_series, 'average_series' => $average_series), + array('name' => $name, 'id_group' => $id_group, 'description' => $description, 'width' => $width, 'height' => $height, 'period' => $period, 'stacked' => $stacked, 'percentil' => $percentil ), array('id_graph' => $id_graph)); if ($success !== false) db_pandora_audit("Report management", "Update graph #$id_graph"); diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index ebd2427ce3..fd7886f275 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -615,6 +615,11 @@ function update_button_palette_callback() { alert('Undefined width'); return false; } + + if($('input[name=bars_graph_height]').val() == ''){ + alert('Undefined height'); + return false; + } $("#text_" + idItem).html(values['label']); $("#image_" + idItem).attr("src", "images/spinner.gif"); @@ -800,6 +805,8 @@ function readFields() { values['top'] = $("input[name=top]").val(); values['agent'] = $("input[name=agent]").val(); values['id_agent'] = $("input[name=id_agent]").val(); + values['agent_string'] = $("input[name=agent_string]").val(); + values['id_agent_string'] = $("input[name=id_agent_string]").val(); values['module'] = $("select[name=module]").val(); values['process_simple_value'] = $("select[name=process_value]").val(); values['background'] = $("#background_image").val(); @@ -815,7 +822,10 @@ function readFields() { values['bars_graph_type'] = $("select[name=bars_graph_type]").val(); values['parent'] = $("select[name=parent]").val(); values['map_linked'] = $("select[name=map_linked]").val(); + values['element_group'] = $("select[name=element_group]").val(); + values['map_linked_weight'] = $("select[name=map_linked_weight]").val(); values['width_percentile'] = $("input[name=width_percentile]").val(); + values['bars_graph_height'] = $("input[name=bars_graph_height]").val(); values['max_percentile'] = parseInt($("input[name=max_percentile]").val()); values['width_module_graph'] = $("input[name=width_module_graph]").val(); values['height_module_graph'] = $("input[name=height_module_graph]").val(); @@ -845,6 +855,7 @@ function readFields() { values['line_color'] = $("input[name='line_color']").val(); values['label_position'] = $(".labelpos[sel=yes]").attr('position'); values['show_statistics'] = $("input[name=show_statistics]").is(':checked') ? 1 : 0; + values['show_on_top'] = $("input[name=show_on_top]").is(':checked') ? 1 : 0; if (is_metaconsole()) { values['metaconsole'] = 1; @@ -910,7 +921,7 @@ function create_button_palette_callback() { } break; case 'donut_graph': - if ((values['agent'] == '')) { + if ((values['agent_string'] == '')) { alert($("#message_alert_no_agent").html()); validate = false; } @@ -983,7 +994,7 @@ function create_button_palette_callback() { } break; case 'bars_graph': - if ((values['agent'] == '')) { + if ((values['agent_string'] == '')) { alert($("#message_alert_no_agent").html()); validate = false; } @@ -991,6 +1002,14 @@ function create_button_palette_callback() { alert($("#message_alert_no_module").html()); validate = false; } + if ((values['width_percentile'] == '')) { + alert($("#message_alert_no_width_percentile").html()); + validate = false; + } + if ((values['bars_graph_height'] == '')) { + alert($("#message_alert_no_bars_graph_height").html()); + validate = false; + } break; case 'simple_value': if ((values['agent'] == '')) { @@ -1277,6 +1296,9 @@ function toggle_item_palette() { } hiddenFields(item); + + $("#show_on_top_row").css('display', 'table-row'); + $("#show_on_top." + item).css('display', 'block'); $("#properties_panel").show("fast"); @@ -1406,6 +1428,17 @@ function loadFieldsFromDB(item) { } } + if (key == 'show_on_top') { + if (val == "1") { + $("input[name=show_on_top]") + .prop("checked", true); + } + else { + $("input[name=show_on_top]") + .prop("checked", false); + } + } + if (key == 'type_graph') { $("select[name=type_graph]").val(val); } @@ -1442,11 +1475,16 @@ function loadFieldsFromDB(item) { if (key == 'pos_y') $("input[name=top]").val(val); if (key == 'agent_name') { $("input[name=agent]").val(val); + $("input[name=agent_string]").val(val); //Reload no-sincrone the select of modules } + if (key == 'id_agent') { $("input[name=id_agent]").val(val); } + if (key == 'id_agent_string') { + $("input[name=id_agent_string]").val(val); + } if (key == 'modules_html') { $("select[name=module]").empty().html(val); $("select[name=module]").val(moduleId); @@ -1489,8 +1527,14 @@ function loadFieldsFromDB(item) { $("select[name=parent]").val(val); if (key == 'id_layout_linked') $("select[name=map_linked]").val(val); + if (key == 'id_layout_linked_weight') + $("select[name=map_linked_weight]").val(val); + if (key == 'element_group') + $("select[name=element_group]").val(val); if (key == 'width_percentile') $("input[name=width_percentile]").val(val); + if (key == 'bars_graph_height') + $("input[name=bars_graph_height]").val(val); if (key == 'max_percentile') $("input[name=max_percentile]").val(val); if (key == 'width_module_graph') @@ -1714,6 +1758,9 @@ function hiddenFields(item) { $("#agent_row").css('display', 'none'); $("#agent_row." + item).css('display', ''); + $("#agent_row_string").css('display', 'none'); + $("#agent_row_string." + item).css('display', ''); + $("#module_row").css('display', 'none'); $("#module_row." + item).css('display', ''); @@ -1741,6 +1788,9 @@ function hiddenFields(item) { $("#percentile_bar_row_1").css('display', 'none'); $("#percentile_bar_row_1." + item).css('display', ''); + $("#height_bars_graph_row").css('display', 'none'); + $("#height_bars_graph_row." + item).css('display', ''); + $("#percentile_bar_row_2").css('display', 'none'); $("#percentile_bar_row_2." + item).css('display', ''); @@ -1771,6 +1821,12 @@ function hiddenFields(item) { $("#map_linked_row").css('display', 'none'); $("#map_linked_row." + item).css('display', ''); + $("#element_group_row").css('display', 'none'); + $("#element_group_row." + item).css('display', ''); + + $("#map_linked_weight").css('display', 'none'); + $("#map_linked_weight." + item).css('display', ''); + $("#module_graph_size_row").css('display', 'none'); $("#module_graph_size_row." + item).css('display', ''); @@ -1821,14 +1877,6 @@ function hiddenFields(item) { if (typeof(enterprise_hiddenFields) == 'function') { enterprise_hiddenFields(item); } - - //~ var code_control = tinyMCE.activeEditor.controlManager.controls['text-label_code']; - //~ if (item == 'label') { - //~ code_control.setDisabled(false); - //~ } - //~ else { - //~ code_control.setDisabled(true); - //~ } } function cleanFields(item) { @@ -1838,16 +1886,20 @@ function cleanFields(item) { $("input[name=left]").val(0); $("input[name=top]").val(0); $("input[name=agent]").val(''); + $("input[name=agent_string]").val(''); $("select[name=module]").val(''); $("select[name=process_value]").val(0); $("select[name=background_image]").val(''); $("input[name=width_percentile]").val(''); + $("input[name=bars_graph_height]").val(''); $("input[name=max_percentile]").val(''); $("select[name=period]").val(''); $("input[name=width]").val(0); $("input[name=height]").val(0); $("select[name=parent]").val(''); $("select[name=map_linked]").val(''); + $("select[name=element_group]").val(''); + $("select[name=map_linked_weight]").val(''); $("input[name=width_module_graph]").val(300); $("input[name=height_module_graph]").val(180); $("input[name='width_box']").val(300); @@ -1864,6 +1916,7 @@ function cleanFields(item) { $("input[name=percentile_label_color]").val(''); $("input[name=percentile_label]").val(''); $(".ColorPickerDivSample").css('background-color', '#FFF'); + $("input[name=show_on_top]").prop("checked", false); $("#preview").empty(); @@ -1923,7 +1976,7 @@ function set_static_graph_status(idElement, image, status) { data: parameter, success: function (data) { set_static_graph_status(idElement, image, data); - if(values['show_statistics'] == 1){ + if(data['show_statistics'] == 1){ if($('#'+idElement+' table').css('float') == 'right' || $('#'+idElement+ ' table').css('float') == 'left'){ $('#'+idElement+ ' img').css('margin-top', parseInt($('#'+idElement).css('height'))/2 - parseInt($('#'+idElement+ ' img').css('height'))/2); } @@ -2013,12 +2066,13 @@ function setBarsGraph(id_data, values) { } width_percentile = values['width_percentile']; + bars_graph_height = values['bars_graph_height']; parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_module_type_string"}); - parameter.push ({name: "id_agent", value: values['id_agent']}); + parameter.push ({name: "id_agent", value: values['id_agent_string']}); parameter.push ({name: "module", value: values['module']}); parameter.push ({name: "id_element", value: id_data}); parameter.push ({name: "id_visual_console", value: id_visual_console}); @@ -2028,28 +2082,16 @@ function setBarsGraph(id_data, values) { type: "POST", dataType: 'json', success: function (data) { - if (data['no_data'] == true) { - if (values['width_percentile'] == "0") { - $("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras-no.png'); - } - else { - $("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras-no.png'); - $("#" + id_data + " img").css('width', width_percentile + 'px'); - $("#" + id_data + " img").css('height', width_percentile + 'px'); - } + $("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras.png'); + + if (values['width_percentile'] == "0" && values["bars_graph_height"] == "0") { + // Image size } - else { - $("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras.png'); - - if (values['width_percentile'] == "0") { - // Image size - } - else{ - $("#" + id_data + " img").css('width', width_percentile+'px'); - $("#" + id_data + " img").css('height', width_percentile+'px'); - } + else{ + $("#" + id_data + " img").css('width', width_percentile + 'px'); + $("#" + id_data + " img").css('height', bars_graph_height + 'px'); } - + if($('#'+id_data+' table').css('float') == 'right' || $('#'+id_data+ ' table').css('float') == 'left'){ $('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2); } @@ -2452,7 +2494,7 @@ function setDonutsGraph (id_data, values) { parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_module_type_string"}); - parameter.push ({name: "id_agent", value: values['id_agent']}); + parameter.push ({name: "id_agent", value: values['id_agent_string']}); parameter.push ({name: "module", value: values['module']}); parameter.push ({name: "id_element", value: id_data}); parameter.push ({name: "id_visual_console", value: id_visual_console}); @@ -2475,7 +2517,7 @@ function setDonutsGraph (id_data, values) { else { $("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/donut-graph.png'); - if($('#text-width').val() == 0 || $('#text-height').val() == 0){ + if($('#text-width_percentile').val() == 0){ // Image size } else{ @@ -3438,8 +3480,6 @@ function createItem(type, values, id_data) { } $("#background").append(item); - $(".item").css('z-index', '2'); - $(".box_item").css('z-index', '1'); if (values['parent'] != 0) { var line = {"id": id_data, @@ -3462,6 +3502,14 @@ function createItem(type, values, id_data) { $('#text_'+id_data).css({'display':'block','float':'left'}); } + if(values['show_on_top'] == 1){ + $("#" + id_data).css('z-index', '10'); + } + + if(values['show_on_top'] == 0){ + $("#" + id_data).css('z-index', '5'); + } + } function addItemSelectParents(id_data, text) { @@ -3664,6 +3712,15 @@ function updateDB_visual(type, idElement , values, event, top, left) { refresh_lines(lines, 'background', true); draw_user_lines("", 0, 0, 0 , 0, 0, true); + + if(values['show_on_top'] == 1){ + $("#" + idElement).css('z-index',10); + } + + if(values['show_on_top'] == 0){ + $("#" + idElement).css('z-index',5); + } + } function updateDB(type, idElement , values, event) { @@ -4499,6 +4556,8 @@ function eventsBackground() { if ((!is_opened_palette) && (autosave)) { toggle_item_palette(); } + $("#show_on_top_row").css('display', 'none'); + $("#show_on_top." + item).css('display', ''); }); } diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index 88ea386ee6..c84cb95f9c 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -180,6 +180,7 @@ ui_require_javascript_file ('encode_decode_base64'); tinyMCE.init({ mode : "exact", elements: "text-label", + convert_urls: false, theme : "advanced", item per module; item_per_agent <> 0 => item per agent $item_per_agent = get_parameter ("item_per_agent", 0); $id_server = (int)get_parameter('servers', 0); diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 1b18f0f7ec..96893aa091 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -106,6 +106,18 @@ if (is_ajax ()) { $row['name'] = __('Login attribute'); $row['control'] = html_print_input_text ('ldap_login_attr', $config['ldap_login_attr'], '', 60, 100, true); $table->data['ldap_login_attr'] = $row; + + // Admin LDAP login + $row = array(); + $row['name'] = __('Admin LDAP login'); + $row['control'] = html_print_input_text ('ldap_admin_login', $config['ldap_admin_login'], '', 60, 100, true); + $table->data['ldap_admin_login'] = $row; + + // Admin LDAP password + $row = array(); + $row['name'] = __('Admin LDAP password'); + $row['control'] = html_print_input_password ('ldap_admin_pass', $config['ldap_admin_pass'], $alt = '', 60, 100, true); + $table->data['ldap_admin_pass'] = $row; break; case 'pandora': diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index 085b23957d..9316b36b05 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -28,6 +28,7 @@ $update_filter = (int) get_parameter ('update_filter', -2); $delete_filter = (int) get_parameter ('delete_filter', -1); $description = (string) get_parameter ('description', ''); $filter = (string) get_parameter ('filter', ''); +$index_post = (int) get_parameter('index_post', 0); // Create/update header if ($edit_filter > -2) { @@ -44,9 +45,35 @@ else {// Overview header // Create/update filter if ($update_filter > -2) { + // UPDATE if ($update_filter > -1) { - $values = array('description' => $description, 'filter' => $filter); - $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $update_filter)); + $new_unified_id = (db_get_value_sql("SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $update_filter)); + $elements = get_parameter('elements', array()); + + $elements = explode(",", $elements); + foreach ($elements as $e) { + $filter = get_parameter('filter_' . $e); + $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $e)); + } + if (count($elements) == 1) { + $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; + + $filter = get_parameter('filter_' . $elements[0]); + $values = array('description' => $description, 'filter' => $filter, 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_update('tsnmp_filter', $values, array('id_snmp_filter' => $elements[0])); + } + for ($i = 1; $i < $index_post; $i++) { + $filter = get_parameter('filter_' . $i); + if ($filter != "") { + $values = array( + 'description' => $description, + 'filter' => $filter, + 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_insert('tsnmp_filter', $values); + } + } + if ($result === false) { ui_print_error_message (__('There was a problem updating the filter')); } @@ -54,11 +81,29 @@ if ($update_filter > -2) { ui_print_success_message (__('Successfully updated')); } } + // CREATE else { - $values = array( - 'description' => $description, - 'filter' => $filter); - $result = db_process_sql_insert('tsnmp_filter', $values); + $new_unified_id = (db_get_value_sql("SELECT MAX(unified_filters_id) FROM tsnmp_filter")) + 1; + + if ($index_post == 1) { + $filter = get_parameter('filter_0'); + $values = array( + 'description' => $description, + 'filter' => $filter, + 'unified_filters_id' => 0); + $result = db_process_sql_insert('tsnmp_filter', $values); + } + else { + for ($i = 0; $i < $index_post; $i++) { + $filter = get_parameter('filter_' . $i); + $values = array( + 'description' => $description, + 'filter' => $filter, + 'unified_filters_id' => $new_unified_id); + $result = db_process_sql_insert('tsnmp_filter', $values); + } + } + if ($result === false) { ui_print_error_message (__('There was a problem creating the filter')); } @@ -68,7 +113,15 @@ if ($update_filter > -2) { } } else if ($delete_filter > -1) { // Delete - $result = db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $delete_filter)); + $unified_id_to_delete = (db_get_value_sql("SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $delete_filter)); + + if ($unified_id_to_delete == 0) { + $result = db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $delete_filter)); + } + else { + $result = db_process_sql_delete('tsnmp_filter', array('unified_filters_id' => $unified_id_to_delete)); + } + if ($result === false) { ui_print_error_message (__('There was a problem deleting the filter')); } @@ -88,19 +141,50 @@ if ($edit_filter > -1) { // Create/update form if ($edit_filter > -2) { + $index = $index_post; $table->data = array (); + $table->id = 'filter_table'; $table->width = '100%'; $table->class = 'databox filters'; $table->data[0][0] = __('Description'); $table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true); $table->data[1][0] = __('Filter'); - $table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true); - $table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); - + if ($edit_filter > -1) { + $filters = db_get_all_rows_sql("SELECT * FROM tsnmp_filter WHERE unified_filters_id = (SELECT unified_filters_id FROM tsnmp_filter WHERE id_snmp_filter = " . $edit_filter . ")"); + $j = 1; + foreach ($filters as $f) { + if ($j != 1) { + $table->data[$j][0] = ""; + } + $table->data[$j][1] = html_print_input_text ('filter_' . $f['id_snmp_filter'], $f['filter'], '', 60, 100, true); + if ($j == 1) { + $table->data[$j][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); + } + else { + $table->data[$j][1] .= html_print_image('images/cross.png', true, array('id' => 'delete_filter_' . $f['id_snmp_filter'], 'alt' => __('Click to add new filter'), 'title' => __('Click to add new filter'))); + } + $j++; + $index++; + } + } + else { + $table->data[1][1] = html_print_input_text ('filter_' . $index, $filter, '', 60, 100, true); + $table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); + } + $index++; echo ''; html_print_input_hidden ('update_filter', $edit_filter); + html_print_input_hidden ('index_post', $index); + if ($edit_filter > -1) { + $filters_to_post = array(); + foreach ($filters as $fil) { + $filters_to_post[] = $fil['id_snmp_filter']; + } + html_print_input_hidden ('elements', implode(",", $filters_to_post)); + } html_print_table ($table); echo '
'; + html_print_image('images/add.png', false, array('id' => 'add_filter', 'alt' => __('Click to add new filter'), 'title' => __('Click to add new filter'), 'style' => 'float:left;')); if ($edit_filter > -1) { html_print_submit_button (__('Update'), 'submit_button', false, 'class="sub upd"'); } @@ -112,13 +196,13 @@ if ($edit_filter > -2) { // Overview } else { - $result = db_get_all_rows_in_table ("tsnmp_filter"); - if ($result === false) { - $result = array (); - require_once ($config['homedir'] . "/general/firts_task/snmp_filters.php"); - return; + $result_unified = db_get_all_rows_sql("SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id ASC"); + + $aglomerate_result = array(); + foreach ($result_unified as $res) { + $aglomerate_result[$res['unified_filters_id']] = db_get_all_rows_sql("SELECT * FROM tsnmp_filter WHERE unified_filters_id = " . $res['unified_filters_id'] . " ORDER BY id_snmp_filter ASC"); } - + $table->data = array (); $table->head = array (); $table->size = array (); @@ -133,16 +217,43 @@ else { $table->head[2] = __('Action'); $table->size[2] = "50px"; $table->align[2] = 'center'; - - foreach ($result as $row) { - $data = array (); - $data[0] = '' . $row['description'] . ''; - $data[1] = $row['filter']; - $data[2] = '' . - html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . - '  ' . - html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; - array_push ($table->data, $data); + + foreach ($aglomerate_result as $ind => $row) { + if ($ind == 0) { + foreach ($row as $r) { + $data = array (); + $data[0] = '' . $r['description'] . ''; + $data[1] = $r['filter']; + $data[2] = '' . + html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . + '  ' . + html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; + array_push ($table->data, $data); + } + } + else { + $ind2 = 0; + $compose_filter = array(); + $compose_id = ""; + $compose_action = ""; + foreach ($row as $i => $r) { + if ($ind2 == 0) { + $compose_id = '' . $r['description'] . ''; + $compose_action = '' . + html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . + '  ' . + html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; + $ind2++; + } + $compose_filter[] = $r['filter']; + } + $data = array (); + $data[0] = $compose_id; + $data[1] = implode(" AND ", $compose_filter); + $data[2] = $compose_action; + array_push ($table->data, $data); + } + } if (!empty ($table->data)) { @@ -157,3 +268,44 @@ else { echo '
'; } ?> + + diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index ef2e4f0f9c..cdd4157fca 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -236,6 +236,8 @@ if ($create_user) { case "postgresql": $result = create_user($id, $password_new, $values); if ($result) { + db_process_sql_insert ('tsesion', array('id_sesion' => '','id_usuario' => $id,'ip_origen' => $_SERVER['REMOTE_ADDR'],'accion' => 'Password change', + 'descripcion' => 'Access password updated','fecha' => date("Y-m-d H:i:s"),'utimestamp' => time())); $res = save_pass_history($id, $password_new); } break; @@ -334,6 +336,8 @@ if ($update_user) { else { $res2 = update_user_password ($id, $password_new); if ($res2) { + db_process_sql_insert ('tsesion', array('id_sesion' => '','id_usuario' => $id,'ip_origen' => $_SERVER['REMOTE_ADDR'],'accion' => 'Password change', + 'descripcion' => 'Access password updated','fecha' => date("Y-m-d H:i:s"),'utimestamp' => time())); $res3 = save_pass_history($id, $password_new); } ui_print_result_message ($res1 || $res2, @@ -345,6 +349,8 @@ if ($update_user) { $res2 = update_user_password ($id, $password_new); if ($res2) { $res3 = save_pass_history($id, $password_new); + db_process_sql_insert ('tsesion', array('id_sesion' => '','id_usuario' => $id,'ip_origen' => $_SERVER['REMOTE_ADDR'],'accion' => 'Password change', + 'descripcion' => 'Access password updated','fecha' => date("Y-m-d H:i:s"),'utimestamp' => time())); } ui_print_result_message ($res1 || $res2, __('User info successfully updated'), diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 71acc33881..2a10e8c7b8 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -76,11 +76,11 @@ switch ($sortField) { switch ($sort) { case 'up': $selectLastConnectUp = $selected; - $order = array('field' => 'fullname', 'order' => 'ASC'); + $order = array('field' => 'last_connect', 'order' => 'ASC'); break; case 'down': $selectLastConnectDown = $selected; - $order = array('field' => 'fullname', 'order' => 'DESC'); + $order = array('field' => 'last_connect', 'order' => 'DESC'); break; } break; @@ -494,10 +494,4 @@ echo ''; enterprise_hook('close_meta_frame'); ?> - diff --git a/pandora_console/images/reset.png b/pandora_console/images/reset.png new file mode 100644 index 0000000000..a3304f8263 Binary files /dev/null and b/pandora_console/images/reset.png differ diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index d431a83dd7..cad5efae1a 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -478,13 +478,10 @@ if ($get_extended_event) { if ($get_events_details) { $event_ids = explode(',',get_parameter ('event_ids')); - $events = db_get_all_rows_filter ( - 'tevento', - array ('id_evento' => $event_ids,'order' => 'utimestamp ASC'), - array ('evento', 'utimestamp', 'estado', 'criticity', 'id_usuario'), - 'AND', - true - ); + $events = db_get_all_rows_filter ('tevento', + array ('id_evento' => $event_ids, + 'order' => 'utimestamp ASC'), + array ('evento', 'utimestamp', 'estado', 'criticity', 'id_usuario')); $out = ''; $out .= ''; diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 32de285b11..66063ed5ab 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -123,12 +123,17 @@ if ($get_module_detail) { $time_from = (string) get_parameter ('time_from', date ('h:iA')); $date_to = (string) get_parameter ('date_to', date ('Y-m-j')); $time_to = (string) get_parameter ('time_to', date ('h:iA')); + $freesearch = (string) get_parameter ('freesearch', ''); + $free_checkbox = (bool) get_parameter ('free_checkbox', false); $formtable->width = '98%'; $formtable->class = "databox"; $formtable->data = array (); $formtable->size = array (); + $moduletype_name = modules_get_moduletype_name( + modules_get_agentmodule_type($module_id)); + $periods = array(SECONDS_5MINUTES =>__('5 minutes'), SECONDS_30MINUTES =>__('30 minutes'), SECONDS_1HOUR =>__('1 hour'), @@ -175,10 +180,19 @@ if ($get_module_detail) { $formtable->data[1][2] .= html_print_input_text('time_to', $time_to, '', 9, 7, true); - html_print_table($formtable); + $freesearch_object = ''; + if (preg_match("/_string/", $moduletype_name)) { + $formtable->data[2][0] = __('Free search') . ' '; + $formtable->data[2][1] = html_print_input_text ('freesearch', $freesearch, '', 20, null, true); + $formtable->data[2][2] = html_print_checkbox('free_checkbox', 1, $free_checkbox, true); + $formtable->data[2][2] .= ' ' . __('Exact phrase'); + $freesearch_object = json_encode( array( + 'value' => io_safe_output($freesearch), + 'exact' => (bool)$free_checkbox + )); + } - $moduletype_name = modules_get_moduletype_name( - modules_get_agentmodule_type($module_id)); + html_print_table($formtable); $offset = (int) get_parameter("offset"); $block_size = (int) $config["block_size"]; @@ -222,10 +236,10 @@ if ($get_module_detail) { } $count = modules_get_agentmodule_data ($module_id, $period, - $date, true, $conexion); + $date, true, $conexion, 'ASC', $freesearch_object); $module_data = modules_get_agentmodule_data ($module_id, $period, - $date, false, $conexion, 'DESC'); + $date, false, $conexion, 'DESC', $freesearch_object); if (empty($module_data)) { $result = array(); diff --git a/pandora_console/include/ajax/snmp.ajax.php b/pandora_console/include/ajax/snmp.ajax.php index 7b3e45c704..a372d50e11 100644 --- a/pandora_console/include/ajax/snmp.ajax.php +++ b/pandora_console/include/ajax/snmp.ajax.php @@ -20,6 +20,7 @@ require_once("include/functions_snmp.php"); $save_snmp_translation = (bool)get_parameter('save_snmp_translation', 0); $delete_snmp_translation = (bool)get_parameter('delete_snmp_translation', 0); $update_snmp_translation = (bool)get_parameter('update_snmp_translation', 0); +$delete_snmp_filter = (bool)get_parameter('delete_snmp_filter', 0); /* skins image checks */ if ($save_snmp_translation) { @@ -56,4 +57,12 @@ if ($update_snmp_translation) { return; } + +if ($delete_snmp_filter) { + $filter_id = get_parameter('filter_id'); +html_debug($filter_id, true); + db_process_sql_delete('tsnmp_filter', array('id_snmp_filter' => $filter_id)); + + return; +} ?> diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index 63053e1919..f7414c2fe1 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -33,8 +33,6 @@ if(is_ajax()){ $snmp3_privacy_pass = io_safe_output(get_parameter('snmp3_browser_privacy_pass')); $targets_oids = get_parameter ("oids", ""); - $targets_oids = explode(",", $targets_oids); - $custom_action = get_parameter ("custom_action", ""); if ($custom_action != "") { diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 89f2cf3bf7..6e7a612171 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -17,8 +17,25 @@ if (is_ajax ()) { global $config; - // Login check - check_login (); + enterprise_include_once("include/functions_dashboard.php"); + + $public_hash = get_parameter('hash', 0); + + // Try to authenticate by hash on public dashboards + if ($public_hash == 0) { + // Login check + check_login(); + } else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, 'tree_view') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } + } require_once($config['homedir'] . "/include/class/Tree.class.php"); enterprise_include_once("include/class/Tree.class.php"); @@ -36,6 +53,10 @@ if (is_ajax ()) { $rootID = get_parameter('rootID', -1); $serverID = get_parameter('serverID', false); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + $hash = get_parameter('hash', false); + if ($hash !== false) { + enterprise_hook('dasboard_validate_public_hash', array($hash, 'tree_view')); + } $default_filters = array( 'searchAgent' => '', diff --git a/pandora_console/include/ajax/visual_console.ajax.php b/pandora_console/include/ajax/visual_console.ajax.php index 789398139c..91af22ec7e 100644 --- a/pandora_console/include/ajax/visual_console.ajax.php +++ b/pandora_console/include/ajax/visual_console.ajax.php @@ -12,10 +12,30 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Login check global $config; -check_login (); +enterprise_include_once ('include/functions_dashboard.php'); +require_once('include/functions_visual_map.php'); +enterprise_include_once('include/functions_visual_map.php'); + +$public_hash = get_parameter('hash', false); +$id_visual_console = get_parameter('id_visual_console', null); + +// Try to authenticate by hash on public dashboards +if ($public_hash === false) { + // Login check + check_login(); +} else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, $id_visual_console, 'visual_console') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } +} // Fix: IW was the old ACL to check for report editing, now is RW if (! check_acl ($config['id_user'], 0, "VR")) { @@ -29,12 +49,6 @@ if (! check_acl ($config['id_user'], 0, "VR")) { //Fix ajax to avoid include the file, 'functions_graph.php'. $ajax = true; - -require_once('include/functions_visual_map.php'); -enterprise_include_once('include/functions_visual_map.php'); - -$id_visual_console = get_parameter('id_visual_console', null); - $render_map = (bool)get_parameter('render_map', false); $graph_javascript = (bool)get_parameter('graph_javascript', false); diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index c7e4484a27..05e6f7fc4c 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -100,7 +100,10 @@ $width = get_parameter('width', null); $height = get_parameter('height', null); $parent = get_parameter('parent', null); $map_linked = get_parameter('map_linked', null); +$map_linked_weight = get_parameter('map_linked_weight', null); +$element_group = get_parameter('element_group', null); $width_percentile = get_parameter('width_percentile', null); +$bars_graph_height = get_parameter('bars_graph_height', null); $max_percentile = get_parameter('max_percentile', null); $height_module_graph = get_parameter('height_module_graph', null); $width_module_graph = get_parameter('width_module_graph', null); @@ -113,6 +116,7 @@ $metaconsole = get_parameter('metaconsole', 0); $server_name = get_parameter('server_name', null); $server_id = (int)get_parameter('server_id', 0); $id_agent = get_parameter('id_agent', null); +$id_agent_string = get_parameter('id_agent_string', null); $id_metaconsole = get_parameter('id_metaconsole', null); $id_group = (int)get_parameter('id_group', 0); $id_custom_graph = get_parameter('id_custom_graph', null); @@ -136,6 +140,7 @@ $line_color = get_parameter('line_color', ''); $get_element_status = get_parameter('get_element_status', 0); $enable_link = get_parameter('enable_link', 1); +$show_on_top = get_parameter('show_on_top', 0); $type_graph = get_parameter('type_graph', 'area'); $label_position = get_parameter('label_position', 'down'); $show_statistics = get_parameter('show_statistics', 0); @@ -378,7 +383,7 @@ switch ($action) { // Linked to other layout ?? - Only if not module defined if ($layoutData['id_layout_linked'] != 0) { - $status = visual_map_get_layout_status ($layoutData['id_layout_linked']); + $status = visual_map_get_layout_status ($layoutData['id_layout_linked'], $layoutData['id_layout_linked_weight']); // Single object } @@ -488,6 +493,7 @@ switch ($action) { $values = array(); $values['label_position'] = $label_position; + $values['show_on_top'] = $show_on_top; // In Graphs, background color is stored in column image (sorry) if ($type == 'module_graph') { @@ -527,6 +533,9 @@ switch ($action) { if ($enable_link !== null) { $values['enable_link'] = $enable_link; } + if ($show_on_top !== null) { + $values['show_on_top'] = $show_on_top; + } if ($label !== null) { $values['label'] = $label; } @@ -552,8 +561,6 @@ switch ($action) { break; } - - if (defined('METACONSOLE') && $metaconsole) { if ($server_name !== null) { $values['id_metaconsole'] = db_get_value('id', @@ -568,6 +575,9 @@ switch ($action) { $values['id_agent'] = $id_agent; } } + else if ($id_agent == 0) { + $values['id_agent'] = 0; + } else if (!empty($id_agent)) { $values['id_agent'] = $id_agent; } @@ -584,6 +594,12 @@ switch ($action) { if ($map_linked !== null) { $values['id_layout_linked'] = $map_linked; } + if ($element_group !== null) { + $values['element_group'] = $element_group; + } + if ($map_linked_weight !== null) { + $values['id_layout_linked_weight'] = $map_linked_weight; + } switch ($type) { // -- line_item ------------------------------------ case 'handler_start': @@ -611,7 +627,7 @@ switch ($action) { } $values['border_color'] = $resume_color; $values['type'] = DONUT_GRAPH; - + $values['id_agent'] = $id_agent_string; break; case 'box_item': $values['border_width'] = $border_width; @@ -654,6 +670,9 @@ switch ($action) { if ($width_percentile !== null) { $values['width'] = $width_percentile; } + if ($bars_graph_height !== null) { + $values['height'] = $bars_graph_height; + } if ($bars_graph_type !== null) { $values['type_graph'] = $bars_graph_type; } @@ -663,6 +682,7 @@ switch ($action) { if ($grid_color !== null) { $values['border_color'] = $grid_color; } + $values['id_agent'] = $id_agent_string; break; case 'percentile_item': case 'percentile_bar': @@ -730,6 +750,14 @@ switch ($action) { // Don't change the label because only change the positions unset($values['label']); unset($values['label_position']); + // Don't change this values when move + unset($values['id_agent']); + unset($values['id_agente_modulo']); + unset($values['enable_link']); + unset($values['show_on_top']); + unset($values['id_layout_linked']); + unset($values['element_group']); + unset($values['id_layout_linked_weight']); // Don't change background color in graphs when move switch ($type) { @@ -745,10 +773,14 @@ switch ($action) { unset($values['image']); unset($values['type_graph']); unset($values['border_color']); + unset($values['width']); + unset($values['id_agent']); + unset($values['height']); break; case 'donut_graph': unset($values['border_color']); unset($values['width']); + unset($values['id_agent']); break; case 'box_item': unset($values['border_width']); @@ -893,6 +925,20 @@ switch ($action) { case 'donut_graph': $elementFields['width_percentile'] = $elementFields['width']; $elementFields['resume_color'] = $elementFields['border_color']; + $elementFields['id_agent_string'] = $elementFields['id_agent']; + if (($elementFields['id_agent_string'] != 0) + && ($elementFields['id_layout_linked'] == 0)) { + $modules = agents_get_modules( + $elementFields['id_agent'], false, + array('disabled' => 0, + 'id_agente' => $elementFields['id_agent'], + 'tagente_modulo.id_tipo_modulo IN' => "(17,23,3,10,33)")); + + $elementFields['modules_html'] = ''; + foreach ($modules as $id => $name) { + $elementFields['modules_html'] .= ''; + } + } break; case 'module_graph': @@ -901,8 +947,23 @@ switch ($action) { break; case 'bars_graph': $elementFields['width_percentile'] = $elementFields['width']; + $elementFields['bars_graph_height'] = $elementFields['height']; $elementFields['bars_graph_type'] = $elementFields['type_graph']; $elementFields['grid_color'] = $elementFields['border_color']; + $elementFields['id_agent_string'] = $elementFields['id_agent']; + if (($elementFields['id_agent_string'] != 0) + && ($elementFields['id_layout_linked'] == 0)) { + $modules = agents_get_modules( + $elementFields['id_agent'], false, + array('disabled' => 0, + 'id_agente' => $elementFields['id_agent'], + 'tagente_modulo.id_tipo_modulo IN' => "(17,23,3,10,33)")); + + $elementFields['modules_html'] = ''; + foreach ($modules as $id => $name) { + $elementFields['modules_html'] .= ''; + } + } break; case 'box_item': $elementFields['width_box'] = $elementFields['width']; @@ -982,8 +1043,11 @@ switch ($action) { } $values['id_agente_modulo'] = $id_module; $values['id_layout_linked'] = $map_linked; + $values['element_group'] = $element_group; + $values['id_layout_linked_weight'] = $map_linked_weight; $values['parent_item'] = $parent; $values['enable_link'] = $enable_link; + $values['show_on_top'] = $show_on_top; $values['image'] = $background_color; $values['type_graph'] = $type_graph; @@ -1010,9 +1074,10 @@ switch ($action) { break; case 'donut_graph': $values['type'] = DONUT_GRAPH; - $values['width'] = $width; - $values['height'] = $height; + $values['width'] = $width_percentile; + $values['height'] = $width_percentile; $values['border_color'] = $resume_color; + $values['id_agent'] = $id_agent_string; break; case 'module_graph': $values['type'] = MODULE_GRAPH; @@ -1048,15 +1113,12 @@ switch ($action) { break; case 'bars_graph': $values['type'] = BARS_GRAPH; - if ($width_percentile == null) { - $values['width'] = 0; - } - else { - $values['width'] = $width_percentile; - } + $values['width'] = $width_percentile; + $values['height'] = $bars_graph_height; $values['type_graph'] = $bars_graph_type; $values['image'] = $background_color; $values['border_color'] = $grid_color; + $values['id_agent'] = $id_agent_string; break; case 'auto_sla_graph': $values['type'] = AUTO_SLA_GRAPH; diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 372f9dfc58..acd777102c 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -215,6 +215,13 @@ function process_user_login_remote ($login, $pass, $api = false) { break; } + if ($config["auth"] === 'ldap') { + $login_user_attribute = $login; + if (($config['ldap_login_user_attr'] != 'name') && ($config['ldap_login_user_attr'] != null)) { + $login = get_ldap_login_attr($login); + } + } + // Authentication ok, check if the user exists in the local database if (is_user ($login)) { if (!user_can_login($login)) { @@ -240,26 +247,19 @@ function process_user_login_remote ($login, $pass, $api = false) { } } } - elseif (($config["auth"] === 'ldap') && - (isset($config['ldap_advanced_config']) && $config['ldap_advanced_config'])) { + elseif ($config["auth"] === 'ldap') { + if ($config['ldap_save_password']) { + $update_credentials = change_local_user_pass_ldap ($login, $pass); - $return = enterprise_hook ('prepare_permissions_groups_of_user_ldap', - array ($login, $pass, false, true, defined('METACONSOLE'))); - - if ($return === "error_permissions") { - $config["auth_error"] = - __("Problems with configuration permissions. Please contact with Administrator"); - return false; - } - else { - if ($return === "permissions_changed") { + if ($update_credentials) { $config["auth_error"] = __("Your permissions have changed. Please, login again."); return false; } } - - change_local_user_pass_ldap ($login, $pass); + else { + delete_user_pass_ldap ($login); + } } return $login; @@ -310,9 +310,7 @@ function process_user_login_remote ($login, $pass, $api = false) { return false; } } - elseif ($config["auth"] === 'ldap' && - (isset($config['ldap_advanced_config']) && - $config['ldap_advanced_config'])) { + elseif ($config["auth"] === 'ldap') { if ( defined('METACONSOLE') ) { enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once ('meta/include/functions_groups_meta.php'); @@ -332,13 +330,11 @@ function process_user_login_remote ($login, $pass, $api = false) { } // Create the user - if (enterprise_hook ('prepare_permissions_groups_of_user_ldap', - array($login, - $pass, - array ('fullname' => $login, - 'comments' => 'Imported from ' . $config['auth']), - false, defined('METACONSOLE'))) === false) { - + $prepare_perms = prepare_permissions_groups_of_user_ldap($login_user_attribute, $pass, + array ('fullname' => $login_user_attribute, 'comments' => 'Imported from ' . $config['auth']), + false, defined('METACONSOLE')); + + if (!$prepare_perms) { $config["auth_error"] = __("User not found in database or incorrect password"); @@ -693,6 +689,20 @@ function ldap_process_user_login ($login, $password) { } } + $correct_admin_bind = true; + if ($config['ldap_admin_login'] != "" && $config['ldap_admin_pass'] != "") { + if (!@ldap_bind($ds, io_safe_output($config['ldap_admin_login']), $config['ldap_admin_pass'])) { + $correct_admin_bind = false; + } + } + + if (!$correct_admin_bind) { + $config["auth_error"] = 'Admin ldap connection fail'; + @ldap_close ($ds); + + return false; + } + $dc = io_safe_output($config["ldap_base_dn"]); #Search group of this user it belong. @@ -715,6 +725,202 @@ function ldap_process_user_login ($login, $password) { $ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; + $correct = false; + if(!empty($ldap_base_dn)) { + if (strlen($password) != 0 && @ldap_bind($ds, io_safe_output($memberof['dn']), $password) ) { + $correct = true; + } + } + else { + if (strlen($password) != 0 && @ldap_bind($ds, io_safe_output($login), $password) ) { + $correct = true; + } + } + + @ldap_close ($ds); + + if ($correct) { + return true; + } + else { + $config["auth_error"] = 'User not found in database or incorrect password'; + + return false; + } +} + +function get_ldap_login_attr ($login) { + global $config; + + if (! function_exists ("ldap_connect")) { + $config["auth_error"] = __('Your installation of PHP does not support LDAP'); + + return false; + } + + // Connect to the LDAP server + $ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]); + + if (!$ds) { + $config["auth_error"] = 'Error connecting to LDAP server'; + + return false; + } + + // Set the LDAP version + ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, $config["ldap_version"]); + + if ($config["ldap_start_tls"]) { + if (!@ldap_start_tls ($ds)) { + $config["auth_error"] = 'Could not start TLS for LDAP connection'; + @ldap_close ($ds); + + return false; + } + } + + $id_user = $login; + + switch ($config['ldap_login_user_attr']) { + case 'email': + $dc = io_safe_output($config["ldap_base_dn"]); + + $correct_admin_bind = true; + if ($config['ldap_admin_login'] != "" && $config['ldap_admin_pass'] != "") { + if (!@ldap_bind($ds, io_safe_output($config['ldap_admin_login']), $config['ldap_admin_pass'])) { + $correct_admin_bind = false; + } + } + + if (!$correct_admin_bind) { + $config["auth_error"] = 'Admin ldap connection fail'; + @ldap_close ($ds); + + return false; + } + + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($id_user) . ")"; + $justthese = array("mail"); + + $sr = ldap_search($ds, $dc, $filter, $justthese); + + $info = ldap_get_entries($ds, $sr); + + if ($info["count"] == 0 && !isset($info[0]["mail"])) { + @ldap_close ($ds); + return $id_user; + } + else { + $info = $info[0]; + } + + $id_user = $info['mail'][0]; + + @ldap_close ($ds); + + break; + } + + return $id_user; +} + +/** + * Checks if a user is in the autocreate blacklist. + * + * @param string User + * + * @return bool True if the user is in the blacklist, false otherwise. + */ +function is_user_blacklisted ($user) { + global $config; + + $blisted_users = explode (',', $config['autocreate_blacklist']); + foreach ($blisted_users as $blisted_user) { + if ($user == $blisted_user) { + return true; + } + } + + return false; +} + +/** + * Check permissions in LDAP for prepare to create user in Pandora. + * + * @param string Login + * @param string Password + * @param string User Info + * @param string check_permissions Check if change permissions + * + * @return bool True if the login succeeds, false otherwise + */ +function prepare_permissions_groups_of_user_ldap ($id_user, $password, + $user_info, $check_permissions = false, $syncronize = false) { + + global $config; + include_once($config['homedir'] . "/include/functions_html.php"); + + if (! function_exists ("ldap_connect")) { + return false; + } + + // Do not allow blank passwords + if ($password == "") { + return false; + } + + // Connect to the LDAP server + $ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]); + if (!$ds) { + return false; + } + + // Set the LDAP version + ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, $config["ldap_version"]); + + if ($config["ldap_start_tls"]) { + if (!@ldap_start_tls ($ds)) { + @ldap_close ($ds); + return false; + } + } + + $dc = io_safe_output($config["ldap_base_dn"]); + + $correct_admin_bind = true; + if ($config['ldap_admin_login'] != "" && $config['ldap_admin_pass'] != "") { + if (!@ldap_bind($ds, io_safe_output($config['ldap_admin_login']), $config['ldap_admin_pass'])) { + $correct_admin_bind = false; + } + } + + if (!$correct_admin_bind) { + $config["auth_error"] = 'Admin ldap connection fail'; + @ldap_close ($ds); + + return false; + } + + #Search group of this user it belong. + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($id_user) . ")"; + $justthese = array("objectclass=group"); + + $sr = ldap_search($ds, $dc, $filter, $justthese); + + $memberof = ldap_get_entries($ds, $sr); + + if ($memberof["count"] == 0 && !isset($memberof[0]["memberof"])) { + @ldap_close ($ds); + return false; + } + else { + $memberof = $memberof[0]; + } + + unset($memberof["count"]); + + $ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : ''; + $correct = false; if(!empty($ldap_base_dn)) { if (strlen($password) != 0 && @ldap_bind($ds, $memberof['dn'], $password) ) { @@ -727,36 +933,381 @@ function ldap_process_user_login ($login, $password) { } } - @ldap_close ($ds); + if (!$correct) { + @ldap_close ($ds); - if ($correct) { - return true; - } - else { - $config["auth_error"] = 'User not found in database or incorrect password'; - return false; } + + $permissions = array(); + $i = 0; + $count_total = 0; + + $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); + + foreach ($ldap_adv_perms as $ldap_adv_perm) { + $groups = $ldap_adv_perm['groups_ldap']; + + if ($groups[0] == '') { + $groups = array(); + } + else { + $groups = $groups[0]; + } + + $count_ad_adv_perms = count(explode(",", $groups)); + + $tags_ids = array(); + $tags = implode(",", $tags); + if ($tags == null) { + $tags = ""; + } + + foreach ($memberof as $member) { + $member_to_compare = str_replace($config['ldap_login_attr'] . "=", "", $member); + $member_to_compare = str_replace($id_user . ",", "", $member_to_compare); + $member_to_compare = str_replace("," . $dc, "", $member_to_compare); + + if (($member_to_compare == $dc) && (empty($groups))) { + $count_total++; + } + else { + $member_to_compare = explode(",", $member_to_compare); + $groups = explode(",", $groups); + foreach ($groups as $g) { + if ($member_to_compare[0] == $g) { + $count_total++; + } + } + } + } + + if ($count_total > 0) { + $profile_id = $ldap_adv_perm['profile']; + $id_grupos = $ldap_adv_perm['group']; + + if (empty($profile_id)) { + @ldap_close ($ds); + return false; + } + + $permissions[$i]["profile"] = $profile_id; + $permissions[$i]["groups"] = $id_grupos; + $permissions[$i]["tags"] = $tags; + } + $i++; + $count_total = 0; + $count_ad_adv_perms = 0; + } + + if ( $check_permissions ) { + $result = check_permission_ldap ($id_user, $password, $user_info, $permissions, $syncronize); + @ldap_close ($ds); + + return $result; + } + + if (!is_user ($id_user)) { + if (($config['ldap_login_user_attr'] != 'name') && ($config['ldap_login_user_attr'] != null)) { + switch ($config['ldap_login_user_attr']) { + case 'email': + $filter="(" . $config['ldap_login_attr'] . "=" . io_safe_output($id_user) . ")"; + $justthese = array("mail"); + + $sr = ldap_search($ds, $dc, $filter, $justthese); + + $info = ldap_get_entries($ds, $sr); + + if ($info["count"] == 0 && !isset($info[0]["mail"])) { + @ldap_close ($ds); + return false; + } + else { + $info = $info[0]; + } + + $id_user = $info['mail'][0]; + $user_info['fullname'] = $id_user; + + break; + } + } + + $create_user = create_user_and_permisions_ldap($id_user, $password, $user_info, $permissions, $syncronize); + } + + @ldap_close ($ds); + + return $create_user; } /** - * Checks if a user is in the autocreate blacklist. + * Create progile with data obtaint from AD * - * @param string User + * @param string Login + * @param string Password + * @param array user_info + * @param array permiisons * - * @return bool True if the user is in the blacklist, false otherwise. + * @return bool */ -function is_user_blacklisted ($user) { +function create_user_and_permisions_ldap ($id_user, $password, $user_info, + $permissions, $syncronize = false) { global $config; - $blisted_users = explode (',', $config['autocreate_blacklist']); - foreach ($blisted_users as $blisted_user) { - if ($user == $blisted_user) { - return true; + $values = $user_info; + $values["id_user"] = $id_user; + + if ($config['ldap_save_password']) { + $values["password"] = md5 ($password); + } + $values["last_connect"] = 0; + $values["registered"] = get_system_time (); + if ( defined("METACONSOLE") && $syncronize ) + $values['metaconsole_access_node'] = $config['ldap_adv_user_node']; + $user = (@db_process_sql_insert ("tusuario", $values)) !== false; + + if ($user) { + if (!empty($permissions)) { + foreach ($permissions as $permission) { + $id_profile = $permission["profile"]; + $id_groups = $permission["groups"]; + $tags = $permission["tags"]; + + foreach ($id_groups as $id_group) { + $profile = profile_create_user_profile( + $id_user, $id_profile, $id_group, false, $tags); + } + + if ( defined("METACONSOLE") && $syncronize ) { + enterprise_include_once('include/functions_metaconsole.php'); + + unset($values['metaconsole_access_node']); + $values['not_login'] = (int) !$config['ldap_adv_user_node']; + + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + $perfil_maestro = db_get_row('tperfil', + 'id_perfil', $permission["profile"]); + + if (metaconsole_connect($server) == NOERR ) { + + if (!profile_exist($perfil_maestro['name'])) { + unset($perfil_maestro['id_perfil']); + $id_profile = db_process_sql_insert('tperfil', $perfil_maestro); + } + else { + $id_profile = db_get_value('id_perfil', 'tperfil', 'name', $perfil_maestro['name']); + } + + db_process_sql_insert ("tusuario", $values); + foreach ($id_groups as $id_group) { + $profile = profile_create_user_profile ($id_user, + $id_profile, $id_group, false, $tags); + } + } + + metaconsole_restore_db(); + } + } + + if (!$profile) + return false; + } + } + else { + $profile = profile_create_user_profile( + $id_user, $config['default_remote_profile'], $config['default_remote_group'], false, $config['default_assign_tags']); + + if (!$profile) + return false; + } + } + return true; +} + +/** + * Check if user have right permission in pandora. This + * permission depend of ldap. + * + * @param string Login + * @param string Password + * + * @return string + */ +function check_permission_ldap ($id_user, $password, $user_info, + $permissions, $syncronize = false) { + + global $config; + include_once($config['homedir'] . "/enterprise/include/functions_metaconsole.php"); + + $result_user = users_get_user_by_id($id_user); + $filter = array("id_usuario" => $id_user); + $profiles_user = array(); + $user_profiles = + db_get_all_rows_filter ("tusuario_perfil", $filter); + + foreach ($user_profiles as $user_profile) { + $profiles_user[$user_profile["id_up"]] = + $user_profile["id_perfil"]; + } + + $profiles_user_nodes = array(); + $permissions_nodes = array(); + if ( is_metaconsole() && $syncronize ) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + if ( metaconsole_connect($server) == NOERR ) { + $user_profiles_nodes = + db_get_all_rows_filter ("tusuario_perfil", $filter); + foreach ($user_profiles_nodes as $user_profile_node) { + $profiles_user_nodes[$server['server_name']][$user_profile_node["id_up"]] = + $user_profile_node["id_perfil"]; + } + } + metaconsole_restore_db(); + } + + foreach ($permissions as $key => $permission) { + $perfil_maestro = db_get_row('tperfil', + 'id_perfil', $permission['profile']); + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR ) { + if (profile_exist($perfil_maestro['name'])) { + $id_profile = db_get_value('id_perfil', 'tperfil', 'name', $perfil_maestro['name']); + $permissions_nodes[$server['server_name']][$key] = $permission; + $permissions_nodes[$server['server_name']][$key]['profile'] = $id_profile; + } + } + metaconsole_restore_db(); + } } } - return false; + $no_found = array(); + if ($result_user) { + foreach ($permissions as $permission) { + $id_profile = $permission["profile"]; + $id_groups = $permission["groups"]; + $tags = $permission["tags"]; + + foreach ($id_groups as $id_group) { + $filter = array("id_usuario" => $id_user, + "id_perfil"=>$id_profile, + "id_grupo" => $id_group); + //~ Find perfil with advance permissions in + //~ authentication menu. This data depends on + //~ groups where this user it belong. + $result_profiles = + db_get_row_filter ("tusuario_perfil", $filter); + if (!$result_profiles) { + #If not found save in array. + $no_found[] = array("id_perfil"=>$id_profile, + "id_grupo" => $id_group, "tags" =>$tags); + } + else { + #if profile is find, delete from array. + db_process_sql_update("tusuario_perfil", + array("tags" =>$tags), + array('id_usuario' => $id_user, + 'id_up' => $profiles_user[$id_profile])); + + unset($profiles_user[$result_profiles["id_up"]]); + } + } + } + + if (is_metaconsole() && $syncronize) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + foreach ($permissions_nodes[$server['server_name']] as $permission_node) { + + $id_profile = $permission_node["profile"]; + $id_groups = $permission_node["groups"]; + $tags = $permission_node["tags"]; + + foreach ($id_groups as $id_group) { + + $filter = array("id_usuario" => $id_user, + "id_perfil"=>$id_profile, + "id_grupo" => $id_group); + + if (metaconsole_connect($server) == NOERR ) { + $result_profiles = + db_get_row_filter ("tusuario_perfil", $filter); + + if (!$result_profiles) { + #If not found save in array. + $no_found_server[$server['server_name']][] = array("id_perfil" => $id_profile, + "id_grupo" => $id_group, "tags" => $tags); + } + else { + #if profile is find, delete from array. + db_process_sql_update("tusuario_perfil", + array("tags" =>$tags), + array('id_usuario' => $id_user, + 'id_up' => $profiles_user_nodes[$server_name][$id_profile])); + + unset($profiles_user_nodes[$server_name][$result_profiles["id_up"]]); + } + } + } + } + metaconsole_restore_db(); + } + } + + if ( empty($profiles_user) && empty($no_found) ) { + #The permmisions of user not changed + return true; + } + else { + foreach ($profiles_user as $key => $profile_user) { + #The other profiles are deleted + profile_delete_user_profile ($id_user, $key); + } + + if ( is_metaconsole() && $syncronize ) { + foreach ($profiles_user_nodes as $server_name => $profile_users) { + $server = metaconsole_get_connection($server_name); + foreach ($profile_users as $key => $profile_user) { + if ( metaconsole_connect($server) == NOERR ) { + profile_delete_user_profile ($id_user, $key); + } + } + metaconsole_restore_db(); + } + } + + foreach ($no_found as $new_profiles) { + #Add the missing permissions + profile_create_user_profile ($id_user, + $new_profiles["id_perfil"], + $new_profiles["id_grupo"], false, + $new_profiles["tags"]); + } + + if ( is_metaconsole() && $syncronize ) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + if ( metaconsole_connect($server) == NOERR ) { + foreach ($no_found_server[$server['server_name']] as $new_profiles) { + profile_create_user_profile ($id_user, + $new_profiles["id_perfil"], + $new_profiles["id_grupo"], false, + $new_profiles["tags"]); + } + } + metaconsole_restore_db(); + } + } + + return "permissions_changed"; + } + } + else { + return "error_permissions"; + } } /** @@ -770,13 +1321,23 @@ function is_user_blacklisted ($user) { function change_local_user_pass_ldap ($id_user, $password) { $local_user_pass = db_get_value_filter('password', 'tusuario', array('id_user' => $id_user)); + $return = false; if (md5($password) !== $local_user_pass) { $values_update = array(); $values_update['password'] = md5($password); - db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user)); + $return = db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user)); } + return $return; +} + +function delete_user_pass_ldap ($id_user) { + $values_update = array(); + $values_update['password'] = null; + + $return = db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user)); + return; } diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 6dc52ea68d..52aa2dee5c 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -23,6 +23,7 @@ class Tree { protected $filter = array(); protected $childrenMethod = "on_demand"; + protected $userGroupsACL; protected $userGroups; protected $strictACL = false; @@ -36,45 +37,54 @@ class Tree { $this->id = $id; $this->rootID = !empty($rootID) ? $rootID : $id; $this->serverID = $serverID; - $this->childrenMethod = $childrenMethod; - $this->access = $access; - - $userGroups = users_get_groups(false, $this->access); + $this->childrenMethod = $childrenMethod; + $this->access = $access; - if (empty($userGroups)) - $this->userGroups = false; - else - $this->userGroups = $userGroups; + $userGroupsACL = users_get_groups(false, $this->access); + $this->userGroupsACL = empty($userGroupsACL) ? false : $userGroupsACL; + $this->userGroups = $this->userGroupsACL; global $config; include_once($config['homedir']."/include/functions_servers.php"); include_once($config['homedir']."/include/functions_modules.php"); require_once($config['homedir']."/include/functions_tags.php"); - if (is_metaconsole()) - enterprise_include_once("meta/include/functions_ui_meta.php"); + if (is_metaconsole()) enterprise_include_once("meta/include/functions_ui_meta.php"); $this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']); $this->acltags = tags_get_user_module_and_tags($config['id_user'], $this->access); } - public function setType($type) { - $this->type = $type; - } - public function setFilter($filter) { + // Filter the user groups + if (!empty($filter['groupID'])) { + $group_id = $filter['groupID']; + $this->userGroups = isset($this->userGroupsACL[$group_id]) + ? array($group_id => $this->userGroupsACL[$group_id]) + : array(); + } + else if (!empty($filter['searchGroup'])) { + $groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $filter['searchGroup'] . '%')); + + // Save the groups which intersect + $userGroupsACL = $this->userGroupsACL; + $this->userGroups = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) { + $group_id = $group['id_grupo']; + if (isset($userGroupsACL[$group_id])) { + $userGroups[$group_id] = $userGroupsACL[$group_id]; + } + + return $userGroups; + }, array()); + } + else { + $this->userGroups = $this->userGroupsACL; + } + $this->filter = $filter; } - public function isStrict () { - return $this->strictACL; - } - - public function setStrict ($value) { - $this->strictACL = (bool) $value; - } - protected function getAgentStatusFilter ($status = -1) { if ($status == -1) $status = $this->filter['statusAgent']; @@ -323,7 +333,7 @@ class Tree { case 'group': // ACL Group $user_groups_str = "-1"; - $group_acl = ""; + $group_filter = ""; if (!$this->strictACL) { if (empty($this->userGroups)) { return; @@ -338,7 +348,7 @@ class Tree { // Asking for all groups. else { $user_groups_str = implode(",", array_keys($this->userGroups)); - $group_acl = "AND ta.id_grupo IN ($user_groups_str)"; + $group_filter = "AND ta.id_grupo IN ($user_groups_str)"; } } else { @@ -356,7 +366,7 @@ class Tree { } } } - $group_acl = "AND ta.id_grupo IN ($user_groups_str)"; + $group_filter = "AND ta.id_grupo IN ($user_groups_str)"; } switch ($type) { @@ -390,7 +400,7 @@ class Tree { $module_status_join WHERE ta.disabled = 0 AND ta.id_grupo = $item_for_count - $group_acl + $group_filter $agent_search_filter $agent_status_filter"; $sql = $this->getAgentCountersSql($agent_table); @@ -411,7 +421,7 @@ class Tree { FROM tmetaconsole_agent ta WHERE ta.disabled = 0 AND ta.id_grupo = $item_for_count - $group_acl + $group_filter $agent_search_filter $agent_status_filter"; $sql = $this->getAgentCountersSql($agent_table); @@ -439,7 +449,7 @@ class Tree { $module_status_join WHERE ta.disabled = 0 AND ta.id_grupo = $rootID - $group_acl + $group_filter $agent_search_filter $agent_status_filter GROUP BY $group_by_fields @@ -456,7 +466,7 @@ class Tree { FROM tmetaconsole_agent ta WHERE ta.disabled = 0 AND ta.id_grupo = $rootID - $group_acl + $group_filter $agent_search_filter $agent_status_filter ORDER BY $order_fields"; @@ -498,7 +508,7 @@ class Tree { ON ta.disabled = 0 AND tam.id_agente = ta.id_agente AND ta.id_grupo = $rootID - $group_acl + $group_filter $agent_search_filter $agent_status_filter WHERE tam.disabled = 0 @@ -1123,7 +1133,8 @@ class Tree { if (empty($data)) return array(); - if ($this->type == 'agent') { + // [26/10/2017] It seems the module hierarchy should be only available into the tree by group + if ($this->rootType == 'group' && $this->type == 'agent') { $data = $this->getProcessedModules($data); } diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 7a81d1d4f7..609cde2096 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,8 +22,8 @@ /** * Pandora build version and version */ -$build_version = 'PC171110'; -$pandora_version = 'v7.0NG.715'; +$build_version = 'PC171130'; +$pandora_version = 'v7.0NG.716'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 7101f960de..7da9316c65 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -738,7 +738,7 @@ function mysql_db_get_row_sql ($sql, $search_history_db = false) { * * @return mixed Array of the row or false in case of error. */ -function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join = 'AND', $historydb = false) { +function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join = 'AND') { if (empty ($fields)) { $fields = '*'; } @@ -758,7 +758,7 @@ function mysql_db_get_row_filter ($table, $filter, $fields = false, $where_join $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); - return db_get_row_sql ($sql, $historydb); + return db_get_row_sql ($sql); } /** diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index f8edfd1d27..4edfe2c512 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1594,7 +1594,7 @@ function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', case '2c': case '1': default: - $command_str = $snmpwalk_bin . ' -m ALL -Oa -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; + $command_str = $snmpwalk_bin . ' -m ALL -Oa -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg(io_safe_output($snmp_community)) . ' ' . escapeshellarg($ip_target) . ' ' . $base_oid . ' 2> ' . $error_redir_dir; break; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 838fb58d55..9c38157300 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -55,6 +55,17 @@ function agents_get_agent_id_by_module_id ($id_agente_modulo) { 'id_agente_modulo', $id_agente_modulo); } +/** + * Get agent id from an agent alias. + * + * @param string $alias Agent alias. + * + * @return int Id from the agent. + */ +function agents_get_agent_id_by_alias ($alias) { + return db_get_all_rows_sql ("SELECT id_agente FROM tagente WHERE upper(alias) LIKE upper('%$alias%')"); +} + /** * Creates an agent * @@ -314,6 +325,13 @@ function agents_get_agents ($filter = false, $fields = false, $search = ''; } + if (isset($filter['search_custom'])) { + $search_custom = $filter['search_custom']; + unset($filter['search_custom']); + } else { + $search_custom = ''; + } + if (isset($filter['offset'])) { $offset = $filter['offset']; unset($filter['offset']); @@ -450,8 +468,8 @@ function agents_get_agents ($filter = false, $fields = false, $sql_extra, $where, $where_nogroup, $status_sql, $search, $disabled); } else { - $where = sprintf('%s AND %s AND (%s) %s AND %s', - $where, $where_nogroup, $status_sql, $search, $disabled); + $where = sprintf('%s AND %s AND (%s) %s AND %s %s', + $where, $where_nogroup, $status_sql, $search, $disabled, $search_custom); } $sql = sprintf('SELECT %s FROM tagente diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 8e87eee5b3..577dfe82f1 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1039,14 +1039,16 @@ function alerts_delete_alert_agent_module ($id_alert_agent_module, $filter = fal $filter = array (); if ($id_alert_agent_module) $filter['id'] = $id_alert_agent_module; - - // Get the modules of the fired alerts that will be deleted to update counts - $filter_get = $filter; - - $filter_get['group'] = 'id_agent_module'; - $filter_get['times_fired'] = '>0'; - - $fired_alert_modules = db_get_all_rows_filter('talert_template_modules', $filter_get, array('id_agent_module', 'COUNT(*) alerts')); + + // Get the id agent to update the fired alert counts + $agent_id = false; + if (isset ($filter['id_agent_module'])){ + $agent_id = modules_get_agentmodule_agent ($filter["id_agent_module"]); + } + else if (isset ($filter['id'])){ + $alert = alerts_get_alert_agent_module($id_alert_agent_module); + $agent_id = modules_get_agentmodule_agent ($alert["id_agent_module"]); + } /* The deletion of actions from talert_template_module_actions, @@ -1054,6 +1056,11 @@ function alerts_delete_alert_agent_module ($id_alert_agent_module, $filter = fal a foreing key and delete on cascade. */ if (@db_process_sql_delete ('talert_template_modules', $filter) !== false) { + // Update fired alert count on the agent + // It will only occur if is specified the alert id or the id_agent_module + if ($agent_id !== false) { + db_process_sql(sprintf('UPDATE tagente SET update_alert_count=1 WHERE id_agente = %d', $agent_id)); + } return true; } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 5ecac3a944..c1c7c9ca50 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -8531,7 +8531,7 @@ function api_set_enable_module ($agent_name, $module_name, $thrast3, $thrash4) { * @param string $template_name Name of the alert template (for example, "Warning event") * @param $thrash4 Don't use. -// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert&id=garfio&id2=Status&other=Warning%20condition +// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert&id=c2cea5860613e363e25f4ba185b54fe28f869ff8a5e8bb46343288337c903531&id2=Status&other=Warning%20condition */ function api_set_disable_alert ($agent_name, $module_name, $template_name, $thrash4) { @@ -8543,11 +8543,53 @@ function api_set_disable_alert ($agent_name, $module_name, $template_name, $thra $id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name)); $id_template = db_get_value_filter('id', 'talert_templates', array('name' => $template_name["data"])); - db_process_sql("UPDATE talert_template_modules + $result = db_process_sql("UPDATE talert_template_modules SET disabled = 1 WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template"); - returnData('string', array('type' => 'string', 'data' => "Correct alert disable")); + if ($result) { + returnData('string', array('type' => 'string', 'data' => "Correct alert disable")); + } else { + returnData('string', array('type' => 'string', 'data' => __('Error alert disable'))); + } +} + + +/** + * Disable an alert with alias + * + * @param string $agent_alias Alias of agent (for example "myagent") + * @param string $module_name Name of the module (for example "Host alive") + * @param string $template_name Name of the alert template (for example, "Warning event") + * @param $thrash4 Don't use. + +// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert_alias&id=garfio&id2=Status&other=Warning%20condition + */ + +function api_set_disable_alert_alias ($agent_alias, $module_name, $template_name, $thrash4) { + if (defined ('METACONSOLE')) { + return; + } + + $agent_id = agents_get_agent_id_by_alias($agent_alias); + $result = false; + foreach ($agent_id as $key => $id_agent) { + $id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent['id_agente'], 'nombre' => $module_name)); + $id_template = db_get_value_filter('id', 'talert_templates', array('name' => $template_name["data"])); + + $result = db_process_sql("UPDATE talert_template_modules + SET disabled = 1 + WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template"); + + if ($result) { + returnData('string', array('type' => 'string', 'data' => "Correct alert disable")); + return; + } + } + + if(!$result){ + returnData('string', array('type' => 'string', 'data' => __('Error alert disable'))); + } } /** diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 06f0d090b5..30078c5685 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -343,9 +343,23 @@ function config_update_config () { $error_update[] = __('Base DN'); if (!config_update_value ('ldap_login_attr', get_parameter ('ldap_login_attr'))) $error_update[] = __('Login attribute'); + if (!config_update_value ('ldap_admin_login', get_parameter ('ldap_admin_login'))) + $error_update[] = __('Admin LDAP login'); + if (!config_update_value ('ldap_admin_pass', get_parameter ('ldap_admin_pass'))) + $error_update[] = __('Admin LDAP password'); if (!config_update_value ('fallback_local_auth', get_parameter ('fallback_local_auth'))) $error_update[] = __('Fallback to local authentication'); - + if (!config_update_value ('ldap_login_user_attr', get_parameter ('ldap_login_user_attr'))) + $error_update[] = __('Login user attribute'); + + if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 0) { + if (!config_update_value ('ldap_save_password', get_parameter ('ldap_save_password'))) + $error_update[] = __('Save Password'); + } + else if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 1) { + config_update_value ('ldap_save_password', 1); + } + if (!config_update_value ('rpandora_server', get_parameter ('rpandora_server'))) $error_update[] = __('MySQL host'); if (!config_update_value ('rpandora_port', get_parameter ('rpandora_port'))) @@ -1348,6 +1362,14 @@ function config_process_config () { if (!isset ($config['ldap_login_attr'])) { config_update_value ( 'ldap_login_attr', 'uid'); } + + if (!isset ($config['ldap_admin_login'])) { + config_update_value ( 'ldap_admin_login', ''); + } + + if (!isset ($config['ldap_admin_pass'])) { + config_update_value ( 'ldap_admin_pass', ''); + } if (!isset ($config['fallback_local_auth'])) { config_update_value ( 'fallback_local_auth', '0'); diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index cf131eac8e..efa5f2f342 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -30,24 +30,30 @@ function cron_update_module_interval ($module_id, $cron) { $module_interval = db_get_value_filter('module_interval','tagente_modulo',array("id_agente_modulo" => $module_id)); return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . $module_interval . ' WHERE id_agente_modulo = ' . (int) $module_id); } else { - return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . cron_next_execution ($cron) . ' WHERE id_agente_modulo = ' . (int) $module_id); + return db_process_sql ( + 'UPDATE tagente_estado SET current_interval = ' . + cron_next_execution ($cron, $module_interval, $module_id) . + ' WHERE id_agente_modulo = ' . + (int) $module_id) + ; } } // Get the number of seconds left to the next execution of the given cron entry. -function cron_next_execution ($cron) { +function cron_next_execution ($cron, $module_interval, $module_id) { // Get day of the week and month from cron config list ($minute, $hour, $mday, $month, $wday) = explode (" ", $cron); - // Get current time - $cur_time = time(); + // Get last execution time + $last_execution = db_get_value('utimestamp', 'tagente_estado', 'id_agente_modulo', $module_id); + $cur_time = ($last_execution !== false) ? $last_execution : time(); // Any day of the way if ($wday == '*') { - $nex_time = cron_next_execution_date ($cron, $cur_time); + $nex_time = cron_next_execution_date ($cron, $cur_time, $module_interval); return $nex_time - $cur_time; } @@ -55,7 +61,7 @@ function cron_next_execution ($cron) { $count = 0; $nex_time = $cur_time; do { - $nex_time = cron_next_execution_date ($cron, $nex_time); + $nex_time = cron_next_execution_date ($cron, $nex_time, $module_interval); $nex_time_wd = $nex_time; list ($nex_mon, $nex_wday) = explode (" ", date ("m w", $nex_time_wd)); @@ -80,90 +86,202 @@ function cron_next_execution ($cron) { } // Get the next execution date for the given cron entry in seconds since epoch. -function cron_next_execution_date ($cron, $cur_time = false) { +function cron_next_execution_date ($cron, $cur_time = false, $module_interval = 300) { // Get cron configuration - list ($min, $hour, $mday, $mon, $wday) = explode (" ", $cron); - + $cron_array = explode (" ", $cron); // Months start from 0 - if ($mon != '*') { - $mon -= 1; + if ($cron_array[3] != '*') { + $mon_s = cron_get_interval ($cron_array[3]); + if ($mon_s['up'] !== false) { + $cron_array[3] = $mon_s['down'] - 1 . "-" . $mon_s['up'] - 1; + } else { + $cron_array[3] = $mon_s['down'] - 1; + } } // Get current time - if ($cur_time === false) { - $cur_time = time(); - } - list ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) = explode (" ", date ("i H d m Y", $cur_time)); + if ($cur_time === false) $cur_time = time(); + + $nex_time = $cur_time + $module_interval; + $nex_time_array = explode (" ", date ("i H d m Y", $nex_time)); + if (cron_is_in_cron($cron_array, $nex_time_array)) return $nex_time; - // Get first next date candidate from cron configuration - $nex_min = $min; - $nex_hour = $hour; - $nex_mday = $mday; - $nex_mon = $mon; - $nex_year = $cur_year; + // Get first next date candidate from next cron configuration + // Initialize some vars + $prev_ovfl = false; + + // Update minutes + $min_s = cron_get_interval ($cron_array[0]); + $nex_time_array[0] = ($min_s['down'] == '*') ? 0 : $min_s['down']; - // Replace wildcards - if ($min == '*') { - if ($hour != '*' || $mday != '*' || $wday != '*' || $mon != '*') { - $nex_min = 0; - } - else { - $nex_min = $cur_min; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time >= $cur_time) { + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; } } - if ($hour == '*') { - if ($mday != '*' || $wday != '*' ||$mon != '*') { - $nex_hour = 0; - } - else { - $nex_hour = $cur_hour; - } - } - if ($mday == '*') { - if ($mon != '*') { - $nex_mday = 1; - } - else { - $nex_mday = $cur_mday; - } - } - if ($mon == '*') { - $nex_mon = $cur_mon; - } - - // Find the next execution date - $count = 0; - do { - $next_time = mktime($nex_hour, $nex_min, 0, $nex_mon, $nex_mday, $nex_year); - if ($next_time > $cur_time) { - return $next_time; - } - if ($min == '*' && $hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') { - list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1MINUTE)); - } - else if ($hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') { - list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1HOUR)); - } - else if ($mday == '*' && $mon == '*') { - list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + SECONDS_1DAY)); - } - else if ($mon == '*') { - $nex_mon = $nex_mon + 1; - if ($nex_mon > 11) { - $nex_mon = 0; - $nex_year++; + + // Check if next hour is in cron + $nex_time_array[1]++; + $nex_time = cron_valid_date($nex_time_array); + + if ($nex_time === false) { + // Update the month day if overflow + $prev_ovfl = true; + $nex_time_array[1] = 0; + $nex_time_array[2]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + // Update the month if overflow + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + #Update the year if overflow + $nex_time_array[3] = 0; + $nex_time_array[4]++; + $nex_time = cron_valid_date($nex_time_array); } } - else { - $nex_year++; - } - $count++; } - while ($count < SECONDS_1DAY); + // Check the hour + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + + // Update the hour if fails + $hour_s = cron_get_interval ($cron_array[1]); + $nex_time_array[1] = ($hour_s['down'] == '*') ? 0 : $hour_s['down']; + + // When an overflow is passed check the hour update again + if ($prev_ovfl) { + $nex_time = cron_valid_date($nex_time_array); + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + } + $prev_ovfl = false; + + // Check if next day is in cron + $nex_time_array[2]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + // Update the month if overflow + $prev_ovfl = true; + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + // Update the year if overflow + $nex_time_array[3] = 0; + $nex_time_array[4]++; + $nex_time = cron_valid_date($nex_time_array); + } + } + // Check the day + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + + // Update the day if fails + $mday_s = cron_get_interval ($cron_array[2]); + $nex_time_array[2] = ($mday_s['down'] == '*') ? 1 : $mday_s['down']; + + // When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date($nex_time_array); + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + } + $prev_ovfl = false; + + // Check if next month is in cron + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + if ($nex_time === false) { + #Update the year if overflow + $prev_ovfl = true; + $nex_time_array[3]++; + $nex_time = cron_valid_date($nex_time_array); + } + + // Check the month + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + + // Update the month if fails + $mon_s = cron_get_interval ($cron_array[3]); + $nex_time_array[3] = ($mon_s['down'] == '*') ? 0 : $mon_s['down']; + + // When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date($nex_time_array); + if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) { + return $nex_time; + } + } + + // Update the year + $nex_time_array[4]++; + $nex_time = cron_valid_date($nex_time_array); + + return ($nex_time !== false) ? $nex_time : $module_interval; +} + +// Get an array with the cron interval +function cron_get_interval ($element) { + # Not a range + if (!preg_match('/(\d+)\-(\d+)/', $element, $capture)) { + return array( + 'down' => $element, + 'up' => false + ); + } + return array( + 'down' => $capture[1], + 'up' => $capture[2] + ); +} + +// Returns if a date is in a cron. Recursive. +function cron_is_in_cron($elems_cron, $elems_curr_time) { - // Something went wrong, default to 5 minutes - return $cur_time + SECONDS_5MINUTES; + $elem_cron = array_shift($elems_cron); + $elem_curr_time = array_shift($elems_curr_time); + + // If there is no elements means that is in cron + if ($elem_cron === null || $elem_curr_time === null) return true; + + // Go to last element if current is a wild card + if ($elem_cron != '*') { + $elem_s = cron_get_interval($elem_cron); + // Check if there is no a range + if (($elem_s['up'] === false) && ($elem_s['down'] != $elem_curr_time)) { + return false; + } + // Check if there is on the range + if ($elem_s['up'] !== false) { + if ($elem_s['down'] < $elem_s['up']) { + if ($elem_curr_time < $elem_s['down'] || $elem_curr_time > $elem_s['up']){ + return false; + } + } else { + if ($elem_curr_time > $elem_s['down'] || $elem_curr_time < $elem_s['up']){ + return false; + } + } + } + } + return cron_is_in_cron($elems_cron, $elems_curr_time); +} + +function cron_valid_date ($da) { + $st = sprintf("%04d:%02d:%02d %02d:%02d:00", $da[4], $da[3], $da[2], $da[1], $da[0]); + $time = strtotime($st); + return $time; } // Check if cron is properly constructed diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index f61a7ee944..adf077ec6a 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -202,10 +202,6 @@ function custom_graphs_print($id_graph, $height, $width, $period, $sources = db_get_all_rows_field_filter('tgraph_source', 'id_graph', $id_graph); - $series = db_get_all_rows_sql('SELECT summatory_series,average_series FROM tgraph WHERE id_graph = '.$id_graph); - $summatory = $series[0]['summatory_series']; - $average = $series[0]['average_series']; - $modules = array (); $weights = array (); $labels = array (); @@ -266,9 +262,7 @@ function custom_graphs_print($id_graph, $height, $width, $period, $percentil, $from_interface, $id_widget_dashboard, - $fullscale, - $summatory, - $average); + $fullscale); if ($return) return $output; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index eac5299982..70395cb205 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -81,7 +81,7 @@ function db_connect($host = null, $db = null, $user = null, $pass = null, $port $ownDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $config['homedir'] = $ownDir; $login_screen = 'error_authconfig'; - require($config['homedir'] . '/general/error_screen.php'); + require($config['homedir'] . '../general/error_screen.php'); exit; } else if ($error == 0) { @@ -416,12 +416,12 @@ function db_get_row ($table, $field_search, $condition, $fields = false) { * * @return mixed Array of the row or false in case of error. */ -function db_get_row_filter($table, $filter, $fields = false, $where_join = 'AND', $historydb = false) { +function db_get_row_filter($table, $filter, $fields = false, $where_join = 'AND') { global $config; switch ($config["dbtype"]) { case "mysql": - return mysql_db_get_row_filter($table, $filter, $fields, $where_join, $historydb); + return mysql_db_get_row_filter($table, $filter, $fields, $where_join); break; case "postgresql": return postgresql_db_get_row_filter($table, $filter, $fields, $where_join); @@ -481,6 +481,9 @@ function db_get_all_rows_sql($sql, $search_history_db = false, $cache = true, $d } } + + + /** * * Returns the time the module is in unknown status (by events) @@ -490,7 +493,7 @@ function db_get_all_rows_sql($sql, $search_history_db = false, $cache = true, $d * @param int $tend end of search * */ -function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend = false, $historydb = false) { +function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend = false) { global $config; if (!isset($id_agente_modulo)) { @@ -511,19 +514,20 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend return false; } + // Retrieve going unknown events in range $query = "SELECT utimestamp,event_type FROM tevento WHERE id_agentmodule = " . $id_agente_modulo; $query .= " AND event_type like 'going_%' "; $query .= " AND utimestamp >= $tstart AND utimestamp <= $tend "; $query .= " ORDER BY utimestamp ASC"; - $events = db_get_all_rows_sql($query, $historydb); + $events = db_get_all_rows_sql($query); if (! is_array($events)){ return false; } - $last_status = $events[0]["event_type"] != "going_unknown" ? 1:0; + $last_status = 0; // normal $return = array(); $i=0; foreach ($events as $event) { @@ -551,9 +555,6 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend } } } - if(!isset($return[0])){ - return false; - } return $return; } @@ -572,16 +573,6 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend * * Note: All "unknown" data are marked as NULL * Warning: Be careful with the amount of data, check your RAM size available - * We'll return a bidimensional array - * Structure returned: schema: - * - * uncompressed_data => - * pool_id (int) - * utimestamp (start of current slice) - * data - * array - * datos - * utimestamp * */ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false) { @@ -591,6 +582,17 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f return false; } + if ((!isset($tstart)) || ($tstart === false)) { + // Return data from the begining + // Get first available utimestamp in active DB + $query_first_man_time = " SELECT utimestamp FROM tagente_datos "; + $query_first_man_time .= " WHERE id_agente_modulo = $id_agente_modulo"; + $query_first_man_time .= " ORDER BY utimestamp ASC LIMIT 1"; + + $first_man_time = db_get_all_rows_sql( $query_first_man_time, false); + $tstart = $first_man_time[0]['utimestamp']; + } + if ((!isset($tend)) || ($tend === false)) { // Return data until now $tend = time(); @@ -614,202 +616,266 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f $table = "tagente_datos_string"; } - $result = modules_get_first_date($id_agente_modulo,$tstart); - $first_utimestamp = $result["first_utimestamp"]; - $search_historydb = $result["search_historydb"]; + // Get first available utimestamp in active DB + $query = " SELECT utimestamp, datos FROM $table "; + $query .= " WHERE id_agente_modulo=$id_agente_modulo AND utimestamp < $tstart"; + $query .= " ORDER BY utimestamp DESC LIMIT 1"; - if ($first_utimestamp === false) { - $first_data["utimestamp"] = $tstart; + $ret = db_get_all_rows_sql( $query , $search_historydb); + + if ( ( $ret === false ) || (( isset($ret[0]["utimestamp"]) && ($ret[0]["utimestamp"] > $tstart )))) { + // Value older than first retrieved from active DB + $search_historydb = true; + + $ret = db_get_all_rows_sql( $query , $search_historydb); + + if ($ret) { + $tstart = $ret[0]["utimestamp"]; + } + } + else { + $first_data["utimestamp"] = $ret[0]["utimestamp"]; + $first_data["datos"] = $ret[0]["datos"]; + } + + if ( ( $ret === false ) || (( isset($ret[0]["utimestamp"]) && ($ret[0]["utimestamp"] > $tstart )))) { + // No previous data. -> not init + // Avoid false unknown status + $first_data["utimestamp"] = time(); $first_data["datos"] = false; } else { - $query = "SELECT datos,utimestamp FROM $table "; - $query .= " WHERE id_agente_modulo=$id_agente_modulo "; - $query .= " AND utimestamp=" . $first_utimestamp; - - $data = db_get_all_rows_sql($query,$search_historydb); - - if ($data === false) { - // first utimestamp not found in active database - // SEARCH HISTORY DB - $search_historydb = true; - $data = db_get_all_rows_sql($query,$search_historydb); - } - - if ($data === false) { // Not init - $first_data["utimestamp"] = $tstart; - $first_data["datos"] = false; - } - else { - $first_data["utimestamp"] = $data[0]["utimestamp"]; - $first_data["datos"] = $data[0]["datos"]; - - } + $first_data["utimestamp"] = $ret[0]["utimestamp"]; + $first_data["datos"] = $ret[0]["datos"]; } $query = " SELECT utimestamp, datos FROM $table "; $query .= " WHERE id_agente_modulo=$id_agente_modulo AND utimestamp >= $tstart AND utimestamp <= $tend"; $query .= " ORDER BY utimestamp ASC"; + // Retrieve all data from module in given range $raw_data = db_get_all_rows_sql($query, $search_historydb); - $module_interval = modules_get_interval ($id_agente_modulo); - - if (($raw_data === false) && ( ($first_utimestamp < $tstart - (SECONDS_1DAY + 2*$module_interval)) ) ) { + if (($raw_data === false) && ($ret === false)) { // No data return false; } // Retrieve going unknown events in range - $unknown_events = db_get_module_ranges_unknown($id_agente_modulo, $tstart, $tend, $search_historydb); - - $previous_unknown_events = db_get_module_ranges_unknown( - $id_agente_modulo, - $tstart - (SECONDS_1DAY + 2*$module_interval), - $tstart, - $search_historydb - ); - - //don't show graph if graph is inside unknown - if( $previous_unknown_events && - !isset($previous_unknown_events[count($previous_unknown_events) -1]['time_to']) && - $unknown_events === false && $raw_data === false){ - return false; - } - - //if time to is missing in last event force time to outside range time - if( $unknown_events && !isset($unknown_events[count($unknown_events) -1]['time_to']) ){ - $unknown_events[count($unknown_events) -1]['time_to'] = $tend + $module_interval; - } - - //if time to is missing in first event force time to outside range time - if ($first_data["datos"] === false) { - $last_inserted_value = false; - }elseif( $unknown_events && !isset($unknown_events[0]['time_from']) || - $first_utimestamp < $tstart - (SECONDS_1DAY + 2*$module_interval) ){ - $last_inserted_value = null; - } - else{ - $last_inserted_value = $first_data["datos"]; - } + $unknown_events = db_get_module_ranges_unknown($id_agente_modulo, $tstart, $tend); // Retrieve module_interval to build the template + $module_interval = modules_get_interval ($id_agente_modulo); $slice_size = $module_interval; + // We'll return a bidimensional array + // Structure returned: schema: + // + // uncompressed_data => + // pool_id (int) + // utimestamp (start of current slice) + // data + // array + // utimestamp + // datos + $return = array(); // Point current_timestamp to begin of the set and initialize flags $current_timestamp = $tstart; + $last_inserted_value = $first_data["datos"]; $last_timestamp = $first_data["utimestamp"]; - $last_value = $first_data["datos"]; + $data_found = 0; // Build template $pool_id = 0; $now = time(); - $current_unknown = array_shift($unknown_events); - $current_raw_data = array_shift($raw_data); - + $in_unknown_status = 0; + if (is_array($unknown_events)) { + $current_unknown = array_shift($unknown_events); + } while ( $current_timestamp < $tend ) { + $expected_data_generated = 0; + $return[$pool_id]["data"] = array(); $tmp_data = array(); - $current_timestamp_end = $current_timestamp + $slice_size; + $data_found = 0; - if ( ( $current_timestamp > $now) || - ( ($current_timestamp_end - $last_timestamp) > - (SECONDS_1DAY + 2*$module_interval) ) ) { - $tmp_data["utimestamp"] = $last_timestamp + SECONDS_1DAY + 2*$module_interval; - - //check not init - $tmp_data["datos"] = $last_value === false ? false : null; - - // debug purpose - //$tmp_data["obs"] = "unknown extra"; - array_push($return[$pool_id]["data"], $tmp_data); - } - - //insert first slice data - $tmp_data["utimestamp"] = $current_timestamp; - $tmp_data["datos"] = $last_inserted_value; - // debug purpose - //$tmp_data["obs"] = "virtual data"; - - $return[$pool_id]["utimestamp"] = $current_timestamp; - array_push($return[$pool_id]["data"], $tmp_data); - - //insert raw data - while ( ($current_raw_data != null) && - ( ($current_timestamp_end >= $current_raw_data['utimestamp']) && - ($current_timestamp < $current_raw_data['utimestamp']) ) ) { - - // Add unknown state detected - $tmp_data["utimestamp"] = $current_raw_data["utimestamp"]; - $tmp_data["datos"] = $current_raw_data["datos"]; - // debug purpose - //$tmp_data["obs"] = "real data"; - array_push($return[$pool_id]["data"], $tmp_data); - - $last_value = $current_raw_data["datos"]; - $last_timestamp = $current_raw_data["utimestamp"]; - $current_raw_data = array_shift($raw_data); - } - - //unknown - $data_slices = $return[$pool_id]["data"]; - while ( ($current_unknown != null) && - ( ( ($current_unknown['time_from'] != null) && - ($current_timestamp_end >= $current_unknown['time_from']) ) || - ($current_timestamp_end >= $current_unknown['time_to']) ) ) { - - if( ( $current_timestamp <= $current_unknown['time_from']) && - ( $current_timestamp_end >= $current_unknown['time_from'] ) ){ - // Add unknown state detected - $tmp_data["utimestamp"] = $current_unknown["time_from"]; - $tmp_data["datos"] = null; - // debug purpose - //$tmp_data["obs"] = "event data unknown from"; - array_push($return[$pool_id]["data"], $tmp_data); - $current_unknown["time_from"] = null; - } - - if( ($current_timestamp < $current_unknown['time_to']) && - ($current_timestamp_end >= $current_unknown['time_to'] ) ){ - $tmp_data["utimestamp"] = $current_unknown["time_to"]; - $i = count($data_slices) - 1; - while ($i >= 0) { - if($data_slices[$i]['utimestamp'] <= $current_unknown["time_to"]){ - $tmp_data["datos"] = - $data_slices[$i]['datos'] == null - ? $last_value - : $data_slices[$i]['datos']; - break; - } - $i--; + if (is_array($unknown_events)) { + $i = 0; + while ($current_timestamp >= $unknown_events[$i]["time_to"] ) { + // Skip unknown events in past + array_splice($unknown_events, $i,1); + $i++; + if (!isset($unknown_events[$i])) { + break; } - - // debug purpose - //$tmp_data["obs"] = "event data unknown to"; - array_push($return[$pool_id]["data"], $tmp_data); - $current_unknown = array_shift($unknown_events); } + if (isset($current_unknown)) { + + // check if recovered from unknown status + if(is_array($unknown_events) && isset($current_unknown)) { + if ( (($current_timestamp+$slice_size) > $current_unknown["time_to"]) + && ($current_timestamp < $current_unknown["time_to"]) + && ($in_unknown_status == 1) ) { + // Recovered from unknown + + if ( ($current_unknown["time_to"] > $current_timestamp) + && ($expected_data_generated == 0) ) { + // also add the "expected" data + $tmp_data["utimestamp"] = $current_timestamp; + if ($in_unknown_status == 1) { + $tmp_data["datos"] = null; + } + else { + $tmp_data["datos"] = $last_inserted_value; + } + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + $expected_data_generated = 1; + } + + + $tmp_data["utimestamp"] = $current_unknown["time_to"]; + $tmp_data["datos"] = $last_inserted_value; + // debug purpose + //$tmp_data["obs"] = "event recovery data"; + + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + $data_found = 1; + $in_unknown_status = 0; + } + + if ( (($current_timestamp+$slice_size) > $current_unknown["time_from"]) + && (($current_timestamp+$slice_size) < $current_unknown["time_to"]) + && ($in_unknown_status == 0) ) { + // Add unknown state detected + + if ( $current_unknown["time_from"] < ($current_timestamp+$slice_size)) { + if ( ($current_unknown["time_from"] > $current_timestamp) + && ($expected_data_generated == 0) ) { + // also add the "expected" data + $tmp_data["utimestamp"] = $current_timestamp; + if ($in_unknown_status == 1) { + $tmp_data["datos"] = null; + } + else { + $tmp_data["datos"] = $last_inserted_value; + } + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + $expected_data_generated = 1; + } + + $tmp_data["utimestamp"] = $current_unknown["time_from"]; + $tmp_data["datos"] = null; + // debug purpose + //$tmp_data["obs"] = "event data"; + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + $data_found = 1; + } + $in_unknown_status = 1; + } + + if ( ($in_unknown_status == 0) && ($current_timestamp >= $current_unknown["time_to"]) ) { + $current_unknown = array_shift($unknown_events); + } + } + } // unknown events handle } - //sort current slice - usort( - $return[$pool_id]['data'], - function ($a, $b) { - if ($a['utimestamp'] == $b['utimestamp']) return 0; - return ($a['utimestamp'] < $b['utimestamp']) ? -1 : 1; + // Search for data + $i=0; + if (is_array($raw_data)) { + foreach ($raw_data as $data) { + if ( ($data["utimestamp"] >= $current_timestamp) + && ($data["utimestamp"] < ($current_timestamp+$slice_size)) ) { + // Data in block, push in, and remove from $raw_data (processed) + + if ( ($data["utimestamp"] > $current_timestamp) + && ($expected_data_generated == 0) ) { + // also add the "expected" data + $tmp_data["utimestamp"] = $current_timestamp; + if ($in_unknown_status == 1) { + $tmp_data["datos"] = null; + } + else { + $tmp_data["datos"] = $last_inserted_value; + } + //$tmp_data["obs"] = "expected data"; + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + $expected_data_generated = 1; + } + + $tmp_data["utimestamp"] = intval($data["utimestamp"]); + $tmp_data["datos"] = $data["datos"]; + // debug purpose + //$tmp_data["obs"] = "real data"; + + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + + $last_inserted_value = $data["datos"]; + $last_timestamp = intval($data["utimestamp"]); + + unset($raw_data[$i]); + $data_found = 1; + $in_unknown_status = 0; + } + elseif ($data["utimestamp"] > ($current_timestamp+$slice_size)) { + // Data in future, stop searching new ones + break; + } } - ); - //put the last slice data like first element of next slice - $last_inserted_value = end($return[$pool_id]['data']); - $last_inserted_value = $last_inserted_value['datos']; - - //increment + $i++; + } + + if ($data_found == 0) { + // No data found, lug the last_value until SECONDS_1DAY + 2*modules_get_interval + // UNKNOWN! + + if (($current_timestamp > $now) || (($current_timestamp - $last_timestamp) > (SECONDS_1DAY + 2*$module_interval))) { + if (isset($last_inserted_value)) { + // unhandled unknown status control + $unhandled_time_unknown = $current_timestamp - (SECONDS_1DAY + 2*$module_interval) - $last_timestamp; + if ($unhandled_time_unknown > 0) { + // unhandled unknown status detected. Add to previous pool + $tmp_data["utimestamp"] = intval($last_timestamp) + (SECONDS_1DAY + 2*$module_interval); + $tmp_data["datos"] = null; + // debug purpose + //$tmp_data["obs"] = "unknown extra"; + // add to previous pool if needed + if (isset($return[$pool_id-1])) { + array_push($return[$pool_id-1]["data"], $tmp_data); + } + } + } + $last_inserted_value = null; + } + + $tmp_data["utimestamp"] = $current_timestamp; + + if ($in_unknown_status == 1) { + $tmp_data["datos"] = null; + } + else { + $tmp_data["datos"] = $last_inserted_value; + } + // debug purpose + //$tmp_data["obs"] = "virtual data"; + + $return[$pool_id]["utimestamp"] = $current_timestamp; + array_push($return[$pool_id]["data"], $tmp_data); + } + $pool_id++; - $current_timestamp = $current_timestamp_end; + $current_timestamp += $slice_size; } + return $return; } diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 1297ea50b2..a27d7d2ec2 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -151,7 +151,7 @@ if ($upload_file) { check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { + if (! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access File manager"); require ("general/noaccess.php"); return; @@ -219,7 +219,7 @@ if ($create_text_file) { check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { + if (! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access File manager"); require ("general/noaccess.php"); return; @@ -279,7 +279,7 @@ if ($upload_zip) { check_login (); - if (! check_acl ($config['id_user'], 0, "PM")) { + if (! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", "Trying to access File manager"); require ("general/noaccess.php"); return; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c91e71c07a..3a063da403 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -550,6 +550,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $datelimit = $date - $period; $search_in_history_db = db_search_in_history_db($datelimit); + + if($force_interval){ $resolution = $period/$time_interval; } @@ -580,29 +582,18 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, // Get event data (contains alert data too) $events = array(); if ($show_unknown == 1 || $show_events == 1 || $show_alerts == 1) { - $events = db_get_all_rows_filter ( - 'tevento', + $events = db_get_all_rows_filter ('tevento', array ('id_agentmodule' => $agent_module_id, "utimestamp > $datelimit", "utimestamp < $date", 'order' => 'utimestamp ASC'), - array ('id_evento', 'evento', 'utimestamp', 'event_type'), - 'AND', - $search_in_history_db - ); + array ('id_evento', 'evento', 'utimestamp', 'event_type')); // Get the last event after inverval to know if graph start on unknown - $prev_event = db_get_row_filter ( - 'tevento', + $prev_event = db_get_row_filter ('tevento', array ('id_agentmodule' => $agent_module_id, "utimestamp <= $datelimit", - 'order' => 'utimestamp DESC' - ), - false, - 'AND', - $search_in_history_db - ); - + 'order' => 'utimestamp DESC')); if (isset($prev_event['event_type']) && $prev_event['event_type'] == 'going_unknown') { $start_unknown = true; } @@ -1123,7 +1114,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $labels = array(), $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false, - $id_widget_dashboard=false, $fullscale = false, $summatory = 0, $average = 0) { + $id_widget_dashboard=false, $fullscale = false) { global $config; global $graphic_type; @@ -1131,6 +1122,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, if(!$fullscale){ $time_format_2 = ''; $temp_range = $period; + $unit_list_aux = array(); if ($projection != false) { if ($period < $prediction_period) @@ -1213,8 +1205,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $weight_list[$i] = 1; } } - - $aux_array = array(); + // Set data containers for ($i = 0; $i < $resolution; $i++) { $timestamp = $datelimit + ($interval * $i);/* @@ -1266,12 +1257,12 @@ function graphic_combined_module ($module_list, $weight_list, $period, // If its a projection graph, // first module will be data and second will be the projection - if ($projection != false && $i != 0) { if ($automatic_custom_graph_meta) $agent_module_id = $module_list[0]['module']; else $agent_module_id = $module_list[0]; + $id_module_type = modules_get_agentmodule_type ($agent_module_id); $module_type = modules_get_moduletype_name ($id_module_type); $uncompressed_module = is_module_uncompressed ($module_type); @@ -1282,6 +1273,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, else $agent_module_id = $module_list[$i]; + $id_module_type = modules_get_agentmodule_type ($agent_module_id); $module_type = modules_get_moduletype_name ($id_module_type); $uncompressed_module = is_module_uncompressed ($module_type); @@ -1379,6 +1371,10 @@ function graphic_combined_module ($module_list, $weight_list, $period, $agent_id = agents_get_agent_id ($agent_name); + if(empty($unit_list)){ + $unit_aux = modules_get_unit($agent_module_id); + array_push($unit_list_aux,$unit_aux); + } //Get and process module name $module_name = io_safe_output( modules_get_agentmodule_name ($agent_module_id)); @@ -1562,6 +1558,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) { $unit = $unit_list[$i]; + }else{ + $unit = $unit_list_aux[$i]; } if ($projection == false or ($projection != false and $i == 0)) { @@ -2116,37 +2114,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $threshold_data['red_inverse'] = (bool)$red_inverse; } } - - //summatory and average series - if($stacked == CUSTOM_GRAPH_AREA || $stacked == CUSTOM_GRAPH_LINE) { - if($summatory && $average){ - foreach ($graph_values as $key => $value) { - $cont = count($value); - $summ = array_sum($value); - array_push($value,$summ); - array_push($value,$summ/$cont); - $graph_values[$key] = $value; - } - array_push($module_name_list,'' . __('summatory'). ''); - array_push($module_name_list,'' . __('average'). ''); - - } elseif($summatory) { - foreach ($graph_values as $key => $value) { - array_push($value,array_sum($value)); - $graph_values[$key] = $value; - } - array_push($module_name_list,'' . __('summatory'). ''); - - } elseif($average) { - foreach ($graph_values as $key => $value) { - $summ = array_sum($value) / count($value); - array_push($value,$summ); - $graph_values[$key] = $value; - } - array_push($module_name_list,'' . __('average'). ''); - } - } - + switch ($stacked) { case CUSTOM_GRAPH_AREA: return area_graph($flash_charts, $graph_values, $width, @@ -3986,33 +3954,22 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, if ($uncompressed_module) { $avg_only = 1; } + $search_in_history_db = db_search_in_history_db($datelimit); // Get event data (contains alert data too) if ($show_unknown == 1 || $show_events == 1 || $show_alerts == 1) { - $events = db_get_all_rows_filter( - 'tevento', + $events = db_get_all_rows_filter('tevento', array ('id_agentmodule' => $agent_module_id, "utimestamp > $datelimit", "utimestamp < $date", - 'order' => 'utimestamp ASC' - ), - array ('evento', 'utimestamp', 'event_type', 'id_evento'), - 'AND', - $search_in_history_db - ); + 'order' => 'utimestamp ASC'), + array ('evento', 'utimestamp', 'event_type', 'id_evento')); // Get the last event after inverval to know if graph start on unknown - $prev_event = db_get_row_filter ( - 'tevento', + $prev_event = db_get_row_filter ('tevento', array ('id_agentmodule' => $agent_module_id, "utimestamp <= $datelimit", - 'order' => 'utimestamp DESC' - ), - false, - 'AND', - $search_in_history_db - ); - + 'order' => 'utimestamp DESC')); if (isset($prev_event['event_type']) && $prev_event['event_type'] == 'going_unknown') { $start_unknown = true; } @@ -4117,7 +4074,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $zero = 0; $total = 0; $count = 0; - + $is_unknown = false; // Read data that falls in the current interval while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && @@ -4150,7 +4107,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, // Is the first point of a unknown interval $first_unknown = false; - $check_unknown = false; + $event_ids = array(); $alert_ids = array(); while (isset ($events[$k]) && @@ -4169,15 +4126,10 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, if ($is_unknown == false) { $first_unknown = true; } - else{ - $first_unknown = false; - } - $check_unknown = true; $is_unknown = true; } else if (substr ($events[$k]['event_type'], 0, 5) == 'going') { $is_unknown = false; - $first_unknown = false; } } $k++; @@ -4260,12 +4212,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $chart[$timestamp]['unknown'.$series_suffix] = 0; } $chart[$timestamp]['unknown'.$series_suffix] = $unknown_value; - - if($unknown_value == 0 && $check_unknown == true){ - $chart[$timestamp]['unknown'.$series_suffix] = 1; - $check_unknown = false; - } - $series_type['unknown'.$series_suffix] = 'area'; } @@ -4396,138 +4342,165 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index, global $min_value; global $series_type; global $chart_extra_data; + + $ranges_unknown = db_get_module_ranges_unknown($agent_module_id, $datelimit, $date); - $first_data = 0; + $table = "tagente_datos"; + $module_type_str = modules_get_type_name ($agent_module_id); + if (strstr ($module_type_str, 'string') !== false) { + $table = "tagente_datos_string"; + } + $query = " SELECT utimestamp, datos FROM $table "; + $query .= " WHERE id_agente_modulo=$agent_module_id "; + $query .= " ORDER BY utimestamp ASC LIMIT 1"; + + $ret = db_get_all_rows_sql( $query , true); + + $first_data = $ret[0]['utimestamp']; $data_uncompress = db_uncompress_module_data($agent_module_id, $datelimit, $date); - - $chart_data = array(); - - $min_value = PHP_INT_MAX-1; - $max_value = PHP_INT_MIN+1; - $previous_data = $first_data; - $previous_unknown = 0; - - $i=0; - $current_event = $events[0]; - $prueba = array(); - foreach ($data_uncompress as $k) { - foreach ($k["data"] as $v) { - $real_date = date("Y M d H:i:s", $v['utimestamp']); - - if(!$flash_chart){ - $real_date = date("Y/M/d", $v['utimestamp']); - $real_date .= "\n"; - $real_date .= date(" H:i:s", $v['utimestamp']); - } - - $event_ids = array(); - $alert_ids = array(); - while (isset($current_event) && ($v['utimestamp'] >= $current_event["utimestamp"]) ) { - $event_date = date("Y M d H:i:s", $current_event['utimestamp']); + $i = 0; + $max_value = 0; + $min_value = 0; + $timestamp_second = 0; + if(is_array($data_uncompress)){ + foreach ($data_uncompress as $v) { + foreach ($v['data'] as $key => $value) { + $real_date = date("Y M d H:i:s", $value['utimestamp']); if(!$flash_chart){ - $event_date = date("Y/M/d", $current_event['utimestamp']); - $event_date .= "\n"; - $event_date .= date(" H:i:s", $current_event['utimestamp']); + $real_date = date("Y/M/d", $value['utimestamp']); + $real_date .= "\n"; + $real_date .= date(" H:i:s", $value['utimestamp']); } - - if ($show_events && (strpos($current_event["event_type"], "going") !== false)) { - $event_ids[$event_date][] = $current_event["id_evento"]; - - $chart_data[$event_date]["event" . $series_suffix] = 1; - $chart_data[$event_date]["alert" . $series_suffix] = NULL; - $chart_extra_data[count($chart_data)-1]['events'] = implode (',', $event_ids[$event_date]); + // Read events and alerts that fall in the current interval + $event_value = 0; + $alert_value = 0; + $unknown_value = 0; + $event_i = 0; + // Is the first point of a unknown interval + $first_unknown = false; + + $event_ids = array(); + $alert_ids = array(); + + // + if($timestamp_second == 0){ + $timestamp_second = $value['utimestamp']; } - elseif ($show_alerts && (strpos($current_event["event_type"], "alert") !== false)) { - $alert_ids[$event_date][] = $current_event["id_evento"]; - - $chart_data[$event_date]["event" . $series_suffix] = NULL; - $chart_data[$event_date]["alert" . $series_suffix] = 1; - $chart_extra_data[count($chart_data)-1]['alerts'] = implode (',', $alert_ids[$event_date]); + $timestamp_first = $timestamp_second; + $timestamp_second = $value['utimestamp']; + + foreach ($events as $key => $val) { + if( $val['utimestamp'] > $timestamp_first && + $val['utimestamp'] <= $timestamp_second ){ + if ($show_events == 1) { + $event_ids[] = $val['id_evento']; + $event_value++; + } + if ($show_alerts == 1 && substr ($val['event_type'], 0, 5) == 'alert') { + $alert_ids[] = $val['id_evento']; + $alert_value++; + } + if ($show_unknown) { + if ($val['event_type'] == 'going_unknown') { + if ($is_unknown == false) { + $first_unknown = true; + } + $is_unknown = true; + } + else if (substr ($val['event_type'], 0, 5) == 'going') { + $is_unknown = false; + } + } + } + } + + if(empty($value['datos'])){ + if($value['utimestamp'] < $first_data){ + //$chart_data[$real_date]['unknown'.$series_suffix] = 0; + $is_unknown = false; + } + else{ + //$chart_data[$real_date]['unknown'.$series_suffix] = 1; + $first_unknown = true; + } + } + + $timestamp_short = date("Y M d H:i:s", $value['utimestamp']); + + if(!$flash_chart){ + $timestamp_short = date("Y/M/d", $value['utimestamp']); + $timestamp_short .= "\n"; + $timestamp_short .= date(" H:i:s", $value['utimestamp']); + } + + + $long_index[$timestamp_short] = date( + html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $value['utimestamp']); + // In some cases, can be marked as known because a recovery event + // was found in same interval. For this cases first_unknown is + // checked too + if ($is_unknown || $first_unknown) { + $unknown_value++; + } + + // Data + if ($show_events) { + if (!isset($chart_data[$real_date]['event'.$series_suffix])) { + $chart_data[$real_date]['event'.$series_suffix] = 0; + } + + $chart_data[$real_date]['event'.$series_suffix] += $event_value; + + $series_type['event'.$series_suffix] = 'points'; + } + + if ($show_alerts) { + if (!isset($chart_data[$real_date]['alert'.$series_suffix])) { + $chart_data[$real_date]['alert'.$series_suffix] = 0; + } + + $chart_data[$real_date]['alert'.$series_suffix] += $alert_value; + + $series_type['alert'.$series_suffix] = 'points'; + } + + $chart_data[$real_date]['sum'.$series_suffix] = $value['datos']; + + if($value['datos'] > $max_value){ + $max_value = $value['datos']; + } + + if($value['datos'] < $min_value){ + $min_value = $value['datos']; } - $chart_data[$event_date]["sum" . $series_suffix] = $previous_data; - if($show_unknown) { - $chart_data[$event_date]["unknown" . $series_suffix] = $previous_unknown; - } - $current_event = $events[$i++]; - } - - if ($v["datos"] === NULL) { - // Unknown - if (!isset($chart_data[$real_date]["event" . $series_suffix])) { - if($show_events) { - $chart_data[$real_date]["event" . $series_suffix] = NULL; - } - if($show_alerts) { - $chart_data[$real_date]["alert" . $series_suffix] = NULL; - } - } - - $chart_data[$real_date]["sum" . $series_suffix] = $previous_data; - if($show_unknown) { - $chart_data[$real_date]["unknown" . $series_suffix] = "1"; - } - $previous_unknown = "1"; - } - elseif($v["datos"] === false) { - // Not Init - $previous_data = $v["datos"]; - if (!isset($chart_data[$real_date]["event" . $series_suffix])) { - if ($show_events) { - $chart_data[$real_date]["event" . $series_suffix] = NULL; - } - if ($show_alerts) { - $chart_data[$real_date]["alert" . $series_suffix] = NULL; - } + if ($show_unknown) { + if (!isset($chart_data[$real_date]['unknown'.$series_suffix])) { + $chart_data[$real_date]['unknown'.$series_suffix] = 0; + } + $chart_data[$real_date]['unknown'.$series_suffix] = $unknown_value; + $series_type['unknown'.$series_suffix] = 'area'; } - $chart_data[$real_date]["sum" . $series_suffix] = $v["datos"]; - - if($v['datos'] >= $max_value){ - $max_value = $v['datos']; + if (!empty($event_ids)) { + $chart_extra_data[count($chart_data)-1]['events'] = implode(',',$event_ids); } - - if($v['datos'] <= $min_value){ - $min_value = $v['datos']; - } - - if($show_unknown) { - $chart_data[$real_date]["unknown" . $series_suffix] = NULL; - $previous_unknown = NULL; + if (!empty($alert_ids)) { + $chart_extra_data[count($chart_data)-1]['alerts'] = implode(',',$alert_ids); } } - else { - $previous_data = $v["datos"]; - if (!isset($chart_data[$real_date]["event" . $series_suffix])) { - if ($show_events) { - $chart_data[$real_date]["event" . $series_suffix] = NULL; - } - if ($show_alerts) { - $chart_data[$real_date]["alert" . $series_suffix] = NULL; - } - } - - $chart_data[$real_date]["sum" . $series_suffix] = $v["datos"]; - - if($v['datos'] >= $max_value){ - $max_value = $v['datos']; - } - - if($v['datos'] <= $min_value){ - $min_value = $v['datos']; - } - - if($show_unknown) { - $chart_data[$real_date]["unknown" . $series_suffix] = NULL; - $previous_unknown = NULL; - } - } + } + + if (!is_null($percentil) && $percentil) { + $avg = array_map(function($item) { return $item['sum']; }, $chart_data); + $percentil_result = get_percentile($percentil, $avg); + //Fill the data of chart + array_walk($chart_data, function(&$item) use ($percentil_result, $series_suffix) { + $item['percentil' . $series_suffix] = $percentil_result; }); + $series_type['percentil' . $series_suffix] = 'line'; } } - $series_type['event'.$series_suffix] = 'points'; - $series_type['alert'.$series_suffix] = 'points'; - $series_type['unknown'.$series_suffix] = 'area'; } function grafico_modulo_boolean ($agent_module_id, $period, $show_events, @@ -5836,17 +5809,40 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false; - $groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); + if ($filter['group'] != 0) { + $groups = db_get_all_rows_sql ("SELECT * FROM tgrupo where id_grupo = " . $filter['group'] . " || parent = " . $filter['group']); + $groups_ax = array(); + foreach ($groups as $g) { + $groups_ax[$g['id_grupo']] = $g; + } + + $groups = $groups_ax; + } + else { + $groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); + } + $data_groups = array(); if (!empty($groups)) { $groups_aux = $groups; - $data_groups = groups_get_tree($groups); + + //$data_groups = groups_get_tree($groups); + + $childrens = array(); + $data_groups = groups_get_tree_good($groups, false, $childrens); + foreach ($childrens as $id_c) { + unset($data_groups[$id_c]); + } + $data_groups_keys = array(); + groups_get_tree_keys($data_groups, $data_groups_keys); + $groups_aux = null; } if (!empty($data_groups)) { - $filter = array('id_grupo' => array_keys($data_groups)); + $filter = array('id_grupo' => array_keys($data_groups_keys)); + $fields = array('id_agente', 'id_parent', 'id_grupo', 'alias'); $agents = agents_get_agents($filter, $fields); @@ -6063,7 +6059,6 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { } function iterate_group_array ($groups, &$data_agents) { - $data = array(); foreach ($groups as $id => $group) { @@ -6100,8 +6095,8 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . " " . __('Group') . ": " . $group_aux['name'] . ""; $group_aux['tooltip_content'] = $tooltip_content; - if (!isset($group['children'])) - $group_aux['children'] = array(); + $group_aux['children'] = array(); + if (!empty($group['children'])) $group_aux['children'] = iterate_group_array($group['children'], $data_agents); @@ -6109,7 +6104,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { if (!empty($agents)) $group_aux['children'] = array_merge($group_aux['children'], $agents); - + $data[] = $group_aux; } @@ -6124,6 +6119,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { unset($agents[$id]); } } + if (!empty($valid_agents)) return $valid_agents; else @@ -6131,7 +6127,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { } $graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents), 'color' => '#3F3F3F'); - + if (empty($graph_data['children'])) return fs_error_image(); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 757e5014d5..db046c09be 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2241,6 +2241,9 @@ function groups_get_tree(&$groups, $parent = false) { if (!empty($children)) { $return[$id]['children'] = $children; } + else { + $return[$id]['children'] = array(); + } } else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { $return[$id] = $group; @@ -2250,6 +2253,9 @@ function groups_get_tree(&$groups, $parent = false) { if (!empty($children)) { $return[$id]['children'] = $children; } + else { + $return[$id]['children'] = array(); + } } else { continue; @@ -2258,6 +2264,55 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + +function groups_get_tree_good (&$groups, $parent = false, &$childs) { + $return = array(); + + foreach ($groups as $id => $group) { + if ($group['parent'] != 0) { + $childs[$id] = $id; + } + if ($parent === false && (!isset($group['parent']) || $group['parent'] == 0 || !in_array($group['parent'], $groups))) { + $return[$id] = $group; + //unset($groups[$id]); + $children = groups_get_tree_good($groups, $id); + + if (!empty($children)) { + $return[$id]['children'] = $children; + } + else { + $return[$id]['children'] = array(); + } + } + else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { + $return[$id] = $group; + //unset($groups[$id]); + $children = groups_get_tree_good($groups, $id); + + if (!empty($children)) { + $return[$id]['children'] = $children; + } + else { + $return[$id]['children'] = array(); + } + } + else { + continue; + } + } + + return $return; +} + +function groups_get_tree_keys ($groups, &$group_keys) { + foreach ($groups as $id => $group) { + $group_keys[$id] = $id; + if (isset($group['children'])) { + groups_get_tree_keys($groups[$id]['children'], $group_keys); + } + } +} + function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { global $config; @@ -2289,6 +2344,8 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { return $hierarchy; } + + function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) { global $config; if ($id_user == false) { @@ -3036,4 +3093,5 @@ function groups_get_group_deep ($id_group) { return $deep; } + ?> diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 03f63e624c..e46334dbef 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -987,6 +987,28 @@ function modules_is_string($id_agentmodule) { return modules_is_string_type($id_type); } + +/** + * Know if a module type is a boolean or not + * + * @param int $id_type Type id + * + * @return bool true if boolean. false if not + */ +function modules_is_boolean_type ($id_type) { + $type_name = modules_get_type_name($id_type); + + return (bool)preg_match('/_proc$/', $type_name); +} + +function modules_is_boolean($id_agentmodule) { + $id_type = db_get_value('id_tipo_modulo', + 'tagente_modulo', 'id_agente_modulo', + (int) $id_agentmodule); + + return modules_is_boolean_type($id_type); +} + /** * Get the icon of a module type * @@ -1716,11 +1738,19 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) * @param int Agent module id * @param int Period of time to check (in seconds) * @param int Top date to check the values. Default current time. + * @param + * @param + * @param string 'ASC' od 'DESC' + * @param string with a json with parameters to filter data + * string object: + * value: Text to search + * exact: Boolean. True if search exact phrase or false to content * * @return array The module value and the timestamp */ function modules_get_agentmodule_data ($id_agent_module, $period, - $date = 0, $trash=false, $conexion = false, $order = 'ASC') { + $date = 0, $trash=false, $conexion = false, $order = 'ASC', + $freesearch = '') { global $config; $module = db_get_row('tagente_modulo', 'id_agente_modulo', @@ -1742,12 +1772,28 @@ function modules_get_agentmodule_data ($id_agent_module, $period, case 17: //async_string case 23: - $sql = sprintf ("SELECT datos AS data, utimestamp - FROM tagente_datos_string - WHERE id_agente_modulo = %d - AND utimestamp > %d AND utimestamp <= %d - ORDER BY utimestamp %s", - $id_agent_module, $datelimit, $date, $order); + // Free search is a json with value and exact modifier + $freesearch = json_decode($freesearch, true); + $freesearch_sql = ''; + if (isset($freesearch['value']) && !empty($freesearch['value'])) { + $freesearch_sql = " AND datos "; + if ($freesearch['exact']){ + $freesearch_sql .= "='" . $freesearch['value'] . "' "; + } else { + $freesearch_sql .= " LIKE '%" . $freesearch['value'] . "%' "; + } + } + $sql = sprintf ( + "SELECT datos AS data, utimestamp FROM tagente_datos_string + WHERE id_agente_modulo = %d + %s + AND utimestamp > %d AND utimestamp <= %d + ORDER BY utimestamp %s", + $id_agent_module, + $freesearch_sql, + $datelimit, $date, + $order + ); break; //log4x case 24: @@ -2261,53 +2307,50 @@ function modules_change_relation_lock ($id_relation) { return ($result !== false ? $new_value : $old_value); } -/* - * @return utimestamp with the first contact of the module or first contact before datelimit, false if not-init - */ -function modules_get_first_date($id_agent_module, $datelimit = 0) { + + +function modules_get_count_datas($id_agent_module, $date_init, $date_end) { + $interval = modules_get_interval ($id_agent_module); + + // TODO REMOVE THE TIME IN PLANNED DOWNTIME + + if (!is_numeric($date_init)) { + $date_init = strtotime($date_init); + } + + if (!is_numeric($date_end)) { + $date_end = strtotime($date_end); + } + + + + $first_date = modules_get_first_contact_date($id_agent_module); + + + + if ($date_init < $first_date) { + $date_init = $first_date; + } + + $diff = $date_end - $date_init; + + + return ($diff / $interval); +} + + +function modules_get_first_contact_date($id_agent_module) { global $config; - //check datatype string or normal - $table = "tagente_datos"; - $module_type_str = modules_get_type_name ($id_agent_module); - if (strstr ($module_type_str, 'string') !== false) { - $table = "tagente_datos_string"; - } - - $search_historydb = false; - - // tagente_estado.first_utimestamp is not valid or is not updated. Scan DBs for first utimestamp - if ($datelimit > 0) { - // get last data before datelimit - $query = " SELECT max(utimestamp) as utimestamp FROM $table "; - $query .= " WHERE id_agente_modulo=$id_agent_module "; - $query .= " AND utimestamp < $datelimit "; + // TODO REMOVE THE TIME IN PLANNED DOWNTIME - } - else { - // get first utimestamp - $query = " SELECT min(utimestamp) as utimestamp FROM $table "; - $query .= " WHERE id_agente_modulo=$id_agent_module "; - } + // TODO FOR OTHER KIND OF DATA - - // SEARCH ACTIVE DB - $data = db_get_all_rows_sql($query,$search_historydb); - if (($data === false) || ($data[0]["utimestamp"] === NULL) || ($data[0]["utimestamp"] <= 0)) { - // first utimestamp not found in active database - // SEARCH HISTORY DB - $search_historydb = true; - $data = db_get_all_rows_sql($query,$search_historydb); - } - - if (($data === false) || ($data[0]["utimestamp"] === NULL) || ($data[0]["utimestamp"] <= 0)) { - // Nor active DB nor history DB have the data, the module is not-init - return array ("first_utimestamp" => false, "search_historydb" => $search_historydb); - } - - // The data has been found - return array ("first_utimestamp" => $data[0]["utimestamp"], "search_historydb" => $search_historydb); - + $first_date = db_get_value('utimestamp', 'tagente_datos', + 'id_agente_modulo', $id_agent_module, + $config['history_db_enabled']); + + return $first_date; } /** diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 34ca395db0..b88fb07510 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -254,7 +254,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true, $relative = false, $text_filter = '', $ip_mask = null, $dont_show_subgroups = false, $strict_user = false, $size_canvas = null, - $old_mode = false) { + $old_mode = false, $map_filter = array()) { global $config; $nooverlap = 1; @@ -361,7 +361,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, // Open Graph $graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, - $ranksep, $font_size, $size_canvas); + $ranksep, $font_size, $size_canvas, $map_filter); // Parse agents $nodes = array (); @@ -1060,8 +1060,8 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu } // Short name - $name = $agent["nombre"]; - if ($cut_names) { + $name = io_safe_output($agent["nombre"]); + if ((strlen ($name) > 16) && ($cut_names)) { $name = ui_print_truncate_text($name, 16, false, true, false); } @@ -1111,7 +1111,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu } $node = "\n" . $agent['id_node'].' [ parent="' . $agent['id_parent'] . '", color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<
-
' . $img_node . '
'.$name.'
>, + '.io_safe_input($name).'>, shape="doublecircle", URL="'.$url.'", tooltip="' . $url_tooltip . '"];' . "\n"; } @@ -1174,7 +1174,7 @@ function networkmap_create_module_group_node ($module_group, $simple = 0, $font_ '", fontsize='.$font_size.', style="filled", ' . 'fixedsize=true, width=0.30, height=0.30, ' . 'label=<
' . - $module_group['name'] . '
>, + io_safe_output($module_group['name']) . '>, shape="square", URL="' . $url . '", tooltip="' . $url_tooltip . '"];'; } @@ -1268,7 +1268,7 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $ 'fixedsize=true, width=0.30, height=0.30, ' . 'label=< -
' . $img_node . '
' . $module['nombre'] . '
>, + ' . io_safe_output($module['nombre']) . '>, shape="circle", URL="' . $url . '", tooltip="' . $url_tooltip . '"];'; } @@ -1396,7 +1396,7 @@ function networkmap_close_group () { // Opens a graph definition function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, - $ranksep, $font_size, $size_canvas) { + $ranksep, $font_size, $size_canvas, $map_filter = array()) { global $config; @@ -1412,42 +1412,79 @@ function networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $size = ''; } - - if ($layout == 'radial') { - $overlap = 'true'; - } - - if ($layout == 'flat' || $layout == 'radial' || $layout == 'spring1' || $layout == "spring2") { - if ($nooverlap != '') { - $overlap = 'scalexy'; - } - } - if ($zoom > 0) { $size_x *= $zoom; $size_y *= $zoom; } + $size = $size_x . ',' . $size_y; if (!is_null($size_canvas)) { $size = ($size_canvas['x'] / 100) . "," . ($size_canvas['y'] / 100); } - + + // Graphviz custom values + if (isset($map_filter['node_sep'])) { + $node_sep = $map_filter['node_sep']; + } + else { + $node_sep = 0.25; + } + if (isset($map_filter['rank_sep'])) { + $rank_sep = $map_filter['rank_sep']; + } + else { + if ($layout == "radial") { + $rank_sep = 1.0; + } + else { + $rank_sep = 0.5; + } + } + if (isset($map_filter['mindist'])) { + $mindist = $map_filter['mindist']; + } + else { + $mindist = 1.0; + } + if (isset($map_filter['kval'])) { + $kval = $map_filter['kval']; + } + else { + $kval = 0.3; + } + // BEWARE: graphwiz DONT use single ('), you need double (") $head = "graph networkmap { dpi=100; bgcolor=\"transparent\"; labeljust=l; margin=0; pad=\"0.75,0.75\";"; if ($nooverlap != '') { - $head .= "overlap=\"$overlap\";"; - $head .= "ranksep=\"$ranksep\";"; + $head .= "overlap=\"false\";"; $head .= "outputorder=edgesfirst;"; } + + if ($layout == 'flat' || $layout == 'spring1' || $layout == "spring2") { + if ($nooverlap != '') { + $head .= "overlap=\"scalexy\";"; + } + if ($layout == 'flat') { + $head .= "ranksep=\"$rank_sep\";"; + } + if ($layout == 'spring2') { + $head .= "K=\"$kval\";"; + } + } + if ($layout == 'radial') { + $head .= "ranksep=\"$rank_sep\";"; + } + if ($layout == 'circular') { + $head .= "mindist=\"$mindist\";"; + } $head .= "ratio=fill;"; $head .= "root=0;"; - $head .= "nodesep=\"0.02\";"; + $head .= "nodesep=\"$node_sep\";"; $head .= "size=\"$size\";"; $head .= "\n"; - return $head; } diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index e09a20f3bc..4058294bbe 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -43,7 +43,7 @@ function networkmap_process_networkmap($id = 0) { $networkmap = db_get_row_filter('tmap', array('id' => $id)); - $filter = json_decode($networkmap['filter'], true); + $map_filter = json_decode($networkmap['filter'], true); $pure = (int)get_parameter('pure', 0); @@ -95,181 +95,316 @@ function networkmap_process_networkmap($id = 0) { } $nodes_and_relations = array(); - + if (enterprise_installed() && ($numNodes > 0)) { $nodes_and_relations = get_structure_nodes($id); } else { - // Generate dot file - $graph = networkmap_generate_dot (__('Pandora FMS'), - $id_group, - $simple, - $font_size, - $layout, - $nooverlap, - $zoom, - $ranksep, - $center, - $regen, - $pure, - $id, - $show_snmp_modules, - false, //cut_names - true, // relative - '', - $ip_mask, - $dont_show_subgroups, - false, - null, - $old_mode); - - switch (PHP_OS) { - case "WIN32": - case "WINNT": - case "Windows": - $filename_dot = sys_get_temp_dir() . "\\networkmap_" . $filter; - break; - default: - $filename_dot = sys_get_temp_dir() . "/networkmap_" . $filter; - break; - } - - if ($simple) { - $filename_dot .= "_simple"; - } - if ($nooverlap) { - $filename_dot .= "_nooverlap"; - } - $filename_dot .= "_" . $id . ".dot"; + if ($map_filter['empty_map']) { + // Open Graph + $graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, + $ranksep, $font_size, null); + $graph .= networkmap_create_pandora_node (__('Pandora FMS'), $font_size, $simple); + $graph .= networkmap_close_graph (); - file_put_contents($filename_dot, $graph); + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_dot = sys_get_temp_dir() . "\\networkmap_" . $filter; + break; + default: + $filename_dot = sys_get_temp_dir() . "/networkmap_" . $filter; + break; + } + + if ($simple) { + $filename_dot .= "_simple"; + } + if ($nooverlap) { + $filename_dot .= "_nooverlap"; + } + $filename_dot .= "_" . $id . ".dot"; - switch (PHP_OS) { - case "WIN32": - case "WINNT": - case "Windows": - $filename_plain = sys_get_temp_dir() . "\\plain.txt"; - - $cmd = io_safe_output($config['graphviz_bin_dir'] . "\\$filter.exe -Tplain -o " . $filename_plain . " " . - $filename_dot); - break; - default: - $filename_plain = sys_get_temp_dir() . "/plain.txt"; + file_put_contents($filename_dot, $graph); - $cmd = "$filter -Tplain -o " . $filename_plain . " " . - $filename_dot; - break; - } + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_plain = sys_get_temp_dir() . "\\plain.txt"; + + $cmd = io_safe_output($config['graphviz_bin_dir'] . "\\$filter.exe -Tplain -o " . $filename_plain . " " . + $filename_dot); + break; + default: + $filename_plain = sys_get_temp_dir() . "/plain.txt"; - system ($cmd); - - unlink($filename_dot); - - $nodes = networkmap_loadfile($id, $filename_plain, - $relation_nodes, $graph); - - unlink($filename_plain); + $cmd = "$filter -Tplain -o " . $filename_plain . " " . + $filename_dot; + break; + } - //Set the position of modules - foreach ($nodes as $key => $node) { - if ($node['type'] == 'module') { - //Search the agent of this module for to get the - //position - foreach ($nodes as $key2 => $node2) { - if ($node2['id_agent'] != 0 && $node2['type'] == 'agent') { - if ($node2['id_agent'] == $node['id_agent']) { - $nodes[$key]['coords'][0] = - $nodes[$key2]['coords'][0] + $node['height'] / 2; - $nodes[$key]['coords'][1] = - $nodes[$key2]['coords'][1] + $node['width'] / 2; + system ($cmd); + + unlink($filename_dot); + + $nodes = networkmap_loadfile($id, $filename_plain, + $relation_nodes, $graph); + + unlink($filename_plain); + + //Set the position of modules + foreach ($nodes as $key => $node) { + if ($node['type'] == 'module') { + //Search the agent of this module for to get the + //position + foreach ($nodes as $key2 => $node2) { + if ($node2['id_agent'] != 0 && $node2['type'] == 'agent') { + if ($node2['id_agent'] == $node['id_agent']) { + $nodes[$key]['coords'][0] = + $nodes[$key2]['coords'][0] + $node['height'] / 2; + $nodes[$key]['coords'][1] = + $nodes[$key2]['coords'][1] + $node['width'] / 2; + } } } } } + + $nodes_and_relations['nodes'] = array(); + $index = 0; + foreach ($nodes as $key => $node) { + $nodes_and_relations['nodes'][$index]['id_map'] = $id; + + $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; + $nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1]; + + if (($node['type'] == 'agent') || ($node['type'] == '')) { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 0; + } + else { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module']; + $nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 1; + } + + $style = array(); + $style['shape'] = 'circle'; + $style['image'] = $node['image']; + $style['width'] = $node['width']; + $style['height'] = $node['height']; + $style['label'] = $node['text']; + $style['id_networkmap'] = $node['networkmap']; + $nodes_and_relations['nodes'][$index]['style'] = json_encode($style); + + $index++; + } + + $nodes_and_relations['relations'] = array(); + + if (enterprise_installed()) { + enterprise_include_once("include/functions_pandora_networkmap.php"); + save_generate_nodes($id, $nodes_and_relations); + } + } + else { + // Generate dot file + $graph = networkmap_generate_dot (__('Pandora FMS'), + $id_group, + $simple, + $font_size, + $layout, + $nooverlap, + $zoom, + $ranksep, + $center, + $regen, + $pure, + $id, + $show_snmp_modules, + false, //cut_names + true, // relative + '', + $ip_mask, + $dont_show_subgroups, + false, + null, + $old_mode, + $map_filter); + + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_dot = sys_get_temp_dir() . "\\networkmap_" . $filter; + break; + default: + $filename_dot = sys_get_temp_dir() . "/networkmap_" . $filter; + break; + } + + if ($simple) { + $filename_dot .= "_simple"; + } + if ($nooverlap) { + $filename_dot .= "_nooverlap"; + } + $filename_dot .= "_" . $id . ".dot"; + + file_put_contents($filename_dot, $graph); + + switch (PHP_OS) { + case "WIN32": + case "WINNT": + case "Windows": + $filename_plain = sys_get_temp_dir() . "\\plain.txt"; + + $cmd = io_safe_output($config['graphviz_bin_dir'] . "\\$filter.exe -Tplain -o " . $filename_plain . " " . + $filename_dot); + break; + default: + $filename_plain = sys_get_temp_dir() . "/plain.txt"; + + $cmd = "$filter -Tplain -o " . $filename_plain . " " . + $filename_dot; + break; + } + + system ($cmd); + + unlink($filename_dot); + + $nodes = networkmap_loadfile($id, $filename_plain, + $relation_nodes, $graph); + + unlink($filename_plain); + + //Set the position of modules + foreach ($nodes as $key => $node) { + if ($node['type'] == 'module') { + //Search the agent of this module for to get the + //position + foreach ($nodes as $key2 => $node2) { + if ($node2['id_agent'] != 0 && $node2['type'] == 'agent') { + if ($node2['id_agent'] == $node['id_agent']) { + $nodes[$key]['coords'][0] = + $nodes[$key2]['coords'][0] + $node['height'] / 2; + $nodes[$key]['coords'][1] = + $nodes[$key2]['coords'][1] + $node['width'] / 2; + } + } + } + } + } + + $nodes_and_relations['nodes'] = array(); + $index = 0; + $node_center = array(); + foreach ($nodes as $key => $node) { + $nodes_and_relations['nodes'][$index]['id_map'] = $id; + + $children_count = 0; + foreach ($relation_nodes as $relation) { + if (($relation['parent_type'] == 'agent') || ($relation['parent_type'] == '')) { + if ($nodes[$relation['id_parent']]['id_agent'] == $node['id_agent']) { + $children_count++; + } + } + else if ($relation['parent_type'] == 'module') { + if ($nodes[$relation['id_parent']]['id_module'] == $node['id_module']) { + $children_count++; + } + } + + } + + if (empty($node_center) || $node_center['counter'] < $children_count) { + $node_center['x'] = (int)$node['coords'][0]; + $node_center['y'] = (int)$node['coords'][1]; + $node_center['counter'] = $children_count; + } + + $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; + $nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1]; + + if (($node['type'] == 'agent') || ($node['type'] == '')) { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 0; + } + else { + $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module']; + $nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent']; + $nodes_and_relations['nodes'][$index]['type'] = 1; + } + + $style = array(); + $style['shape'] = 'circle'; + $style['image'] = $node['image']; + $style['width'] = $node['width']; + $style['height'] = $node['height']; + $style['label'] = $node['text']; + $nodes_and_relations['nodes'][$index]['style'] = json_encode($style); + + $index++; + } + + $nodes_and_relations['relations'] = array(); + $index = 0; + foreach ($relation_nodes as $relation) { + $nodes_and_relations['relations'][$index]['id_map'] = $id; + + if (($relation['parent_type'] == 'agent') || ($relation['parent_type'] == '')) { + $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; + $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_agent']; + $nodes_and_relations['relations'][$index]['parent_type'] = 0; + } + else if ($relation['parent_type'] == 'module') { + $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; + $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_module']; + $nodes_and_relations['relations'][$index]['parent_type'] = 1; + } + else { + $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; + $nodes_and_relations['relations'][$index]['parent_type'] = 3; + } + + if (($relation['child_type'] == 'agent') || ($relation['child_type'] == '')) { + $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_agent']; + $nodes_and_relations['relations'][$index]['child_type'] = 0; + } + else if ($relation['child_type'] == 'module') { + $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_module']; + $nodes_and_relations['relations'][$index]['child_type'] = 1; + } + else { + $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; + $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; + $nodes_and_relations['relations'][$index]['child_type'] = 3; + } + + $index++; + } + + if (enterprise_installed()) { + enterprise_include_once("include/functions_pandora_networkmap.php"); + save_generate_nodes($id, $nodes_and_relations); + } + + $pandorafms_node = $nodes_and_relations['nodes'][0]; + $center = array('x' => $node_center['x'], 'y' => $node_center['y']); + + $networkmap['center_x'] = $center['x']; + $networkmap['center_y'] = $center['y']; + db_process_sql_update('tmap', + array('center_x' => $networkmap['center_x'], 'center_y' => $networkmap['center_y']), + array('id' => $id)); } - $nodes_and_relations['nodes'] = array(); - $index = 0; - foreach ($nodes as $key => $node) { - $nodes_and_relations['nodes'][$index]['id_map'] = $id; - - $nodes_and_relations['nodes'][$index]['x'] = (int)$node['coords'][0]; - $nodes_and_relations['nodes'][$index]['y'] = (int)$node['coords'][1]; - - if (($node['type'] == 'agent') || ($node['type'] == '')) { - $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_agent']; - $nodes_and_relations['nodes'][$index]['type'] = 0; - } - else { - $nodes_and_relations['nodes'][$index]['source_data'] = $node['id_module']; - $nodes_and_relations['nodes'][$index]['id_agent'] = $node['id_agent']; - $nodes_and_relations['nodes'][$index]['type'] = 1; - } - - $style = array(); - $style['shape'] = 'circle'; - $style['image'] = $node['image']; - $style['width'] = $node['width']; - $style['height'] = $node['height']; - $style['label'] = $node['text']; - $nodes_and_relations['nodes'][$index]['style'] = json_encode($style); - - $index++; - } - - $nodes_and_relations['relations'] = array(); - $index = 0; - foreach ($relation_nodes as $relation) { - $nodes_and_relations['relations'][$index]['id_map'] = $id; - - if (($relation['parent_type'] == 'agent') || ($relation['parent_type'] == '')) { - $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; - $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_agent']; - $nodes_and_relations['relations'][$index]['parent_type'] = 0; - } - else if ($relation['parent_type'] == 'module') { - $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; - $nodes_and_relations['relations'][$index]['id_parent_source_data'] = $nodes[$relation['id_parent']]['id_module']; - $nodes_and_relations['relations'][$index]['parent_type'] = 1; - } - else { - $nodes_and_relations['relations'][$index]['id_parent'] = $relation['id_parent']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; - $nodes_and_relations['relations'][$index]['parent_type'] = 3; - } - - if (($relation['child_type'] == 'agent') || ($relation['child_type'] == '')) { - $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_agent']; - $nodes_and_relations['relations'][$index]['child_type'] = 0; - } - else if ($relation['child_type'] == 'module') { - $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = $nodes[$relation['id_child']]['id_module']; - $nodes_and_relations['relations'][$index]['child_type'] = 1; - } - else { - $nodes_and_relations['relations'][$index]['id_child'] = $relation['id_child']; - $nodes_and_relations['relations'][$index]['id_child_source_data'] = -2; - $nodes_and_relations['relations'][$index]['child_type'] = 3; - } - - $index++; - } - - if (enterprise_installed()) { - enterprise_include_once("include/functions_pandora_networkmap.php"); - save_generate_nodes($id, $nodes_and_relations); - } - - $pandorafms_node = $nodes_and_relations['nodes'][0]; - $center = array('x' => $pandorafms_node['x'], 'y' => $pandorafms_node['y']); - - $networkmap['center_x'] = $center['x']; - $networkmap['center_y'] = $center['y']; - db_process_sql_update('tmap', - array('center_x' => $networkmap['center_x'], 'center_y' => $networkmap['center_y']), - array('id' => $id)); } return $nodes_and_relations; @@ -342,6 +477,7 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area $item['py'] = (int)$node['y']; $item['z'] = (int)$node['z']; $item['state'] = $node['state']; + $item['deleted'] = $node['deleted']; if ($item['state'] == 'holding_area') { //40 = DEFAULT NODE RADIUS //30 = for to align @@ -399,6 +535,13 @@ function networkmap_db_node_to_js_node($node, &$count, &$count_item_holding_area if (isset($node['id_map'])) { $item['map_id'] = $node['id_map']; } + + if (!isset($node['style']['id_networkmap']) || $node['style']['id_networkmap'] == '' || $node['style']['id_networkmap'] == 0) { + $item['networkmap_id'] = 0; + } + else { + $item['networkmap_id'] = $node['style']['id_networkmap']; + } $count++; @@ -518,8 +661,10 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $item['id_agent_start'] = (int)$id_source_agent; $item['id_module_end'] = 0; $item['id_agent_end'] = (int)$id_target_agent; + $item['link_color'] = "#999"; $item['target'] = -1; $item['source'] = -1; + $item['deleted'] = $relation['deleted']; if (enterprise_installed()) { $target_and_source = array(); @@ -572,14 +717,42 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $agent2 = 0; if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) { + $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_parent_source_data'])); + $mod2_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_child_source_data'])); + + if (($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) || ($mod2_status == AGENT_MODULE_STATUS_CRITICAL_BAD)) { + $item['link_color'] = "#FC4444"; + } + else if (($mod1_status == AGENT_MODULE_STATUS_WARNING) || ($mod2_status == AGENT_MODULE_STATUS_WARNING)) { + $item['link_color'] = "#FAD403"; + } + $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); $agent2 = agents_get_agent_id_by_module_id($relation['id_child_source_data']); } else if ($relation['child_type'] == 1) { + $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_child_source_data'])); + + if ($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) { + $item['link_color'] = "#FC4444"; + } + else if ($mod1_status == AGENT_MODULE_STATUS_WARNING) { + $item['link_color'] = "#FAD403"; + } + $agent = $relation['id_parent_source_data']; $agent2 = agents_get_agent_id_by_module_id($relation['id_child_source_data']); } else if ($relation['parent_type'] == 1) { + $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_parent_source_data'])); + + if ($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) { + $item['link_color'] = "#FC4444"; + } + else if ($mod1_status == AGENT_MODULE_STATUS_WARNING) { + $item['link_color'] = "#FAD403"; + } + $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); $agent2 = $relation['id_child_source_data']; } @@ -717,7 +890,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das $item = networkmap_db_node_to_js_node( $node, $count, $count_item_holding_area); - + if ($item['deleted']) { + continue; + } echo "networkmap.nodes.push(" . json_encode($item) . ");\n"; $nodes_graph[$item['id']] = $item; } @@ -733,6 +908,9 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das $links_js = networkmap_links_to_js_links($relations, $nodes_graph); foreach ($links_js as $link_js) { + if ($link_js['deleted']) { + continue; + } if ($link_js['target'] == -1) continue; if ($link_js['source'] == -1) @@ -790,6 +968,12 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das echo "var set_center_menu = '" . __('Set center') . "';\n"; echo "var refresh_menu = '" . __('Refresh') . "';\n"; echo "var refresh_holding_area_menu = '" . __('Refresh Holding area') . "';\n"; + echo "var ok_button = '" . __('Proceed') . "';\n"; + echo "var message_to_confirm = '" . __('Resetting the map will delete all customizations you have done, including manual relationships between elements, new items, etc.') . "';\n"; + echo "var warning_message = '" . __('WARNING') . "';\n"; + echo "var ok_button = '" . __('Proceed') . "';\n"; + echo "var cancel_button = '" . __('Cancel') . "';\n"; + echo "var restart_map_menu = '" . __('Restart map') . "';\n"; echo "var abort_relationship_interface = '" . __('Abort the interface relationship') . "';\n"; echo "var abort_relationship_menu = '" . __('Abort the action of set relationship') . "';\n"; @@ -1335,7 +1519,6 @@ function show_networkmap($id = 0, $user_readonly = false, $nodes_and_relations = } .link { - stroke: #999; stroke-opacity: .6; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php old mode 100644 new mode 100755 index c058d94188..16387091be --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -127,7 +127,7 @@ function reporting_make_reporting_data($report = null, $id_report, } $metaconsole_on = is_metaconsole(); - + $index_content = 0; foreach ($contents as $content) { $server_name = $content['server_name']; @@ -519,29 +519,41 @@ function reporting_make_reporting_data($report = null, $id_report, break; case 'agent_detailed_event': case 'event_report_agent': - $report['contents'][] = reporting_event_report_agent( + $report_control = reporting_event_report_agent( $report, $content, $type, $force_width_chart, $force_height_chart); + if($report_control['total_events'] == 0 && $content['hide_no_data'] == 1){ + continue; + } + $report['contents'][] = $report_control; break; case 'event_report_module': - $report['contents'][] = reporting_event_report_module( + $report_control = reporting_event_report_module( $report, $content, $type, $force_width_chart, $force_height_chart, $pdf); + if($report_control['total_events'] == 0 && $content['hide_no_data'] == 1){ + continue; + } + $report['contents'][] = $report_control; break; case 'event_report_group': - $report['contents'][] = reporting_event_report_group( + $report_control = reporting_event_report_group( $report, $content, $type, $force_width_chart, $force_height_chart); + if($report_control['total_events'] == 0 && $content['hide_no_data'] == 1){ + continue; + } + $report['contents'][] = $report_control; break; case 'top_n': $report['contents'][] = reporting_event_top_n( @@ -589,6 +601,7 @@ function reporting_make_reporting_data($report = null, $id_report, $pdf); break; } + $index_content++; } return reporting_check_structure_report($report); diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index b98d66789b..390d6ec151 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -196,7 +196,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve } } else { - $command = $snmpwalk_bin . " -m ALL -M +" . escapeshellarg($config['homedir'] . "/attachment/mibs") . " -Cc -c " . escapeshellarg($community) . " -v " . escapeshellarg($version) . " " . escapeshellarg($target_ip) . " " . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir; + $command = $snmpwalk_bin . " -m ALL -M +" . escapeshellarg($config['homedir'] . "/attachment/mibs") . " -Cc -c " . escapeshellarg(io_safe_output($community)) . " -v " . escapeshellarg($version) . " " . escapeshellarg($target_ip) . " " . escapeshellarg($starting_oid) . " 2> " . $error_redir_dir; } exec("ssh pandora_exec_proxy@" . $server_data['ip_address'] . " \"" . $command . "\"", $output, $rc); } @@ -216,7 +216,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve } } else { - exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); + exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg(io_safe_output($community)) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } } } @@ -236,7 +236,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve } } else { - exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); + exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg(io_safe_output($community)) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } } @@ -348,7 +348,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = ' exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } else { - exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc); + exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg(io_safe_output($community)) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc); } if ($rc != 0) { @@ -725,35 +725,38 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height }); // Prepare the AJAX call - var params = [ - "target_ip=" + target_ip, - "community=" + community, - "oids=" + oids, - "snmp_browser_version=" + snmp_version, - "snmp3_browser_auth_user=" + snmp3_auth_user, - "snmp3_browser_security_level=" + snmp3_security_level, - "snmp3_browser_auth_method=" + snmp3_auth_method, - "snmp3_browser_auth_pass=" + snmp3_auth_pass, - "snmp3_browser_privacy_method=" + snmp3_privacy_method, - "snmp3_browser_privacy_pass=" + snmp3_privacy_pass, - "action=" + "create_modules_snmp", - "custom_action=" + custom_action, - "page=include/ajax/snmp_browser.ajax" - ]; + var params = {}; + params["target_ip"] = target_ip; + params["community"] = community; + params["oids"] = oids; + params["snmp_browser_version"] = snmp_version; + params["snmp3_browser_auth_user"] = snmp3_auth_user; + params["snmp3_browser_security_level"] = snmp3_security_level; + params["snmp3_browser_auth_method"] = snmp3_auth_method; + params["snmp3_browser_auth_pass"] = snmp3_auth_pass; + params["snmp3_browser_privacy_method"] = snmp3_privacy_method; + params["snmp3_browser_privacy_pass"] = snmp3_privacy_pass; + params["action"] = "create_modules_snmp"; + params["custom_action"] = custom_action; + params["page"] = "include/ajax/snmp_browser.ajax"; $.ajax({ type: "GET", url: "ajax.php", - data: params.join ("&"), - dataType: "json", + data: params, + dataType: "html", success: function(data) { + + var dato = data.replace(/[^]+(?=\[)/,""); $('input[name*=create_network_component]').removeClass("sub spinn"); $('input[name*=create_network_component]').addClass("sub add"); - if(data.length !== 0){ + dato = JSON.parse(dato); + + if(dato.length !== 0){ $('#error_text').text(""); - data.forEach( function(valor, indice, array) { - console.log(valor); + + dato.forEach( function(valor, indice, array) { $('#error_text').append('
'+ valor ); }); $("#dialog_error") diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 11395a37ba..e76ba9399f 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2973,6 +2973,11 @@ function ui_print_agent_autocomplete_input($parameters) { else $metaconsole_enabled = false; } + + $get_only_string_modules = false; + if (isset($parameters['get_only_string_modules'])) { + $get_only_string_modules = true; + } $spinner_image = html_print_image('images/spinner.gif', true, false, true); if (isset($parameters['spinner_image'])) { @@ -3128,6 +3133,10 @@ function ui_print_agent_autocomplete_input($parameters) { if (' . ((int) $get_order_json) . ') { inputs.push ("get_order_json=1"); } + + if (' . ((int) $get_only_string_modules) . ') { + inputs.push ("get_only_string_modules=1"); + } if (' . ((int)$metaconsole_enabled) . ') { if ((' . ((int)$use_input_server) . ') diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index f6293d8743..2085e9d56d 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -111,6 +111,14 @@ function visual_map_print_item($mode = "read", $layoutData, $border_color = $layoutData['border_color']; $fill_color = $layoutData['fill_color']; $label_position = $layoutData['label_position']; + $show_on_top = $layoutData['show_on_top']; + + if($show_on_top){ + $show_on_top_index = 10; + } + else{ + $show_on_top_index = ''; + } $sizeStyle = ''; $borderStyle = ''; @@ -442,7 +450,7 @@ function visual_map_print_item($mode = "read", $layoutData, // Link to an module if (empty($layoutData['id_metaconsole'])) { $url = $config['homeurl'] . - 'index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + 'index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = ui_meta_get_url_console_child( @@ -613,7 +621,7 @@ function visual_map_print_item($mode = "read", $layoutData, // Link to an module if (empty($layoutData['id_metaconsole'])) { $url = $config['homeurl'] . - 'index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + 'index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = ui_meta_get_url_console_child( @@ -662,11 +670,11 @@ function visual_map_print_item($mode = "read", $layoutData, $url = $server["server_url"] . - '/index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + '/index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = - $config['homeurl'].'/index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + $config['homeurl'].'/index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } } else { @@ -730,7 +738,7 @@ function visual_map_print_item($mode = "read", $layoutData, else { if (empty($layoutData['id_metaconsole'])) { $url = $config['homeurl'] . - '/index.php?sec=estado&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; + '/index.php?sec=view&sec2=operation/agentes/status_monitor&id_module=' . $layoutData['id_agente_modulo']; } else { $url = ui_meta_get_url_console_child( @@ -961,14 +969,14 @@ function visual_map_print_item($mode = "read", $layoutData, else { if ($width == 0 || $height == 0) { if ($layoutData['label_position']=='left') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], 180, 480, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, false, false, true, 1, false, true).'
'; } elseif ($layoutData['label_position']=='right') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], 180, 480, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, @@ -988,14 +996,14 @@ function visual_map_print_item($mode = "read", $layoutData, } else { if ($layoutData['label_position']=='left') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], $height, $width, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, false, false, true, 1, false, true).'
'; } elseif($layoutData['label_position']=='right') { - $img = '
'.custom_graphs_print( + $img = '
'.custom_graphs_print( $layoutData['id_custom_graph'], $height, $width, $period, null, true, 0, $only_image, $layoutData['image'], array(), '', array(), array(), true, @@ -1041,7 +1049,7 @@ function visual_map_print_item($mode = "read", $layoutData, if ($width == 0 || $height == 0) { if ($layoutData['label_position']=='left') { - $img = '
'. + $img = '
'. grafico_modulo_sparse($id_module, $period, 0, 300, 180, modules_get_agentmodule_name($id_module),null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, '', 1, false, '', @@ -1049,7 +1057,7 @@ function visual_map_print_item($mode = "read", $layoutData, null, true, false, $type_graph) . '
'; } elseif($layoutData['label_position']=='right') { - $img = '
' . + $img = '
' . grafico_modulo_sparse($id_module, $period, 0, 300, 180, modules_get_agentmodule_name($id_module),null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, '', @@ -1067,7 +1075,7 @@ function visual_map_print_item($mode = "read", $layoutData, } else{ if ($layoutData['label_position']=='left') { - $img = '
' . + $img = '
' . grafico_modulo_sparse($id_module, $period, 0, $width, $height, modules_get_agentmodule_name($id_module), null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, '', @@ -1076,7 +1084,7 @@ function visual_map_print_item($mode = "read", $layoutData, false, $type_graph) . '
'; } elseif ($layoutData['label_position']=='right') { - $img = '
' . + $img = '
' . grafico_modulo_sparse($id_module, $period, 0, $width, $height, modules_get_agentmodule_name($id_module), null, false, 1, false, 0, modules_get_unit($id_module), 0, 0, true, $only_image, @@ -1140,224 +1148,180 @@ function visual_map_print_item($mode = "read", $layoutData, if ( (get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap') ) { if($width == 0){ - if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) || - ($is_string == 10) || ($is_string == 33)) { - if ($layoutData['id_metaconsole'] != 0) { - $img = ''; - } - else{ - $img = ''; - } + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; } - else { - if ($layoutData['id_metaconsole'] != 0) { - $img = ''; - } - else{ - $img = ''; - } + else{ + $img = ''; } } else{ - if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) || - ($is_string == 10) || ($is_string == 33)) { - if ($layoutData['id_metaconsole'] != 0) { - $img = ''; - } - else{ - $img = ''; - } + if ($layoutData['id_metaconsole'] != 0) { + $img = ''; } - else { - if ($layoutData['id_metaconsole'] != 0) { - $img = ''; - } - else{ - $img = ''; - } + else{ + $img = ''; } } } else { - if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) || - ($is_string == 10) || ($is_string == 33)) { + $color = array(); - $color = array(); - - $color[0] = array('border' => '#000000', - 'color' => $config['graph_color1'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[1] = array('border' => '#000000', - 'color' => $config['graph_color2'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[2] = array('border' => '#000000', - 'color' => $config['graph_color3'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[3] = array('border' => '#000000', - 'color' => $config['graph_color4'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[4] = array('border' => '#000000', - 'color' => $config['graph_color5'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[5] = array('border' => '#000000', - 'color' => $config['graph_color6'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[6] = array('border' => '#000000', - 'color' => $config['graph_color7'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[7] = array('border' => '#000000', - 'color' => $config['graph_color8'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[8] = array('border' => '#000000', - 'color' => $config['graph_color9'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[9] = array('border' => '#000000', - 'color' => $config['graph_color10'], - 'alpha' => CHART_DEFAULT_ALPHA); - $color[11] = array('border' => '#000000', - 'color' => COL_GRAPH9, - 'alpha' => CHART_DEFAULT_ALPHA); - $color[12] = array('border' => '#000000', - 'color' => COL_GRAPH10, - 'alpha' => CHART_DEFAULT_ALPHA); - $color[13] = array('border' => '#000000', - 'color' => COL_GRAPH11, - 'alpha' => CHART_DEFAULT_ALPHA); - $color[14] = array('border' => '#000000', - 'color' => COL_GRAPH12, - 'alpha' => CHART_DEFAULT_ALPHA); - $color[15] = array('border' => '#000000', - 'color' => COL_GRAPH13, - 'alpha' => CHART_DEFAULT_ALPHA); + $color[0] = array('border' => '#000000', + 'color' => $config['graph_color1'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[1] = array('border' => '#000000', + 'color' => $config['graph_color2'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[2] = array('border' => '#000000', + 'color' => $config['graph_color3'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[3] = array('border' => '#000000', + 'color' => $config['graph_color4'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[4] = array('border' => '#000000', + 'color' => $config['graph_color5'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[5] = array('border' => '#000000', + 'color' => $config['graph_color6'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[6] = array('border' => '#000000', + 'color' => $config['graph_color7'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[7] = array('border' => '#000000', + 'color' => $config['graph_color8'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[8] = array('border' => '#000000', + 'color' => $config['graph_color9'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[9] = array('border' => '#000000', + 'color' => $config['graph_color10'], + 'alpha' => CHART_DEFAULT_ALPHA); + $color[11] = array('border' => '#000000', + 'color' => COL_GRAPH9, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[12] = array('border' => '#000000', + 'color' => COL_GRAPH10, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[13] = array('border' => '#000000', + 'color' => COL_GRAPH11, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[14] = array('border' => '#000000', + 'color' => COL_GRAPH12, + 'alpha' => CHART_DEFAULT_ALPHA); + $color[15] = array('border' => '#000000', + 'color' => COL_GRAPH13, + 'alpha' => CHART_DEFAULT_ALPHA); - $module_data = get_bars_module_data($id_module); - $water_mark = array('file' => '/var/www/html/pandora_console/images/logo_vertical_water.png', - 'url' => 'http://localhost/pandora_console/images/logo_vertical_water.png'); - - if ($width == 0) { - if ($layoutData['label_position']=='left') { - if ($layoutData['type_graph'] == 'horizontal') { - $img = '
'. - hbar_graph(true, $module_data, - 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; - } - else { - $img = '
'. - vbar_graph(true, $module_data, - 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; - } - } - elseif($layoutData['label_position']=='right') { - if ($layoutData['type_graph'] == 'horizontal') { - $img = '
'. - hbar_graph(true, $module_data, - 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; - } - else { - $img = '
'. - vbar_graph(true, $module_data, - 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; - } + $module_data = get_bars_module_data($id_module); + $water_mark = array('file' => '/var/www/html/pandora_console/images/logo_vertical_water.png', + 'url' => 'http://localhost/pandora_console/images/logo_vertical_water.png'); + + if ($width == 0 && $height == 0) { + if ($layoutData['label_position']=='left') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; } else { - if ($layoutData['type_graph'] == 'horizontal') { - $img = hbar_graph(true, $module_data, - 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); - } - else { - $img = vbar_graph(true, $module_data, - 400, 400, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); - } + $img = '
'. + vbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; } } - else{ - if ($layoutData['label_position']=='left') { - if ($layoutData['type_graph'] == 'horizontal') { - $img = '
'. - hbar_graph(true, $module_data, - $width, $width, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; - } - else { - $img = '
'. - vbar_graph(true, $module_data, - $width, $width, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; - } - } - elseif($layoutData['label_position']=='right') { - if ($layoutData['type_graph'] == 'horizontal') { - $img = '
'. - hbar_graph(true, $module_data, - $width, $width, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; - } - else { - $img = '
'. - vbar_graph(true, $module_data, - $width, $width, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; - } + elseif($layoutData['label_position']=='right') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; } else { - if ($layoutData['type_graph'] == 'horizontal') { - $img = hbar_graph(true, $module_data, - $width, $width, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); - } - else { - $img = vbar_graph(true, $module_data, - $width, $width, $color, array(), array(), - ui_get_full_url("images/image_problem.opaque.png", false, false, false), - "", "", $water_mark, $config['fontpath'], 6, - "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); - } + $img = '
'. + vbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; + } + } + else { + if ($layoutData['type_graph'] == 'horizontal') { + $img = hbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); + } + else { + $img = vbar_graph(true, $module_data, + 400, 400, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); } } } - else { - if($width == 0){ - if ($layoutData['id_metaconsole'] != 0) { - $img = ''; + else{ + if ($layoutData['label_position']=='left') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; } - else{ - $img = ''; + else { + $img = '
'. + vbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; } } - else{ - if ($layoutData['id_metaconsole'] != 0) { - $img = ''; + elseif($layoutData['label_position']=='right') { + if ($layoutData['type_graph'] == 'horizontal') { + $img = '
'. + hbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']) . '
'; } - else{ - $img = ''; + else { + $img = '
'. + vbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']) . '
'; + } + } + else { + if ($layoutData['type_graph'] == 'horizontal') { + $img = hbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], $layoutData['border_color']); + } + else { + $img = vbar_graph(true, $module_data, + $width, $height, $color, array(), array(), + ui_get_full_url("images/image_problem.opaque.png", false, false, false), + "", "", $water_mark, $config['fontpath'], 6, + "", 0, $config['homeurl'], $layoutData['image'], true, false, $layoutData['border_color']); } } } @@ -1436,7 +1400,7 @@ function visual_map_print_item($mode = "read", $layoutData, } else { if ($width == 0) { - $img = d3_donut_graph ($layoutData['id'], 400, 400, $donut_data, $layoutData['border_color']); + $img = d3_donut_graph ($layoutData['id'], 300, 300, $donut_data, $layoutData['border_color']); } else{ $img = d3_donut_graph ($layoutData['id'], $width, $width, $donut_data, $layoutData['border_color']); @@ -1480,10 +1444,10 @@ function visual_map_print_item($mode = "read", $layoutData, else { if ($width == 0 || $height == 0) { if ($layoutData['label_position']=='left') { - $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; + $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; } elseif ($layoutData['label_position']=='right') { - $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; + $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true).'
'; } else { $img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], 500, 50, $layoutData['period'], '', true); @@ -1491,10 +1455,10 @@ function visual_map_print_item($mode = "read", $layoutData, } else{ if ($layoutData['label_position']=='left') { - $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; + $img = '
' . graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; } elseif ($layoutData['label_position']=='right') { - $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; + $img = '
' .graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true).'
'; } else { $img = graph_graphic_moduleevents ($layoutData['id_agent'], $layoutData['id_agente_modulo'], $width, $height, $layoutData['period'], '', true); @@ -1559,6 +1523,10 @@ function visual_map_print_item($mode = "read", $layoutData, break; } + if($show_on_top){ + $z_index = 10; + } + echo '
"; } - + + //for clean link text from bbdd only edit_visualmap + if (get_parameter('action') == 'edit' || get_parameter('operation') == 'edit_visualmap') { + $text = preg_replace("/<\/*a.*?>/", '', $text); + } + switch ($type) { case BOX_ITEM: if ($width == 0 || $width == 0) { @@ -1580,7 +1553,7 @@ function visual_map_print_item($mode = "read", $layoutData, $style .= "border-width: " . $border_width . "px; "; $style .= "border-color: " . $border_color . "; "; $style .= "background-color: " . $fill_color . "; "; - echo "
"; + echo "
"; } else { if (!empty($proportion)) { @@ -1591,7 +1564,7 @@ function visual_map_print_item($mode = "read", $layoutData, $style .= "border-width: " . $border_width . "px; "; $style .= "border-color: " . $border_color . "; "; $style .= "background-color: " . $fill_color . "; "; - echo "
"; + echo "
"; } else { $style = ""; @@ -1601,7 +1574,7 @@ function visual_map_print_item($mode = "read", $layoutData, $style .= "border-width: " . $border_width . "px; "; $style .= "border-color: " . $border_color . "; "; $style .= "background-color: " . $fill_color . "; "; - echo "
"; + echo "
"; } } break; @@ -1627,8 +1600,12 @@ function visual_map_print_item($mode = "read", $layoutData, if (!empty($unit_text)) $value .= " " . $unit_text; - $img_style_title .= "
" . __("Last value: ") . - $value; + // Hide value on boolean modules + if (!modules_is_boolean($layoutData['id_agente_modulo'])) { + $img_style_title .= + "
" . __("Last value: ") + . $value; + } } if(get_parameter('action') == 'edit'){ @@ -2182,7 +2159,7 @@ function get_bars_module_data ($id_module) { $color_index = 0; $total = 0; foreach ($values as $val) { - $data = explode(":", $val); + $data = explode(",", $val); $values_to_return[$data[0]] = array('g' =>$data[1]); } @@ -2583,16 +2560,22 @@ function get_donut_module_data ($id_module) { $total = 0; foreach ($values as $val) { if ($index < $max_elements) { - $data = explode(":", $val); - $values_to_return[$index]['tag_name'] = $data[0] . ", " . $data[1]; + $data = explode(",", $val); + if ($data[1] == 0) { + $data[1] = __('No data'); + } + $values_to_return[$index]['tag_name'] = $data[0] . ": " . $data[1]; $values_to_return[$index]['color'] = $colors[$index]; $values_to_return[$index]['value'] = (int)$data[1]; $total += (int)$data[1]; $index++; } else { - $data = explode(":", $val); - $values_to_return[$index]['tag_name'] = __('Others') . ", " . $data[1]; + if ($data[1] == 0) { + $data[1] = __('No data'); + } + $data = explode(",", $val); + $values_to_return[$index]['tag_name'] = __('Others') . ": " . $data[1]; $values_to_return[$index]['color'] = $colors[$index]; $values_to_return[$index]['value'] += (int)$data[1]; $total += (int)$data[1]; @@ -2603,6 +2586,33 @@ function get_donut_module_data ($id_module) { $values_to_return[$ind]['percent'] = ($donut_data['value'] * 100) / $total; } + $new_values_to_return = array(); + while (!empty($values_to_return)) { + $first = true; + $max_elem = 0; + $max_elem_array = array(); + $index_to_del = 0; + foreach ($values_to_return as $i => $val) { + if ($first) { + $max_elem = $val['value']; + $max_elem_array = $val; + $index_to_del = $i; + $first = false; + } + else { + if ($val['value'] > $max_elem) { + $max_elem = $val['value']; + $max_elem_array = $val; + $index_to_del = $i; + } + } + } + + $new_values_to_return[] = $max_elem_array; + unset($values_to_return[$index_to_del]); + } + $values_to_return = $new_values_to_return; + return $values_to_return; } @@ -2906,6 +2916,8 @@ function visual_map_get_image_status_element($layoutData, $status = false) { * @return integer */ function visual_map_get_status_element($layoutData) { + global $config; + enterprise_include_once('include/functions_visual_map.php'); if (enterprise_installed()) { $status = enterprise_visual_map_get_status_element($layoutData); @@ -2923,7 +2935,34 @@ function visual_map_get_status_element($layoutData) { //Linked to other layout ?? - Only if not module defined if ($layoutData['id_layout_linked'] != 0) { - $status = visual_map_get_layout_status ($layoutData['id_layout_linked']); + if ($layoutData['id_layout_linked_weight'] != 0) { + $calculate_weight = true; + } + else { + $calculate_weight = false; + } + $status = visual_map_get_layout_status ($layoutData['id_layout_linked'], 0, 0, $calculate_weight); + + if ($layoutData['id_layout_linked_weight'] > 0) { + $elements_to_compare = db_get_all_rows_sql("SELECT id, element_group FROM tlayout_data WHERE type = 0 AND id_layout = " . $layoutData['id_layout_linked']); + + $childs_group_acl = array(); + foreach ($elements_to_compare as $c) { + if (check_acl ($config['id_user'], $c['element_group'], "VR")) { + $childs_group_acl[] = $c['id']; + } + } + $elements_to_compare = $childs_group_acl; + + $aux_weight = ($status['elements_in_critical'] / count($elements_to_compare)) * 100; + + if ($aux_weight >= $layoutData['id_layout_linked_weight']) { + $status = $status['temp_total']; + } + else { + $status = VISUAL_MAP_STATUS_NORMAL; + } + } } else { switch ($layoutData["type"]) { @@ -3248,6 +3287,11 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, foreach ($layout_datas as $layout_data) { + $layout_group = $layout_data['element_group']; + if (!check_acl ($config['id_user'], $layout_group, "VR")) { + continue; + } + //Check the items are from disabled or pending delete modules if ($layout_data['id_agente_modulo'] != 0 && (($layout_data['type'] != LABEL) @@ -3275,7 +3319,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, 'proportion_width' => $proportion_width); } - $layout_data['label'] = visual_map_macro($layout_data['label']); + $layout_data['label'] = visual_map_macro($layout_data['label'],$layout_data["id_agente_modulo"]); switch ($layout_data['type']) { case LINE_ITEM: @@ -3314,13 +3358,32 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, * @return array A list of layouts the user can see. */ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter = false, $returnAllGroup = true) { - if (! is_array ($filter)) + if (! is_array ($filter)){ $filter = array (); - - if ($returnAllGroup) + } else { + if(!empty($filter['name'])){ + $where .= "name LIKE '%".io_safe_output($filter['name'])."%'"; + unset($filter['name']); + } + } + + if ($returnAllGroup) { $groups = users_get_groups ($id_user, 'VR'); - else - $groups = users_get_groups ($id_user, 'VR', false); + } else { + if(!empty($filter['group'])) { + $permissions_group = users_get_groups ($id_user, 'VR', false); + if(empty($permissions_group)){ + $permissions_group = users_get_groups ($id_user, 'VM', false); + } + $groups = array_intersect_key($filter['group'], $permissions_group); + } else { + $groups = users_get_groups ($id_user, 'VR', false); + if(empty($groups)) { + $groups = users_get_groups ($id_user, 'VM', false); + } + } + unset($filter['group']); + } if (!empty($groups)) { if (empty($where)) @@ -3367,7 +3430,9 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter * * @return bool The status of the given layout. True if it's OK, false if not. */ -function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { +function visual_map_get_layout_status ($id_layout = 0, $depth = 0, $elements_in_critical = 0, $calculate_weight = false) { + global $config; + $temp_status = VISUAL_MAP_STATUS_NORMAL; $temp_total = VISUAL_MAP_STATUS_NORMAL; $depth++; // For recursion depth checking @@ -3387,11 +3452,20 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { 'parent_item', 'id_layout_linked', 'id_agent', - 'type')); + 'type', + 'id_layout_linked_weight', + 'id', + 'id_layout', + 'element_group')); if ($result === false) return VISUAL_MAP_STATUS_NORMAL; foreach ($result as $data) { + $layout_group = $data['element_group']; + if (!check_acl ($config['id_user'], $layout_group, "VR")) { + continue; + } + switch ($data['type']) { case GROUP_ITEM: if ($data["id_layout_linked"] == 0) { @@ -3429,12 +3503,39 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { // Other Layout (Recursive!) if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { - $status = visual_map_get_layout_status($data["id_layout_linked"], $depth); + if ($data['id_layout_linked_weight'] > 0) { + $calculate_weight_c = true; + } + else { + $calculate_weight_c = false; + } + $status = visual_map_get_layout_status($data["id_layout_linked"], $depth, 0, $calculate_weight_c); + + $elements_in_child = db_get_all_rows_sql("SELECT id, element_group FROM tlayout_data WHERE type = 0 AND id_layout = " . $data['id_layout_linked']); + $layout_group = $data['element_group']; + + $childs_group_acl = array(); + foreach ($elements_in_child as $c) { + if (check_acl ($config['id_user'], $c['element_group'], "VR")) { + $childs_group_acl[] = $c['id']; + } + } + $elements_in_child = $childs_group_acl; + + if ($calculate_weight_c) { + $aux_weight = ($status['elements_in_critical'] / count($elements_in_child)) * 100; + + if ($aux_weight >= $data['id_layout_linked_weight']) { + $status = $status['temp_total']; + } + else { + $status = VISUAL_MAP_STATUS_NORMAL; + } + } } // Module elseif ($data["id_agente_modulo"] != 0) { $status = modules_get_agentmodule_status($data["id_agente_modulo"]); - } // Agent else { @@ -3448,11 +3549,31 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { break; } - if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) - return VISUAL_MAP_STATUS_CRITICAL_BAD; + if ($calculate_weight) { + if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD || $status == VISUAL_MAP_STATUS_WARNING) { + $elements_in_critical++; + } + } + else { + if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) { + return VISUAL_MAP_STATUS_CRITICAL_BAD; + } - if ($status > $temp_total) + } + if ($calculate_weight) { + if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) { + $temp_total = VISUAL_MAP_STATUS_CRITICAL_BAD; + } + else if ($status == VISUAL_MAP_STATUS_WARNING && $temp_total != VISUAL_MAP_STATUS_CRITICAL_BAD) { + $temp_total = VISUAL_MAP_STATUS_WARNING; + } + } + else if ($status > $temp_total) { $temp_total = $status; + } + } + if ($calculate_weight) { + return array('elements_in_critical' => $elements_in_critical, 'temp_total' => $temp_total); } return $temp_total; @@ -3661,9 +3782,14 @@ function visual_map_type_in_js($type) { } } -function visual_map_macro($label){ +function visual_map_macro($label,$module){ $label = str_replace('_date_',strftime("%x"),$label); $label = str_replace('_time_',strftime("%T"),$label); + $label = str_replace('_agent_',agents_get_alias(modules_get_agentmodule_agent($module)),$label); + $label = str_replace('_module_',modules_get_agentmodule_name($module),$label); + $label = str_replace('_agentdescription_',agents_get_description(modules_get_agentmodule_agent($module)),$label); + $label = str_replace('_address_',agents_get_address(modules_get_agentmodule_agent($module)),$label); + $label = str_replace('_moduledescription_',modules_get_agentmodule_descripcion($module),$label); return $label; } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 513c6ccc32..682b78d3e5 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -290,7 +290,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['agent_row'] = array(); $form_items['agent_row']['items'] = array('static_graph', 'percentile_bar', 'percentile_item', 'module_graph', - 'simple_value', 'datos', 'auto_sla_graph', 'bars_graph', 'donut_graph'); + 'simple_value', 'datos', 'auto_sla_graph'); $form_items['agent_row']['html'] = '' . __('Agent') . ''; $params = array(); @@ -320,6 +320,39 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['agent_row']['html'] .= '' . ui_print_agent_autocomplete_input($params) . ''; + + $form_items['agent_row_string'] = array(); + $form_items['agent_row_string']['items'] = array('donut_graph', 'bars_graph'); + $form_items['agent_row_string']['html'] = '' . + __('Agent') . ''; + $params = array(); + $params['return'] = true; + $params['show_helptip'] = true; + $params['input_name'] = 'agent_string'; + $params['size'] = 30; + $params['selectbox_id'] = 'module'; + $params['javascript_is_function_select'] = true; + $params['use_hidden_input_idagent'] = true; + $params['print_hidden_input_idagent'] = true; + $params['hidden_input_idagent_name'] = 'id_agent_string'; + $params['get_order_json'] = true; + $params['get_only_string_modules'] = true; + if (defined('METACONSOLE')) { + $params['javascript_ajax_page'] = '../../ajax.php'; + $params['disabled_javascript_on_blur_function'] = true; + + $params['print_input_server'] = true; + $params['print_input_id_server'] = true; + $params['input_server_id'] = 'id_server_name'; + $params['input_id_server_name'] = 'id_server_metaconsole'; + $params['input_server_value'] = ''; + $params['use_input_id_server'] = true; + $params['metaconsole_enabled'] = true; + $params['print_hidden_input_idagent'] = true; + } + $form_items['agent_row_string']['html'] .= '' . + ui_print_agent_autocomplete_input($params) . + ''; $form_items['module_row'] = array(); $form_items['module_row']['items'] = array('static_graph', @@ -426,7 +459,12 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['percentile_bar_row_1']['html'] = '' . __('Width') . ' ' . html_print_input_text('width_percentile', 0, '', 3, 5, true) . ''; - + + $form_items['height_bars_graph_row'] = array(); + $form_items['height_bars_graph_row']['items'] = array('bars_graph'); + $form_items['height_bars_graph_row']['html'] = '' . + __('Height') . ' + ' . html_print_input_text('bars_graph_height', 0, '', 3, 5, true) . ''; $form_items['percentile_bar_row_2'] = array(); $form_items['percentile_bar_row_2']['items'] = array('percentile_bar', 'percentile_item', 'datos'); @@ -504,7 +542,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { '' . __('Show statistics') . ' ' . html_print_checkbox('show_statistics', 1, '', true) . ''; - + + $form_items['show_on_top_row'] = array(); + $form_items['show_on_top_row']['items'] = array('group_item'); + $form_items['show_on_top_row']['html'] = + '' . __('Always show on top') . ' + ' . + html_print_checkbox('show_on_top', 1, '', true) . ''; $form_items['module_graph_size_row'] = array(); $form_items['module_graph_size_row']['items'] = array('module_graph', 'datos'); @@ -621,10 +665,40 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { WHERE id != ' . $visualConsole_id, 'map_linked', '', '', 'None', '0', true) . ''; + $form_items_advance['map_linked_weight'] = array(); + $form_items_advance['map_linked_weight']['items'] = array('static_graph'); + $form_items_advance['map_linked_weight']['html'] = ''. + __('Map linked weight') . '' . + '' . html_print_select(array('10' => '10%', + '20' => '20%', + '30' => '30%', + '40' => '40%', + '50' => '50%', + '60' => '60%', + '70' => '70%', + '80' => '80%', + '90' => '90%', + '100' => '100%'), + 'map_linked_weight', '', '', __('By default'), 0, true) . + ui_print_help_icon ("linked_map_weight", true) . + ''; + $form_items_advance['line_case']['items'] = array('line_item'); $form_items_advance['line_case']['html'] = ' ' . __('Lines haven\'t advanced options') . ''; + $user_groups = users_get_groups($config['id_user']); + $form_items_advance['element_group_row'] = array(); + $form_items_advance['element_group_row']['items'] = array( + 'group_item', 'static_graph', 'percentile_bar', + 'percentile_item', 'module_graph', 'simple_value', + 'icon', 'label', 'datos'); + $form_items_advance['element_group_row']['html'] = ''. + __('Restrict access to group') . '' . + '' . html_print_select($user_groups, 'element_group', '', '', '', 0, true) . + ui_print_help_tip ( + __("If selected, restrict visualization of this item in the visual console to users who have access to selected group. This is also used on calculating child visual consoles."), true) . + ''; //Insert and modify before the buttons to create or update. if (enterprise_installed()) { @@ -731,7 +805,7 @@ function visual_map_editor_print_toolbox() { visual_map_print_button_editor('static_graph', __('Static Graph'), 'left', false, 'camera_min', true); visual_map_print_button_editor('percentile_item', __('Percentile Item'), 'left', false, 'percentile_item_min', true); visual_map_print_button_editor('module_graph', __('Module Graph'), 'left', false, 'graph_min', true); - visual_map_print_button_editor('donut_graph', __('Donut Graph'), 'left', false, 'donut_graph_min', true); + visual_map_print_button_editor('donut_graph', __('Serialized pie graph'), 'left', false, 'donut_graph_min', true); visual_map_print_button_editor('bars_graph', __('Bars Graph'), 'left', false, 'bars_graph_min', true); visual_map_print_button_editor('auto_sla_graph', __('Auto SLA Graph'), 'left', false, 'auto_sla_graph_min', true); visual_map_print_button_editor('simple_value', __('Simple Value'), 'left', false, 'binary_min', true); @@ -794,6 +868,8 @@ function visual_map_editor_print_hack_translate_strings() { __('No Max value defined.') .''; echo ''; + echo ''; echo ''; echo '
"; + + if (enterprise_installed()) { + echo "
"; + echo '
'; + html_print_input_hidden ('new_empty_networkmap', 1); + html_print_submit_button (__('Create empty networkmap'), 'crt', false, 'class="sub next" style="float: right; margin-right:20px;"'); + echo "
"; + echo "
"; + } } break; diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 2ebc1447d2..d2a7830f83 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -13,13 +13,29 @@ // Load global variables global $config; -// Check user credentials -check_login(); - require_once ('include/functions_pandora_networkmap.php'); enterprise_include_once('include/functions_policies.php'); +enterprise_include_once('include/functions_dashboard.php'); require_once ('include/functions_modules.php'); +$public_hash = get_parameter('hash', false); + +// Try to authenticate by hash on public dashboards +if ($public_hash === false) { + // Login check + check_login(); +} else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, get_parameter('networkmap_id'), 'network_map') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } +} + //--------------INIT AJAX----------------------------------------------- if (is_ajax ()) { $update_refresh_state = (bool)get_parameter('update_refresh_state',false); @@ -677,10 +693,16 @@ if (is_ajax ()) { } } //--------------END AJAX------------------------------------------------ -$id = (int) get_parameter('id_networkmap', 0); +if (_id_ != "_id_") { + $id = _id_; +} +else { + $id = (int) get_parameter('id_networkmap', 0); +} + $dash_mode = 0; $map_dash_details = array(); - +$networkmap = db_get_row('tmap', 'id', $id); if (enterprise_installed()) { include_once("enterprise/dashboard/widgets/network_map.php"); if ($id_networkmap) { @@ -692,11 +714,32 @@ if (enterprise_installed()) { $map_dash_details['x_offs'] = $x_offs; $map_dash_details['y_offs'] = $y_offs; $map_dash_details['z_dash'] = $z_dash; + + $networkmap = db_get_row('tmap', 'id', $id); + } + else { + $networkmap_filter = json_decode($networkmap['filter'], true); + if ($networkmap_filter['x_offs'] != null) { + $map_dash_details['x_offs'] = $networkmap_filter['x_offs']; + } + else { + $map_dash_details['x_offs'] = 0; + } + if ($networkmap_filter['y_offs'] != null) { + $map_dash_details['y_offs'] = $networkmap_filter['y_offs']; + } + else { + $map_dash_details['y_offs'] = 0; + } + if ($networkmap_filter['z_dash'] != null) { + $map_dash_details['z_dash'] = $networkmap_filter['z_dash']; + } + else { + $map_dash_details['z_dash'] = 0; + } } } -$networkmap = db_get_row('tmap', 'id', $id); - if ($networkmap === false) { ui_print_page_header(__('Networkmap'), "images/bricks.png", false, "network_map_enterprise", false); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index f0fdf37082..ba7965fd63 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -111,6 +111,8 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); $id = (int) get_parameter ("id", 0); // Agent id $agent_id = (int) modules_get_agentmodule_agent($id); + // Kind module + $type_module = modules_get_agentmodule_kind($id); if (empty($id) || empty($agent_id)) { ui_print_error_message(__('There was a problem locating the source of the graph')); @@ -169,6 +171,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); $time_compare_overlapped = get_parameter ("time_compare_overlapped", 0); $unknown_graph = get_parameter_checkbox ("unknown_graph", 1); + //$type_module == 'predictionserver'; $fullscale_sent = get_parameter ("fullscale_sent", 0); if(!$fullscale_sent){ if(!isset($config['full_scale_option']) || $config['full_scale_option'] == 0){ @@ -420,12 +423,14 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); break; } - $data = array(); - $data[0] = __('Show full scale graph (TIP)'); - $data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, - true, false); - $table->data[] = $data; - $table->rowclass[] = ''; + if($type_module != 'predictionserver'){ + $data = array(); + $data[0] = __('Show full scale graph (TIP)'); + $data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, + true, false); + $table->data[] = $data; + $table->rowclass[] = ''; + } $form_table = html_print_table($table, true); diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 27baeced96..480dc6b354 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -365,6 +365,9 @@ else { $prediction_available = db_get_sql ("SELECT count(*) FROM tserver WHERE server_type = 5"); //POSTGRESQL AND ORACLE COMPATIBLE + $wux_available = db_get_sql ("SELECT count(*) + FROM tserver + WHERE server_type = 17"); //POSTGRESQL AND ORACLE COMPATIBLE // Development mode to use all servers if ($develop_bypass) { @@ -386,6 +389,9 @@ else { $typemodules[5] = __('Prediction server module'); if (enterprise_installed()) { $typemodules[7] = __('Web server module'); + if ($wux_available) { + $typemodules[8] = __('Wux server module'); + } } @@ -443,6 +449,11 @@ else { FROM ttipo_modulo WHERE categoria = 0'); break; + case 8: + $sql = sprintf ('SELECT id_tipo, descripcion + FROM ttipo_modulo + WHERE nombre = \'web_analysis\''); + break; case '': $sql = sprintf ('SELECT id_tipo, descripcion FROM ttipo_modulo'); @@ -516,7 +527,7 @@ foreach ($custom_fields as $custom_field) { } -$filters = '
'; if (is_metaconsole()) { @@ -943,31 +954,31 @@ if (!empty($result)) { $table->head[0] = '' . __('P.') . ''; $table->head[1] = __('Agent'); - $table->head[1] .=' ' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . ''; + $table->head[1] .=' ' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . ''; $table->head[2] = __('Data Type'); - $table->head[2] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectTypeDown, 'alt' => 'down')) . ''; + $table->head[2] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectTypeDown, 'alt' => 'down')) . ''; $table->align[2] = 'left'; $table->head[3] = __('Module name'); - $table->head[3] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; + $table->head[3] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; $table->head[4] = __('Server type'); - $table->head[4] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; + $table->head[4] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; $table->head[5] = __('Interval'); - $table->head[5] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectIntervalUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectIntervalDown, 'alt' => 'down')) . ''; + $table->head[5] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectIntervalUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectIntervalDown, 'alt' => 'down')) . ''; $table->align[5] = 'left'; $table->head[6] = __('Status'); - $table->head[6] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + $table->head[6] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; $table->align[6] = 'left'; @@ -980,13 +991,13 @@ if (!empty($result)) { $table->head[9] = __('Data'); $table->align[9] = 'left'; if ( is_metaconsole() ) { - $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; } $table->head[10] = __('Timestamp'); - $table->head[10] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTimestampUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectTimestampDown, 'alt' => 'down')) . ''; + $table->head[10] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTimestampUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectTimestampDown, 'alt' => 'down')) . ''; $table->align[10] = 'left'; $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 97c4f01720..b2479fec88 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -589,6 +589,11 @@ if (is_ajax ()) { if (empty($filter)) $filter = false; + $get_only_string_modules = get_parameter('get_only_string_modules', false); + if ($get_only_string_modules) { + $filter['tagente_modulo.id_tipo_modulo IN'] = "(17,23,3,10,33)"; + } + // Status selector if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) { //Normal $sql_conditions .= ' estado = 0 AND utimestamp > 0 ) diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 303fdcc435..8a506c979e 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -36,7 +36,7 @@ if ($group_rep == 2) { $table->head[1] = __('Agent'); $table->head[5] = __('More detail'); - $params = "search=" . rawurlencode(io_safe_input($search)) . + $params = "search=" . io_safe_input($search) . "&severity=" . $severity . "&status=" . $status . "&id_group=" . $id_group . diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 15da1cf221..1fbcde3ad4 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -165,7 +165,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Alert fired in module ') . io_safe_output($module_name) . + $return['message'] = io_safe_output($agent_name) . " - " . __('Alert fired in module ') . io_safe_output($module_name) . " - " . $event['timestamp']; } else if ($resultCritical) { @@ -176,7 +176,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to critical') . + $return['message'] = io_safe_output($agent_name) . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to critical') . " - " . $event['timestamp']; } else if ($resultWarning) { @@ -187,7 +187,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to warning') . + $return['message'] = io_safe_output($agent_name) . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to warning') . " - " . $event['timestamp']; } else if ($resultUnknown) { @@ -198,7 +198,7 @@ if (is_ajax ()) { $module_name = modules_get_agentmodule_name($event['id_agentmodule']); $agent_name = agents_get_alias($event['id_agente']); - $return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to unknown') . + $return['message'] = io_safe_output($agent_name) . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to unknown') . " - " . $event['timestamp']; } else { @@ -307,9 +307,7 @@ users_get_groups ($config["id_user"], "ER"); $ids = (array) get_parameter ("eventid", -1); - - -$params = "search=" . rawurlencode(io_safe_input($search)) . +$params = "search=" . io_safe_input($search) . "&event_type=" . $event_type . "&severity=" . $severity . "&status=" . $status . diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index a9574b21bf..a4d773fde7 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -13,7 +13,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // Load global vars global $config; @@ -671,8 +670,6 @@ if ($event_w || $event_m) { $data[0] .= '' . html_print_image("images/load.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '  '; -$data[0] .= '' . - html_print_image('images/chart_curve.png', true, array('title' => __('Show events graph'))) . '
'; $data[0] .= '
'; @@ -787,8 +784,6 @@ elseif ($group_rep == 2) { $history); } - - // Active filter tag view call (only enterprise version) // It is required to pass some references to enterprise function // to translate the active filters @@ -803,87 +798,6 @@ enterprise_hook('print_event_tags_active_filters', ) ); -if (!empty($result)) { - if ($group_rep == 0) { - $sql = "SELECT COUNT(id_evento) - FROM $event_table - WHERE 1=1 " . $sql_post; - } - elseif ($group_rep == 1) { - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - $sql = "SELECT COUNT(1) - FROM (SELECT 1 - FROM $event_table - WHERE 1=1 " . $sql_post . " - GROUP BY evento, id_agentmodule) t"; - break; - case "oracle": - $sql = "SELECT COUNT(1) - FROM (SELECT 1 - FROM $event_table - WHERE 1=1 " . $sql_post . " - GROUP BY to_char(evento), id_agentmodule) t"; - break; - } - } - elseif ($group_rep == 2) { - - } - $limit = (int) db_get_sql ($sql); - - if ($group_rep == 0) { - switch ($config["dbtype"]) { - case "mysql": - $sql = "SELECT *, 1 event_rep - FROM $event_table - WHERE 1=1 " . $sql_post . " - ORDER BY utimestamp DESC LIMIT 0,".$limit; - break; - case "postgresql": - $sql = "SELECT *, 1 event_rep - FROM $event_table - WHERE 1=1 " . $sql_post . " - ORDER BY utimestamp DESC LIMIT ".$limit." OFFSET 0"; - break; - case "oracle": - $set = array(); - $set['limit'] = $pagination; - $set['offset'] = $offset; - $sql = "SELECT $event_table.*, 1 event_rep - FROM $event_table - WHERE 1=1 " . $sql_post . " - ORDER BY utimestamp DESC"; - $sql = oracle_recode_query ($sql, $set); - break; - } - - //Extract the events by filter (or not) from db - $results_graph = db_get_all_rows_sql ($sql); - } - elseif ($group_rep == 1) { - $results_graph = events_get_events_grouped($sql_post, - 0, - $limit, - $meta, - $history); - } - elseif ($group_rep == 2) { - - } - - if (($group_rep == 1) OR ($group_rep == 0)) { - $graph = '
' . - grafico_eventos_agente(350, 185, - $results_graph, $meta, $history, $tags_acls_condition,$limit) . - '
'; - html_print_div(array('id' => 'events_graph', - 'hidden' => true, 'content' => $graph)); - } -} - - if (!empty($result)) { //~ Checking the event tags exactly. The event query filters approximated tags to keep events //~ with several tags @@ -986,11 +900,6 @@ $(document).ready( function() { $("#text-date_from, #text-date_to").datepicker({dateFormat: ""}); - // If the events are not charged, dont show graphs link - if ($('#events_graph').val() == undefined) { - $('#events_graph_link').hide(); - } - // Don't collapse filter if update button has been pushed if ($("#hidden-open_filter").val() == 'true') { $("#event_control").toggle(); @@ -1658,23 +1567,6 @@ function reorder_tags_inputs() { } } -// Show the modal window of an module -function show_events_graph_dialog() { - $("#events_graph").hide () - .dialog ({ - resizable: true, - draggable: true, - title: '', - modal: true, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 450, - height: 380 - }) - .show (); -} /* ]]> */ //function datetime diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 6c27ce428d..b7c57882a8 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -59,6 +59,8 @@ if (check_acl ($config['id_user'], 0, "AR")) { $sub2["operation/agentes/status_monitor"]["text"] = __('Monitor detail'); $sub2["operation/agentes/status_monitor"]["refr"] = 0; + enterprise_hook ('tag_view_submenu'); + $sub2["operation/agentes/alerts_status"]["text"] = __('Alert detail'); $sub2["operation/agentes/alerts_status"]["refr"] = 0; diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index c7a23fb0fd..993f95c4fe 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -18,6 +18,7 @@ global $config; $pure = get_parameter('pure', 0); $tab = get_parameter('tab', 'group'); +$search_group = get_parameter('searchGroup', ''); $search_agent = get_parameter('searchAgent', ''); $status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL); $search_module = get_parameter('searchModule', ''); @@ -135,13 +136,16 @@ $agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); $agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init'); $row = array(); +$row[] = __('Search group'); +$row[] = html_print_input_text("search_group", $search_group, '', is_metaconsole() ? 70 : 40, 30, true); + +$table->data[] = $row; + +$row = array(); +$row[] = __('Search agent'); +$row[] = html_print_input_text("search_agent", $search_agent, '', is_metaconsole() ? 70 : 40, 30, true); $row[] = __('Agent status'); $row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true); -$row[] = __('Search agent'); -if (is_metaconsole()) - $row[] = html_print_input_text("search_agent", $search_agent, '', 70, 30, true); -else - $row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true); // Button $row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true); @@ -160,10 +164,10 @@ if (!is_metaconsole()) { $module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); $row = array(); - $row[] = __('Module status'); - $row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); $row[] = __('Search module'); $row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true); + $row[] = __('Module status'); + $row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); $table->data[] = $row; } @@ -240,8 +244,9 @@ enterprise_hook('close_meta_frame'); var parameters = {}; parameters['page'] = "include/ajax/tree.ajax"; parameters['getChildren'] = 1; - parameters['filter'] = {}; parameters['type'] = ""; + parameters['filter'] = {}; + parameters['filter']['searchGroup'] = $("input#text-search_group").val(); parameters['filter']['searchAgent'] = $("input#text-search_agent").val(); parameters['filter']['statusAgent'] = $("select#status_agent").val(); parameters['filter']['searchModule'] = $("input#text-search_module").val(); diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index 5b955def1f..21bf94fe65 100755 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -208,6 +208,11 @@ $ignored_params['refr'] = ''; $(".overlay").removeClass("overlay").addClass("overlaydisabled"); + // Start the map fetch + //~ fetchMap(); + }); + + $(window).load (function () { $('.item:not(.icon) img:not(.b64img)').each( function() { if ($(this).css('float')=='left' || $(this).css('float')=='right') { if( $(this).parent()[0].tagName == 'DIV'){ diff --git a/pandora_console/operation/visual_console/pure_ajax.php b/pandora_console/operation/visual_console/pure_ajax.php index 08b5460067..58e920550f 100644 --- a/pandora_console/operation/visual_console/pure_ajax.php +++ b/pandora_console/operation/visual_console/pure_ajax.php @@ -183,7 +183,10 @@ $ignored_params['refr'] = ''; }); $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - + + }); + + $(window).load (function () { $('.item:not(.icon) img').each(function(){ diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index 261205818b..0f2a2b9750 100755 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -244,10 +244,11 @@ $ignored_params['refr'] = ''; $('div.vc-countdown').countdown('destroy'); //cb(); url = js_html_entity_decode( href ) + duration; - //$(document).attr ("location", url); - $.post(window.location.href.replace("refr=300","refr="+new_count), function(respuestaSolicitud){ + $(document).attr ("location", url); + /*$.post(window.location.href.replace("refr=300","refr="+new_count), function(respuestaSolicitud){ $('#background_').html(respuestaSolicitud); }); + */ $("#main_pure").css('background-color',''); } @@ -279,7 +280,10 @@ $ignored_params['refr'] = ''; }); $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - + + }); + + $(window).load (function () { $('.item:not(.icon) img:not(.b64img)').each( function() { if ($(this).css('float')=='left' || $(this).css('float')=='right') { if( $(this).parent()[0].tagName == 'DIV'){ @@ -332,6 +336,6 @@ $ignored_params['refr'] = ''; height = parseInt($(this).css("height")) - 30; $(this).css('height', height); }); - + }); \ No newline at end of file diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 2bbdfca620..89d14e6341 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.715 -%define release 171110 +%define version 7.0NG.716 +%define release 171130 # 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 8cd68e775e..02cfb81e0f 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.715 -%define release 171110 +%define version 7.0NG.716 +%define release 171130 %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 16fee61027..2ffb7db4e2 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.715" +PI_VERSION="7.0NG.716" 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 28fb2575cf..0ad6e9073e 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `alias` varchar(600) BINARY NOT NULL default '', `transactional_agent` tinyint(1) NOT NULL default '0', `alias_as_name` tinyint(2) NOT NULL default '0', + `safe_mode_module` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), @@ -1204,6 +1205,7 @@ CREATE TABLE IF NOT EXISTS `tgraph_source` ( `id_agent_module` int(11) NOT NULL default 0, `weight` float(8,3) NOT NULL DEFAULT 0, `label` varchar(150) DEFAULT '', + `order` int(10) DEFAULT 0, PRIMARY KEY(`id_gs`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -1362,6 +1364,9 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` ( `border_color` varchar(200) DEFAULT "", `fill_color` varchar(200) DEFAULT "", `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -1713,6 +1718,7 @@ CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, `description` varchar(255) default '', `filter` varchar(255) default '', + `unified_filters_id` int(10) not null default 0, PRIMARY KEY (`id_snmp_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -2212,6 +2218,7 @@ CREATE TABLE IF NOT EXISTS `tdashboard` ( `id_group` int(10) NOT NULL default 0, `active` tinyint(1) NOT NULL default 0, `cells` int(10) unsigned default 0, + `cells_slideshow` TINYINT(1) NOT NULL default 0, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -2966,6 +2973,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( `transactional_agent` tinyint(1) NOT NULL default '0', `alias` varchar(600) BINARY NOT NULL default '', `alias_as_name` tinyint(2) NOT NULL default '0', + `safe_mode_module` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1ceae8c3e2..476750758f 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 7), +('MR', 9), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '715'), +('current_package_enterprise', '716'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); UNLOCK TABLES; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 1dec9e350b..737178fb8a 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.715-171110 +Version: 7.0NG.716-171130 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 6592cb3722..11a1afba0e 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.715-171110" +pandora_version="7.0NG.716-171130" 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 f3214ee626..c50235daa7 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.715 +# Version 7.0NG.716 # 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 23b6776544..85a05dfa34 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -42,8 +42,8 @@ our @EXPORT = qw( ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.715"; -my $pandora_build = "171110"; +my $pandora_version = "7.0NG.716"; +my $pandora_build = "171130"; 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 0f9e40a66b..11278d61fe 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -537,7 +537,7 @@ Process an alert given the status returned by pandora_evaluate_alert. ########################################################################## sub pandora_process_alert ($$$$$$$$;$) { my ($pa_config, $data, $agent, $module, $alert, $rc, $dbh, $timestamp, $extra_macros) = @_; - + if (defined ($agent)) { logger ($pa_config, "Processing alert '" . safe_output($alert->{'name'}) . "' for agent '" . safe_output($agent->{'nombre'}) . "': " . (defined ($AlertStatus[$rc]) ? $AlertStatus[$rc] : 'Unknown status') . ".", 10); } @@ -577,12 +577,12 @@ sub pandora_process_alert ($$$$$$$$;$) { # Generate an event if ($table eq 'tevent_alert') { pandora_event ($pa_config, "Alert ceased (" . - $alert->{'name'} . ")", 0, 0, $alert->{'priority'}, $id, + safe_output($alert->{'name'}) . ")", 0, 0, $alert->{'priority'}, $id, (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), "alert_ceased", 0, $dbh, 'Pandora', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions); } else { pandora_event ($pa_config, "Alert ceased (" . - $alert->{'name'} . ")", $agent->{'id_grupo'}, + safe_output($alert->{'name'}) . ")", $agent->{'id_grupo'}, $agent->{'id_agente'}, $alert->{'priority'}, $id, (defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0), "alert_ceased", 0, $dbh, 'Pandora', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions); @@ -1542,6 +1542,11 @@ sub pandora_process_module ($$$$$$$$$;$) { # Update module status count. $mark_for_update = 1; + + # Safe mode execution. + if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) { + safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh); + } } # Set not-init modules to normal status even if min_ff_event is not matched the first time they receive data. # if critical or warning status, just pass through here and wait the time min_ff_event will be matched. @@ -1634,9 +1639,8 @@ sub pandora_planned_downtime_disabled_once_stop($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); - pandora_event ($pa_config, - '(Created by ' . $downtime->{'id_user'} . ') Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . $downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + '(Created by ' . $downtime->{'id_user'} . ') Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_unset_disabled_elements($pa_config, $dbh, $downtime); @@ -1681,8 +1685,9 @@ sub pandora_planned_downtime_disabled_once_start($$) { SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_disabled_once_start\n"; pandora_event ($pa_config, - "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_set_disabled_elements($pa_config, $dbh, $downtime); @@ -1872,7 +1877,7 @@ sub pandora_planned_downtime_quiet_once_stop($$) { SET executed = 0 WHERE id = ?', $downtime->{'id'}); pandora_event ($pa_config, - "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_unset_quiet_elements($pa_config, $dbh, $downtime->{'id'}); @@ -1913,8 +1918,9 @@ sub pandora_planned_downtime_quiet_once_start($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_quiet_once_start\n"; pandora_event ($pa_config, - "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); pandora_planned_downtime_set_quiet_elements($pa_config, $dbh, $downtime->{'id'}); @@ -1967,8 +1973,9 @@ sub pandora_planned_downtime_monthly_start($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_monthly_start\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { @@ -2043,8 +2050,9 @@ sub pandora_planned_downtime_monthly_stop($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_monthly_stop\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { pandora_planned_downtime_unset_quiet_elements($pa_config, @@ -2152,8 +2160,9 @@ sub pandora_planned_downtime_weekly_start($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); + print"pandora_planned_downtime_weekly_start\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { pandora_planned_downtime_set_quiet_elements($pa_config, @@ -2266,8 +2275,10 @@ sub pandora_planned_downtime_weekly_stop($$) { db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); + + print"pandora_planned_downtime_weekly_stop\n"; pandora_event ($pa_config, - "Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh); + "Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh); if ($downtime->{'type_downtime'} eq "quiet") { pandora_planned_downtime_unset_quiet_elements($pa_config, @@ -2997,7 +3008,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) { } logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10); - pandora_event ($pa_config, "Agent [$alias] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh); + pandora_event ($pa_config, "Agent [" . safe_output($alias) . "] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh); return $agent_id; } @@ -4725,23 +4736,29 @@ sub pandora_self_monitoring ($$) { $xml_output .=" $agents_unknown"; $xml_output .=" "; - $xml_output .=" "; - $xml_output .=" System_Load_AVG"; - $xml_output .=" generic_data"; - $xml_output .=" $load_average"; - $xml_output .=" "; + if (defined($load_average)) { + $xml_output .=" "; + $xml_output .=" System_Load_AVG"; + $xml_output .=" generic_data"; + $xml_output .=" $load_average"; + $xml_output .=" "; + } - $xml_output .=" "; - $xml_output .=" Free_RAM"; - $xml_output .=" generic_data"; - $xml_output .=" $free_mem"; - $xml_output .=" "; + if (defined($free_mem)) { + $xml_output .=" "; + $xml_output .=" Free_RAM"; + $xml_output .=" generic_data"; + $xml_output .=" $free_mem"; + $xml_output .=" "; + } - $xml_output .=" "; - $xml_output .=" FreeDisk_SpoolDir"; - $xml_output .=" generic_data"; - $xml_output .=" $free_disk_spool"; - $xml_output .=" "; + if (defined($free_disk_spool)) { + $xml_output .=" "; + $xml_output .=" FreeDisk_SpoolDir"; + $xml_output .=" generic_data"; + $xml_output .=" $free_disk_spool"; + $xml_output .=" "; + } $xml_output .= ""; @@ -5479,6 +5496,30 @@ sub pandora_output_password($$) { return $decrypted_password; } +########################################################################## +=head2 C<< safe_mode (I<$pa_config>, I<$agent>, I<$module>, I<$new_status>, I<$known_status>, I<$dbh>) >> + +Execute safe mode for the given agent based on the status of the given module. + +=cut +########################################################################## +sub safe_mode($$$$$$) { + my ($pa_config, $agent, $module, $new_status, $known_status, $dbh) = @_; + + return unless $agent->{'safe_mode_module'} > 0; + + # Going to critical. Disable the rest of the modules. + if ($new_status == MODULE_CRITICAL) { + logger($pa_config, "Enabling safe mode for agent " . $agent->{'nombre'}, 10); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=1 WHERE id_agente=? AND id_agente_modulo!=?', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); + } + # Coming back from critical. Enable the rest of the modules. + elsif ($known_status == MODULE_CRITICAL) { + logger($pa_config, "Disabling safe mode for agent " . $agent->{'nombre'}, 10); + db_do($dbh, 'UPDATE tagente_modulo SET disabled=0 WHERE id_agente=? AND id_agente_modulo!=?', $agent->{'id_agente'}, $module->{'id_agente_modulo'}); + } +} + # End of function declaration # End of defined Code diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ebd8f860ee..dab25b57e6 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -186,6 +186,7 @@ sub data_consumer ($$) { for (0..1) { eval { threads->yield; + $xml_data = XMLin ($file_name, forcearray => 'module'); }; @@ -333,19 +334,22 @@ sub process_xml_data ($$$$$) { if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') { $group_id = $data->{'group_id'}; if (! defined (get_group_name ($dbh, $group_id))) { - pandora_event ($pa_config, "Unable to create agent '$agent_name': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); + print "UNABLE GROUP ID\n"; + pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); logger($pa_config, "Group ID " . $group_id . " does not exist.", 3); return; } } elsif (defined ($data->{'group'}) && $data->{'group'} ne '') { $group_id = get_group_id ($dbh, $data->{'group'}); if (! defined (get_group_name ($dbh, $group_id))) { - pandora_event ($pa_config, "Unable to create agent '$agent_name': group '" . $data->{'group'} . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); + print "UNABLE GROUP\n"; + pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group '" . safe_output($data->{'group'}) . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh); logger($pa_config, "Group " . $data->{'group'} . " does not exist.", 3); return; } } else { - pandora_event ($pa_config, "Unable to create agent '$agent_name': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh); + print "UNABLE AUTOCREATE\n"; + pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh); logger($pa_config, "Group id $group_id does not exist (check autocreate_group config token).", 3); return; } @@ -527,7 +531,7 @@ sub process_xml_data ($$$$$) { # Single data if (! defined ($module_data->{'datalist'})) { my $data_timestamp = get_tag_value ($module_data, 'timestamp', $timestamp); - process_module_data ($pa_config, $module_data, $server_id, $agent_name, $module_name, $module_type, $interval, $data_timestamp, $dbh, $new_agent); + process_module_data ($pa_config, $module_data, $server_id, $agent, $module_name, $module_type, $interval, $data_timestamp, $dbh, $new_agent); next; } @@ -544,7 +548,7 @@ sub process_xml_data ($$$$$) { $module_data->{'data'} = $data->{'value'}; my $data_timestamp = get_tag_value ($data, 'timestamp', $timestamp); - process_module_data ($pa_config, $module_data, $server_id, $agent_name, $module_name, + process_module_data ($pa_config, $module_data, $server_id, $agent, $module_name, $module_type, $interval, $data_timestamp, $dbh, $new_agent); } } @@ -584,16 +588,16 @@ sub process_xml_data ($$$$$) { # Process module data, creating module if necessary. ########################################################################## sub process_module_data ($$$$$$$$$$) { - my ($pa_config, $data, $server_id, $agent_name, + my ($pa_config, $data, $server_id, $agent, $module_name, $module_type, $interval, $timestamp, $dbh, $force_processing) = @_; # Get agent data - my $agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE nombre = ?', safe_input($agent_name)); if (! defined ($agent)) { - logger($pa_config, "Invalid agent '$agent_name' for module '$module_name'.", 3); + logger($pa_config, "Invalid agent for module '$module_name'.", 3); return; } + my $agent_name = $agent->{'nombre'}; # Get module parameters, matching column names in tagente_modulo my $module_conf; diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/ReconServer.pm index b25c222bf7..3261729569 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/ReconServer.pm @@ -421,7 +421,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) { $agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device, $self->{'group_id'}, 0, $id_os, '', 300, $self->{'dbh'}); return undef unless defined ($agent_id) and ($agent_id > 0); - pandora_event($self->{'pa_config'}, "[RECON] New " . $self->get_device_type($device) . " found (" . join(',', $self->get_addresses($device)) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); + pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); $agent_learning = 1; # Create network profile modules for the agent diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index bc7b3a708a..9328f56c68 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -196,10 +196,10 @@ sub pandora_snmptrapd { my ($pa_config, $line, $server_id, $dbh) = @_; (my $trap_ver, $line) = split(/\[\*\*\]/, $line, 2); - +print STDERR "ANTES"; # Process SNMP filter next if (matches_filter ($dbh, $pa_config, $line) == 1); - +print STDERR "DESPUES"; logger($pa_config, "Reading trap '$line'", 10); my ($date, $time, $source, $oid, $type, $type_desc, $value, $data) = ('', '', '', '', '', '', '', ''); @@ -345,22 +345,34 @@ sub pandora_snmptrapd { sub matches_filter ($$$) { my ($dbh, $pa_config, $string) = @_; - # Get filters - my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter'); - foreach my $filter (@filters) { - my $regexp = safe_output($filter->{'filter'}) ; - my $eval_result; + my @filter_unique_functions = get_db_rows ($dbh, 'SELECT DISTINCT(unified_filters_id) FROM tsnmp_filter ORDER BY unified_filters_id'); + + foreach my $filter_unique_func (@filter_unique_functions) { + # Get filters + my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter WHERE unified_filters_id = ' . $filter_unique_func->{'unified_filters_id'}); + + my $eval_acum = 1; + foreach my $filter (@filters) { + my $regexp = safe_output($filter->{'filter'}) ; + my $eval_result; - # eval protects against server down (by invalid regular expressions) - $eval_result = eval { - $string =~ m/$regexp/i ; - }; - - if ($eval_result) { - logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10); - return 1; - } + # eval protects against server down (by invalid regular expressions) + $eval_result = eval { + $string =~ m/$regexp/i ; + }; + if ($eval_result && $eval_acum) { + $eval_acum = 1; + } + else { + $eval_acum = 0; + last; + } + } + + if ($eval_acum) { + return 1; + } } return 0; diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index c6d60626cb..4e77d3f25b 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -69,6 +69,11 @@ our @EXPORT = qw( $OS_VERSION RECOVERED_ALERT FIRED_ALERT + MODULE_NORMAL + MODULE_CRITICAL + MODULE_WARNING + MODULE_UNKNOWN + MODULE_NOTINIT cron_get_closest_in_range cron_next_execution cron_next_execution_date @@ -129,6 +134,13 @@ use constant SYNCSERVER => 16; use constant WUXSERVER => 17; use constant SYSLOGSERVER => 18; +# Module status +use constant MODULE_NORMAL => 0; +use constant MODULE_CRITICAL => 1; +use constant MODULE_WARNING => 2; +use constant MODULE_UNKNOWN => 3; +use constant MODULE_NOTINIT => 4; + # Value for a metaconsole license type use constant METACONSOLE_LICENSE => 0x01; @@ -153,6 +165,141 @@ if ($OS eq 'linux') { } chomp($OS_VERSION); +# Entity to character mapping. Contains a few tweaks to make it backward compatible with the previous safe_input implementation. +my %ENT2CHR = ( + '#x00' => chr(0), + '#x01' => chr(1), + '#x02' => chr(2), + '#x03' => chr(3), + '#x04' => chr(4), + '#x05' => chr(5), + '#x06' => chr(6), + '#x07' => chr(7), + '#x08' => chr(8), + '#x09' => chr(9), + '#x0a' => chr(10), + '#x0b' => chr(11), + '#x0c' => chr(12), + '#x0d' => chr(13), + '#x0e' => chr(14), + '#x0f' => chr(15), + '#x10' => chr(16), + '#x11' => chr(17), + '#x12' => chr(18), + '#x13' => chr(19), + '#x14' => chr(20), + '#x15' => chr(21), + '#x16' => chr(22), + '#x17' => chr(23), + '#x18' => chr(24), + '#x19' => chr(25), + '#x1a' => chr(26), + '#x1b' => chr(27), + '#x1c' => chr(28), + '#x1d' => chr(29), + '#x1e' => chr(30), + '#x1f' => chr(31), + '#x20' => chr(32), + 'quot' => chr(34), + 'amp' => chr(38), + '#039' => chr(39), + '#40' => chr(40), + '#41' => chr(41), + 'lt' => chr(60), + 'gt' => chr(62), + '#92' => chr(92), + '#x80' => chr(128), + '#x81' => chr(129), + '#x82' => chr(130), + '#x83' => chr(131), + '#x84' => chr(132), + '#x85' => chr(133), + '#x86' => chr(134), + '#x87' => chr(135), + '#x88' => chr(136), + '#x89' => chr(137), + '#x8a' => chr(138), + '#x8b' => chr(139), + '#x8c' => chr(140), + '#x8d' => chr(141), + '#x8e' => chr(142), + '#x8f' => chr(143), + '#x90' => chr(144), + '#x91' => chr(145), + '#x92' => chr(146), + '#x93' => chr(147), + '#x94' => chr(148), + '#x95' => chr(149), + '#x96' => chr(150), + '#x97' => chr(151), + '#x98' => chr(152), + '#x99' => chr(153), + '#x9a' => chr(154), + '#x9b' => chr(155), + '#x9c' => chr(156), + '#x9d' => chr(157), + '#x9e' => chr(158), + '#x9f' => chr(159), + '#xa0' => chr(160), + '#xa1' => chr(161), + '#xa2' => chr(162), + '#xa3' => chr(163), + '#xa4' => chr(164), + '#xa5' => chr(165), + '#xa6' => chr(166), + '#xa7' => chr(167), + '#xa8' => chr(168), + '#xa9' => chr(169), + '#xaa' => chr(170), + '#xab' => chr(171), + '#xac' => chr(172), + '#xad' => chr(173), + '#xae' => chr(174), + '#xaf' => chr(175), + '#xb0' => chr(176), + '#xb1' => chr(177), + '#xb2' => chr(178), + '#xb3' => chr(179), + '#xb4' => chr(180), + '#xb5' => chr(181), + '#xb6' => chr(182), + '#xb7' => chr(183), + '#xb8' => chr(184), + '#xb9' => chr(185), + '#xba' => chr(186), + '#xbb' => chr(187), + '#xbc' => chr(188), + '#xbd' => chr(189), + '#xbe' => chr(190), + 'Aacute' => chr(193), + 'Auml' => chr(196), + 'Eacute' => chr(201), + 'Euml' => chr(203), + 'Iacute' => chr(205), + 'Iuml' => chr(207), + 'Ntilde' => chr(209), + 'Oacute' => chr(211), + 'Ouml' => chr(214), + 'Uacute' => chr(218), + 'Uuml' => chr(220), + 'aacute' => chr(225), + 'auml' => chr(228), + 'eacute' => chr(233), + 'euml' => chr(235), + 'iacute' => chr(237), + 'iuml' => chr(239), + 'ntilde' => chr(241), + 'oacute' => chr(243), + 'ouml' => chr(246), + 'uacute' => chr(250), + 'uuml' => chr(252), +); + +# Construct the character to entity mapping. +my %CHR2ENT; +while (my ($ent, $chr) = each(%ENT2CHR)) { + $CHR2ENT{$chr} = "&" . $ent . ";"; +} ############################################################################### # Sets user:group owner for the given file @@ -203,49 +350,7 @@ sub pandora_trash_ascii { sub safe_input($) { my $value = shift; - $value = encode_entities ($value, "<>&"); - - #//Replace the character '\' for the equivalent html entitie - $value =~ s/\\/\/gi; - - #// First attempt to avoid SQL Injection based on SQL comments - #// Specific for MySQL. - $value =~ s/\/\*//*/gi; - $value =~ s/\*\//*//gi; - - #//Replace ' for the html entitie - $value =~ s/\"/"/gi; - - #//Replace ' for the html entitie - $value =~ s/\'/'/gi; - - #//Replace ( for the html entitie - $value =~ s/\(/(/gi; - - #//Replace ( for the html entitie - $value =~ s/\)/)/gi; - - #//Replace some characteres for html entities - for (my $i=0;$i<33;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$pattern/$hex/gi; - } - - for (my $i=128;$i<191;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$pattern/$hex/gi; - } - - #//Replace characteres for tildes and others - my $trans = get_html_entities(); - - foreach(keys(%$trans)) - { - my $pattern = chr($_); - $value =~ s/$pattern/$trans->{$_}/g; - } + $value =~ s/([\x00-\xFF])/$CHR2ENT{$1}||$1/ge; return $value; } @@ -256,99 +361,11 @@ sub safe_input($) { sub safe_output($) { my $value = shift; - $value = decode_entities ($value); - - #//Replace the character '\' for the equivalent html entitie - $value =~ s/\/\\/gi; - - #// First attempt to avoid SQL Injection based on SQL comments - #// Specific for MySQL. - $value =~ s//*/\/\*/gi; - $value =~ s/*//\*\//gi; - - #//Replace ( for the html entitie - $value =~ s/(/\(/gi; - - #//Replace ( for the html entitie - $value =~ s/)/\)/gi; - - #//Replace ' for the html entitie - $value =~ s/'/')/gi; - - #//Replace " for the html entitie - $value =~ s/"/")/gi; - - #//Replace some characteres for html entities - for (my $i=0;$i<33;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$hex/$pattern/gi; - } - - for (my $i=128;$i<191;$i++) { - my $pattern = chr($i); - my $hex = ascii_to_html($i); - $value =~ s/$hex/$pattern/gi; - } - - #//Replace characteres for tildes and others - my $trans = get_html_entities(); - - foreach(keys(%$trans)) - { - my $pattern = chr($_); - $value =~ s/$trans->{$_}/$pattern/g; - } - + _decode_entities ($value, \%ENT2CHR); + return $value; } -########################################################################## -# SUB get_html_entities -# Returns a hash table with the acute and special html entities -# Usefull for future chars addition: -# http://cpansearch.perl.org/src/GAAS/HTML-Parser-3.68/lib/HTML/Entities.pm -########################################################################## - -sub get_html_entities { - my %trans = ( - 225 => 'á', - 233 => 'é', - 237 => 'í', - 243 => 'ó', - 250 => 'ú', - 193 => 'Á', - 201 => 'É', - 205 => 'Í', - 211 => 'Ó', - 218 => 'Ú', - 228 => 'ä', - 235 => 'ë', - 239 => 'ï', - 246 => 'ö', - 252 => 'ü', - 196 => 'Ä', - 203 => 'Ë', - 207 => 'Ï', - 214 => 'Ö', - 220 => 'Ü', - 241 => 'ñ', - 209 => 'Ñ' - ); - - return \%trans; -} -######################################################################## -# SUB ascii_to_html (string) -# Convert an ascii string to hexadecimal -######################################################################## - -sub ascii_to_html($) { - my $ascii = shift; - - return "&#x".substr(unpack("H*", pack("N", $ascii)),6,3).";"; -} - ######################################################################## # Sub daemonize () # Put program in background (for daemon mode) @@ -863,6 +880,24 @@ sub dateTimeToTimestamp { sub disk_free ($) { my $target = $_[0]; + my $OSNAME = $^O; + + # Get the free disk on data_in folder unit + if ($OSNAME eq "MSWin32") { + # Check relative path + my $unit; + if ($target =~ m/^([a-zA-Z]):/gi) { + $unit = $1/(1024*1024); + } else { + return; + } + # Get the free space of unit found + my $all_disk_info = `wmic logicaldisk get caption, freespace`; + if ($all_disk_info =~ m/$unit:\D*(\d+)/gmi){ + return $1; + } + return; + } # Try to use df command with Posix parameters... my $command = "df -k -P ".$target." | tail -1 | awk '{ print \$4/1024}'"; my $output = `$command`; @@ -876,6 +911,9 @@ sub load_average { if ($OSNAME eq "freebsd"){ $load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]); + } elsif ($OSNAME eq "MSWin32") { + # Windows hasn't got load average. + $load_average = undef; } # by default LINUX calls else { @@ -898,6 +936,14 @@ sub free_mem { elsif ($OSNAME eq "netbsd"){ $free_mem = `cat /proc/meminfo | grep MemFree | awk '{ print \$2 }'`; } + elsif ($OSNAME eq "MSWin32"){ + $free_mem = `wmic OS get FreePhysicalMemory /Value`; + if ($free_mem =~ m/=(.*)$/gm) { + $free_mem = $1; + } else { + $free_mem = undef; + } + } # by default LINUX calls else { $free_mem = `free | grep Mem | awk '{ print \$4 }'`; @@ -1325,7 +1371,12 @@ sub cron_next_execution_date { # Months start from 0 if($mon ne '*') { - $mon -= 1; + my ($mon_down, $mon_up) = cron_get_interval ($mon); + if (defined($mon_up)) { + $mon = $mon_down - 1 . "-" . $mon_up - 1; + } else { + $mon = $mon_down - 1; + } } # Get current time @@ -1340,76 +1391,113 @@ sub cron_next_execution_date { my @cron_array = ($min, $hour, $mday, $mon); my @curr_time_array = ($cur_min, $cur_hour, $cur_mday, $cur_mon); return ($nex_time) if cron_is_in_cron(\@cron_array, \@curr_time_array) == 1; - - # Parse intervals - ($min, undef) = cron_get_interval ($min); - ($hour, undef) = cron_get_interval ($hour); - ($mday, undef) = cron_get_interval ($mday); - ($mon, undef) = cron_get_interval ($mon); - # Get first next date candidate from cron configuration - my ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) - = ($min, $hour, $mday, $mon, $cur_year); + # Get first next date candidate from next cron configuration + # Initialize some vars + my @nex_time_array = @curr_time_array; + my $prev_ovfl = 0; - # Replace wildcards - if ($min eq '*') { - if ($hour ne '*' || $mday ne '*' || $wday ne '*' || $mon ne '*') { - $nex_min = 0; - } - else { - $nex_min = $cur_min; - } - } - if ($hour eq '*') { - if ($mday ne '*' || $wday ne '*' ||$mon ne '*') { - $nex_hour = 0; - } - else { - $nex_hour = $cur_hour; - } - } - if ($mday eq '*') { - if ($mon ne '*') { - $nex_mday = 1; - } - else { - $nex_mday = $cur_mday; - } - } - if ($mon eq '*') { - $nex_mon = $cur_mon; + # Update minutes + my ($min_down, undef) = cron_get_interval ($min); + $nex_time_array[0] = ($min_down eq '*') ? 0 : $min_down; + + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time >= $cur_time) { + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); } - # Find the next execution date - my $count = 0; - do { - my $next_time = timelocal(0, $nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year); - if ($next_time > $cur_time) { - return $next_time; - } - if ($min eq '*' && $hour eq '*' && $wday eq '*' && $mday eq '*' && $mon eq '*') { - ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = (localtime ($next_time + 60))[1, 2, 3, 4, 5]; - } - elsif ($hour eq '*' && $wday eq '*' && $mday eq '*' && $mon eq '*') { - ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = (localtime ($next_time + 3600))[1, 2, 3, 4, 5]; - } - elsif ($mday eq '*' && $mon eq '*') { - ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = (localtime ($next_time + 86400))[1, 2, 3, 4, 5]; - } - elsif ($mon eq '*') { - $nex_mon = $nex_mon + 1; - if ($nex_mon > 11) { - $nex_mon = 0; - $nex_year++; + # Check if next hour is in cron + $nex_time_array[1]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + + if ($nex_time == 0) { + #Update the month day if overflow + $prev_ovfl = 1; + $nex_time_array[1] = 0; + $nex_time_array[2]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the month if overflow + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the year if overflow + $cur_year++; + $nex_time_array[3] = 0; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); } } - else { - $nex_year++; + } + #Check the hour + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + + #Update the hour if fails + my ($hour_down, undef) = cron_get_interval ($hour); + $nex_time_array[1] = ($hour_down eq '*') ? 0 : $hour_down; + + # When an overflow is passed check the hour update again + if ($prev_ovfl) { + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + } + $prev_ovfl = 0; + + # Check if next day is in cron + $nex_time_array[2]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the month if overflow + $prev_ovfl = 1; + $nex_time_array[2] = 1; + $nex_time_array[3]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the year if overflow + $nex_time_array[3] = 0; + $cur_year++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); } - $count++; - } while ($count < 60); + } + #Check the day + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); - # Something went wrong, default to 5 minutes + #Update the day if fails + my ($mday_down, undef) = cron_get_interval ($mday); + $nex_time_array[2] = ($mday_down eq '*') ? 1 : $mday_down; + + # When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + } + $prev_ovfl = 0; + + # Check if next month is in cron + $nex_time_array[3]++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + if ($nex_time == 0) { + #Update the year if overflow + $prev_ovfl = 1; + $cur_year++; + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + } + + #Check the month + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + + #Update the month if fails + my ($mon_down, undef) = cron_get_interval ($mon); + $nex_time_array[3] = ($mday_down eq '*') ? 0 : $mday_down; + + # When an overflow is passed check the hour update in the next execution + if ($prev_ovfl) { + $nex_time = cron_valid_date(@nex_time_array, $cur_year); + return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); + } + + $nex_time = cron_valid_date(@nex_time_array, $cur_year + 1); + return $nex_time; } ############################################################################### @@ -1419,9 +1507,12 @@ sub cron_next_execution_date { ############################################################################### sub cron_is_in_cron { my ($elems_cron, $elems_curr_time) = @_; + + my @deref_elems_cron = @$elems_cron; + my @deref_elems_curr_time = @$elems_curr_time; - my $elem_cron = shift(@$elems_cron); - my $elem_curr_time = shift (@$elems_curr_time); + my $elem_cron = shift(@deref_elems_cron); + my $elem_curr_time = shift (@deref_elems_curr_time); #If there is no elements means that is in cron return 1 unless (defined($elem_cron) || defined($elem_curr_time)); @@ -1430,15 +1521,17 @@ sub cron_is_in_cron { if ($elem_cron ne '*') { my ($down, $up) = cron_get_interval($elem_cron); # Check if there is no a range - return 0 if (!defined($up) && ($down != $cron)); + return 0 if (!defined($up) && ($down != $elem_curr_time)); # Check if there is on the range - if ($down < $up) { - return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); - } else { - return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + if (defined($up)) { + if ($down < $up) { + return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); + } else { + return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + } } } - return cron_is_in_cron($elems_cron, $elems_curr_time); + return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time); } ############################################################################### # Returns the interval of a cron element. If there is not a range, @@ -1480,6 +1573,22 @@ sub cron_get_closest_in_range ($$) { return $target; } +############################################################################### +# Check if a date is valid to get timelocal +############################################################################### +sub cron_valid_date { + my ($min, $hour, $mday, $month, $year) = @_; + my $utime; + eval { + local $SIG{__DIE__} = sub {}; + $utime = timelocal(0, $min, $hour, $mday, $month, $year); + }; + if ($@) { + return 0; + } + return $utime; +} + ############################################################################### # Attempt to resolve the given hostname. ############################################################################### diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 310b8b8bb7..937f088aa0 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.715 -%define release 171110 +%define version 7.0NG.716 +%define release 171130 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 2738f223f7..d2ecac53a2 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.715 -%define release 171110 +%define version 7.0NG.716 +%define release 171130 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 9576c3f8c8..1b2e016056 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.715" -PI_BUILD="171110" +PI_VERSION="7.0NG.716" +PI_BUILD="171130" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index dc29db1eb8..ce7d59b791 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -33,7 +33,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.715 PS171110"; +my $version = "7.0NG.716 PS171130"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 9342fd419b..e8a2b003a1 100644 --- 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.715 PS171110"; +my $version = "7.0NG.716 PS171130"; # save program name for logging my $progname = basename($0); @@ -4824,9 +4824,13 @@ sub cli_create_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $show_statistics = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; - my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] The element id in position $elem_count is '$elem_id' \n\n"; @@ -4893,9 +4897,13 @@ sub cli_create_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; + - my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $vc_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] The element id in position $elem_count is '$elem_id' \n\n"; @@ -5001,6 +5009,9 @@ sub cli_edit_visual_console() { my $new_label_position = $element_in_db->{'label_position'}; my $new_border_color = $element_in_db->{'border_color'}; my $new_fill_color = $element_in_db->{'fill_color'}; + my $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $new_element_group = $elem->{'element_group'}; + my $new_show_on_top = $elem->{'show_on_top'}; if(defined($elem->{'pos_x'})) { $new_pos_x = $elem->{'pos_x'}; @@ -5065,6 +5076,15 @@ sub cli_edit_visual_console() { if(defined($elem->{'fill_color'})) { $new_fill_color = $elem->{'fill_color'}; } + if(defined($elem->{'id_layout_linked_weight'})) { + $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + } + if(defined($elem->{'element_group'})) { + $new_element_group = $elem->{'element_group'}; + } + if(defined($elem->{'show_on_top'})) { + $new_show_on_top = $elem->{'show_on_top'}; + } db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y . ", width = " . $new_width . ", height = " . $new_height . ", label = '" . $new_label . "', image = '" . $new_image . @@ -5073,6 +5093,7 @@ sub cli_edit_visual_console() { ", enable_link = " . $new_enable_link . ", id_metaconsole = " . $new_id_metaconsole . ", id_group = " . $new_id_group . ", id_custom_graph = " . $new_id_custom_graph . ", border_width = " . $new_border_width . ", type_graph = '" . $new_type_graph . "', label_position = '" . $new_label_position . "', border_color = '" . $new_border_color . "', fill_color = '" . $new_fill_color . + "', id_layout_linked_weight = '" . $new_id_layout_linked_weight . "', element_group = '" . $new_element_group . "', show_on_top = '" . $new_show_on_top . "' WHERE id = " . $elem->{'id'}); print_log "[INFO] Element with id " . $elem->{'id'} . " has been updated \n\n"; @@ -5099,9 +5120,12 @@ sub cli_edit_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; - my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] New element with id $new_elem_id has been created \n\n"; } @@ -5142,6 +5166,9 @@ sub cli_edit_visual_console() { my $new_label_position = $element_in_db->{'label_position'}; my $new_border_color = $element_in_db->{'border_color'}; my $new_fill_color = $element_in_db->{'fill_color'}; + my $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $new_element_group = $elem->{'element_group'}; + my $new_show_on_top = $elem->{'show_on_top'}; if(defined($elem->{'width'})) { $new_width = $elem->{'width'}; @@ -5200,6 +5227,15 @@ sub cli_edit_visual_console() { if(defined($elem->{'fill_color'})) { $new_fill_color = $elem->{'fill_color'}; } + if(defined($elem->{'id_layout_linked_weight'})) { + $new_id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + } + if(defined($elem->{'element_group'})) { + $new_element_group = $elem->{'element_group'}; + } + if(defined($elem->{'show_on_top'})) { + $new_show_on_top = $elem->{'show_on_top'}; + } db_update ($dbh, "UPDATE tlayout_data SET pos_x = " . $new_pos_x . ", pos_y = " . $new_pos_y . ", width = " . $new_width . ", height = " . $new_height . ", label = '" . $new_label . "', image = '" . $new_image . @@ -5208,6 +5244,7 @@ sub cli_edit_visual_console() { ", enable_link = " . $new_enable_link . ", id_metaconsole = " . $new_id_metaconsole . ", id_group = " . $new_id_group . ", id_custom_graph = " . $new_id_custom_graph . ", border_width = " . $new_border_width . ", type_graph = '" . $new_type_graph . "', label_position = '" . $new_label_position . "', border_color = '" . $new_border_color . "', fill_color = '" . $new_fill_color . + "', id_layout_linked_weight = '" . $new_id_layout_linked_weight . "', element_group = '" . $new_element_group . "', show_on_top = '" . $new_show_on_top . "' WHERE id = " . $elem->{'id'}); print_log "[INFO] Element with id " . $elem->{'id'} . " has been updated \n\n"; @@ -5234,9 +5271,12 @@ sub cli_edit_visual_console() { my $label_position = $elem->{'label_position'}; my $border_color = $elem->{'border_color'}; my $fill_color = $elem->{'fill_color'}; + my $id_layout_linked_weight = $elem->{'id_layout_linked_weight'}; + my $element_group = $elem->{'element_group'}; + my $show_on_top = $elem->{'show_on_top'}; - my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $new_elem_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] New element with id $new_elem_id has been created \n\n"; } @@ -5441,9 +5481,12 @@ sub cli_duplicate_visual_console () { my $label_position = $element->{'label_position'}; my $border_color = $element->{'border_color'}; my $fill_color = $element->{'fill_color'}; + my $id_layout_linked_weight = $element->{'id_layout_linked_weight'}; + my $element_group = $element->{'element_group'}; + my $show_on_top = $element->{'show_on_top'}; - my $element_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $new_console_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0); + my $element_id = db_insert ($dbh, 'id', 'INSERT INTO tlayout_data (id_layout, pos_x, pos_y, height, width, label, image, type, period, id_agente_modulo, id_agent, id_layout_linked, parent_item, enable_link, id_metaconsole, id_group, id_custom_graph, border_width, type_graph, label_position, border_color, fill_color, show_statistics, id_layout_linked_weight, element_group, show_on_top) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $new_console_id, $pos_x, $pos_y, $height, $width, $label, $image, $type, $period, $id_agente_modulo, $id_agent, $id_layout_linked, $parent_item, $enable_link, $id_metaconsole, $id_group, $id_custom_graph, $border_width, $type_graph, $label_position, $border_color, $fill_color, 0, $id_layout_linked_weight, $element_group, $show_on_top); print_log "[INFO] Element with ID " . $element->{"id"} . " has been duplicated to the new console \n\n"; } @@ -5509,6 +5552,9 @@ sub cli_export_visual_console() { my $label_position = $element->{'label_position'}; my $border_color = $element->{'border_color'}; my $fill_color = $element->{'fill_color'}; + my $id_layout_linked_weight = $element->{'id_layout_linked_weight'}; + my $element_group = $element->{'element_group'}; + my $show_on_top = $element->{'show_on_top'}; if ($first == 0) { $data_to_json .= ',' @@ -5546,6 +5592,9 @@ sub cli_export_visual_console() { $data_to_json .= ',"label_position":"' . $label_position . '"'; $data_to_json .= ',"border_color":"' . $border_color . '"'; $data_to_json .= ',"fill_color":"' . $fill_color . '"'; + $data_to_json .= ',"id_layout_linked_weight":' . $id_layout_linked_weight; + $data_to_json .= ',"element_group":' . $element_group; + $data_to_json .= ',"show_on_top":' . $show_on_top; $data_to_json .= '}'; } diff --git a/pandora_server/util/pwrd/install_pwrd.sh b/pandora_server/util/pwrd/install_pwrd.sh index 66cb0a9795..2de6b11e3d 100644 --- a/pandora_server/util/pwrd/install_pwrd.sh +++ b/pandora_server/util/pwrd/install_pwrd.sh @@ -45,7 +45,7 @@ ln -s $PWR_FIREFOX_INSTALLDIR/firefox/firefox /usr/bin/firefox # Generate logrotate configuration -echo < /etc/logrotate.d/pwrd +cat > /etc/logrotate.d/pwrd <