diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 0b22878285..90c4bf6519 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -16,7 +16,7 @@ else fi VERSION=$2 if [ $# == 2 ]; then - BUILD=`date +%g%m%d` + BUILD=`date +%y%m%d` else BUILD=$3 fi diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index ad9f9f3c3d..969c6c3edc 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.729, AIX version +# Version 7.0NG.730, 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 8de6468c19..968b8b2273 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.729, FreeBSD Version +# Version 7.0NG.730, 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 0c7582879b..1bb7afe932 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.729, HP-UX Version +# Version 7.0NG.730, 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 17b4e3ec67..1032e972c3 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.729, GNU/Linux +# Version 7.0NG.730, 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 15f274095a..27d6bc2499 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.729, GNU/Linux +# Version 7.0NG.730, 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 b4e901951d..86860f55e6 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.729, Solaris Version +# Version 7.0NG.730, 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 bbf52b6bc1..5e5d0580e6 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.729 +# Version 7.0NG.730 # 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 72375ecebe..1b3ba629b7 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.729, AIX version +# Version 7.0NG.730, 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 6d08062786..4ed22c0a3e 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.729 +# Version 7.0NG.730 # 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 9b452127ca..22faee00e8 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.729, HPUX Version +# Version 7.0NG.730, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index c8ebc2b25f..a784ce4fc0 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.729 +# Version 7.0NG.730 # 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 d0044b7398..456802c06a 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.729 +# Version 7.0NG.730 # 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 53b696ba06..44e244c74e 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.729 +# Version 7.0NG.730 # 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 c592279323..fdb61b9888 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.729, Solaris version +# Version 7.0NG.730, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 64671fae84..54451441dd 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.729, AIX version +# Version 7.0NG.730, 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 41cc911f04..5edf2e031e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.729-181205 +Version: 7.0NG.730-190121 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 8f76eb020a..47d6c97643 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.729-181205" +pandora_version="7.0NG.730-190121" 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 160a20b253..2c4ea59daa 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.729, GNU/Linux +# Version 7.0NG.730, 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 e97a1675fb..3feebad741 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.729, FreeBSD Version +# Version 7.0NG.730, 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 366928ea65..b0f9dd590e 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.729, HP-UX Version +# Version 7.0NG.730, 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 e6a3200726..2679f78617 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.729, GNU/Linux +# Version 7.0NG.730, 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 c3f4b791f1..8d3736b35f 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.729, GNU/Linux +# Version 7.0NG.730, 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 8efe821f74..e0eea4b59e 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.729, NetBSD Version +# Version 7.0NG.730, 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 b32f162d4b..30ac06a0ca 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.729, Solaris Version +# Version 7.0NG.730, 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 55a4df5cfb..54b12f4f5b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,8 +41,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.729'; -use constant AGENT_BUILD => '181205'; +use constant AGENT_VERSION => '7.0NG.730'; +use constant AGENT_BUILD => '190121'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -516,11 +516,18 @@ sub parse_conf_modules($) { log_message ('setup', "Invalid regular expression in intensive condition: $line"); } } - } elsif ($line =~ /^\s*module_crontab\s+(((\*|(\d+(-\d+){0,1}))\s*){5}).*$/) { + } elsif ($line =~ /^\s*module_crontab\s+(.*)$/) { my $cron_text = $1; chomp ($cron_text); + $cron_text =~ s/\s+$//; + # Get module name if is already read. + my $module_name_message = ""; + $module_name_message = " (module $module->{'name'})" if defined($module->{'name'}); if (cron_check_syntax($cron_text)) { $module->{'cron'} = $cron_text; + log_message('debug', "Cron '$module->{'cron'}' configured $module_name_message."); + } else { + log_message('setup', "Incorrect cron syntax '$cron_text'. This module$module_name_message will be executed always."); } } elsif ($line =~ /^\s*module_end\s*$/) { @@ -2397,6 +2404,7 @@ sub check_module_cron { $interval ); + my $is_first = ($module->{'cron_utimestamp'} == 0) ? 1 : 0; $module->{'cron_utimestamp'} = $now + $time_to_next_execution; $module->{'cron_interval'} = $time_to_next_execution; @@ -2405,7 +2413,7 @@ sub check_module_cron { } # On first execution checking if cron is valid is required - return 1 unless ($module->{'cron_utimestamp'} == 0); + return 1 unless ($is_first); # Check if current timestamp is a valid cron date my $next_execution = cron_next_execution_date( diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 107458342e..6fb7b30b81 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.729 -%define release 181205 +%define version 7.0NG.730 +%define release 190121 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 824db2d44f..5bbd32b462 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.729 -%define release 181205 +%define version 7.0NG.730 +%define release 190121 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 15ce482e20..47fb301e3b 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.729" -PI_BUILD="181205" +PI_VERSION="7.0NG.730" +PI_BUILD="190121" 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 9ba6eff68d..795842f5f5 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.729 +# Version 7.0NG.730 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index a04af66252..945e983da3 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.729} +{Pandora FMS Windows Agent v7.0NG.730} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{181205} +{190121} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 80251b3ad4..fee3ef8459 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.729(Build 181205)") +#define PANDORA_VERSION ("7.0NG.730(Build 190121)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 76824914ca..71d61237d1 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.729(Build 181205))" + VALUE "ProductVersion", "(7.0NG.730(Build 190121))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 50ed14c136..ec72bc0293 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.729-181205 +Version: 7.0NG.730-190121 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 7e7319dc37..7aa7dbadd5 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.729-181205" +pandora_version="7.0NG.730-190121" package_pear=0 package_pandora=1 diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index 97ffe031a9..c7d21fff1a 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -14,6 +14,15 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +// Enable profiler for testing +if (!defined("__PAN_XHPROF__")) define ("__PAN_XHPROF__", 0); + +if (__PAN_XHPROF__ === 1) { + if (function_exists('tideways_xhprof_enable')) { + tideways_xhprof_enable(); + } +} + if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) { exit; } @@ -88,4 +97,8 @@ if (file_exists ($page)) { else { echo '
Sorry! I can\'t find the page '.$page.'!'; } + +if (__PAN_XHPROF__ === 1) { + pandora_xhprof_display_result("ajax", "console"); +} ?> diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index b7eca3b3e9..18ba051b60 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -61,17 +61,27 @@ function mainModuleGroups() { $info = groupview_plain_groups($info); $counter = count($info); $offset = get_parameter('offset', 0); - $groups_view = $is_not_paginated - ? $info - : array_slice($info, $offset, $config['block_size']); - $agents_counters = array_reduce($groups_view, function($carry, $item){ - $carry[$item['id']] = $item; - return $carry; - }, array()); + $agent_group_search = get_parameter('agent_group_search', ''); + $module_group_search = get_parameter('module_group_search', ''); - $ids_array = array_keys($agents_counters); + $info = array_filter($info, function($v, $k) use ($agent_group_search) { + return preg_match("/$agent_group_search/i", $v['name']); + }, ARRAY_FILTER_USE_BOTH); - $ids_group = implode(',', $ids_array); + if (!empty($info)) { + $groups_view = $is_not_paginated + ? $info + : array_slice($info, $offset, $config['block_size']); + $agents_counters = array_reduce($groups_view, function($carry, $item){ + $carry[$item['id']] = $item; + return $carry; + }, array()); + + $ids_array = array_keys($agents_counters); + + $ids_group = implode(',', $ids_array); + } else + $ids_group = -1; $condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT); $condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT); @@ -90,6 +100,12 @@ function mainModuleGroups() { $array_module_group[$value['id_mg']] = $value['name']; } $array_module_group[0] = 'Nothing'; + + + $array_module_group = array_filter($array_module_group, function($v, $k) use ($module_group_search) { + return preg_match("/$module_group_search/i", $v); + }, ARRAY_FILTER_USE_BOTH); + foreach ($agents_counters as $key => $value) { $array_for_defect[$key]['gm'] = $array_module_group; $array_for_defect[$key]['data']['name'] = $value['name']; @@ -167,7 +183,26 @@ $sql = ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, ''); - if(count($array_for_defect) > 0){ + echo " + "; + echo ""; + + echo "
"; + echo __('Search by agent group') . ' '; + html_print_input_text ("agent_group_search", $agent_group_search); + + echo ""; + echo __('Search by module group') . ' '; + html_print_input_text ("module_group_search", $module_group_search); + + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + + if(true){ $table = new StdClass(); $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; $table->width = '100%'; diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.js b/pandora_console/extensions/realtime_graphs/realtime_graphs.js index 34da7b1704..924331cafe 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.js +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.js @@ -30,7 +30,7 @@ }, yaxis: { tickFormatter: function (value, axis) { - return shortNumber(value); + return shortNumber(roundToTwo(value)) ; } }, series: { @@ -178,6 +178,9 @@ return number + " " + shorts[pos]; } + function roundToTwo(num) { + return +(Math.round(num + "e+2") + "e-2"); + } $('#graph').change(function() { $('form#realgraph').submit(); diff --git a/pandora_console/extras/mr/23.sql b/pandora_console/extras/mr/23.sql index a602023e3b..98ef4f5747 100644 --- a/pandora_console/extras/mr/23.sql +++ b/pandora_console/extras/mr/23.sql @@ -6,4 +6,6 @@ ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600 ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0'; +ALTER TABLE `tevent_rule` ADD COLUMN `group_recursion` INT(1) unsigned default 0; + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/mr/24.sql b/pandora_console/extras/mr/24.sql new file mode 100644 index 0000000000..f93d9c6e6e --- /dev/null +++ b/pandora_console/extras/mr/24.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `treport` ADD COLUMN `orientation` varchar(25) NOT NULL default 'vertical'; + +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 5b98fdbec0..5dc7cd70c4 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 @@ -48,8 +48,6 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` ( `dynamic_interval` int(4) unsigned default '0', `dynamic_max` int(4) default '0', `dynamic_min` int(4) default '0', - `dynamic_next` bigint(20) NOT NULL default '0', - `dynamic_two_tailed` tinyint(1) unsigned default '0', `prediction_sample_window` int(10) default 0, `prediction_samples` int(4) default 0, `prediction_threshold` int(4) default 0, @@ -58,6 +56,9 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; +ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; + -- ----------------------------------------------------- -- Table `tpolicy_modules` -- ----------------------------------------------------- @@ -125,8 +126,6 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` ( `dynamic_interval` int(4) unsigned default '0', `dynamic_max` int(4) default '0', `dynamic_min` int(4) default '0', - `dynamic_next` bigint(20) NOT NULL default '0', - `dynamic_two_tailed` tinyint(1) unsigned default '0', `prediction_sample_window` int(10) default 0, `prediction_samples` int(4) default 0, `prediction_threshold` int(4) default 0, @@ -135,6 +134,9 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` ( UNIQUE (`id_policy`, `name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; +ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; + -- --------------------------------------------------------------------- -- Table `tpolicies` -- --------------------------------------------------------------------- @@ -181,6 +183,9 @@ CREATE TABLE IF NOT EXISTS `tpolicy_agents` ( UNIQUE (`id_policy`, `id_agent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tpolicy_agents` ADD COLUMN `id_node` int(10) NOT NULL DEFAULT '0'; +ALTER TABLE `tpolicy_agents` ADD UNIQUE(`id_policy`, `id_agent`, `id_node`); + -- ----------------------------------------------------- -- Table `tpolicy_groups` -- ----------------------------------------------------- @@ -292,6 +297,8 @@ CREATE TABLE IF NOT EXISTS `tagent_module_inventory` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tagent_module_inventory` ADD COLUMN `custom_fields` MEDIUMBLOB NOT NULL; + -- --------------------------------------------------------------------- -- Table `tpolicy_modules_inventory` -- --------------------------------------------------------------------- @@ -310,6 +317,8 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules_inventory` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tpolicy_modules_inventory` ADD COLUMN `custom_fields` MEDIUMBLOB NOT NULL; + -- ----------------------------------------------------- -- Table `tagente_datos_inventory` -- ----------------------------------------------------- @@ -341,18 +350,13 @@ CREATE TABLE IF NOT EXISTS `ttrap_custom_values` ( -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( `id` int(10) NOT NULL auto_increment primary key, - `server_name` text, - `server_url` text, - `dbuser` text, - `dbpass` text, - `dbhost` text, - `dbport` text, - `dbname` text, - `meta_dbuser` text, - `meta_dbpass` text, - `meta_dbhost` text, - `meta_dbport` text, - `meta_dbname` text, + `server_name` text default '', + `server_url` text default '', + `dbuser` text default '', + `dbpass` text default '', + `dbhost` text default '', + `dbport` text default '', + `dbname` text default '', `auth_token` text default '', `id_group` int(10) unsigned NOT NULL default 0, `api_password` text NOT NULL, @@ -362,6 +366,12 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( COMMENT = 'Table to store metaconsole sources' DEFAULT CHARSET=utf8; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbuser` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbpass` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbhost` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbport` text; +ALTER TABLE tmetaconsole_setup ADD COLUMN `meta_dbname` text; + -- --------------------------------------------------------------------- -- Table `tprofile_view` -- --------------------------------------------------------------------- @@ -400,7 +410,7 @@ CREATE TABLE IF NOT EXISTS `tservice` ( `id_template_alert_warning` int(10) unsigned NOT NULL default 0, `id_template_alert_critical` int(10) unsigned NOT NULL default 0, `id_template_alert_unknown` int(10) unsigned NOT NULL default 0, - `id_template_alert_critical_sla` int(10) unsigned NOT NULL default 0 + `id_template_alert_critical_sla` int(10) unsigned NOT NULL default 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB COMMENT = 'Table to define services to monitor' @@ -548,6 +558,8 @@ CREATE TABLE IF NOT EXISTS `tevent_rule` ( KEY `idx_id_event_alert` (`id_event_alert`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `tevent_rule` ADD COLUMN `group_recursion` INT(1) unsigned default 0; + -- ----------------------------------------------------- -- Table `tevent_alert` -- ----------------------------------------------------- @@ -744,14 +756,15 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `module_names` TEXT, `module_free_text` TEXT, `each_agent` tinyint(1) default 1, - `historical_db` tinyint(1) UNSIGNED NOT NULL default 0, - `lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0', - `lapse` int(11) UNSIGNED NOT NULL default '300', - `visual_format` tinyint(1) UNSIGNED NOT NULL default '0', - `hide_no_data` tinyint(1) default 0, PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE treport_content_template ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0'; +ALTER TABLE treport_content_template ADD COLUMN `lapse_calc` tinyint(1) default '0'; +ALTER TABLE treport_content_template ADD COLUMN `lapse` int(11) default '300'; +ALTER TABLE treport_content_template ADD COLUMN `visual_format` tinyint(1) default '0'; +ALTER TABLE treport_content_template ADD COLUMN `hide_no_data` tinyint(1) default '0'; + -- ----------------------------------------------------- -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) -- ----------------------------------------------------- @@ -860,6 +873,9 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( -- Criticity: 5 - Minor -- Criticity: 6 - Major +ALTER TABLE `tmetaconsole_event` ADD COLUMN `data` double(22,5) default NULL; +ALTER TABLE `tmetaconsole_event` ADD COLUMN `module_status` int(4) NOT NULL default '0'; + -- --------------------------------------------------------------------- -- Table `tmetaconsole_event_history` -- --------------------------------------------------------------------- @@ -905,6 +921,8 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` ( -- Criticity: 5 - Minor -- Criticity: 6 - Major +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `data` double(22,5) default NULL; +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `module_status` int(4) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `textension_translate_string` -- --------------------------------------------------------------------- @@ -957,12 +975,10 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( `agent_version` varchar(100) default '', `ultimo_contacto_remoto` datetime default '1970-01-01 00:00:00', `disabled` tinyint(2) NOT NULL default '0', - `remote` tinyint(1) NOT NULL default '0', `id_parent` int(10) unsigned default '0', `custom_id` varchar(255) default '', `server_name` varchar(100) default '', `cascade_protection` tinyint(2) NOT NULL default '0', - `cascade_protection_module` int(10) unsigned default '0', `timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'number of hours of diference with the server timezone' , `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , `update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' , @@ -977,8 +993,6 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( `fired_count` bigint(20) NOT NULL default '0', `update_module_count` tinyint(1) NOT NULL default '0', `update_alert_count` tinyint(1) NOT NULL default '0', - `transactional_agent` tinyint(1) NOT NULL default '0', - `alias` varchar(600) BINARY NOT NULL default '', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)), KEY `direccion` (`direccion`), @@ -987,6 +1001,11 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE tmetaconsole_agent ADD COLUMN `remote` tinyint(1) NOT NULL default '0'; +ALTER TABLE tmetaconsole_agent ADD COLUMN `cascade_protection_module` int(10) default '0'; +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 ''; + -- --------------------------------------------------------------------- -- Table `ttransaction` -- --------------------------------------------------------------------- @@ -1305,6 +1324,10 @@ ALTER TABLE tlayout_data ADD COLUMN `clock_animation` varchar(60) NOT NULL defau ALTER TABLE tlayout_data ADD COLUMN `time_format` varchar(60) NOT NULL default "time"; ALTER TABLE tlayout_data ADD COLUMN `timezone` varchar(60) NOT NULL default "Europe/Madrid"; ALTER TABLE tlayout_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0'; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default'; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; -- --------------------------------------------------------------------- -- Table `tagent_custom_fields` @@ -1358,26 +1381,15 @@ ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL; -- --------------------------------------------------------------------- ALTER TABLE tmodule_relationship ADD COLUMN `id_server` varchar(100) NOT NULL DEFAULT ''; --- Table `tlocal_component` --- --------------------------------------------------------------------- -ALTER TABLE tlocal_component ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; -ALTER TABLE tlocal_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; - -- --------------------------------------------------------------------- -- Table `tpolicy_module` -- --------------------------------------------------------------------- ALTER TABLE tpolicy_modules ADD COLUMN `ip_target`varchar(100) default ''; -ALTER TABLE tpolicy_modules ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; -ALTER TABLE tpolicy_modules ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE `tpolicy_modules` ADD COLUMN `cps` int NOT NULL DEFAULT 0; -- --------------------------------------------------------------------- -- Table `tmetaconsole_agent` -- --------------------------------------------------------------------- -ALTER TABLE tmetaconsole_agent ADD COLUMN `remote` tinyint(1) NOT NULL default '0'; -ALTER TABLE tmetaconsole_agent ADD COLUMN `cascade_protection_module` int(10) default '0'; -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'; ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL default 0; @@ -1542,6 +1554,8 @@ ALTER TABLE `tdashboard` ADD COLUMN `cells_slideshow` TINYINT(1) NOT NULL defaul -- --------------------------------------------------------------------- -- Table `tsnmp_filter` -- --------------------------------------------------------------------- +ALTER TABLE tsnmp_filter ADD unified_filters_id int(10) NOT NULL DEFAULT 0; + SELECT max(unified_filters_id) INTO @max FROM tsnmp_filter; UPDATE tsnmp_filter tsf,(SELECT @max:= @max) m SET tsf.unified_filters_id = @max:= @max + 1 where tsf.unified_filters_id=0; @@ -1732,7 +1746,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, + `name` varchar(600) NOT NULL, `id_group` INTEGER UNSIGNED NOT NULL, `background` varchar(200) NOT NULL, `height` INTEGER UNSIGNED NOT NULL default 0, @@ -1778,11 +1792,15 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `clock_animation` varchar(60) NOT NULL default "analogic_1", `time_format` varchar(60) NOT NULL default "time", `timezone` varchar(60) NOT NULL default "Europe/Madrid", + `show_last_value` tinyint(1) UNSIGNED NULL default '0', + `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', + `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0, + `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0, + `linked_layout_node_id` INT(10) NOT NULL default 0, PRIMARY KEY(`id`), FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE tlayout_template_data ADD COLUMN `show_last_value` tinyint(1) UNSIGNED NULL default '0'; -- --------------------------------------------------------------------- -- Table `tlog_graph_models` -- --------------------------------------------------------------------- @@ -1804,6 +1822,7 @@ INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', -- ----------------------------------------------------- ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE `treport` ADD COLUMN `orientation` varchar(25) NOT NULL default 'vertical'; ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1'; ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default ''; @@ -1824,11 +1843,28 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( `id_custom_fields_data` varchar(600) default '', `id_status` varchar(600) default '', `module_search` varchar(600) default '', + `module_status` varchar(600) default '', + `recursion` int(1) unsigned default '0', + `group_search` int(10) unsigned default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default ''; +-- --------------------------------------------------------------------- +-- Table `tevento` +-- --------------------------------------------------------------------- +ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; -ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0'; +ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; -ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0'; +-- ----------------------------------------------------- +-- Table `tgis_map_layer_groups` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( + `layer_id` INT NOT NULL, + `group_id` MEDIUMINT(4) UNSIGNED NOT NULL, + `agent_id` INT(10) UNSIGNED NOT NULL COMMENT 'Used to link the position to the group', + PRIMARY KEY (`layer_id`, `group_id`), + FOREIGN KEY (`layer_id`) REFERENCES `tgis_map_layer` (`id_tmap_layer`) ON DELETE CASCADE, + FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, + FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 658f7dd9fc..54a0a77d49 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -228,11 +228,11 @@ foreach ($result as $row) { $rowPair = !$rowPair; $data = array(); - $data[0] = $row["id_usuario"]; + $data[0] = io_safe_output($row["id_usuario"]); $data[1] = ui_print_session_action_icon($row["accion"], true) . $row["accion"]; $data[2] = ui_print_help_tip(date($config["date_format"], $row["utimestamp"]), true) . ui_print_timestamp($row["utimestamp"], true); - $data[3] = $row["ip_origen"]; + $data[3] = io_safe_output($row["ip_origen"]); $data[4] = io_safe_output($row["descripcion"]); if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 4e6be0e725..f94cb7737b 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -484,7 +484,7 @@ $table->data[4][1] = __('Disabled') . ' ' . $table->data[4][1] .= __('Enabled') . ' ' . html_print_radio_button_extended ("disabled", 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); if (enterprise_installed()) { - $table->data[4][2] = __('Url address'); + $table->data[4][2] = __('Url address') . ui_print_help_tip(__('URL address must be complete, for example: https://pandorafms.com/'), true); $table->data[4][3] = html_print_input_text ('url_description', $url_description, '', 45, 255, true); }else{ diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 5f364389ed..fab0ad7637 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -924,9 +924,8 @@ if ($update_agent) { // if modified some agent paramenter enterprise_hook ('update_agent', array ($id_agente)); ui_print_success_message (__('Successfully updated')); - $unsafe_alias = io_safe_output($alias); db_pandora_audit("Agent management", - "Updated agent $unsafe_alias", false, false, $info); + "Updated agent $alias", false, false, $info); } } @@ -1427,7 +1426,7 @@ if ($update_module) { $edit_module = true; db_pandora_audit("Agent management", - "Fail to try update module '".io_safe_output($name)."' for agent " . io_safe_output($agent["alias"])); + "Fail to try update module '$name' for agent " . $agent["alias"]); } else { if ($prediction_module == 3) { @@ -1445,7 +1444,7 @@ if ($update_module) { $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", - "Updated module '".io_safe_output($name)."' for agent ". io_safe_output($agent["alias"]), false, false, io_json_mb_encode($values)); + "Updated module '$name' for agent ".$agent["alias"], false, false, io_json_mb_encode($values)); } } @@ -1586,7 +1585,7 @@ if ($create_module) { $edit_module = true; $moduletype = $id_module; db_pandora_audit("Agent management", - "Fail to try added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"])); + "Fail to try added module '$name' for agent ".$agent["alias"]); } else { if ($prediction_module == 3) { @@ -1604,7 +1603,7 @@ if ($create_module) { $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", - "Added module '".io_safe_output($name)."' for agent ".io_safe_output($agent["alias"]), false, true, io_json_mb_encode($values)); + "Added module '$name' for agent ".$agent["alias"], false, true, io_json_mb_encode($values)); } } @@ -1727,7 +1726,7 @@ if ($delete_module) { // DELETE agent module ! $agent = db_get_row ('tagente', 'id_agente', $id_agente); db_pandora_audit("Agent management", - "Deleted module '".io_safe_output($module_data["nombre"])."' for agent ".io_safe_output($agent["alias"])); + "Deleted module '".$module_data["nombre"]."' for agent ".$agent["alias"]); } @@ -1760,11 +1759,11 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module ! if ($result) { db_pandora_audit("Agent management", - "Duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"]) . " with the new id for clon " . $result); + "Duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"] . " with the new id for clon " . $result); } else { db_pandora_audit("Agent management", - "Fail to try duplicate module '".$id_duplicate_module."' for agent " . io_safe_output($agent["alias"])); + "Fail to try duplicate module '".$id_duplicate_module."' for agent " . $agent["alias"]); } } diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index f9347c8b9b..079ff74573 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -573,18 +573,27 @@ ui_require_javascript_file ('pandora_modules'); ?> @@ -86,9 +86,8 @@ if (file_exists ('languages/'.$user_language.'.mo')) { -'; $config['font_size'] = $aux_font_size; -?> + ?> + + - - diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 1f6c20bbc6..fd05f10323 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 = 'PC181205'; -$pandora_version = 'v7.0NG.729'; +$build_version = 'PC190121'; +$pandora_version = 'v7.0NG.730'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index c223738b2a..22f46257dc 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -204,6 +204,7 @@ define('CIRCULAR_INTERIOR_PROGRESS_BAR', 16); define('DONUT_GRAPH', 17); define('BARS_GRAPH', 18); define('CLOCK', 19); +define('COLOR_CLOUD', 20); //Some styles define('MIN_WIDTH', 300); define('MIN_HEIGHT', 120); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d36c68ada2..f2056f058e 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3285,11 +3285,19 @@ function series_type_graph_array($data, $show_elements_graph){ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = false, $module_list = false){ global $config; + if(is_metaconsole()){ + $hack_metaconsole = "../.."; + } + else{ + $hack_metaconsole = ""; + } + $file_js = $config["homedir"] . "/include/web2image.js"; - $url = $config["homeurl"] . "include/chart_generator.php"; + $url = ui_get_full_url(false) . $hack_metaconsole . "/include/chart_generator.php"; + $img_file = "img_". uniqid() .".png"; $img_path = $config["homedir"] . "/attachment/" . $img_file; - $img_url = $config["homeurl"] . "attachment/" . $img_file; + $img_url = ui_get_full_url(false) . $hack_metaconsole . "/attachment/" . $img_file; $width_img = 500; $height_img = (isset($config['graph_image_height'])) ? $config['graph_image_height'] : 280; @@ -3320,7 +3328,10 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal . ' "' . $session_id . '"' . ' "' . $params['return_img_base_64'] . '"'; - exec($cmd, $result); + $result = null; + $retcode = null; + exec($cmd, $result, $retcode); + $img_content = join("\n", $result); if($params['return_img_base_64']){ @@ -3389,5 +3400,39 @@ function validate_csrf_code() { function generate_hash_to_api(){ hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key')); +} + +/** + * Disable the profiller and display de result + * + * @param string Key to identify the profiler run. + * @param string Way to display the result + * "link" (default): Click into word "Performance" to display the profilling info. + * "console": Display with a message in pandora_console.log. + */ +function pandora_xhprof_display_result($key = "", $method = "link") { + // Check if function exists + if (!function_exists('tideways_xhprof_disable')) { + error_log("Cannot find tideways_xhprof_disable function"); + return; } + + $run_id = uniqid(); + $data = tideways_xhprof_disable(); + $source = "pandora_$key"; + file_put_contents( + sys_get_temp_dir() . "/" . $run_id . ".$source.xhprof", + serialize($data) + ); + $new_url = "http://{$_SERVER['HTTP_HOST']}/profiler/index.php?run={$run_id}&source={$source}"; + switch($method) { + case "console": + error_log("'{$new_url}'"); + case "link": + default: + echo "Performance\n"; + break; + + } +} ?> diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index d69a27d8fe..b1d258e223 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -827,7 +827,8 @@ function agents_get_group_agents ( $filter = array(); - if (!$noACL) { + // check available groups for target user only if asking for 'All' group + if (!$noACL && $id_group == 0) { $id_group = $id_group == 0 ? array_keys(users_get_groups(false, "AR", false)) : groups_safe_acl($config["id_user"], $id_group, "AR"); @@ -848,7 +849,8 @@ function agents_get_group_agents ( $id_group = groups_get_id_recursive($id_group, true); } - if (!$noACL) { + // check available groups for target user only if asking for 'All' group + if (!$noACL && $id_group == 0) { $id_group = array_keys( users_get_groups(false, "AR", true, false, (array)$id_group)); } @@ -1231,8 +1233,8 @@ function agents_get_modules ($id_agent = null, $details = false, ON tagente.id_agente = tasg.id_agent WHERE tagente_modulo.delete_pending = 0 AND %s - GROUP BY tagente_modulo.id_agente_modulo - ORDER BY tagente_modulo.nombre', + GROUP BY 1 + ORDER BY 1', ($details != 'tagente_modulo.*' && $indexed) ? 'tagente_modulo.id_agente_modulo,' : '', io_safe_output(implode (",", (array) $details)), $sql_tags_join, diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 3aca9aae6e..3bbb329702 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -32,6 +32,7 @@ include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); include_once($config['homedir'] . "/include/functions_db.php"); include_once($config['homedir'] . "/include/functions_event_responses.php"); +include_once($config['homedir'] . "/include/functions_policies.php"); enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_agents.php'); @@ -6448,6 +6449,63 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { array('type' => 'string', 'data' => __('SNMP policy module updated.'))); } +/** + * Remove an agent from a policy. + * @param $id Id of the policy + * @param $id2 Id of the agent policy + * @param $trash1 + * @param $trash2 + * + * Example: + * api.php?op=set&op2=remove_agent_from_policy&apipass=1234&user=admin&pass=pandora&id=11&id2=2 + */ +function api_set_remove_agent_from_policy ($id, $id2, $thrash2, $thrash3) { + global $config; + + if (!check_acl($config['id_user'], 0, "AW")){ + returnError('forbidden', 'string'); + return; + } + + if ($id == '' || !$id) { + returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.')); + return; + } + + if ($id2 == '' || !$id2) { + returnError('error_parameter', __('Error deleting agent from policy. Agent cannot be left blank.')); + return; + } + + $policy = policies_get_policy ($id, false, false); + $agent = db_get_row_filter('tagente', array('id_agente' => $id2)); + $policy_agent = db_get_row_filter('tpolicy_agents', array('id_policy' => $id ,'id_agent' => $id2)); + + if (empty ($policy)){ + returnError('error_policy', __('This policy does not exist.')); + return; + } + if (empty ($agent)){ + returnError('error_agent', __('This agent does not exist.')); + return; + } + if (empty ($policy_agent)){ + returnError('error_policy_agent', __('This agent does not exist in this policy.')); + return; + } + + $return = policies_change_delete_pending_agent($policy_agent['id']); + $data = __('Successfully added to delete pending id agent %d to id policy %d.', $id2, $id); + + if ($return === false) + returnError('error_delete_policy_agent', 'Could not be deleted id agent %d from id policy %d', $id2, $id); + else + returnData('string', array('type' => 'string', 'data' => $data)); + + +} + + /** * Create a new group. And return the id_group of the new group. * @@ -9804,6 +9862,11 @@ function api_set_create_event($id, $trash1, $other, $returnType) { return; } $values['id_grupo'] = $other['data'][1]; + + if (groups_get_name($values['id_grupo']) === false) { + returnError('error_parameter', 'Group ID does not exist'); + return; + } } else { returnError('error_parameter', 'Group ID required.'); @@ -10147,7 +10210,7 @@ function api_get_netflow_get_summary ($discard_1, $discard_2, $params) { } //http://localhost/pandora_console/include/api.php?op=set&op2=validate_event_by_id&id=23&apipass=1234&user=admin&pass=pandora -function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) { +function api_set_validate_event_by_id ($id, $trash1 = null, $trash2 = null, $returnType = 'string') { global $config; $data['type'] = 'string'; $check_id = db_get_value('id_evento', 'tevento', 'id_evento', $id); @@ -10166,7 +10229,7 @@ function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) { 'ack_utimestamp' => $ack_utimestamp, 'estado' => 1 ); - + $result = db_process_sql_update('tevento', $values, array('id_evento' => $id)); if ($result === false) { @@ -11940,6 +12003,445 @@ function api_get_cluster_items ($cluster_id){ } } + +/** + * Create an event filter. + * + * @param string $id Name of event filter to add. + * @param $thrash1 Don't use. + * @param array $other it's array, $other as param is;;; + * ;;;;;;;; + * ;;;;;;; + * ; in this order + * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_) + * + * example: api.php?op=set&op2=create_event_filter&id=test&other=||error|4|||1||12|||2018-12-09|2018-12-13|[%226%22]|[%2210%22,%226%22,%223%22]|1|10|||&other_mode=url_encode_separator_| + * + * + * @param $thrash3 Don't use + */ +function api_set_create_event_filter($name, $thrash1, $other, $thrash3) { + + if ($name == "") { + returnError('error_create_event_filter', + __('Error creating event filter. Event filter name cannot be left blank.')); + return; + } + + $event_w = check_acl ($config['id_user'], 0, "EW"); + $event_m = check_acl ($config['id_user'], 0, "EM"); + $access = ($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'EW'); + + $event_filter_name = $name; + + $user_groups = users_get_groups ($config['id_user'], "AR", true); + + $id_group_filter = (array_key_exists($other['data'][0], $user_groups)) ? $other['data'][0] : 0; + + $id_group = (array_key_exists($other['data'][1], $user_groups)) ? $other['data'][1] : 0; + + $event_type = (array_key_exists($other['data'][2], get_event_types ()) || $other['data'][2]=='') ? $other['data'][2] : ''; + + $severity = (array_key_exists($other['data'][3], get_priorities()) || $other['data'][3]==-1) ? $other['data'][3] : -1; + + $status = (array_key_exists($other['data'][4], events_get_all_status()) || $other['data'][4]==-1) ? $other['data'][4] : -1; + + if (!is_numeric($other['data'][6]) || empty($other['data'][6])) { + $text_agent = ''; + $id_agent = 0; + } + else { + $filter = array (); + + if ($id_group == 0) + $filter['id_grupo'] = array_keys ($user_groups); + else + $filter['id_grupo'] = $id_group; + + $filter[] = '(id_agente = '.$other["data"][6].')'; + $agent = agents_get_agents($filter, array ('id_agente')); + + if ($agent === false) + $text_agent = ''; + else { + $sql = sprintf('SELECT alias + FROM tagente + WHERE id_agente = %d', $agent[0]['id_agente']); + + $id_agent = $other["data"][6]; + $text_agent = db_get_value_sql($sql); + } + } + + $pagination = (in_array($other['data'][7], [20,25,50,100,200,500])) ? $other['data'][7] : 20; + + $users = users_get_user_users($config['id_user'], $access, users_can_manage_group_all()); + + $id_user_ack = (in_array($other['data'][9], $users)) ? $other['data'][9] : 0; + + $group_rep = ($other['data'][10] == 0 || $other['data'][10] == 1) ? $other['data'][10] : 0; + + $date_from = (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$other['data'][11])) ? $other['data'][11] : '0000-00-00'; + + $date_to = (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$other['data'][12])) ? $other['data'][12] : '0000-00-00'; + + $tag_with = (preg_match('/^\[(("\d+"((,|\])("\d+"))+)|"\d+")\]$/', io_safe_output($other['data'][13]))) ? $other['data'][13] : '[]'; + + $tag_without = (preg_match('/^\[(("\d+"((,|\])("\d+"))+)|"\d+")\]$/', io_safe_output($other['data'][14]))) ? $other['data'][14] : '[]'; + + $filter_only_alert = (in_array($other['data'][15], [-1,0,1])) ? $other['data'][15] : -1; + + if (!is_numeric($other['data'][16]) || empty($other['data'][16])) + $id_agent_module = 0; + else { + $groups = array(); + + $groups = users_get_groups($config['id_user'], "AW", false); + $groups = array_keys($groups); + + if (empty($groups)) { + $id_groups = 0; + } + else { + $id_groups = implode(',', $groups); + } + + $agents = db_get_all_rows_sql('SELECT id_agente + FROM tagente + WHERE id_grupo IN (' . $id_groups . ')'); + + if ($agents === false) $agents = array(); + + $id_agents = array(); + foreach ($agents as $agent) { + $id_agents[] = $agent['id_agente']; + } + + $filter = '(' . $other['data'][16] . ')'; + + $modules = agents_get_modules($id_agents, false, + (array('tagente_modulo.id_agente_modulo in' => $filter))); + + $id_agent_module = (array_key_exists($other['data'][16], $modules)) ? $other['data'][16] : 0; + } + + $values = array( + 'id_group_filter' => $id_group_filter, + 'id_group' => $id_group, + 'event_type' => $event_type, + 'severity' => $severity, + 'status' => $status, + 'search' => $other['data'][5], + 'text_agent' => $text_agent, + 'id_agent' => $id_agent, + 'pagination' => $pagination, + 'event_view_hr' => $other['data'][8], + 'id_user_ack' => $id_user_ack, + 'group_rep' => $group_rep, + 'date_from' => $date_from, + 'date_to' => $date_to, + 'tag_with' => $tag_with, + 'tag_without' => $tag_without, + 'filter_only_alert' => $filter_only_alert, + 'id_agent_module' => $id_agent_module, + 'source' => $other['data'][17], + 'id_extra' => $other['data'][18], + 'user_comment' => $other['data'][19] + ); + + $values['id_name'] = $event_filter_name; + + $id_filter = db_process_sql_insert('tevent_filter', $values); + + if ($id_filter === false) { + returnError('error_create_event_filter', __('Error creating event filter.')); + } + else { + returnData('string', array('type' => 'string', + 'data' => __('Event filter successfully created.'))); + } + +} + +/** + * Update an event filter. And return a message with the result of the operation. + * + * @param string $id_event_filter Id of the event filter to update. + * @param $thrash1 Don't use. + * @param array $other it's array, $other as param is ;;; + * ;;;;;;;; + * ;;;;;;; + * ; in this order + * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_) + * + * example: + * + * api.php?op=set&op2=update_event_filter&id=198&other=new_name|||alert_recovered|||||||||||||||||&other_mode=url_encode_separator_%7C + * + * @param $thrash3 Don't use + */ +function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash3) { + global $config; + + if (!check_acl($config['id_user'], 0, "LM")) { + returnError('forbidden', 'string'); + return; + } + + if ($id_event_filter == "") { + returnError('error_update_event_filter', + __('Error updating event filter. Event filter ID cannot be left blank.')); + return; + } + + $sql = "SELECT * FROM tevent_filter WHERE id_filter=$id_event_filter"; + $result_event_filter = db_get_row_sql($sql); + + if (!$result_event_filter) { + returnError('error_update_event_filter', + __('Error updating event filter. Event filter ID doesn\'t exist.')); + return; + } + + $values = array(); + + for ($i=0; $i<21; $i++) { + if ($other['data'][$i] != "") { + switch ($i) { + case 0: + $values['id_name'] = $other['data'][0]; + break; + case 1: + $user_groups = users_get_groups ($config['id_user'], "AR", true); + $values['id_group_filter'] = (array_key_exists($other['data'][1], $user_groups)) ? $other['data'][1] : 0; + break; + case 2: + $user_groups = users_get_groups ($config['id_user'], "AR", true); + $values['id_group'] = (array_key_exists($other['data'][2], $user_groups)) ? $other['data'][2] : 0; + break; + case 3: + $values['event_type'] = (array_key_exists($other['data'][3], get_event_types ()) || $other['data'][3]=='') ? $other['data'][3] : ''; + break; + case 4: + $values['severity'] = (array_key_exists($other['data'][4], get_priorities()) || $other['data'][4]==-1) ? $other['data'][4] : -1; + break; + case 5: + $values['status'] = (array_key_exists($other['data'][5], events_get_all_status()) || $other['data'][5]==-1) ? $other['data'][5] : -1; + break; + case 6: + $values['search'] = $other['data'][6]; + break; + case 7: + $user_groups = users_get_groups ($config['id_user'], "AR", true); + + if (!is_numeric($other['data'][7]) || empty($other['data'][7])) { + $values['text_agent'] = ''; + $values['id_agent'] = 0; + } + else { + + $filter = array (); + + if ($id_group == 0) + $filter['id_grupo'] = array_keys ($user_groups); + else + $filter['id_grupo'] = $id_group; + + $filter[] = '(id_agente = '.$other["data"][7].')'; + $agent = agents_get_agents($filter, array ('id_agente')); + + if ($agent === false) + $values['text_agent'] = ''; + else { + $sql = sprintf('SELECT alias + FROM tagente + WHERE id_agente = %d', $agent[0]['id_agente']); + + $values['id_agent'] = $other["data"][7]; + $values['text_agent'] = db_get_value_sql($sql); + } + } + break; + case 8: + $values['pagination'] = (in_array($other['data'][8], [20,25,50,100,200,500])) ? $other['data'][8] : 20; + break; + case 9: + $values['event_view_hr'] = $other['data'][9]; + break; + case 10: + + $event_w = check_acl ($config['id_user'], 0, "EW"); + $event_m = check_acl ($config['id_user'], 0, "EM"); + $access = ($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'EW'); + + $users = users_get_user_users($config['id_user'], $access, users_can_manage_group_all()); + + $values['id_user_ack'] = (in_array($other['data'][10], $users)) ? $other['data'][10] : 0; + break; + case 11: + $values['group_rep'] = ($other['data'][11] == 0 || $other['data'][11] == 1) ? $other['data'][11] : 0; + break; + case 12: + $values['date_from'] = (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$other['data'][12])) ? $other['data'][12] : '0000-00-00'; + break; + case 13: + $values['date_to'] = (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$other['data'][13])) ? $other['data'][13] : '0000-00-00'; + break; + case 14: + print_r("14444444"); + $values['tag_with'] = (preg_match('/^\[(("\d+"((,|\])("\d+"))+)|"\d+")\]$/', io_safe_output($other['data'][14]))) ? $other['data'][14] : '[]'; + break; + case 15: + print_r("1555555555"); + $values['tag_without'] = (preg_match('/^\[(("\d+"((,|\])("\d+"))+)|"\d+")\]$/', io_safe_output($other['data'][15]))) ? $other['data'][15] : '[]'; + break; + case 16: + $values['filter_only_alert'] = (in_array($other['data'][16], [-1,0,1])) ? $other['data'][16] : -1; + break; + case 17: + if (!is_numeric($other['data'][17]) || empty($other['data'][17])) + $values['id_agent_module'] = 0; + else { + $groups = array(); + + $groups = users_get_groups($config['id_user'], "AW", false); + $groups = array_keys($groups); + + if (empty($groups)) { + $id_groups = 0; + } + else { + $id_groups = implode(',', $groups); + } + + $agents = db_get_all_rows_sql('SELECT id_agente + FROM tagente + WHERE id_grupo IN (' . $id_groups . ')'); + + if ($agents === false) $agents = array(); + + $id_agents = array(); + foreach ($agents as $agent) { + $id_agents[] = $agent['id_agente']; + } + + $filter = '(' . $other['data'][17] . ')'; + + $modules = agents_get_modules($id_agents, false, + (array('tagente_modulo.id_agente_modulo in' => $filter))); + + $values['id_agent_module'] = (array_key_exists($other['data'][17], $modules)) ? $other['data'][17] : 0; + } + break; + case 18: + $values['source'] = $other['data'][18]; + break; + case 19: + $values['id_extra'] = $other['data'][19]; + break; + case 20: + print_r("adadadasds"); + $values['user_comment'] = $other['data'][20]; + break; + + } + } + } + + $result = db_process_sql_update ('tevent_filter', + $values, + array ('id_filter' => $id_event_filter)); + + if ($result === false) { + returnError('error_update_event_filter', __('Error updating event filter.')); + } + else { + returnData('string', array('type' => 'string', + 'data' => __('Event filter successfully updated.'))); + } + +} + + +/** + * Delete an event filter. And return a message with the result of the operation. + * + * @param string $id_template Id of the event filter to delete. + * @param $thrash1 Don't use. + * @param array $other Don't use + * + * example: + * + * api.php?op=set&op2=delete_event_filter&id=38 + * + * @param $thrash3 Don't use + */ +function api_set_delete_event_filter($id_event_filter, $thrash1, $other, $thrash3) { + + if ($id_event_filter == "") { + returnError('error_delete_event_filter', + __('Error deleting event_filter. Event filter ID cannot be left blank.')); + return; + } + + $result = db_process_sql_delete ('tevent_filter',array('id_filter' => $id_event_filter)); + + if ($result == 0) { + returnError('error_delete_event_filter', + __('Error deleting event filter.')); + } + else { + returnData('string', array('type' => 'string', + 'data' => __('Event filter successfully deleted.'))); + } +} + + +/** + * Get all event filters, and print all the result like a csv. + * + * @param $thrash1 Don't use. + * @param $thrash2 Don't use. + * @param array $other it's array, but only is available. + * example: + * + * api.php?op=get&op2=all_event_filters&return_type=csv&other=; + * + * @param $thrash3 Don't use. + */ +function api_get_all_event_filters($thrash1, $thrash2, $other, $thrash3) { + global $config; + + if (!isset($other['data'][0])) + $separator = ';'; // by default + else + $separator = $other['data'][0]; + + if (!check_acl($config["id_user"], 0, "LM")) { + returnError("forbidden", "csv"); + return; + } + + $filter = false; + + $sql = "SELECT * FROM tevent_filter"; + $event_filters = db_get_all_rows_sql($sql); + + if ($event_filters !== false) { + $data['type'] = 'array'; + $data['data'] = $event_filters; + } + + if (!$event_filters) { + returnError('error_get_all_event_filters', + __('Error getting all event filters.')); + } + else { + returnData('csv', $data, $separator); + } +} + + ///////////////////////////////////////////////////////////////////// // AUX FUNCTIONS ///////////////////////////////////////////////////////////////////// @@ -11959,6 +12461,231 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access = return false; } +function api_get_user_info($thrash1, $thrash2, $other, $returnType) { + + $separator = ';'; + + $other = json_decode(base64_decode($other['data']),true); + + $sql = 'select * from tusuario where id_user = "'.$other[0]['id_user'].'" and password = "'.$other[0]['password'].'"'; + + $user_info = db_get_all_rows_sql($sql); + + if (count($user_info) > 0 and $user_info !== false) { + $data = array('type' => 'array', 'data' => $user_info); + returnData($returnType, $data, $separator); + } + else { + return 0; + } +} + + +/* + +This function receives different parameters to process one of these actions the logging process in our application from the records in the audit of pandora fms, to avoid concurrent access of administrator users, and optionally to prohibit access to non-administrator users: + +Parameter 0 + +The User ID that attempts the action is used to check the status of the application for access. + +Parameter 1 + +Login, logout, exclude, browse. + +These requests receive a response that we can treat as we consider, this function only sends answers, does not perform any action in your application, you must customize them. + +Login action: free (register our access), taken, denied (if you are not an administrator user and parameter four is set to 1, register the expulsion). + +Browse action: It has the same answers as login, but does not register anything in the audit. + +Logout action: It records the deslogeo but does not send a response. + +All other actions do not return a response, + +Parameter 2 + +IP address of the application is also used to check the status of the application for access. + +Parameter 3 + +Name of the application, it is also used to check the status of the application for access. + +Parameter 4 + +If you mark 1 you will avoid the access to the non-administrators users, returning the response `denied' and registering that expulsion in the audit of pandora fms. + +*/ + + + +function api_set_access_process($thrash1, $thrash2, $other, $returnType) { + if (defined ('METACONSOLE')) { + return; + } + + $other['data'] = explode('|',$other['data']); + + $sql = 'select id_usuario,utimestamp from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logon%" and id_usuario IN (select id_user from tusuario where is_admin = 1) and id_usuario != "'.$other['data'][0].'" order by utimestamp DESC limit 1'; + $audit_concurrence = db_get_all_rows_sql($sql); + $sql_user = 'select id_usuario,utimestamp from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logon%" and id_usuario IN (select id_user from tusuario where is_admin = 1) and id_usuario = "'.$other['data'][0].'" order by utimestamp DESC limit 1'; + $audit_concurrence_user = db_get_all_rows_sql($sql_user); + $sql2 = 'select id_usuario,utimestamp,accion from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logoff%" and id_usuario = "'.$audit_concurrence[0]['id_usuario'].'" order by utimestamp DESC limit 1'; + $audit_concurrence_2 = db_get_all_rows_sql($sql2); + + //The user trying to log in is an administrator + if(users_is_admin($other['data'][0])){ + //The admin user is trying to login + if($other['data'][1] == 'login'){ + // Check if there is an administrator user logged in prior to our last login + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_user[0]['utimestamp']){ + // Check if the administrator user logged in later to us has unlogged and left the node free + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_2[0]['utimestamp']){ + // The administrator user logged in later has not yet unlogged + returnData('string', array('type' => 'string', 'data' => 'taken')); + } + else{ + // The administrator user logged in later has already unlogged + returnData('string', array('type' => 'string', 'data' => 'free')); + } + } + else{ + // There is no administrator user who has logged in since then to log us in. + db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'free')); + } + + } + elseif ($other['data'][1] == 'logout') { + // The administrator user wants to log out + db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2], $other['data'][0]); + } + elseif ($other['data'][1] == 'exclude') { + // The administrator user has ejected another administrator user who was logged in + db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2] , $audit_concurrence[0]['id_usuario']); + + } + //The admin user is trying to browse + elseif ($other['data'][1] == 'browse') { + // Check if there is an administrator user logged in prior to our last login + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_user[0]['utimestamp']){ + // Check if the administrator user logged in later to us has unlogged and left the node free + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_2[0]['utimestamp']){ + // The administrator user logged in later has not yet unlogged + returnData('string', array('type' => 'string', 'data' => $audit_concurrence[0]['id_usuario'])); + } + else{ + // The administrator user logged in later has already unlogged + returnData('string', array('type' => 'string', 'data' => 'free')); + } + } + else{ + // There is no administrator user who has logged in since then to log us in. + returnData('string', array('type' => 'string', 'data' => 'free')); + } + + } + elseif ($other['data'][1] == 'cancelled'){ + //The administrator user tries to log in having another administrator logged in, but instead of expelling him he cancels his log in. + db_pandora_audit($other['data'][3].' cancelled access', 'Cancelled access in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'cancelled')); + } + +} +else{ + + if($other['data'][4] == 1){ + //The user trying to log in is not an administrator and is not allowed no admin access + db_pandora_audit($other['data'][3].' denied access', 'Denied access to non-admin user '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'denied')); + } + else{ + //The user trying to log in is not an administrator and is allowed no admin access + if($other['data'][1] == 'login'){ + //The user trying to login is not admin, can enter without concurrent use filter + db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'free')); + + } + elseif ($other['data'][1] == 'logout') { + //The user trying to logoff is not admin + db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2], $other['data'][0]); + } + elseif ($other['data'][1] == 'browse'){ + //The user trying to browse in an app page is not admin, can enter without concurrent use filter + returnData('string', array('type' => 'string', 'data' => 'free')); + } + } + } +} + + +function api_get_traps($thrash1, $thrash2, $other, $returnType) { + + if (defined ('METACONSOLE')) { + return; + } + + $other['data'] = explode('|',$other['data']); + + $other['data'][1] = date("Y-m-d H:i:s",$other['data'][1]); + + $sql = 'SELECT * from ttrap where timestamp >= "'.$other['data'][1].'"'; + + // $sql = 'SELECT * from ttrap where source = "'.$other['data'][0].'" and timestamp >= "'.$other['data'][1].'"'; + + if($other['data'][4]){ + $other['data'][4] = date("Y-m-d H:i:s",$other['data'][4]); + $sql .= ' and timestamp <= "'.$other['data'][4].'"'; + } + + if($other['data'][2]){ + $sql .= ' limit '.$other['data'][2]; + } + + if($other['data'][3]){ + $sql .= ' offset '.$other['data'][3]; + } + + if($other['data'][5]){ + $sql .= ' and status = 0'; + } + + if(sizeof($other['data']) == 0){ + $sql = 'SELECT * from ttrap'; + } + + + $traps = db_get_all_rows_sql($sql); + + if($other['data'][6]){ + + foreach ($traps as $key => $value) { + + if(!strpos($value['oid_custom'],$other['data'][6]) && $other['data'][7] == 'false'){ + unset($traps[$key]); + } + + if(strpos($value['oid_custom'],$other['data'][6]) && $other['data'][7] == 'true'){ + unset($traps[$key]); + } + + } + + } + + $traps_json = json_encode($traps); + + if (count($traps) > 0 and $traps !== false) { + returnData('string', array('type' => 'string', 'data' => $traps_json)); + } + else { + return 0; + } + +} + function api_set_validate_traps ($id, $thrash2, $other, $thrash3) { if (defined ('METACONSOLE')) { @@ -11984,117 +12711,116 @@ function api_set_validate_traps ($id, $thrash2, $other, $thrash3) { } } - function api_set_delete_traps ($id, $thrash2, $other, $thrash3) { - - if (defined ('METACONSOLE')) { - return; - } - - if($id == 'all'){ - $result = db_process_sql ('delete from ttrap'); - } - else{ - $result = db_process_sql_delete('ttrap',array('id_trap' => $id)); - } - - if (is_error($result)) { - // TODO: Improve the error returning more info - returnError('error_delete_trap', __('Error in trap delete.')); - } - else { - returnData('string', - array('type' => 'string', - 'data' => __('Deleted traps.'))); - } - } - - function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) { - if (defined ('METACONSOLE')) { - return; - } - - $sql = sprintf('SELECT id_grupo - FROM tgrupo WHERE nombre = "'.$other['data'].'"'); - - $group_id = db_get_all_rows_sql($sql); - - if (count($group_id) > 0 and $group_id !== false) { - $data = array('type' => 'array', 'data' => $group_id); - - returnData('csv', $data, ';'); - } - else { - returnError('error_group_name', 'No groups retrieved.'); - } - } - - function api_get_timezone($thrash1, $thrash2, $other, $thrash3) { - if (defined ('METACONSOLE')) { - return; - } - - $sql = sprintf('SELECT value - FROM tconfig WHERE token = "timezone"'); - - $timezone = db_get_all_rows_sql($sql); - - if (count($timezone) > 0 and $timezone !== false) { - - $data = array('type' => 'string', 'data' => $timezone); - - returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); - - } - else { - returnError('error_timezone', 'No timezone retrieved.'); - } +function api_set_delete_traps ($id, $thrash2, $other, $thrash3) { + + if (defined ('METACONSOLE')) { + return; + } + + if($id == 'all'){ + $result = db_process_sql ('delete from ttrap'); + } + else{ + $result = db_process_sql_delete('ttrap',array('id_trap' => $id)); + } + + if (is_error($result)) { + // TODO: Improve the error returning more info + returnError('error_delete_trap', __('Error in trap delete.')); + } + else { + returnData('string', + array('type' => 'string', + 'data' => __('Deleted traps.'))); } + } - function api_get_language($thrash1, $thrash2, $other, $thrash3) { - if (defined ('METACONSOLE')) { - return; - } - - $sql = sprintf('SELECT value - FROM tconfig WHERE token = "language"'); - - $language = db_get_all_rows_sql($sql); - - if (count($language) > 0 and $language !== false) { - - $data = array('type' => 'string', 'data' => $language); - - returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); - - } - else { - returnError('error_language', 'No language retrieved.'); - } - } - - function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) { - if (defined ('METACONSOLE')) { - return; - } - - $sql = sprintf('SELECT value - FROM tconfig WHERE token = "session_timeout"'); - - $language = db_get_all_rows_sql($sql); - - if (count($language) > 0 and $language !== false) { - - $data = array('type' => 'string', 'data' => $language); - - returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); - - } - else { - returnError('error_session_timeout', 'No session timeout retrieved.'); - } - } - - + +function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT id_grupo + FROM tgrupo WHERE nombre = "'.$other['data'].'"'); + + $group_id = db_get_all_rows_sql($sql); + + if (count($group_id) > 0 and $group_id !== false) { + $data = array('type' => 'array', 'data' => $group_id); + + returnData('csv', $data, ';'); + } + else { + returnError('error_group_name', 'No groups retrieved.'); + } +} + +function api_get_timezone($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "timezone"'); + + $timezone = db_get_all_rows_sql($sql); + + if (count($timezone) > 0 and $timezone !== false) { + + $data = array('type' => 'string', 'data' => $timezone); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_timezone', 'No timezone retrieved.'); + } +} + +function api_get_language($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "language"'); + + $language = db_get_all_rows_sql($sql); + + if (count($language) > 0 and $language !== false) { + + $data = array('type' => 'string', 'data' => $language); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_language', 'No language retrieved.'); + } +} + +function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) { + if (defined ('METACONSOLE')) { + return; + } + + $sql = sprintf('SELECT value + FROM tconfig WHERE token = "session_timeout"'); + + $language = db_get_all_rows_sql($sql); + + if (count($language) > 0 and $language !== false) { + + $data = array('type' => 'string', 'data' => $language); + + returnData('string',array('type' => 'string','data' => $data['data'][0]['value'])); + + } + else { + returnError('error_session_timeout', 'No session timeout retrieved.'); + } +} ?> diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index e773224c16..17f6d9b345 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -312,6 +312,8 @@ function config_update_config () { $error_update[] = __('Autocreate profile group'); if (!config_update_value ('default_assign_tags', implode(",",get_parameter ('default_assign_tags')))) $error_update[] = __('Autocreate profile tags'); + if (!config_update_value ('default_no_hierarchy', (int)get_parameter ('default_no_hierarchy'))) + $error_update[] = __('Automatically assigned no hierarchy'); if (!config_update_value ('autocreate_blacklist', get_parameter ('autocreate_blacklist'))) $error_update[] = __('Autocreate blacklist'); @@ -1452,7 +1454,10 @@ function config_process_config () { if (!isset ($config['default_assign_tags'])) { config_update_value ( 'default_assign_tags', ''); } - + if (!isset ($config['default_no_hierarchy'])) { + config_update_value ('default_no_hierarchy', 0); + } + if (!isset ($config['ldap_server'])) { config_update_value ( 'ldap_server', 'localhost'); } @@ -2027,6 +2032,14 @@ function config_process_config () { if (!isset($config["metaconsole_deploy_collection"])) { config_update_value('metaconsole_deploy_collection', 0); } + + if (!isset($config["metaconsole_deploy_inventory_plugin"])) { + config_update_value('metaconsole_deploy_inventory_plugin', 0); + } + + if (!isset($config["metaconsole_deploy_plugin_server"])) { + config_update_value('metaconsole_deploy_plugin_server', 0); + } } /* Finally, check if any value was overwritten in a form */ diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index dcc038b620..c182e76479 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -193,6 +193,13 @@ function get_custom_fields_data ($custom_field_name) { function agent_counters_custom_fields($filters){ //filter by status agent $and_status = ""; + + $agent_state_normal = 0; + $agent_state_critical = 0; + $agent_state_warning = 0; + $agent_state_unknown = 0; + $agent_state_notinit = 0; + $agent_state_total = 0; if(is_array($filters['id_status'])){ if(!in_array(-1, $filters['id_status'])){ if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $filters['id_status'])){ @@ -200,34 +207,34 @@ function agent_counters_custom_fields($filters){ $and_status = " AND ( "; foreach ($filters['id_status'] as $key => $value) { $and_status .= ($key != 0) - ? " OR (" - : " ("; + ? " OR " + : " "; switch ($value) { default: case AGENT_STATUS_NORMAL: - $and_status .= " ta.critical_count = 0 - AND ta.warning_count = 0 - AND ta.unknown_count = 0 - AND ta.total_count <> ta.notinit_count ) "; + $agent_state_normal = agents_get_status_clause(AGENT_STATUS_NORMAL); + $and_status .= agents_get_status_clause(AGENT_STATUS_NORMAL); break; case AGENT_STATUS_CRITICAL: - $and_status .= " ta.critical_count > 0 ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_CRITICAL); + $agent_state_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); break; case AGENT_STATUS_WARNING: - $and_status .= " ta.critical_count = 0 - AND ta.warning_count > 0 ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_WARNING); + $agent_state_warning = agents_get_status_clause(AGENT_STATUS_WARNING); break; case AGENT_STATUS_UNKNOWN: - $and_status .= " ta.critical_count = 0 - AND ta.warning_count = 0 - AND ta.unknown_count > 0 ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $agent_state_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); break; case AGENT_STATUS_NOT_INIT: - $and_status .= " ta.total_count = ta.notinit_count ) "; + $and_status .= agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $agent_state_notinit = agents_get_status_clause(AGENT_STATUS_NOT_INIT); break; } } $and_status .= " ) "; + $agent_state_total = agents_get_status_clause(AGENT_STATUS_ALL); } } else{ @@ -237,14 +244,45 @@ function agent_counters_custom_fields($filters){ OR ( ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0 ) OR ( ta.total_count = ta.notinit_count ) ) "; + + $agent_state_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); + $agent_state_warning = agents_get_status_clause(AGENT_STATUS_WARNING); + $agent_state_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $agent_state_notinit = agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $agent_state_total = agents_get_status_clause(AGENT_STATUS_ALL); } } + else{ + $agent_state_normal = agents_get_status_clause(AGENT_STATUS_NORMAL); + $agent_state_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); + $agent_state_warning = agents_get_status_clause(AGENT_STATUS_WARNING); + $agent_state_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $agent_state_notinit = agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $agent_state_total = agents_get_status_clause(AGENT_STATUS_ALL); + } } //filter by status module + $empty_agents_count = "UNION ALL + SELECT ta.id_agente, + 0 AS c_m_total, + 0 AS mm_normal, + 0 AS mm_critical, + 0 AS mm_warning, + 0 AS mm_unknown, + 0 AS mm_not_init, + 0 AS mm_total + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND ta.total_count = 0 + $groups_and"; + $and_module_status = ""; if(is_array($filters['module_status'])){ if(!in_array(-1, $filters['module_status'])){ + $empty_agents_count = ""; if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $filters['module_status'])){ if(count($filters['module_status']) > 0){ $and_module_status = " AND ( "; @@ -277,25 +315,15 @@ function agent_counters_custom_fields($filters){ else{ //not normal $and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 "; + $empty_agents_count = ""; } } } //filters module if($filters['module_search']){ - $and_module_search = 'AND nombre LIKE "%' . $filters['module_search'] . '%"'; - } - - $module_filter = ""; - if($and_module_search != '' || $and_module_status != ''){ - $module_filter = ' AND ( - SELECT count(*) AS n - FROM tagente_modulo tam - INNER JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo - WHERE tam.id_agente=ta.id_agente - '. $and_module_search . ' ' . $and_module_status .' - ) > 0 '; + $and_module_search = 'AND tam.nombre LIKE "%' . $filters['module_search'] . '%"'; + $empty_agents_count = ""; } //filter group and check ACL groups @@ -359,42 +387,63 @@ function agent_counters_custom_fields($filters){ // Establishes connection if (metaconsole_load_external_db ($server_data) !== NOERR) continue; - $query = sprintf("SELECT - tcd.description as name_data, - SUM(ta.normal_count) AS m_normal, - SUM(ta.critical_count) AS m_critical, - SUM(ta.warning_count) AS m_warning, - SUM(ta.unknown_count) AS m_unknown, - SUM(ta.notinit_count) AS m_not_init, - SUM(ta.fired_count) AS m_alerts, - SUM(ta.total_count) AS m_total, - SUM(IF(ta.critical_count > 0, 1, 0)) AS a_critical, - SUM(IF(ta.critical_count = 0 AND ta.warning_count > 0, 1, 0)) AS a_warning, - SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS a_unknown, - SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count = 0 AND ta.notinit_count <> ta.total_count, 1, 0)) AS a_normal, - SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS a_not_init, - COUNT(ta.id_agente) AS a_agents, - GROUP_CONCAT(DISTINCT(ta.id_agente) SEPARATOR ',') as ids - FROM tagente ta - INNER JOIN tagent_custom_data tcd - ON tcd.id_agent = ta.id_agente + $query = sprintf( + "SELECT tcd.description AS name_data, + SUM(IF($agent_state_total, 1, 0)) AS a_agents, + SUM(IF($agent_state_critical, 1, 0)) AS a_critical, + SUM(IF($agent_state_warning, 1, 0)) AS a_warning, + SUM(IF($agent_state_unknown, 1, 0)) AS a_unknown, + SUM(IF($agent_state_normal, 1, 0)) AS a_normal, + SUM(IF($agent_state_notinit, 1, 0)) AS a_not_init, + SUM(tagent_counters.mm_normal) AS m_normal, + SUM(tagent_counters.mm_critical) AS m_critical, + SUM(tagent_counters.mm_warning) AS m_warning, + SUM(tagent_counters.mm_unknown) AS m_unknown, + SUM(tagent_counters.mm_not_init) AS m_not_init, + SUM(tagent_counters.mm_total) AS m_total + FROM tagent_custom_data tcd INNER JOIN tagent_custom_fields tcf ON tcd.id_field = tcf.id_field - LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND tcf.name = '%s' + INNER JOIN ( + SELECT ta.id_agente, + ta.total_count AS c_m_total, + SUM( IF(tae.estado = 0, 1, 0) ) AS mm_normal, + SUM( IF(tae.estado = 1, 1, 0) ) AS mm_critical, + SUM( IF(tae.estado = 2, 1, 0) ) AS mm_warning, + SUM( IF(tae.estado = 3, 1, 0) ) AS mm_unknown, + SUM( IF(tae.estado = 4 OR tae.estado = 5, 1, 0) ) AS mm_not_init, + COUNT(tam.id_agente_modulo) AS mm_total + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente = tae.id_agente + AND tam.id_agente_modulo = tae.id_agente_modulo + WHERE ta.disabled = 0 + AND tam.disabled = 0 + %s + %s + %s + %s + GROUP by ta.id_agente + %s + ) AS tagent_counters + ON tcd.id_agent = tagent_counters.id_agente + INNER JOIN tagente ta + ON ta.id_agente = tagent_counters.id_agente + WHERE tcf.name = '%s' AND tcd.description <> '' %s - %s - %s - %s GROUP BY tcd.description", - $custom_field_name, - $custom_data_and, $groups_and, $and_status, - $module_filter + $and_module_search, + $and_module_status, + $empty_agents_count, + $custom_field_name, + $custom_data_and ); $result_meta[$server_data['id']] = db_get_all_rows_sql($query); @@ -402,10 +451,34 @@ function agent_counters_custom_fields($filters){ $query_data = sprintf("SELECT tcd.description, ta.id_agente, - %d AS id_server + %d AS id_server, + (CASE + WHEN ta.critical_count > 0 + THEN 1 + WHEN ta.critical_count = 0 + AND ta.warning_count > 0 + THEN 2 + WHEN ta.critical_count = 0 + AND ta.warning_count = 0 + AND ta.unknown_count > 0 + THEN 3 + WHEN ta.critical_count = 0 + AND ta.warning_count = 0 + AND ta.unknown_count = 0 + AND ta.notinit_count <> ta.total_count + THEN 0 + WHEN ta.total_count = ta.notinit_count + THEN 5 + ELSE 0 + END) AS `status` FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente = tae.id_agente + AND tam.id_agente_modulo = tae.id_agente_modulo INNER JOIN tagent_custom_data tcd ON tcd.id_agent = ta.id_agente INNER JOIN tagent_custom_fields tcf @@ -413,22 +486,28 @@ function agent_counters_custom_fields($filters){ WHERE ta.disabled = 0 AND tcf.name = '%s' AND tcd.description <> '' + AND tam.disabled = 0 %s %s %s %s + %s + GROUP BY ta.id_agente ", $server_data['id'], $custom_field_name, $custom_data_and, $groups_and, $and_status, - $module_filter + $and_module_search, + $and_module_status ); $node_result = db_get_all_rows_sql($query_data); + if (empty($node_result)) $node_result = array(); + $data = array_merge($data, $node_result); // Restore connection to root node metaconsole_restore_db(); @@ -455,7 +534,6 @@ function agent_counters_custom_fields($filters){ 't_a_not_init' => 0, 't_a_agents' => 0 ); - foreach ($result_meta as $k => $nodo) { if(isset($nodo) && is_array($nodo)){ foreach ($nodo as $key => $value) { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index b646a26945..591f3ae89d 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -853,10 +853,7 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret $filter = '1 = 1'; } - $secondary_join = ''; - if (!users_can_manage_group_all("ER")) { - $secondary_join = "LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent"; - } + $secondary_join = "LEFT JOIN tagent_secondary_group tasg ON tevento.id_agente = tasg.id_agent"; $sql = sprintf ("SELECT DISTINCT tevento.* FROM tevento %s diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index b53f0041ca..42128d5c74 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -238,7 +238,7 @@ function grafico_modulo_sparse_data( } } - if($array_data === false || !isset($array_data['sum1']['data'][0][1])){ + if ($array_data === false || (!$params['graph_combined'] && !isset($array_data['sum1']['data'][0][1]))) { return false; } @@ -1049,6 +1049,10 @@ function graphic_combined_module ( $params_combined['id_graph'] = 0; } + if(!isset($params_combined['type_report'])){ + $params_combined['type_report'] = ''; + } + if(!isset($params['percentil'])){ $params_combined['percentil'] = null; } @@ -1207,8 +1211,8 @@ function graphic_combined_module ( ); $series = db_get_all_rows_sql( - 'SELECT summatory_series,average_series,modules_series - FROM tgraph + 'SELECT summatory_series,average_series, modules_series + FROM tgraph WHERE id_graph = '. $params_combined['id_graph'] ); @@ -1301,7 +1305,6 @@ function graphic_combined_module ( ); } - //XXX arreglar estas $long_index = ''; switch ($params_combined['stacked']) { default: @@ -1324,7 +1327,16 @@ function graphic_combined_module ( $i=0; $array_data = array(); + foreach ($module_list as $key => $agent_module_id) { + if(is_metaconsole() && $params_combined['type_report'] == 'automatic_graph'){ + $server = metaconsole_get_connection_by_id ($agent_module_id['server']); + if (metaconsole_connect ($server) != NOERR){ + continue; + } + $agent_module_id = $agent_module_id['module']; + } + $module_data = db_get_row_sql ( 'SELECT * FROM tagente_modulo WHERE id_agente_modulo = ' . @@ -1340,12 +1352,12 @@ function graphic_combined_module ( $data_module_graph['id_module_type'] = $module_data['id_tipo_modulo']; $data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']); $data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']); - $data_module_graph['w_min'] = $module_data['min_warning']; - $data_module_graph['w_max'] = $module_data['max_warning']; - $data_module_graph['w_inv'] = $module_data['warning_inverse']; - $data_module_graph['c_min'] = $module_data['min_critical']; - $data_module_graph['c_max'] = $module_data['max_critical']; - $data_module_graph['c_inv'] = $module_data['critical_inverse']; + $data_module_graph['w_min'] = $module_data['min_warning']; + $data_module_graph['w_max'] = $module_data['max_warning']; + $data_module_graph['w_inv'] = $module_data['warning_inverse']; + $data_module_graph['c_min'] = $module_data['min_critical']; + $data_module_graph['c_max'] = $module_data['max_critical']; + $data_module_graph['c_inv'] = $module_data['critical_inverse']; $data_module_graph['module_id'] = $agent_module_id; //stract data @@ -1357,7 +1369,7 @@ function graphic_combined_module ( $i ); - $series_suffix = $i; + $series_suffix = $i; //convert to array graph and weight foreach ($array_data_module as $key => $value) { @@ -1386,6 +1398,10 @@ function graphic_combined_module ( //$array_events_alerts[$series_suffix] = $events; $i++; + + if(is_metaconsole() && $params_combined['type_report'] == 'automatic_graph'){ + metaconsole_restore_db(); + } } if($params_combined['projection']){ @@ -1544,7 +1560,6 @@ function graphic_combined_module ( $water_mark, $array_events_alerts ); - break; case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD: case CUSTOM_GRAPH_BULLET_CHART: diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index bfc5d3af55..be2c23518d 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -441,7 +441,7 @@ function groups_get_all($groupWithAgents = false) { * Get all groups recursive from an initial group. * * @param int Id of the parent group - * @param bool Whether to return All group or not + * @param bool Whether to force recursive search ignoring propagation (true) or not (false) * * @return Array with all result groups */ @@ -451,10 +451,11 @@ function groups_get_id_recursive($id_parent, $all = false) { $return = array_merge($return, array($id_parent)); //Check propagate - $id = db_get_value_filter('id_grupo', 'tgrupo', array('id_grupo' => $id_parent, 'propagate' => 1)); + $propagate = db_get_value_filter('propagate', 'tgrupo', array('id_grupo' => $id_parent)); - if (($id !== false) || $all) { + if (($propagate != 1) || $all) { $children = db_get_all_rows_filter("tgrupo", array('parent' => $id_parent, 'disabled' => 0), array('id_grupo')); + if ($children === false) { $children = array(); } diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index e9b7ca7c1d..55256313b2 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -68,6 +68,7 @@ function groupview_get_modules_counters($groups_ids = false) { ta.id_grupo AS g FROM $table ta WHERE ta.id_grupo IN ($groups_ids) + AND ta.disabled = 0 GROUP BY ta.id_grupo UNION ALL SELECT SUM(ta.normal_count) AS module_normal, diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 932e8a3457..06257a5457 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -97,6 +97,15 @@ function hd ($var, $file = '', $oneline = false) { html_debug_print ($var, $file, $oneline); } +function debug () { + $args_num = func_num_args(); + $arg_list = func_get_args(); + + for ($i = 0; $i < $args_num; $i++) { + html_debug_print($arg_list[$i], true); + } +} + function html_f2str($function, $params) { ob_start(); @@ -726,8 +735,11 @@ function html_print_extended_select_for_post_process($name, $selected = '', $selected_float = (float)$selected; $found = false; - if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) - $found = true; + if($selected){ + if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) { + $found = true; + } + } if (!$found) { $fields[$selected] = floatval($selected); @@ -1008,7 +1020,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle ++$idcounter; $valid_attrs = array ("accept", "disabled", "maxlength", - "name", "readonly", "size", "value", "accesskey", + "name", "readonly", "placeholder", "size", "value", "accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang", "onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", @@ -1338,6 +1350,36 @@ function html_print_input_hidden_extended($name, $value, $id, $return = false, $ echo $output; } +/** + * Render a color input element. + * + * The element will have an id like: "hidden-$name" + * + * @param string $name Input name. + * @param int $value Input value. Decimal representation of the color's hexadecimal value. + * @param string $class Set the class of input. + * @param bool $return Whether to return an output string or echo now (optional, echo by default). + * + * @return string HTML code if return parameter is true. + */ +function html_print_input_color ($name, $value, $class = false, $return = false) { + $attr_type = 'type="color"'; + $attr_id = 'id="color-' . htmlspecialchars($name, ENT_QUOTES) . '"'; + $attr_name = 'name="' . htmlspecialchars($name, ENT_QUOTES) . '"'; + $attr_value = 'value="' . htmlspecialchars($value, ENT_QUOTES) . '"'; + $attr_class = 'class="' . ($class !== false ? htmlspecialchars($class, ENT_QUOTES) : "") . '"'; + + $output = ''; + + if ($return) return $output; + echo $output; +} + /** * Render an submit input button element. * @@ -2479,7 +2521,7 @@ function html_print_result_div ($text) { $text = preg_replace ('/\n/i','
',$text); $text = preg_replace ('/\s/i',' ',$text); - $enclose = "
"; + $enclose = "
"; $enclose .= $text; $enclose .= "
"; return $enclose; diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 57603eca0b..687445bb7f 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -375,8 +375,8 @@ function __ ($string /*, variable arguments */) { global $config; static $extensions_cache = array(); - if( !isset($config["id_user"]) && count($extensions_cache) > 0 ) { - if (array_key_exists($config["id_user"], $extensions_cache)) { + if( isset($config["id_user"]) ) { + if ( count($extensions_cache) > 0 && array_key_exists($config["id_user"], $extensions_cache)) { $extensions = $extensions_cache[$config["id_user"]]; } else { @@ -385,8 +385,9 @@ function __ ($string /*, variable arguments */) { } } else{ - $extension =null; + $extensions=null; } + if (empty($extensions)) $extensions = array(); diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index 01d876697d..292d2892a7 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -79,14 +79,10 @@ function profile_create_user_profile ($id_user, $tags = '', $no_hierarchy = false ) { - global $config; if (empty ($id_profile) || $id_group < 0) - return false; - - // Secondary server is an enterprise function - if (!enterprise_installed() && $no_hierarchy) return false; + return false; // Checks if the user exists $result_user = users_get_user_by_id($id_user); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 613574ee27..3209a61492 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -159,7 +159,8 @@ function reporting_make_reporting_data($report = null, $id_report, true); $sql_tags_join = "INNER JOIN tagente ON tagente.id_agente = t1.id_agente - INNER JOIN ttag_module ON ttag_module.id_agente_modulo = t1.id_agente_modulo"; + INNER JOIN ttag_module ON ttag_module.id_agente_modulo = t1.id_agente_modulo + LEFT JOIN tagent_secondary_group tasg ON tagente.id_agente = tasg.id_agent"; $sql = sprintf('SELECT count(*) FROM tagente_modulo t1 %s WHERE t1.delete_pending = 0 AND t1.id_agente_modulo = '. $content["id_agent_module"] .' @@ -303,7 +304,8 @@ function reporting_make_reporting_data($report = null, $id_report, $report['contents'][] = reporting_availability_graph( $report, $content, - $pdf); + $pdf + ); break; case 'sql': $report['contents'][] = reporting_sql( @@ -3821,7 +3823,7 @@ function reporting_agent_configuration($report, $content) { return reporting_check_structure_content($return); } -function reporting_value($report, $content, $type, $pdf) { +function reporting_value($report, $content, $type, $pdf=false) { global $config; $return = array(); @@ -6342,13 +6344,18 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', require_once ($config["homedir"] . '/include/functions_graph.php'); - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content["server_name"]); - $server = metaconsole_get_connection_by_id ($id_meta); - metaconsole_connect($server); + if ($type_report == "custom_graph") { + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($content["server_name"]); + $server = metaconsole_get_connection_by_id ($id_meta); + if (metaconsole_connect ($server) != NOERR){ + return false; + } + } } $graph = db_get_row ("tgraph", "id_graph", $content['id_gs']); + $return = array(); $return['type'] = 'custom_graph'; @@ -6372,30 +6379,25 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', $graphs[0]["average_series"] = ''; $graphs[0]["modules_series"] = ''; $graphs[0]["fullscale"] = $content['style']['fullscale']; + $modules = $content['id_agent_module']; - if(is_array($content['id_agent_module'])){ - foreach ($content['id_agent_module'] as $key => $value) { - if($content['each_agent']){ - $modules[] = $value; - } - else{ - $modules[] = $value['module']; - } - } - } - else{ - if ($content['id_agent_module']) { - $modules[] = $content['id_agent_module']; - } else { - // restore to metaconsole database - metaconsole_restore_db(); - $module_source = db_get_all_rows_sql("SELECT id_agent_module FROM tgraph_source WHERE id_graph = " . $content['id_gs']); + if(!$modules){ + $module_source = db_get_all_rows_sql( + "SELECT id_agent_module, id_server + FROM tgraph_source + WHERE id_graph = " . + $content['id_gs'] + ); + + if(isset($module_source) && is_array($module_source)){ + $modules = array(); foreach ($module_source as $key => $value) { - $modules[$key] = $value['id_agent_module']; + $modules[$key]['module'] = $value['id_agent_module']; + $modules[$key]['server'] = $value['id_server']; } - metaconsole_connect($server); } } + $id_graph = 0; } else { @@ -6435,7 +6437,8 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', 'summatory' => $graphs[0]["summatory_series"], 'average' => $graphs[0]["average_series"], 'modules_series' => $graphs[0]["modules_series"], - 'id_graph' => $id_graph + 'id_graph' => $id_graph, + 'type_report' => $type_report ); $return['chart'] = graphic_combined_module( @@ -6444,13 +6447,13 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', $params_combined ); - break; - case 'data': break; } - if ($config['metaconsole']) { - metaconsole_restore_db(); + if ($type_report == "custom_graph") { + if (is_metaconsole()) { + metaconsole_restore_db(); + } } return reporting_check_structure_content($return); @@ -10000,7 +10003,7 @@ You can of course remove the warnings, that's why we include the source and do n $output .= 'parameters["page"] = "include/ajax/events";'; $output .= 'parameters["total_events"] = 1;'; - $output .= '$.ajax({type: "GET",url: "ajax.php",data: parameters,'; + $output .= '$.ajax({type: "GET",url: "/pandora_console/ajax.php",data: parameters,'; $output .= 'success: function(data) {'; $output .= '$("#total_events").text(data);'; $output .= '}'; @@ -10361,7 +10364,7 @@ function reporting_label_macro ($item, $label) { case 'MTTR': case 'automatic_graph': if (preg_match("/_agent_/", $label)) { - if (count($item['agents']) > 1) { + if (isset($item['agents']) && count($item['agents']) > 1) { $agent_name = count($item['agents']) . __(' agents'); } else { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 3df0b56cfe..182977207d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2428,12 +2428,18 @@ function reporting_html_availability(&$table, $item) { function reporting_html_availability_graph(&$table, $item, $pdf=0) { global $config; $metaconsole_on = is_metaconsole(); - if($metaconsole_on && $pdf==0){ - $src= '../../'; + + if($metaconsole_on){ + $hack_metaconsole = "../../"; } else{ - $src=$config['homeurl']; + $hack_metaconsole = ""; } + + $src=ui_get_full_url(false); + + $tables_chart = ''; + $table1 = new stdClass(); $table1->width = '99%'; $table1->data = array (); @@ -2471,6 +2477,7 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) { $table1->data[0][1] = $chart['chart']; $table1->data[0][2] = "" . $sla_value . ''; $table1->data[0][3] = $checks_resume; + $tables_chart .= html_print_table($table1, true); } if($item['type'] == 'availability_graph'){ @@ -2480,43 +2487,43 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) { $table2->data = array (); $table2->size = array (); $table2->size[0] = '2%'; - $table2->data[0][0] = ''; + $table2->data[0][0] = ''; $table2->size[1] = '14%'; $table2->data[0][1] = ''.__('OK') . ''; $table2->size[2] = '2%'; - $table2->data[0][2] = ''; + $table2->data[0][2] = ''; $table2->size[3] = '14%'; $table2->data[0][3] = ''.__('Critical'). ''; $table2->size[4] = '2%'; - $table2->data[0][4] = ''; + $table2->data[0][4] = ''; $table2->size[5] = '14%'; $table2->data[0][5] = ''.__('Unknow'). ''; $table2->size[6] = '2%'; - $table2->data[0][6] = ''; + $table2->data[0][6] = ''; $table2->size[7] = '14%'; $table2->data[0][7] = ''.__('Not Init'). ''; $table2->size[8] = '2%'; - $table2->data[0][8] = ''; + $table2->data[0][8] = ''; $table2->size[9] = '14%'; $table2->data[0][9] = ''.__('Downtimes'). ''; $table2->size[10] = '2%'; - $table2->data[0][10] = ''; + $table2->data[0][10] = ''; $table2->size[11] = '15%'; $table2->data[0][11] = ''.__('Ignore time'). ''; } $table->colspan['charts']['cell'] = 2; - $table->data['charts']['cell'] = html_print_table($table1, true); + $table->data['charts']['cell'] = $tables_chart; $table->colspan['legend']['cell'] = 2; $table->data['legend']['cell'] = html_print_table($table2, true); if($pdf){ - return html_print_table($table1, true) . '
' . html_print_table($table2, true); + return $tables_chart . '
' . html_print_table($table2, true); } } diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index bd6aaebd63..b6c7647562 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -770,7 +770,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group_and_tag = false, $force_equal = false) { global $config; - $condition = ''; + $condition = array(); // Get all tags of the system $all_tags = tags_get_all_tags(false); @@ -808,8 +808,11 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group $tags_condition = $group_condition . " AND (" . implode(" OR ", $tags_condition_array) . ")"; $condition[] = "($tags_condition)\n"; } + if (!empty($condition)) { $condition = implode(' OR ', $condition); + } else { + $condition = ''; } if (!empty($without_tags)) { diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 72a222becd..a4be0d445e 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -278,6 +278,11 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = )); $salida = ui_get_snapshot_image($link, $is_snapshot) . '  '; } + + if($salida !== NULL){ + $last_data_str = html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px')); + } + $last_data_str .= $salida; } else { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 999ff4337b..8f6f5a35d8 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3884,7 +3884,7 @@ function ui_print_module_string_value($value, $id_agente_module, " / " . $module_name; $salida = "
" . + style='display: none; width: 100%; height: 100%; overflow: auto; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left' title='" . $title_dialog . "'>" . $value . "
" . "".io_safe_output($text).""; break; case PERCENTILE_BUBBLE: @@ -1911,7 +1916,9 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; - echo io_safe_output($text); + + if (get_parameter('tab')=='editor') + echo "".io_safe_output($text).""; break; case CIRCULAR_PROGRESS_BAR: @@ -1955,7 +1962,9 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; - echo io_safe_output($text); + + if (get_parameter('tab')=='editor') + echo "".io_safe_output($text).""; break; case CIRCULAR_INTERIOR_PROGRESS_BAR: @@ -2000,7 +2009,9 @@ function visual_map_print_item($mode = "read", $layoutData, } echo $img; - echo io_safe_output($text); + + if (get_parameter('tab')=='editor') + echo "".io_safe_output($text).""; break; case MODULE_GRAPH: @@ -2173,6 +2184,9 @@ function visual_map_print_item($mode = "read", $layoutData, } break; + case COLOR_CLOUD: + echo visual_map_get_color_cloud_element($layoutData); + break; default: if (!empty($element_enterprise)) { echo $element_enterprise['item']; @@ -3451,7 +3465,9 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter $filter = array (); } else { if(!empty($filter['name'])){ - $where .= "name LIKE '%".io_safe_output($filter['name'])."%'"; + $where .= sprintf("name LIKE '%%%s%%'", + db_escape_string_sql(io_safe_output($filter['name']))); + unset($filter['name']); } } @@ -3875,6 +3891,10 @@ function visual_map_create_internal_name_item($label = null, $type, $image, $age case 'group_item': $text = __('Group') . " - "; break; + case COLOR_CLOUD: + case 'color_cloud': + $text = __('Color cloud') . " - "; + break; case 'icon': case ICON: $text = __('Icon') . " - " . @@ -4012,6 +4032,8 @@ function visual_map_type_in_js($type) { break; case LINE_ITEM: return 'line_item'; + case COLOR_CLOUD: + return 'color_cloud'; break; } } @@ -4027,5 +4049,76 @@ function visual_map_macro($label,$module){ return $label; } +function visual_map_get_color_cloud_element ($data) { + $id = (int) $data["id"]; + $diameter = (int) $data["width"]; + $dynamic_fields = array(); + + try { + // Yes, the dynamic fields object is stored into the label field. ¯\_(ツ)_/¯ + if (!empty($data["label"])) { + $dynamic_fields = json_decode($data["label"], true); + } + } catch (Exception $ex) {} + + $default_color = !empty($dynamic_fields["default_color"]) + ? $dynamic_fields["default_color"] + : "#FFFFFF"; + $color = $default_color; + // The svg gradient needs a unique identifier + $gradient_id = "grad_" . $id; + + // Color ranges + if ( + !empty($dynamic_fields["color_ranges"]) && + !empty($data["id_agente_modulo"]) + ) { + $node_id = null; + $node_connected = false; + // Connect to node + if (is_metaconsole() && !empty($data["id_metaconsole"])) { + $node_id = (int) $data["id_metaconsole"]; + if (metaconsole_connect(null, $node_id) === NOERR) $node_connected = true; + } + + // Fetch module value + $value = (!$node_id || ($node_id && $node_connected)) + ? modules_get_last_value($data["id_agente_modulo"]) + : false; + + // Restore connection + if ($node_connected) metaconsole_restore_db(); + + if ($value !== false) { + /* TODO: It would be ok to give support to string values in the future? + * It can be done by matching the range value with the value if it is a + * string. I think the function to retrieve the value only supports + * numeric values. + */ + $value = (float) $value; + foreach ($dynamic_fields["color_ranges"] as $range) { + if ($range["from_value"] <= $value && $range["to_value"] >= $value) { + $color = $range["color"]; + break; + } + } + } + } + + ob_start(); +?> + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index d658a53b67..4b835d65fc 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -62,7 +62,9 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'clock' => __('Clock'), 'group_item' => __('Group'), 'box_item' => __('Box'), - 'line_item' => __('Line')); + 'line_item' => __('Line'), + 'color_cloud' => __('Color cloud') + ); if (enterprise_installed()) { enterprise_visual_map_editor_add_title_palette($titles); @@ -328,7 +330,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'); + 'simple_value', 'datos', 'auto_sla_graph', 'color_cloud'); $form_items['agent_row']['html'] = '' . __('Agent') . ''; $params = array(); @@ -395,7 +397,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['module_row'] = array(); $form_items['module_row']['items'] = array('static_graph', 'percentile_bar', 'percentile_item', 'module_graph', - 'simple_value', 'datos', 'auto_sla_graph', 'donut_graph', 'bars_graph'); + 'simple_value', 'datos', 'auto_sla_graph', 'donut_graph', 'bars_graph', + 'color_cloud'); $form_items['module_row']['html'] = '' . __('Module') . ' ' . @@ -510,7 +513,12 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { __('Max value') . ' ' . html_print_input_text('max_percentile', 0, '', 3, 5, true) . ''; - $percentile_type = array('percentile' => __('Percentile'), 'bubble' => __('Bubble'), 'circular_progress_bar' => __('Circular porgress bar'), 'interior_circular_progress_bar' => __('Circular progress bar (interior)')); + $percentile_type = array( + "percentile" => __("Percentile"), + "bubble" => __("Bubble"), + "circular_progress_bar" => __("Circular porgress bar"), + "interior_circular_progress_bar" => __("Circular progress bar (interior)") + ); $percentile_value = array('percent' => __('Percent'), 'value' => __('Value')); if (is_metaconsole()){ $form_items['percentile_item_row_3'] = array(); @@ -534,14 +542,14 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['percentile_item_row_3']['html'] = '' . __('Type') . ' ' . - html_print_select($percentile_type, 'type_percentile', 'percentile', '', '', '', true) . + html_print_select($percentile_type, 'type_percentile', 'percentile', '', '', '', true, false, false) . ''; $form_items['percentile_item_row_4'] = array(); $form_items['percentile_item_row_4']['items'] = array('percentile_bar', 'percentile_item', 'datos'); $form_items['percentile_item_row_4']['html'] = '' . __('Value to show') . ' ' . - html_print_select($percentile_value, 'value_show', 'percent', '', '', '', true) . + html_print_select($percentile_value, 'value_show', 'percent', '', '', '', true, false, false) . ''; } @@ -580,7 +588,70 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { '' . __('Show statistics') . ' ' . html_print_checkbox('show_statistics', 1, '', true) . ''; + + // Start of Color Cloud rows + + // Diameter + $default_diameter = 100; + $form_items["color_cloud_diameter_row"] = array(); + $form_items["color_cloud_diameter_row"]["items"] = array("color_cloud"); + $form_items["color_cloud_diameter_row"]["html"] = + "" . __("Diameter") . " + " . + html_print_input_text("diameter", $default_diameter, "", 3, 5, true) . + ""; + + // Default color + $default_color = "#FFFFFF"; + $form_items["color_cloud_def_color_row"] = array(); + $form_items["color_cloud_def_color_row"]["items"] = array("color_cloud"); + $form_items["color_cloud_def_color_row"]["html"] = + "" . __("Default color") . " + " . + html_print_input_color("default_color", $default_color, false, true) . + ""; + + // Color ranges + $color_range_tip = __("The color of the element will be the one selected in the first range created in which the value of the module is found (with the initial and final values of the range included)") . "."; + $form_items["color_cloud_color_ranges_row"] = array(); + $form_items["color_cloud_color_ranges_row"]["items"] = array("color_cloud"); + $form_items["color_cloud_color_ranges_row"]["html"] = + "" . + __("Ranges") . + ui_print_help_tip($color_range_tip, true) . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "" . + "
" . __("From value") . "" . + html_print_input_text("from_value_new", "", "", 5, 255, true) . + "" . + "" . + html_print_image("images/add.png", true) . + "" . + "
" . __("To value") . "" . + html_print_input_text("to_value_new", "", "", 5, 255, true) . + "
" . __("Color") . "" . + html_print_input_color("color_new", $default_color, false, true) . + "
" . + ""; + // End of Color Cloud rows + $form_items['show_on_top_row'] = array(); $form_items['show_on_top_row']['items'] = array('group_item'); $form_items['show_on_top_row']['html'] = @@ -616,7 +687,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { __('Type') . ' ' . html_print_select($bars_graph_types, 'bars_graph_type', 'vertical', '', '', '', true) . ''; - + //Insert and modify before the buttons to create or update. if (enterprise_installed()) { enterprise_visual_map_editor_modify_form_items_palette($form_items); @@ -661,7 +732,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['position_row']['items'] = array('static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', 'label', 'icon', 'datos', 'box_item', - 'auto_sla_graph', 'bars_graph','clock', 'donut_graph'); + 'auto_sla_graph', 'bars_graph','clock', 'donut_graph', 'color_cloud'); $form_items_advance['position_row']['html'] = ' ' . __('Position') . ' (' . html_print_input_text('left', '0', '', 3, 5, true) . @@ -750,6 +821,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { var $mapLinkedSelect = $("select#map_linked"); var $linkedMapNodeIDInput = $("input#hidden-linked_map_node_id"); var visualMaps = ; + if (!(visualMaps instanceof Array)) visualMaps = []; var nodesById = ; visualMaps.forEach(function (vMap) { @@ -870,7 +942,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items_advance['element_group_row']['items'] = array( 'group_item', 'static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', - 'icon', 'label', 'datos', 'donut_graph'); + 'icon', 'label', 'datos', 'donut_graph', 'color_cloud'); $form_items_advance['element_group_row']['html'] = ''. __('Restrict access to group') . '' . '' . @@ -903,11 +975,6 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { '; @@ -1026,6 +1093,7 @@ function visual_map_editor_print_toolbox() { visual_map_print_button_editor('group_item', __('Group'), 'left', false, 'group_item_min', true); visual_map_print_button_editor('box_item', __('Box'), 'left', false, 'box_item_min', true); visual_map_print_button_editor('line_item', __('Line'), 'left', false, 'line_item_min', true); + visual_map_print_button_editor('color_cloud', __('Color cloud'), 'left', false, 'color_cloud_min', true); if(defined("METACONSOLE")){ echo 'The data displayed in editor mode is not real'; diff --git a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js index 781c1d1cc0..5bc3ef32b1 100644 --- a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js +++ b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js @@ -159,9 +159,10 @@ if (custom_graph) { dataObject = retrieveDataOject(dataObjects,0); - dataObjects.forEach(function (element) { - elements.push(processDataObject(element)); - }); + //dataObjects.forEach(function (element) { + //elements.push(processDataObject(element)); + //}); + elements.push(processDataObject(dataObject)); graphData = elements; } else { diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 7067e1d560..e69fb155e0 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -362,10 +362,11 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, tickFormatter: xFormatter, }, yaxis: { - color: tick_color, - axisLabelUseCanvas: true, - axisLabelFontSizePixels: font_size, - axisLabelFontFamily: font+'Font', + font: { + size: font_size + 2, + color: 'rgb(84, 84, 84)', + family: font+'Font' + }, ticks: yFormatter, }, legend: { @@ -417,7 +418,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, div_attributes += "min-height: 2.5em;"; } - div_attributes += '" title="'+title+'" class="'+font+'" '+ ' style="overflow: hidden;"'; + div_attributes += '" title="'+title+'" style="overflow: hidden;"'; format.push([i,'
' + label diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 7524fc119e..46191aed93 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -409,12 +409,14 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $colors = implode($separator, $colors); } - $return .= ""; return $return; @@ -474,11 +476,11 @@ function flot_custom_pie_chart ($graph_values, $colors = implode($separator, $temp_colors); $return .= ""; return $return; @@ -575,10 +577,10 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = // Javascript code $return .= ""; return $return; @@ -666,7 +668,7 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon // Javascript code $return .= ""; return $return; @@ -841,7 +843,9 @@ function flot_slicesbar_graph ( // Javascript code $return .= ""; diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 29728984e1..f33a3b5e68 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1332,7 +1332,7 @@ function print_phases_donut (recipient, phases) { var svg = d3.select(recipient) .append("svg") .attr("width", 800) - .attr("height", 400) + .attr("height", 500) .append("g"); svg.append("g") @@ -1361,7 +1361,7 @@ function print_phases_donut (recipient, phases) { .outerRadius(radius * 0.9); width = 800; - height = 400; + height = 500; svg.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); var key = function(d){ return d.data.label; }; @@ -1440,6 +1440,8 @@ function print_phases_donut (recipient, phases) { return d.startAngle + (d.endAngle - d.startAngle)/2; } + var ex = 1; + var sum = 0; text.transition().duration(0) .attrTween("transform", function(d) { this._current = this._current || d; @@ -1447,8 +1449,26 @@ function print_phases_donut (recipient, phases) { this._current = interpolate(0); return function(t) { var d2 = interpolate(t); - var pos = outerArc.centroid(d2); - pos[0] = radius * (midAngle(d2) < Math.PI ? 1 : -1); + + //fix for labels of a very small portion increase the + //height of the label so that they do not overlap + if( ( d2.endAngle - d2.startAngle ) < 0.1){ + var pos = outerArc.centroid(d2); + if (ex%2==0){ + pos[0] = 150; + } + else{ + pos[0] = -150; + sum++; + } + pos[1] = pos[1] - (35*sum); + ex++; + } + else{ + var pos = outerArc.centroid(d2); + pos[0] = radius * (midAngle(d2) < Math.PI ? 1 : -1); + } + return "translate("+ pos +")"; }; }) @@ -1458,6 +1478,17 @@ function print_phases_donut (recipient, phases) { this._current = interpolate(0); return function(t) { var d2 = interpolate(t); + + //fix for labels of a very small portion increase the + //height of the label so that they do not overlap + if( ( d2.endAngle - d2.startAngle ) < 0.1){ + if (ex%2==0){ + return "start"; + } + else{ + return "end"; + } + } return midAngle(d2) < Math.PI ? "start":"end"; }; }); @@ -1468,10 +1499,12 @@ function print_phases_donut (recipient, phases) { /* ------- SLICE TO TEXT POLYLINES -------*/ var polyline = svg.select(".lines").selectAll("polyline") .data(pie(data), key); - + polyline.enter() .append("polyline"); + var ex2 = 1; + var sum2 = 0; polyline.transition().duration(0) .attrTween("points", function(d){ this._current = this._current || d; @@ -1479,16 +1512,33 @@ function print_phases_donut (recipient, phases) { this._current = interpolate(0); return function(t) { var d2 = interpolate(t); - var pos = outerArc.centroid(d2); - pos[0] = radius * 0.95 * (midAngle(d2) < Math.PI ? 1 : -1); + + //fix for labels of a very small portion increase the + //height of the label so that they do not overlap + if( ( d2.endAngle - d2.startAngle ) < 0.1){ + var pos = outerArc.centroid(d2); + if (ex2%2==0){ + pos[0] = 150 * 0.95; + } + else{ + pos[0] = -150 * 0.95; + sum2++; + } + pos[1] = pos[1] - (30*sum2); + ex2++; + } + else{ + var pos = outerArc.centroid(d2); + pos[0] = radius * 0.95 * (midAngle(d2) < Math.PI ? 1 : -1); + } return [arc.centroid(d2), outerArc.centroid(d2), pos]; - }; + }; }) .style("stroke", "black") .style("opacity", ".3") .style("stroke-width", "2px") .style("fill", "none"); - + polyline.exit() .remove(); } @@ -2331,4 +2381,4 @@ var digitPattern = [ setTimeout(tick, 1000 - now % 1000); })(); -} \ No newline at end of file +} diff --git a/pandora_console/include/help/en/help_plugin_macros.php b/pandora_console/include/help/en/help_plugin_macros.php index 1660c45e13..6d1e508b21 100644 --- a/pandora_console/include/help/en/help_plugin_macros.php +++ b/pandora_console/include/help/en/help_plugin_macros.php @@ -31,10 +31,10 @@ Hidden this macros because they cannot edit in the module form -->
  • _plugin_parameters_ : Plug-in Parameters of the module.
  • -
  • _name_tag_ : Nombre de los tags asociados al módulo.
  • -
  • _email_tag_ : Emails asociados a los tags de módulos.
  • -
  • _phone_tag_ : Teléfonos asociados a los tags de módulos.
  • -
  • _moduletags_ : Teléfonos asociados a los tags de módulos.
  • +
  • _name_tag_ : Names of the tags associated to the module.
  • +
  • _email_tag_ : Emails associated to module tags.
  • +
  • _phone_tag_ : Phone numbers associated to module tags.
  • +
  • _moduletags_ : URLs associated to module tags.
  • _agentcustomfield_n_: Agent custom field number n (eg. _agentcustomfield_9_).
  • diff --git a/pandora_console/include/help/es/help_plugin_macros.php b/pandora_console/include/help/es/help_plugin_macros.php index 701d15f35e..77c97aa4d7 100644 --- a/pandora_console/include/help/es/help_plugin_macros.php +++ b/pandora_console/include/help/es/help_plugin_macros.php @@ -30,9 +30,9 @@ Hidden this macros because they cannot edit in the module form -->

  • _plugin_parameters_ : Parámetros del Plug-in del módulo.
  • -
  • _name_tag_ : Names of the tags associated to the module.
  • -
  • _email_tag_ : Emails associated to the module tags.
  • -
  • _phone_tag_ : Phone numbers associated to the module tags.
  • -
  • _moduletags_ : URLs associated to the module tags.
  • +
  • _name_tag_ : Nombre de los tags asociados al módulo.
  • +
  • _email_tag_ : Emails asociados a los tags de módulos.
  • +
  • _phone_tag_ : Teléfonos asociados a los tags de módulos.
  • +
  • _moduletags_ : URLs asociadas a los tags de módulos.
  • _agentcustomfield_n_: Campo personalizado número n del agente (eg. _agentcustomfield_9_).
  • diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js index 7cc18ec790..bd0da308c4 100644 --- a/pandora_console/include/javascript/jquery.pandora.js +++ b/pandora_console/include/javascript/jquery.pandora.js @@ -26,7 +26,8 @@ $.fn.showMessage = function (msg) { return $(this).hide ().empty () - .text (msg) + // here, previously .text (msg) + .html (msg) .slideDown (); }; }) (jQuery); diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 2b323a55f1..1ca0759801 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -594,12 +594,51 @@ function post_process_select_init_unit(name,selected) { function post_process_select_events_unit(name,selected) { $('.' + name + '_toggler').click(function() { - $('#' + name + '_select option[value=none]').attr("selected",true); - $('#text-' + name + '_text').val(""); + var value = $('#text-' + name + '_text').val(); + + var count = $('#' + name + '_select option') + .filter(function(i, item) { + + if ($(item).val() == value) + return true; + else return false; + }) + .length; + + if (count != 1) { + $('#' + name + '_select') + .append($("
    -
    "; - if ($_SERVER['SERVER_ADDR'] == 'localhost' || $_SERVER['SERVER_ADDR'] == '127.0.0.1') { - echo " - Drop Database if exists
    - - "; - } else { - echo ""; - } + echo ""; echo "URL path to Pandora FMS Console
    For example '/pandora_console'
    @@ -670,17 +679,8 @@ function install_step3() { echo "
    "; ?> getRequest('id_event', 0); - if (events_change_status($id_event, EVENT_VALIDATE)) { + if (events_change_status($id_event, EVENT_VALIDATE,$system->getConfig('metaconsole'))) { echo json_encode(array('correct' => 1)); } else { @@ -379,11 +379,20 @@ class Events { $this->default_filters['severity'] = false; } - $this->filter = $system->getRequest('filter', __('Preset Filters')); - if (($this->filter === __("Preset Filters")) || ($this->filter == 0)) { - $this->filter = 0; + if ($system->getRequest('filter', __('Preset Filters')) === __("Preset Filters")) { + //Set filter as default user event filter (only first time) + $this->filter = db_get_value('default_event_filter', 'tusuario', 'id_user', $system->getConfig('id_user')); + + //Use user set default filter if admin set default filter is "none" + if ($this->filter == 0){ + $this->filter = db_get_value('id_filter', 'tusuario', 'id_user', $system->getConfig('id_user')); + } } - else { + else { + $this->filter = $system->getRequest('filter', __('Preset Filters')); + } + + if ($this->filter != 0) { $this->default = false; } diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index 4c9a546798..49c2f27cb4 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -18,6 +18,7 @@ global $config; require_once ("include/functions_agents.php"); require_once ("include/functions_custom_graphs.php"); +ui_require_javascript_file ('calendar'); if (! check_acl ($config['id_user'], $id_grupo, "AR") && ! check_acl ($config['id_user'], 0, "AW")) { db_pandora_audit("ACL Violation", @@ -242,7 +243,7 @@ echo '
    '; //Dialog to save the custom graph echo "'; } -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index ad692695ae..5f76201864 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -559,6 +559,18 @@ if ($validate) { if ($delete) { $ids = (array) get_parameter ("validate_ids", -1); + // Discard deleting in progress events + $in_process_status = db_get_all_rows_sql(" + SELECT id_evento + FROM tevento + WHERE estado=2"); + + foreach ($in_process_status as $val) { + if (($key = array_search($val['id_evento'], $ids)) !== false) { + unset($ids[$key]); + } + } + if ($ids[0] != -1) { $return = events_delete_event ($ids, ($group_rep == 1), $meta); ui_print_result_message ($return, diff --git a/pandora_console/operation/gis_maps/ajax.php b/pandora_console/operation/gis_maps/ajax.php index d1a66c0a3e..3f8775dced 100644 --- a/pandora_console/operation/gis_maps/ajax.php +++ b/pandora_console/operation/gis_maps/ajax.php @@ -321,7 +321,7 @@ switch ($opt) { // Last contact $row = array(); $row[] = __('Last contact'); - if ($agent["ultimo_contacto"] == "01-01-1970 00:00:00") { + if ($agent["ultimo_contacto"] == "1970-01-01 00:00:00") { $row[] = __('Never'); } else { @@ -332,7 +332,7 @@ switch ($opt) { // Last remote contact $row = array(); $row[] = __('Remote'); - if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { + if ($agent["ultimo_contacto_remoto"] == "1970-01-01 00:00:00") { $row[] = __('Never'); } else { diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 2c33acdea6..1c2eb0ef2e 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -74,9 +74,9 @@ if (isset ($_GET["modified"]) && !$view_mode) { $upd_info["lastname"] = get_parameter_post ("lastname", $user_info["lastname"]); $password_new = get_parameter_post ("password_new", ""); $password_confirm = get_parameter_post ("password_conf", ""); - $upd_info["email"] = get_parameter_post ("email", $user_info["email"]); - $upd_info["phone"] = get_parameter_post ("phone", $user_info["phone"]); - $upd_info["comments"] = get_parameter_post ("comments", $user_info["comments"]); + $upd_info["email"] = get_parameter_post ("email", ""); + $upd_info["phone"] = get_parameter_post ("phone", ""); + $upd_info["comments"] = get_parameter_post ("comments", ""); $upd_info["language"] = get_parameter_post ("language", $user_info["language"]); $upd_info["timezone"] = get_parameter_post ("timezone", ""); $upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]); @@ -164,25 +164,36 @@ if (isset ($_GET["modified"]) && !$view_mode) { $success_msg = __('Password successfully updated'); } - $return_update_user = update_user ($id, $upd_info); + // if info is valid then proceed with update + if ((filter_var($upd_info["email"], FILTER_VALIDATE_EMAIL) || $upd_info["email"]=="") && (preg_match('/^[0-9- ]+$/D', $upd_info["phone"]) || $upd_info["phone"]=="")) { + $return_update_user = update_user ($id, $upd_info); - if ($return_update_user === false) { - $error_msg = __('Error updating user info'); - } - elseif($return_update_user == true){ - $success_msg = __('User info successfully updated'); - } - else{ - if(!empty($password_new) && !empty($password_confirm)){ - $success_msg = __('Password successfully updated'); - } + if ($return_update_user === false) { + $error_msg = __('Error updating user info'); + } + elseif($return_update_user == true){ + $success_msg = __('User info successfully updated'); + } else{ - $return=false; - $error_msg = __('No changes have been made'); - } + if(!empty($password_new) && !empty($password_confirm)){ + $success_msg = __('Password successfully updated'); + } + else{ + $return=false; + $error_msg = __('No changes have been made'); + } + } + + ui_print_result_message ($return, $success_msg, $error_msg,$user_auth_error); + } + else if (!filter_var($upd_info["email"], FILTER_VALIDATE_EMAIL)) + ui_print_error_message (__('Please enter a valid email')); + else if (!preg_match('/^[0-9- ]+$/D', $upd_info["phone"])) + ui_print_error_message (__('Please enter a valid phone number')); $user_info = $upd_info; + } else{ if(!$error_msg){ @@ -190,9 +201,10 @@ if (isset ($_GET["modified"]) && !$view_mode) { } $user_auth_error= $config['auth_error']; + + ui_print_result_message ($return, $success_msg, $error_msg,$user_auth_error); } - ui_print_result_message ($return, $success_msg, $error_msg,$user_auth_error); } // Prints action status for current message @@ -221,7 +233,7 @@ $data = array(); $data[0] = '' . __('User ID') . ''; $data[0] .= $jump . '' . $id . ''; $data[1] = '' . __('Full (display) name') . ''; -$data[1] .= $jump . '' . html_print_input_text_extended ("fullname", $user_info["fullname"], '', '', 20, 100, $view_mode, '', 'class="input"', true).''; +$data[1] .= $jump . '' . html_print_input_text_extended ("fullname", $user_info["fullname"], 'fullname', '', 20, 100, $view_mode, '', 'class="input"', true).''; // Show "Picture" (in future versions, why not, allow users to upload it's own avatar here. if (is_user_admin ($id)) { @@ -243,9 +255,9 @@ $table->data[] = $data; $data = array(); $data[0] = ''.__('E-mail').''; -$data[0] .= $jump .''. html_print_input_text_extended ("email", $user_info["email"], '', '', '25', '100', $view_mode, '', 'class="input"', true).''; +$data[0] .= $jump .''. html_print_input_text_extended ("email", $user_info["email"], 'email', '', '25', '100', $view_mode, '', 'class="input"', true).''; $data[1] = ''.__('Phone number').''; -$data[1] .= $jump . '
    '.html_print_input_text_extended ("phone", $user_info["phone"], '', '', '20', '30', $view_mode, '', 'class="input"', true).'
    '; +$data[1] .= $jump . '
    '.html_print_input_text_extended ("phone", $user_info["phone"], 'phone', '', '20', '30', $view_mode, '', 'class="input"', true).'
    '; $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; @@ -254,9 +266,9 @@ if ($view_mode === false) { if ($config["user_can_update_password"]) { $data = array(); $data[0] = ''.__('New Password').''; - $data[0] .= $jump .''.html_print_input_text_extended ("password_new", "", '', '', '25', '45', $view_mode, '', 'class="input"', true, true).''; + $data[0] .= $jump .''.html_print_input_text_extended ("password_new", "", 'password_new', '', '25', '45', $view_mode, '', 'class="input"', true, true).''; $data[1] = ''.__('Password confirmation').''; - $data[1] .= $jump . ''.html_print_input_text_extended ("password_conf", "", '', '', '20', '45', $view_mode, '', 'class="input"', true, true).''; + $data[1] .= $jump . ''.html_print_input_text_extended ("password_conf", "", 'password_conf', '', '20', '45', $view_mode, '', 'class="input"', true, true).''; $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 145be59b50..0d78116347 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.729 -%define release 181205 +%define version 7.0NG.730 +%define release 190121 # 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 ec6e768186..32229a152a 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.729 -%define release 181205 +%define version 7.0NG.730 +%define release 190121 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 @@ -28,7 +28,7 @@ BuildRoot: %{_tmppath}/%{name} BuildArch: noarch AutoReq: 0 Requires: apache2 -Requires: (apache2-mod_php5 or apache2-mod_php7) +Requires: apache2-mod_php7 Requires: php >= 4.3.0 Requires: php-gd, php-snmp, php-json, php-gettext Requires: php-mysqlnd, php-ldap, php-mbstring, php diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install index bc6c9e9752..c834f83769 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.729" +PI_VERSION="7.0NG.730" 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 054204d85a..7f8197540b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1251,6 +1251,7 @@ CREATE TABLE IF NOT EXISTS `treport` ( `metaconsole` tinyint(1) DEFAULT 0, `non_interactive` tinyint(1) UNSIGNED NOT NULL default 0, `hidden` tinyint(1) DEFAULT 0, + `orientation` varchar(25) NOT NULL default 'vertical', PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -2621,6 +2622,7 @@ CREATE TABLE IF NOT EXISTS `tevent_rule` ( `user_comment` text NOT NULL, `id_tag` integer(10) unsigned NOT NULL default '0', `name` text default '', + `group_recursion` INT(1) unsigned default 0, PRIMARY KEY (`id_event_rule`), KEY `idx_id_event_alert` (`id_event_alert`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 9c5df40153..4ef07c8a81 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.729-181205 +Version: 7.0NG.730-190121 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 e40f00fd64..788e214de2 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.729-181205" +pandora_version="7.0NG.730-190121" 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 681ca471d8..cf651cfeb3 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.729 +# Version 7.0NG.730 # 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 3d34777910..fe0edab8e1 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -44,8 +44,8 @@ our @EXPORT = qw( ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.729"; -my $pandora_build = "181205"; +my $pandora_version = "7.0NG.730"; +my $pandora_build = "190121"; 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 be948e9415..c986eb0510 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3060,7 +3060,8 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) { 'custom_id' => $custom_id, 'url_address' => $url_address, 'timezone_offset' => $timezone_offset, - 'alias' => $alias + 'alias' => $alias, + 'update_module_count' => 1, # Force to replicate in metaconsole }); my $agent_id = db_insert ($dbh, 'id_agente', "INSERT INTO tagente $columns", @{$values}); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 3c05ae3fa5..6ff42d34ed 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -396,7 +396,7 @@ sub process_xml_data ($$$$$) { # If it exists add the value to the agent if (defined ($custom_field_info)) { - my $cf_value = get_tag_value ($custom_field, 'value', ''); + my $cf_value = safe_input(get_tag_value ($custom_field, 'value', '')); my $field_agent; @@ -482,7 +482,7 @@ sub process_xml_data ($$$$$) { my $custom_field_data = get_db_single_row($dbh, 'SELECT * FROM tagent_custom_data WHERE id_field = ? AND id_agent = ?', $custom_field_info->{"id_field"}, $agent->{"id_agente"}); - my $cf_value = get_tag_value ($custom_field, 'value', ''); + my $cf_value = safe_input(get_tag_value ($custom_field, 'value', '')); #If not defined we must create if defined just updated if(!defined($custom_field_data)) { @@ -497,7 +497,7 @@ sub process_xml_data ($$$$$) { } else { db_update ($dbh, "UPDATE tagent_custom_data SET description = ? WHERE id_field = ? AND id_agent = ?", - $cf_value ,$custom_field_info->{"id_field"}, $agent->{'id_agente'}); + $cf_value, $custom_field_info->{"id_field"}, $agent->{'id_agente'}); } } else { diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 67db70593a..2d0e505f3d 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -31,8 +31,8 @@ use base 'Exporter'; our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.729"; -my $pandora_build = "181205"; +my $pandora_version = "7.0NG.730"; +my $pandora_build = "190121"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index cec179c499..22096c292a 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -35,6 +35,8 @@ use threads; # Used to calculate the MD5 checksum of a string use constant MOD232 => 2**32; +# 2 to the power of 32. +use constant POW232 => 2**32; # UTF-8 flags deletion from multibyte characters when files are opened. use open OUT => ":utf8"; @@ -122,6 +124,7 @@ our @EXPORT = qw( check_server_threads start_server_thread stop_server_threads + generate_agent_name_hash ); # ID of the different servers @@ -1813,6 +1816,146 @@ sub stop_server_threads { @ServerThreads = (); } +################################################################################ +# Generate random hash as agent name. +################################################################################ +sub generate_agent_name_hash { + my ($agent_alias, $server_ip) = @_; + return sha256(join('|', ($agent_alias, $server_ip, time(), sprintf("%04d", rand(10000))))); +} + +############################################################################### +# Return the SHA256 checksum of the given string as a hex string. +# Pseudocode from: http://en.wikipedia.org/wiki/SHA-2#Pseudocode +############################################################################### +my @K2 = ( + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, + 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, + 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, + 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, + 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +); +sub sha256 { + my $str = shift; + + # No input! + if (!defined($str)) { + return ""; + } + + # Note: All variables are unsigned 32 bits and wrap modulo 2^32 when + # calculating. + + # First 32 bits of the fractional parts of the square roots of the first 8 + # primes. + my $h0 = 0x6a09e667; + my $h1 = 0xbb67ae85; + my $h2 = 0x3c6ef372; + my $h3 = 0xa54ff53a; + my $h4 = 0x510e527f; + my $h5 = 0x9b05688c; + my $h6 = 0x1f83d9ab; + my $h7 = 0x5be0cd19; + + # Pre-processing. + my $msg = unpack ("B*", pack ("A*", $str)); + my $bit_len = length ($msg); + + # Append "1" bit to message. + $msg .= '1'; + + # Append "0" bits until message length in bits = 448 (mod 512). + $msg .= '0' while ((length ($msg) % 512) != 448); + + # Append bit /* bit, not byte */ length of unpadded message as 64-bit + # big-endian integer to message. + $msg .= unpack ("B32", pack ("N", $bit_len >> 32)); + $msg .= unpack ("B32", pack ("N", $bit_len)); + + # Process the message in successive 512-bit chunks. + for (my $i = 0; $i < length ($msg); $i += 512) { + + my @w; + my $chunk = substr ($msg, $i, 512); + + # Break chunk into sixteen 32-bit big-endian words. + for (my $j = 0; $j < length ($chunk); $j += 32) { + push (@w, unpack ("N", pack ("B32", substr ($chunk, $j, 32)))); + } + + # Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: + for (my $i = 16; $i < 64; $i++) { + my $s0 = rightrotate($w[$i - 15], 7) ^ rightrotate($w[$i - 15], 18) ^ ($w[$i - 15] >> 3); + my $s1 = rightrotate($w[$i - 2], 17) ^ rightrotate($w[$i - 2], 19) ^ ($w[$i - 2] >> 10); + $w[$i] = ($w[$i - 16] + $s0 + $w[$i - 7] + $s1) % POW232; + } + + # Initialize working variables to current hash value. + my $a = $h0; + my $b = $h1; + my $c = $h2; + my $d = $h3; + my $e = $h4; + my $f = $h5; + my $g = $h6; + my $h = $h7; + + # Compression function main loop. + for (my $i = 0; $i < 64; $i++) { + my $S1 = rightrotate($e, 6) ^ rightrotate($e, 11) ^ rightrotate($e, 25); + my $ch = ($e & $f) ^ ((0xFFFFFFFF & (~ $e)) & $g); + my $temp1 = ($h + $S1 + $ch + $K2[$i] + $w[$i]) % POW232; + my $S0 = rightrotate($a, 2) ^ rightrotate($a, 13) ^ rightrotate($a, 22); + my $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c); + my $temp2 = ($S0 + $maj) % POW232; + + $h = $g; + $g = $f; + $f = $e; + $e = ($d + $temp1) % POW232; + $d = $c; + $c = $b; + $b = $a; + $a = ($temp1 + $temp2) % POW232; + } + + # Add the compressed chunk to the current hash value. + $h0 = ($h0 + $a) % POW232; + $h1 = ($h1 + $b) % POW232; + $h2 = ($h2 + $c) % POW232; + $h3 = ($h3 + $d) % POW232; + $h4 = ($h4 + $e) % POW232; + $h5 = ($h5 + $f) % POW232; + $h6 = ($h6 + $g) % POW232; + $h7 = ($h7 + $h) % POW232; + } + + # Produce the final hash value (big-endian). + return unpack ("H*", pack ("N", $h0)) . + unpack ("H*", pack ("N", $h1)) . + unpack ("H*", pack ("N", $h2)) . + unpack ("H*", pack ("N", $h3)) . + unpack ("H*", pack ("N", $h4)) . + unpack ("H*", pack ("N", $h5)) . + unpack ("H*", pack ("N", $h6)) . + unpack ("H*", pack ("N", $h7)); +} + +############################################################################### +# Rotate a 32-bit number a number of bits to the right. +############################################################################### +sub rightrotate { + my ($x, $c) = @_; + + return (0xFFFFFFFF & ($x << (32 - $c))) | ($x >> $c); +} + # End of function declaration # End of defined Code diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index c29caad2c2..bc18642b58 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.729 -%define release 181205 +%define version 7.0NG.730 +%define release 190121 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 252aad5895..c89ed5b2f2 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.729 -%define release 181205 +%define version 7.0NG.730 +%define release 190121 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3b7041493d..98b3dc1cb8 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.729" -PI_BUILD="181205" +PI_VERSION="7.0NG.730" +PI_BUILD="190121" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 406a5702cb..74dfd0b39b 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.729 PS181205"; +my $version = "7.0NG.730 PS190121"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 1c226ad44e..338075ed7b 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.729 PS181205"; +my $version = "7.0NG.730 PS190121"; # save program name for logging my $progname = basename($0); @@ -103,7 +103,7 @@ sub help_screen{ print "Available options by category:\n\n" unless $param ne ''; print "Available options for $param:\n\n" unless $param eq ''; print "AGENTS:\n\n" unless $param ne ''; - help_screen_line('--create_agent', " \n\t [
    ]", 'Create agent'); + help_screen_line('--create_agent', " \n\t [
    ]", 'Create agent'); help_screen_line('--update_agent', ' ', "Update an agent field. The fields can be \n\t the following: agent_name, address, description, group_name, interval, os_name, disabled (0-1), \n\t parent_name, cascade_protection (0-1), icon_path, update_gis_data (0-1), custom_id"); help_screen_line('--delete_agent', '', 'Delete agent'); help_screen_line('--disable_group', '', 'Disable agents from an entire group'); @@ -195,6 +195,7 @@ sub help_screen{ help_screen_line('--apply_policy', '', 'Force apply a policy'); help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); help_screen_line('--add_agent_to_policy', ' ', 'Add an agent to a policy'); + help_screen_line('--remove_agent_from_policy', ' ', 'Delete an agent to a policy'); help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file'); help_screen_line('--disable_policy_alerts', '', 'Disable all the alerts of a policy'); help_screen_line('--create_policy', ' '); @@ -996,21 +997,29 @@ sub cli_enable_group() { ############################################################################## sub cli_create_agent() { - my ($agent_name,$os_name,$group_name,$server_name,$address,$description,$interval) = @ARGV[2..8]; + my ($agent_name,$os_name,$group_name,$server_name,$address,$description,$interval, $alias_as_name) = @ARGV[2..9]; print_log "[INFO] Creating agent '$agent_name'\n\n"; $address = '' unless defined ($address); $description = (defined ($description) ? safe_input($description) : '' ); # safe_input() might be better at pandora_create_agent() (when passing 'description' to db_insert()) $interval = 300 unless defined ($interval); - + $alias_as_name = 1 unless defined ($alias_as_name); + my $agent_alias = undef; + + if (!$alias_as_name) { + $agent_alias = $agent_name; + $agent_name = generate_agent_name_hash($agent_alias, $conf{'dbhost'}); + } + my $id_group = get_group_id($dbh,$group_name); exist_check($id_group,'group',$group_name); my $os_id = get_os_id($dbh,$os_name); exist_check($id_group,'operating system',$group_name); my $agent_exists = get_agent_id($dbh,$agent_name); non_exist_check($agent_exists, 'agent name', $agent_name); - pandora_create_agent ($conf, $server_name, $agent_name, $address, $id_group, 0, $os_id, $description, $interval, $dbh); + pandora_create_agent ($conf, $server_name, $agent_name, $address, $id_group, 0, $os_id, $description, $interval, $dbh, + undef, undef, undef, undef, undef, undef, undef, undef, $agent_alias); } ############################################################################## @@ -4093,6 +4102,19 @@ sub cli_policy_add_agent() { } } +############################################################################## +# delete an agent to a policy +# Related option: --remove_agent_from_policy +############################################################################## + +sub cli_policy_delete_agent() { + my ($policy_id, $agent_id) = @ARGV[2..3]; + + my $result = api_call(\%conf,'set', 'remove_agent_from_policy', $policy_id, $agent_id); + print "$result \n\n "; + +} + sub cli_create_planned_downtime() { my $name = @ARGV[2]; my @todo = @ARGV[3..21]; @@ -5697,7 +5719,7 @@ sub pandora_manage_main ($$$) { cli_enable_group(); } elsif ($param eq '--create_agent') { - param_check($ltotal, 7, 3); + param_check($ltotal, 8, 4); cli_create_agent(); } elsif ($param eq '--delete_agent') { @@ -5828,6 +5850,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 2); cli_policy_add_agent(); } + elsif ($param eq '--remove_agent_from_policy') { + param_check($ltotal, 2); + cli_policy_delete_agent(); + } elsif ($param eq '--enable_user') { param_check($ltotal, 1); cli_user_enable(); diff --git a/pandora_server/util/pwrd/README.txt b/pandora_server/util/pwrd/README.txt deleted file mode 100644 index 8cdd5d2c6c..0000000000 --- a/pandora_server/util/pwrd/README.txt +++ /dev/null @@ -1,14 +0,0 @@ -instalar java -instalar selenium (descargar) -instalar xorg-x11-server-Xvfb -#wget ftp://rpmfind.net/linux/centos/6.6/os/x86_64/Packages/xorg-x11-server-Xvfb-1.15.0-22.el6.centos.x86_64.rpm -#yum install xorg-x11-server-Xvfb-1.15.0-22.el6.centos.x86_64.rpm -#Xvfb :99 -ac & ----> Pulsar Enter para continuar -#export DISPLAY=:99 -#java -jar seleniumXXX.jar - -Ya tenemos funcionando Selenium sin necesidad de X. - - - diff --git a/pandora_server/util/pwrd/config.json b/pandora_server/util/pwrd/config.json deleted file mode 100644 index a93b44f7b7..0000000000 --- a/pandora_server/util/pwrd/config.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "capabilities": [ - { - "browserName": "*firefox", - "maxInstances": 1, - "seleniumProtocol": "Selenium" - }, - { - "browserName": "firefox", - "maxInstances": 1, - "seleniumProtocol": "WebDriver" - } - ], - "configuration": { - "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", - "maxSession": 1, - "port": 5555, - "register": true, - "registerCycle": 5000 - } -} \ No newline at end of file diff --git a/pandora_server/util/pwrd/extras/crontab_entries_sample b/pandora_server/util/pwrd/extras/crontab_entries_sample deleted file mode 100644 index 8dc9018ef5..0000000000 --- a/pandora_server/util/pwrd/extras/crontab_entries_sample +++ /dev/null @@ -1,20 +0,0 @@ -# Sample PWRD crontab control tweaks - -# Do not allow firefox running for more than 1h -0 * * * * root /opt/pwrd_maintenance.sh -k - -# Force node-start -*/5 * * * * root /opt/pwrd_maintenance.sh -s - -# Reset firefox version if does not match required 47.0.1 -* * * * * root /opt/pwrd_maintenance.sh -f - -# Restart node if java process is not found -* * * * * root /opt/pwrd_maintenance.sh -r - -# Restart node if no activity since last check -*/5 * * * * root /opt/pwrd_maintenance.sh -c1 - -# Restart node if connection have been lost to hub -*/5 * * * * root /opt/pwrd_maintenance.sh -c2 - diff --git a/pandora_server/util/pwrd/extras/pwrd_maintenance.sh b/pandora_server/util/pwrd/extras/pwrd_maintenance.sh deleted file mode 100755 index cc71eefb9f..0000000000 --- a/pandora_server/util/pwrd/extras/pwrd_maintenance.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# Sample PWRD maintenance script -# ********************************************************************** - -# ********************************************************************** -# Settings -hub_ip="192.168.1.10" -hub_port="4444" - -# Customize PWR global installation directory -PWR_FIREFOX_INSTALLDIR="/opt" - -# ********************************************************************** - -if [ "$1" == "-k" ]; then - killall --older-than 1h firefox >/dev/null 2>&1 - -elif [ "$1" == "-s" ]; then - /etc/init.d/pwrd start-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 - -elif [ "$1" == "-f" ]; then - if [ "`firefox --version`" != "Mozilla Firefox 47.0.1" ]; then - $PWR_FIREFOX_INSTALLDIR/restore_firefox.sh >/dev/null 2>&1 - echo `date +"%c"` Firefox restored > /tmp/restore_firefox.log - [`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 - [`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1 - fi - -elif [ "$1" == "-r" ]; then - if [ ` ps aux | grep "java -jar" | grep -v grep | wc -l` -lt 1 ]; then - [`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 - [`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1 - echo `date +"%c"` PWRD restarted, java process not found > /tmp/pwrd_restart_detected.log - fi - -elif [ "$1" == "-c1" ]; then - if [ $(/etc/pandora/plugins/grep_log /var/log/pwr/pwr_std.log check_pwrd ".*" | wc -l) -eq 0 ]; then - [`/etc/init.d/pwrd status | grep "Node is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 - [`/etc/init.d/pwrd status | grep "PWRD is running" | wc -l` -eq 1 ] && /etc/init.d/pwrd restart > /dev/null 2>&1 - echo $(date +"%c") PWRD restarted, no output detected in log > /tmp/pwrd_restart_detected.log - fi - -elif [ "$1" == "-c2" ]; then - if [ $(/etc/pandora/plugins/grep_log /var/log/pwr/pwr_std.log check_pwrd_err_conn "refused" | grep "$hub_ip:$hub_port [/$hub_ip] failed:" | wc -l) -gt 0 ]; then - /etc/init.d/pwrd restart-node http://$hub_ip:$hub_port/grid/register > /dev/null 2>&1 - echo $(date +"%c") PWRD restarted, lost connection with hub > /tmp/pwrd_restart_detected.log - fi -fi - - - diff --git a/pandora_server/util/pwrd/extras/restore_firefox.sh b/pandora_server/util/pwrd/extras/restore_firefox.sh deleted file mode 100755 index 245a7dde19..0000000000 --- a/pandora_server/util/pwrd/extras/restore_firefox.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Script to restore firefox to tar -# -# ********************************************************************** - -# Customize PWR global installation directory -PWR_FIREFOX_INSTALLDIR="/opt" - -cd $PWR_FIREFOX_INSTALLDIR - -if [ -f firefox-47.0.1.tar ]; then - rm -rf firefox-47 >/dev/null 2>&1 - mv firefox firefox_ >/dev/null 2>&1 - tar xvf firefox-47.0.1.tar >/dev/null 2>&1 - mv firefox firefox-47 >/dev/null 2>&1 - mv firefox_ firefox >/dev/null 2>&1 -else - echo "firefox-47.0.1.tar not found, please leave a copy at $PWR_FIREFOX_INSTALLDIR" -fi diff --git a/pandora_server/util/pwrd/firefox-47.0.1.tar.REMOVED.git-id b/pandora_server/util/pwrd/firefox-47.0.1.tar.REMOVED.git-id deleted file mode 100644 index 03f39ef914..0000000000 --- a/pandora_server/util/pwrd/firefox-47.0.1.tar.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4881ba55982d75040775bafdffcdf57b2cd7ea13 \ No newline at end of file diff --git a/pandora_server/util/pwrd/firefox_profile.tar.gz b/pandora_server/util/pwrd/firefox_profile.tar.gz deleted file mode 100644 index 15e1e4f2fc..0000000000 Binary files a/pandora_server/util/pwrd/firefox_profile.tar.gz and /dev/null differ diff --git a/pandora_server/util/pwrd/install_pwrd.sh b/pandora_server/util/pwrd/install_pwrd.sh deleted file mode 100755 index e36d87b640..0000000000 --- a/pandora_server/util/pwrd/install_pwrd.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/bash - -HELP=`cat<<_HELP -********************** - PWR Server installer -********************** - -To install the Pandora web robot daemon (pwrd) -Please launch this script as root: - -$0 --install [[user] [directory]] - - -_HELP -` - -if [ "$1" == "" ] || [ "$1" != "--install" ]; then - echo "$HELP" - exit 0 -fi - -if [ "`which rpm`" ]; then - if [ "`rpm -qa | grep xorg-x11-server-Xvfb | wc -l`" == "0" ]; then - echo "Package xorg-x11-server-Xvfb is required" - exit 0 - fi -else - echo "Xvfb is required, please confirm is installed in your system" -fi - -# default user is running user -GLOBAL_INST_USER=`whoami` - -if [ "$2" != "" ]; then - if [ `cat /etc/passwd | cut -f1 -d':' | grep -w "$2" | wc -l` -gt 0 ]; then - GLOBAL_INST_USER=$2 - elif [ -d "$2" ]; then - GLOBAL_INST_DIR=$2 - else - echo "Cannot use \"$2\" as user nor directory" - echo "$HELP" - exit 0 - fi -fi - -if [ "$3" != "" ]; then - if [ -d "$3" ]; then - GLOBAL_INST_DIR=$3 - elif [ `cat /etc/passwd | cut -f1 -d':' | grep -w "$3" | wc -l` -gt 0 ]; then - GLOBAL_INST_USER=$3 - else - echo "Cannot use \"$3\" as directory nor user" - echo "$HELP" - exit 0 - fi -fi - -chmod +x pwrd - -PWR_SERVER_DEST=$GLOBAL_INST_DIR/usr/lib/pwr -PWR_SERVER_RSC=$GLOBAL_INST_DIR/etc/pwr/tmp -PWR_SERVER_LOG=$GLOBAL_INST_DIR/var/log/pwr -PWR_FIREFOX_INSTALLDIR=$GLOBAL_INST_DIR/opt - -PWR_FIREFOX_INSTALLDIR_ESCAPED=`echo $PWR_FIREFOX_INSTALLDIR | sed 's/\\//\\\\\//g'` -GLOBAL_INST_DIR_ESCAPED=`echo $GLOBAL_INST_DIR | sed 's/\\//\\\\\//g'` - -[ -d $PWR_SERVER_DEST ] || mkdir -p $PWR_SERVER_DEST -[ -d $PWR_SERVER_LOG ] || mkdir -p $PWR_SERVER_LOG -[ -d $PWR_SERVER_RSC ] || mkdir -p $PWR_SERVER_RSC -[ -d $PWR_FIREFOX_INSTALLDIR ] || mkdir -p $PWR_FIREFOX_INSTALLDIR -[ -d $GLOBAL_INST_DIR/etc/init.d ] || mkdir -p $GLOBAL_INST_DIR/etc/init.d - -tar xvf firefox-47.0.1.tar >/dev/null -mv firefox $PWR_FIREFOX_INSTALLDIR/firefox-47 -ln -s $PWR_FIREFOX_INSTALLDIR/firefox-47/firefox $PWR_FIREFOX_INSTALLDIR/firefox - -tar xvzf firefox_profile.tar.gz >/dev/null -if [ $? -ne 0 ]; then - echo "Failed to deploy firefox profile, please retry installation" - exit 1 -fi -chown -R "$GLOBAL_INST_USER". firefox_profile -[ ! -d "$PWR_FIREFOX_INSTALLDIR/firefox_profile" ] && mv firefox_profile $PWR_FIREFOX_INSTALLDIR - -[ -d "$PWR_FIREFOX_INSTALLDIR/selenium" ] || mkdir -p $PWR_FIREFOX_INSTALLDIR/selenium - -cp config.json $PWR_FIREFOX_INSTALLDIR/selenium/ - -ln -s $PWR_FIREFOX_INSTALLDIR/firefox /usr/bin/firefox - -# Generate logrotate configuration -echo < /etc/logrotate.d/pwrd -/var/log/pwr/pwr_std.log -/var/log/pwr/xvfb.log -/var/log/pwr/pwr_error.log { - weekly - missingok - size 300000 - rotate 3 - maxage 90 - compress - notifempty - copytruncate -} - -EO_LROTATE - -cp ./extras/restore_firefox.sh $PWR_FIREFOX_INSTALLDIR/ -cp ./extras/pwrd_maintenance.sh $PWR_FIREFOX_INSTALLDIR/ -cp ./selenium-server-standalone-2.53.1.jar $PWR_SERVER_DEST/ -cp ./pwrd /etc/init.d/pwrd -cp ./pwrd $GLOBAL_INST_DIR/etc/init.d/pwrd -chmod +x /etc/init.d/pwrd - -# Update pwrd daemon -if [ "$GLOBAL_INST_DIR" != "" ]; then - echo "Adjusting pwrd global directory to: $GLOBAL_INST_DIR" - sed -i "s/PWR_GLOBAL_DIR=\"\"/PWR_GLOBAL_DIR=\"$GLOBAL_INST_DIR_ESCAPED\"/g" /etc/init.d/pwrd - sed -i "s/PWR_GLOBAL_DIR=\"\"/PWR_GLOBAL_DIR=\"$GLOBAL_INST_DIR_ESCAPED\"/g" $GLOBAL_INST_DIR/etc/init.d/pwrd - echo "Adjusting pwrd_maintenance global directory to: $PWR_FIREFOX_INSTALLDIR" - sed -i "s/PWR_FIREFOX_INSTALLDIR=\"\/opt\"/PWR_FIREFOX_INSTALLDIR=\"$PWR_FIREFOX_INSTALLDIR_ESCAPED\"/g" $PWR_FIREFOX_INSTALLDIR/pwrd_maintenance.sh - echo "Adjusting restore_firefox global directory to: $PWR_FIREFOX_INSTALLDIR" - sed -i "s/PWR_FIREFOX_INSTALLDIR=\"\/opt\"/PWR_FIREFOX_INSTALLDIR=\"$PWR_FIREFOX_INSTALLDIR_ESCAPED\"/g" $PWR_FIREFOX_INSTALLDIR/restore_firefox.sh -fi - -if [ "$GLOBAL_INST_USER" != "" ]; then - echo "Adjusting pwrd global user to: $GLOBAL_INST_USER" - sed -i "s/USER=\"root\"/USER=\"$GLOBAL_INST_USER\"/g" /etc/init.d/pwrd - sed -i "s/USER=\"root\"/USER=\"$GLOBAL_INST_USER\"/g" $GLOBAL_INST_DIR/etc/init.d/pwrd -fi - - -[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_DEST -[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_LOG -[ "$GLOBAL_INST_USER" != "" ] && chown -R "$GLOBAL_INST_USER". $PWR_SERVER_RSC - -cat </dev/null 2>&1` - if [ $? -ne 0 ]; then - echo "Xvfb not found, please install it" - if [ -e /etc/rc.d/init.d/functions ]; then - failure - echo 1 - fi - else - Xvfb :99 -screen 0 1400x768x24 -ac +extension RANDR > $LOG_DIR/xvfb.log 2>&1 & echo $! > $XVFB_PID_FILE - export DISPLAY=:99 - echo 0 - fi -} - -# Stop Xvfb -function stop_xvfb() { - echo - if test -f $XVFB_PID_FILE ; then - # Check if there's more instances of pwrd running i.e. standalone + node - if [ ! -e "$BASE_DIR/pwrd_node.pid" ] && [ ! -e "$BASE_DIR/pwrd.pid" ]; then - if [ ! -e /etc/rc.d/init.d/functions ]; then - echo -n "Stopping Xvfb..." - fi - PID=$(cat $XVFB_PID_FILE) - if [ "$PID" != "" ] && [ `kill -9 $PID 2>&1 | grep "No such process" | wc -l` == "1" ]; then - # PID file exists but no process - [ -f $XVFB_PID_FILE ] && rm -f $XVFB_PID_FILE - if [ -e /etc/rc.d/init.d/functions ]; then - success - fi - return 0 - fi - else - [ -e $BASE_DIR/pwrd_node.pid ] && echo -n `cat $BASE_DIR/pwrd_node.pid` - [ -e $BASE_DIR/pwrd.pid ] && echo -n `cat $BASE_DIR/pwrd.pid` - echo -e "\nThere're pwrd processes left. Skipping Xvfb" - fi - fi -} - - -######################################################################## -# START -######################################################################## - -# Start Selenium Standalone server -function start() { - if test -f $pid_file; then - PID=`cat $pid_file` - if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then - echo "PWRD is already running: $PID" - exit 2 - else - echo "Removing stale pid file: $pid_file" - fi - fi - - if [ "`start_xvfb`" != "0" ]; then - if [ -e /etc/rc.d/init.d/functions ]; then - failure - fi - echo "Failed... Check Xvfb" - return 1 - fi - - if [ ! -e /etc/rc.d/init.d/functions ]; then - echo -n "Starting PWRD..." - fi - - export DISPLAY=:99 - PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_PORT $PWR_OPTS > $STD_LOG 2>&1 & echo \$!") - if [ $? == "0" ]; then - if [ -e /etc/rc.d/init.d/functions ]; then - success - fi - echo "Success" - else - if [ -e /etc/rc.d/init.d/functions ]; then - failure - fi - echo "Failed" - fi - - # Store PID - echo -n $PID > $pid_file - -} - -# Start Selenium GRID server: HUB component -function start-hub() { - if test -f $pid_file; then - PID=`cat $pid_file` - if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then - echo "PWRD is already running: $PID" - exit 2 - else - echo "Removing stale pid file: $pid_file" - fi - fi - - if [ ! -e /etc/rc.d/init.d/functions ]; then - echo -n "Starting PWRD..." - fi - - # No Xvfb needed in hub mode - - PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_HUB_PORT -role hub $PWR_HUB_OPTS > $STD_LOG 2>&1 & echo \$!") - if [ $? == "0" ]; then - if [ -e /etc/rc.d/init.d/functions ]; then - success - fi - echo "Success" - else - if [ -e /etc/rc.d/init.d/functions ]; then - failure - fi - echo "Failed" - fi - - # Store PID - echo -n $PID > $pid_file - - echo - echo -e "Add nodes to HUB executing:\n $0 start-node http://$host:$PWR_HUB_PORT/grid/register" -} - -# Start Selenium GRID server: Node Connect to hub -function start-node() { - if test -f $pid_file ; then - PID=`cat $pid_file` - if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then - echo "PWRD is already running: $PID" - exit 2 - else - echo "Removing stale pid file: $pid_file" - fi - fi - - if [ "`start_xvfb`" != "0" ]; then - if [ -e /etc/rc.d/init.d/functions ]; then - failure - fi - echo "Failed... Check Xvfb" - return 1 - fi - - if [ ! -e /etc/rc.d/init.d/functions ]; then - echo -n "Starting PWRD..." - fi - - export DISPLAY=:99 - PID=$(su $USER -c "$JAVA -jar $PWR -host $host -port $PWR_NODE_PORT -role node -hub $1 $PWR_OPTS > $STD_LOG 2>&1 & echo \$!") - if [ $? == "0" ]; then - if [ -e /etc/rc.d/init.d/functions ]; then - success - fi - echo "Success" - else - if [ -e /etc/rc.d/init.d/functions ]; then - failure - fi - echo "Failed" - fi - - # Store PID - echo -n $PID > $pid_file -} - - -######################################################################## -# STOP -######################################################################## - -# Stop Selenium Standalone server -function stop() { - if test -f $pid_file ; then - echo -n "Stopping PWRD..." - PID=$(cat $pid_file) - [ "$PID" == "" ] && PID=`ps aux | grep "$JAVA -jar $PWR" | grep -v grep | awk '{print $2}'` - [ "$PID" != "" ] && ps --pid $PID >/dev/null && su $USER -c "kill -3 $PID" - [ "$PID" != "" ] && ps --pid $PID >/dev/null && kill -9 $PID >/dev/null 2>&1 - if [ $? -eq 0 ]; then - sleep 2 - if [ -e /etc/rc.d/init.d/functions ]; then - success - fi - test -f $pid_file && rm -f $pid_file - - stop_xvfb - else - if [ -e /etc/rc.d/init.d/functions ]; then - failure - else - echo "Failed" - fi - fi - # Clean pid file - test -f $pid_file && rm -f $pid_file - else - echo "PWRD is not running." - stop_xvfb - if [ -e /etc/rc.d/init.d/functions ]; then - success - fi - fi - echo -} - - -######################################################################## -# STATUS -######################################################################## - -# Status of Selenium Standalone server -function status() { - mode=$1 - if test -f $pid_file ; then - echo "checking: $pid_file" - PID=`cat $pid_file` - if [ "$PID" != "" ] && ps --pid $PID >/dev/null; then - echo "PWRD$mode is running: $PID" - if test -f $XVFB_PID_FILE ; then - PID=`cat $XVFB_PID_FILE` - if test -f $XVFB_PID_FILE ; then - echo "Xvfb is running: $PID" - fi - fi - else - echo "PWRD$mode isn't running..." - fi - else - echo "PWRD$mode isn't running..." - fi -} - - - -######################################################################## -# MAIN -######################################################################## - -if [ ! -x "$JAVA" ]; then - echo "Please verify $JAVA is a valid java" 2>&1 - exit 1 -fi - -case "$1" in - start) # Standalone - pid_file=$BASE_DIR/pwrd.pid - start - ;; - start-hub) # hub - pid_file=$BASE_DIR/pwrd_hub.pid - start-hub - ;; - start-node) # node - pid_file=$BASE_DIR/pwrd_node.pid - start-node $2 - ;; - stop) # standalone - pid_file=$BASE_DIR/pwrd.pid - stop - ;; - stop-hub) # hub - pid_file=$BASE_DIR/pwrd_hub.pid - stop - ;; - stop-node) # node - pid_file=$BASE_DIR/pwrd_node.pid - stop - ;; - restart) # standalone - pid_file=$BASE_DIR/pwrd.pid - stop - start - ;; - restart-hub) # hub - pid_file=$BASE_DIR/pwrd_hub.pid - stop - start-hub - ;; - restart-node) # node - pid_file=$BASE_DIR/pwrd_node.pid - stop - start-node $2 - ;; - status) - pid_file=$BASE_DIR/pwrd.pid - status "" - pid_file=$BASE_DIR/pwrd_hub.pid - status " HUB" - pid_file=$BASE_DIR/pwrd_node.pid - status " Node" - ;; - *) - echo "Usage: $SELF start*|stop*|restart*|status" - echo " start* (standalone, hub or node)" - echo " start" - echo " start-hub" - echo " start-node http://hub:4444/grid/register" - echo " stop* (standalone, hub or node)" - echo " stop" - echo " stop-hub" - echo " stop-node" - echo " restart* (standalone, hub or node)" - echo " restart" - echo " restart-hub" - echo " restart-node http://hub:4444/grid/register" - exit 9 - ;; -esac diff --git a/pandora_server/util/pwrd/selenium-server-standalone-2.53.1.jar b/pandora_server/util/pwrd/selenium-server-standalone-2.53.1.jar deleted file mode 100644 index 5c3c4fd210..0000000000 Binary files a/pandora_server/util/pwrd/selenium-server-standalone-2.53.1.jar and /dev/null differ diff --git a/pandora_server/util/pwrd/selenium_ide_2.9.1.xpi b/pandora_server/util/pwrd/selenium_ide_2.9.1.xpi deleted file mode 100644 index c93d15d840..0000000000 Binary files a/pandora_server/util/pwrd/selenium_ide_2.9.1.xpi and /dev/null differ