From 47401ccfeb8a8d146c7361b1e7ddbde033352e45 Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 9 Jan 2015 00:01:12 +0100 Subject: [PATCH 01/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 184c0331ab..e3d9b20e2e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150108 +Version: 6.0dev-150109 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 9af643fa25..8dd1b67e4c 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="6.0dev-150108" +pandora_version="6.0dev-150109" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 7a8ba1da27..2977fa8218 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150108'; +use constant AGENT_BUILD => '150109'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index f0081211c1..d0ee72fe8a 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150108 +%define release 150109 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 a95dd515a0..5326bff35e 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150108 +%define release 150109 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 1874ed38df..0a8fdb055f 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150108} +{150109} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 2904d25753..2d92f4327e 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 ("6.0dev(Build 150108)") +#define PANDORA_VERSION ("6.0dev(Build 150109)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index db5e0b231e..845d103af3 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", "(6.0dev(Build 150108))" + VALUE "ProductVersion", "(6.0dev(Build 150109))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 563a8d176f..13719983e7 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150108 +Version: 6.0dev-150109 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 166a037f56..b8a89727a3 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="6.0dev-150108" +pandora_version="6.0dev-150109" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index d4d85a1626..ce6c6c36d0 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150108'; +$build_version = 'PC150109'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 54948ec47e..9ebffc84c6 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Fri, 9 Jan 2015 11:28:18 +0100 Subject: [PATCH 02/41] Changed the default path for fping so that it works OOTB on CentOS. --- pandora_server/conf/pandora_server.conf.new | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 9673646fcd..8bc4010ac4 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -249,7 +249,7 @@ xprobe2 /usr/bin/xprobe2 nmap /usr/bin/nmap # Path to the fping binary. Used by the Enterprise ICMP Server. -fping /usr/bin/fping +fping /usr/sbin/fping # A value that specifies how aggressive nmap should be from 1 to 5. 1 means slower but more reliable, 5 means faster but less reliable. 2 by default. nmap_timing_template 2 From 1a541b1657070c8e8add94e23eee2a7f9bc6c35c Mon Sep 17 00:00:00 2001 From: Sancho Lerena Date: Thu, 8 Jan 2015 19:05:43 +0100 Subject: [PATCH 03/41] Solved a problem with autorefresh URL. This fixes problem on refreshing the same URL for a long time (p.e: 4 hours). Problem was the filename was not passed, and this, in someway, makes the whole system to add parameters to the right until it too long and breaks it. To avoid other problems, I've added a safe check to see if coming URL contains "index.php" before adding it. Tested on several subcomponents and works. --- pandora_console/include/functions_ui.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ecc77c7e30..986a0ec065 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1237,7 +1237,7 @@ function ui_process_page_head ($string, $bitfield) { $_GET['sec2'] == 'operation/snmpconsole/snmp_view' || $_GET['sec2'] == 'enterprise/dashboard/main_dashboard') { - $query = ui_get_url_refresh (false); + $query = ui_get_url_refresh (false, false); $output .= ''; @@ -1250,8 +1250,8 @@ function ui_process_page_head ($string, $bitfield) { - - + + @@ -2135,8 +2135,13 @@ function ui_toggle($code, $name, $title = '', $hidden_default = true, $return = function ui_get_url_refresh ($params = false, $relative = true, $add_post = true) { // Agent selection filters and refresh global $config; - $url = ''; - + + // slerena, 8/Ene/2015 - Need to put index.php on URL which have it. + if (strpos($_SERVER['REQUEST_URI'], 'index.php') === false) + $url = ''; + else + $url = 'index.php'; + if (sizeof ($_REQUEST)) { //Some (old) browsers don't like the ?&key=var $url .= '?'; @@ -2215,6 +2220,7 @@ function ui_get_url_refresh ($params = false, $relative = true, $add_post = true } $url = htmlspecialchars ($url); + if (! $relative) { return ui_get_full_url ($url); } From 44fa308e847615f7fe628e90a2a10e8c58c58b0e Mon Sep 17 00:00:00 2001 From: artica Date: Sat, 10 Jan 2015 00:01:11 +0100 Subject: [PATCH 04/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index e3d9b20e2e..a54fece1ee 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150109 +Version: 6.0dev-150110 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 8dd1b67e4c..ca8673a822 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="6.0dev-150109" +pandora_version="6.0dev-150110" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 2977fa8218..68a90ccf45 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150109'; +use constant AGENT_BUILD => '150110'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d0ee72fe8a..2c02bd0de6 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150109 +%define release 150110 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 5326bff35e..11fbcb6b8b 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150109 +%define release 150110 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 0a8fdb055f..98d40eda45 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150109} +{150110} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 2d92f4327e..d6e2ae61c9 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 ("6.0dev(Build 150109)") +#define PANDORA_VERSION ("6.0dev(Build 150110)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 845d103af3..5be3132740 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", "(6.0dev(Build 150109))" + VALUE "ProductVersion", "(6.0dev(Build 150110))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 13719983e7..7291d3fdc8 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150109 +Version: 6.0dev-150110 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 b8a89727a3..e072cc8af6 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="6.0dev-150109" +pandora_version="6.0dev-150110" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ce6c6c36d0..87398b0312 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150109'; +$build_version = 'PC150110'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 9ebffc84c6..d2fd5b464b 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Sun, 11 Jan 2015 00:01:08 +0100 Subject: [PATCH 05/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a54fece1ee..d1557cf7cf 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150110 +Version: 6.0dev-150111 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 ca8673a822..f8429a195e 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="6.0dev-150110" +pandora_version="6.0dev-150111" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 68a90ccf45..975fb69226 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150110'; +use constant AGENT_BUILD => '150111'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 2c02bd0de6..3a172ce1ff 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150110 +%define release 150111 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 11fbcb6b8b..f42d49aa39 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150110 +%define release 150111 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 98d40eda45..10312c0174 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150110} +{150111} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index d6e2ae61c9..9ad35034dc 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 ("6.0dev(Build 150110)") +#define PANDORA_VERSION ("6.0dev(Build 150111)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5be3132740..9d4d3add67 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", "(6.0dev(Build 150110))" + VALUE "ProductVersion", "(6.0dev(Build 150111))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 7291d3fdc8..030cf32a18 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150110 +Version: 6.0dev-150111 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 e072cc8af6..c822277ed3 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="6.0dev-150110" +pandora_version="6.0dev-150111" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 87398b0312..4333133f9e 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150110'; +$build_version = 'PC150111'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index d2fd5b464b..d7ff0bee1c 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Mon, 12 Jan 2015 00:01:09 +0100 Subject: [PATCH 06/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index d1557cf7cf..d1dfd99e04 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150111 +Version: 6.0dev-150112 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 f8429a195e..606eb2ba2a 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="6.0dev-150111" +pandora_version="6.0dev-150112" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 975fb69226..32a2909868 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150111'; +use constant AGENT_BUILD => '150112'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 3a172ce1ff..850fd705e7 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150111 +%define release 150112 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 f42d49aa39..cd59c414d5 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150111 +%define release 150112 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 10312c0174..175a6c82e6 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150111} +{150112} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 9ad35034dc..6665e768f4 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 ("6.0dev(Build 150111)") +#define PANDORA_VERSION ("6.0dev(Build 150112)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 9d4d3add67..093b8c6457 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", "(6.0dev(Build 150111))" + VALUE "ProductVersion", "(6.0dev(Build 150112))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 030cf32a18..0a1b48ebf1 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150111 +Version: 6.0dev-150112 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 c822277ed3..04e273b244 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="6.0dev-150111" +pandora_version="6.0dev-150112" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 4333133f9e..8320ea5607 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150111'; +$build_version = 'PC150112'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index d7ff0bee1c..9e631ff744 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Mon, 12 Jan 2015 13:19:14 +0100 Subject: [PATCH 07/41] Added the fixed of commit 'Fixed calculation of group items in visual maps on linked maps.' --- .../include/functions_visual_map.php | 86 ++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 8e0efcc478..3ddcd6eb18 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1916,34 +1916,78 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { $id_layout = (int) $id_layout; - $result = db_get_all_rows_filter ('tlayout_data', array ('id_layout' => $id_layout), - array ('id_agente_modulo', 'parent_item', 'id_layout_linked', 'id_agent', 'type')); + $result = db_get_all_rows_filter ('tlayout_data', + array ('id_layout' => $id_layout), + array ( + 'id_agente_modulo', + 'id_group', + 'parent_item', + 'id_layout_linked', + 'id_agent', + 'type')); if ($result === false) return VISUAL_MAP_STATUS_NORMAL; - foreach ($result as $rownum => $data) { - if (($data["id_layout_linked"] == 0 && $data["id_agente_modulo"] == 0 && $data["id_agent"] == 0) || $data['type'] != 0) - continue; - // Other Layout (Recursive!) - if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { - $status = visual_map_get_layout_status ($data["id_layout_linked"], $depth); + foreach ($result as $data) { + switch ($data['type']) { + case GROUP_ITEM: + if (($data["id_layout_linked"] == 0) { + $group_status = groups_get_status($data['id_group']); + switch ($group_status) { + case AGENT_STATUS_ALERT_FIRED: + $status = VISUAL_MAP_STATUS_CRITICAL_ALERT; + break; + case AGENT_STATUS_CRITICAL: + $status = VISUAL_MAP_STATUS_CRITICAL_BAD; + break; + case AGENT_STATUS_WARNING: + $status = VISUAL_MAP_STATUS_WARNING; + break; + case AGENT_STATUS_UNKNOWN: + $status = VISUAL_MAP_STATUS_UNKNOWN; + break; + case AGENT_STATUS_NORMAL: + default: + $status = VISUAL_MAP_STATUS_NORMAL; + break; + } + } + else { + $status = visual_map_get_layout_status( + $data["id_layout_linked"], $depth); + } + break; + default: + if (($data["id_layout_linked"] == 0 && + $data["id_agente_modulo"] == 0 && + $data["id_agent"] == 0) || + $data['type'] != 0) + continue; + + // Other Layout (Recursive!) + if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { + $status = visual_map_get_layout_status($data["id_layout_linked"], $depth); + } + // Module + elseif ($data["id_agente_modulo"] != 0) { + $status = modules_get_agentmodule_status($data["id_agente_modulo"]); + + } + // Agent + else { + //-------------------------------------------------- + // ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT + // MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS + //-------------------------------------------------- + + $status = agents_get_status($data["id_agent"], true); + } + break; } - // Module - elseif ($data["id_agente_modulo"] != 0) { - $status = modules_get_agentmodule_status ($data["id_agente_modulo"]); - } - // Agent - else { - //-------------------------------------------------- - // ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT - // MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS - //-------------------------------------------------- - - $status = agents_get_status ($data["id_agent"], true); - } if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD) return VISUAL_MAP_STATUS_CRITICAL_BAD; + if ($status > $temp_total) $temp_total = $status; } From c726c0f9bdb40bc1787308260ac5f1ae84c5090c Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 12 Jan 2015 15:40:02 +0100 Subject: [PATCH 08/41] Fixed the topology networkmaps, sometimes the relationships of agents showed bad --- .../include/functions_networkmap.php | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 2844fdd3df..9f0383c59f 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -333,16 +333,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $node_ref[$agent['id_agente']] = $node_count; - // Save node parent information to define edges later - if ($agent['id_parent'] != "0" && - array_key_exists($agent['id_parent'], $node_ref)) { - - $parents[$node_count] = $node_ref[$agent['id_parent']]; - } - else { - $orphans[$node_count] = 1; - } - $agent['id_node'] = $node_count; $agent['type'] = 'agent'; @@ -389,6 +379,19 @@ function networkmap_generate_dot ($pandora_name, $group = 0, } } + // Addded the relationship of parents of agents + foreach ($agents as $agent) { + if ($agent['id_parent'] != "0" && + array_key_exists($agent['id_parent'], $node_ref)) { + + + $parents[$node_ref[$agent['id_agente']]] = $node_ref[$agent['id_parent']]; + } + else { + $orphans[$node_ref[$agent['id_agente']]] = 1; + } + } + // Drop the modules without a partner if l2_network is true // and the snmp interfaces token is false if ($l2_network) { From 4310344d39b44c84d5244d0485b74494ed2fafa5 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Mon, 12 Jan 2015 16:20:07 +0100 Subject: [PATCH 09/41] Add combox filter in search form, view: Manage Agents in Admistration --- .../godmode/agentes/modificar_agente.php | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index bd460fea7f..e79a653d6b 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -23,6 +23,7 @@ $ag_group = get_parameter ("ag_group_refresh", -1); $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $recursion = get_parameter('recursion'); +$disabled = get_parameter('disabled'); if ($ag_group == -1 ) $ag_group = (int) get_parameter ("ag_group", -1); @@ -138,6 +139,16 @@ if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "PM")) else $return_all_group = true; html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;'); +echo ""; +echo __('Show Agents') . ' '; +$fields = array( + 2 => __('Everyone'), + 1 => __('Only disabled'), + 0 => __('Only enabled'), + ); +html_print_select($fields,"disabled",$disabled,'this.form.submit()'); + +echo ""; echo ""; echo __('Recursion') . ' '; @@ -247,6 +258,16 @@ if ($search != "") { LIKE '%$search%' OR direccion LIKE '%$search%') "; } +if ($disabled==1) +{ + $search_sql = " AND disabled = ". $disabled . $search_sql; +} +else{ + if ($disabled==0){ + $search_sql = " AND disabled = 0" . $search_sql; + } +} + // Show only selected groups if ($ag_group > 0) { $sql = sprintf ('SELECT COUNT(*) @@ -395,23 +416,23 @@ if (($config['dbtype'] == 'oracle') && ($agents !== false)) { } // Prepare pagination -ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort", $offset); +ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled", $offset); if ($agents !== false) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; @@ -529,18 +550,18 @@ if ($agents !== false) { if ($agent['disabled']) { echo "". + enable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled''>". html_print_image('images/lightbulb_off.png', true, array('alt' => __('Enable agent'), 'title' => __('Enable agent'))) .""; } else { echo "". + disable_agent=".$agent["id_agente"]."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'>". html_print_image('images/lightbulb.png', true, array('alt' => __('Disable agent'), 'title' => __('Disable agent'))) .""; } if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { echo "  '; echo html_print_image('images/cross.png', true, array("border" => '0')) . ""; } @@ -548,7 +569,7 @@ if ($agents !== false) { echo ""; } echo "
".__('Agent name') . ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown)) . ''; echo "".__('R')."".__('OS'). ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown)) . ''; echo "".__('Group'). ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; echo "" . __('Description') . "" . __('Actions') . "
"; - ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); + ui_pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled", $offset); echo "'."\n"; + + $output .= '' . "\n"; } - $output .= ''."\n"; + $output .= '' . "\n"; } } - $output .= '
"; } else { From 9709123ec7dca0383b5bec24f4be62337515c56f Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 13 Jan 2015 00:01:10 +0100 Subject: [PATCH 10/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index d1dfd99e04..9f8ce8e040 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150112 +Version: 6.0dev-150113 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 606eb2ba2a..5c49f2d4c8 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="6.0dev-150112" +pandora_version="6.0dev-150113" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 32a2909868..fc622e294a 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150112'; +use constant AGENT_BUILD => '150113'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 850fd705e7..51666f6598 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150112 +%define release 150113 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 cd59c414d5..5c14d225bc 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150112 +%define release 150113 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 175a6c82e6..173d69dcd3 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150112} +{150113} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 6665e768f4..3ae4c2e6c1 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 ("6.0dev(Build 150112)") +#define PANDORA_VERSION ("6.0dev(Build 150113)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 093b8c6457..dd0c322f31 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", "(6.0dev(Build 150112))" + VALUE "ProductVersion", "(6.0dev(Build 150113))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0a1b48ebf1..f74d5f7981 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150112 +Version: 6.0dev-150113 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 04e273b244..a0ae325323 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="6.0dev-150112" +pandora_version="6.0dev-150113" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 8320ea5607..bdd04f0b83 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150112'; +$build_version = 'PC150113'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 9e631ff744..b1a71280bc 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Tue, 13 Jan 2015 10:54:19 +0100 Subject: [PATCH 11/41] Added support for multiple master servers. --- pandora_server/bin/pandora_server | 167 +++++++++--------- pandora_server/lib/PandoraFMS/Config.pm | 4 +- pandora_server/lib/PandoraFMS/Core.pm | 42 +++++ .../lib/PandoraFMS/NetworkServer.pm | 2 +- pandora_server/lib/PandoraFMS/PluginServer.pm | 2 +- .../lib/PandoraFMS/PredictionServer.pm | 2 +- pandora_server/lib/PandoraFMS/WMIServer.pm | 2 +- 7 files changed, 136 insertions(+), 85 deletions(-) diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 14e38f51a8..d542295d01 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -264,88 +264,95 @@ sub pandora_server_tasks ($) { my $counter = 0; while ($RUN == 1) { eval{ - # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) - # -------------------------------------------------- - if (($counter % 5) == 0) { - - # Update forced alerts - pandora_exec_forced_alerts ($pa_config, $dbh); + if (pandora_is_master($pa_config) == 1) { - # Rotate Log File - pandora_rotate_logfile($pa_config); - } - - # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) - # --------------------------------------------------- - if (($counter % 30) == 0) { + # TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks) + # -------------------------------------------------- + if (($counter % 5) == 0) { + + # Update forced alerts + pandora_exec_forced_alerts ($pa_config, $dbh); - # Update module status and fired alert counts - my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)'); - foreach my $agent (@agents) { - logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); - - if ($agent->{'update_module_count'} == 1) { - pandora_update_agent_module_count ($dbh, $agent->{'id_agente'}); - } - - if ($agent->{'update_alert_count'} == 1) { - pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'}); - } - } - - # Keepalive module control.(very DB intensive, not run frecuently - pandora_module_keep_alive_nd ($pa_config, $dbh); - - # Set the status of unknown modules - pandora_module_unknown ($pa_config, $dbh); - - # Set event storm protection - pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); - } - - # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) - # ---------------------------------------------------- - if (($counter % 60) == 0) { - # Downtimes are executed only 30 x Server Threshold secs - pandora_planned_downtime ($pa_config, $dbh); - - # Realtime stats (Only master server!) - ( VERY HEAVY !) - # Realtimestats == 1, generated by WEB Console, not by server! - if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){ - - # Check if I need to refresh stats - my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat"); - if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){ - pandora_group_statistics ($pa_config, $dbh); - pandora_server_statistics ($pa_config, $dbh); - } + # Rotate Log File + pandora_rotate_logfile($pa_config); } - # Event auto-expiry - my $expiry_time = $pa_config->{"event_expiry_time"}; - my $expiry_window = $pa_config->{"event_expiry_window"}; - if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) { - my $time_ref = time (); - my $expiry_limit = $time_ref - $expiry_time; - my $expiry_window = $time_ref - $expiry_window; - db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window); - } - } - - # Pandora self monitoring - if (defined($pa_config->{"self_monitoring"}) - && $pa_config->{"self_monitoring"} == 1 - && $counter % $pa_config->{'self_monitoring_interval'} == 0) { - pandora_self_monitoring ($pa_config, $dbh); - } - + # TASKS EXECUTED EVERY 30 SECONDS (Mid latency tasks) + # --------------------------------------------------- + if (($counter % 30) == 0) { - # Avoid counter overflow - if ($counter > 10000){ - $counter = 0; + # Update module status and fired alert counts + my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1)'); + foreach my $agent (@agents) { + logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); + + if ($agent->{'update_module_count'} == 1) { + pandora_update_agent_module_count ($dbh, $agent->{'id_agente'}); + } + + if ($agent->{'update_alert_count'} == 1) { + pandora_update_agent_alert_count ($dbh, $agent->{'id_agente'}); + } + } + + # Keepalive module control.(very DB intensive, not run frecuently + pandora_module_keep_alive_nd ($pa_config, $dbh); + + # Set the status of unknown modules + pandora_module_unknown ($pa_config, $dbh); + + # Set event storm protection + pandora_set_event_storm_protection (pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0)); + } + + # TASKS EXECUTED EVERY 60 SECONDS (High latency tasks) + # ---------------------------------------------------- + if (($counter % 60) == 0) { + # Downtimes are executed only 30 x Server Threshold secs + pandora_planned_downtime ($pa_config, $dbh); + + # Realtime stats (Only master server!) - ( VERY HEAVY !) + # Realtimestats == 1, generated by WEB Console, not by server! + if (defined($pa_config->{"realtimestats"}) && $pa_config->{"realtimestats"} == 0){ + + # Check if I need to refresh stats + my $last_execution_stats = get_db_value ($dbh, "SELECT MAX(utimestamp) FROM tgroup_stat"); + if (!defined($last_execution_stats) || $last_execution_stats < (time() - $pa_config->{"stats_interval"})){ + pandora_group_statistics ($pa_config, $dbh); + pandora_server_statistics ($pa_config, $dbh); + } + } + + # Event auto-expiry + my $expiry_time = $pa_config->{"event_expiry_time"}; + my $expiry_window = $pa_config->{"event_expiry_window"}; + if ($expiry_time > 0 && $expiry_window > 0 && $expiry_window > $expiry_time) { + my $time_ref = time (); + my $expiry_limit = $time_ref - $expiry_time; + my $expiry_window = $time_ref - $expiry_window; + db_do ($dbh, 'UPDATE tevento SET estado=1, ack_utimestamp=? WHERE estado=0 AND utimestamp < ? AND utimestamp > ?', $time_ref, $expiry_limit, $expiry_window); + } + } + + # Pandora self monitoring + if (defined($pa_config->{"self_monitoring"}) + && $pa_config->{"self_monitoring"} == 1 + && $counter % $pa_config->{'self_monitoring_interval'} == 0) { + pandora_self_monitoring ($pa_config, $dbh); + } + + + # Avoid counter overflow + if ($counter > 10000){ + $counter = 0; + } + else { + $counter++; + } } else { - $counter++; + # Do an additional sleep if we are not the master server + sleep ($pa_config->{'server_threshold'}); } }; @@ -518,7 +525,7 @@ sub main() { pandora_startup (); # Start thread to execute server tasks on the master server - threads->create('pandora_server_tasks', (\%Config))->detach() if ($Config{"pandora_master"} == 1); + threads->create('pandora_server_tasks', (\%Config))->detach(); # Generate 'going up' events foreach my $server (@Servers) { @@ -568,9 +575,11 @@ sub main() { $server->update(); } - # Not needed. The console assumes a server is down if it has not updated its status in the last 15 minutes. - ## Update fallen servers - #db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'}))); + # Update fallen servers + db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'}))); + + # Set the master server + pandora_set_master(\%Config, $DBH); }; # Restart on error or auto restart diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index ea8339bc0b..0dca80d4bc 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -850,8 +850,8 @@ sub pandora_load_config { if ($pa_config->{"pandora_check"} == 1) { print " [*] MD5 Security enabled.\n"; } - if ($pa_config->{"pandora_master"} == 1) { - print " [*] This server is running in MASTER mode.\n"; + if ($pa_config->{"pandora_master"} != 0) { + print " [*] This server is running with MASTER priority " . $pa_config->{"pandora_master"} . "\n"; } } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 131270e4ed..d3587caf2d 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -165,6 +165,7 @@ our @EXPORT = qw( pandora_get_module_phone_tags pandora_get_module_email_tags pandora_get_os + pandora_is_master pandora_mark_agent_for_alert_update pandora_mark_agent_for_module_update pandora_module_keep_alive @@ -189,6 +190,7 @@ our @EXPORT = qw( pandora_reset_server pandora_server_keep_alive pandora_set_event_storm_protection + pandora_set_master pandora_update_agent pandora_update_agent_address pandora_update_agent_alert_count @@ -225,6 +227,9 @@ our @AlertStatus = ('Execute the alert', 'Do not execute the alert', 'Do not exe # Event storm protection (no alerts or events) our $EventStormProtection :shared = 0; +# Current master server +my $Master :shared = 0; + ########################################################################## # Return the agent given the IP address. ########################################################################## @@ -4221,6 +4226,43 @@ sub pandora_self_monitoring ($$) { close (XMLFILE); } +########################################################################## +=head2 C<< set_master (I<$pa_config>, I<$dbh>) >> + +Set the current master server. + +=cut +########################################################################## +sub pandora_set_master ($$) { + my ($pa_config, $dbh) = @_; + + my $current_master = get_db_value ($dbh, 'SELECT name FROM tserver + WHERE master <> 0 AND status = 1 + ORDER BY master DESC LIMIT 1'); + return unless defined($current_master) and ($current_master ne $Master); + + logger($pa_config, "Server $current_master is the current master.", 1); + $Master = $current_master; +} + +########################################################################## +=head2 C<< is_master (I<$pa_config>) >> + +Returns 1 if this server is the current master, 0 otherwise. + +=cut +########################################################################## +sub pandora_is_master ($) { + my ($pa_config) = @_; + + if ($Master eq $pa_config->{'servername'}) { + return 1; + } + + return 0; +} + + ########################################################################## =head2 C<< pandora_module_unknown (I<$pa_config>, I<$dbh>) >> diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm index c3544ac76d..86b1f05025 100644 --- a/pandora_server/lib/PandoraFMS/NetworkServer.pm +++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm @@ -96,7 +96,7 @@ sub data_producer ($) { my @rows; my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]); - if ($pa_config->{'pandora_master'} == 0) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index dfc75519d3..e8144f4dfb 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -96,7 +96,7 @@ sub data_producer ($) { my @tasks; my @rows; - if ($pa_config->{'pandora_master'} != 1) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index 3c07c11baf..1818f68b55 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -92,7 +92,7 @@ sub data_producer ($) { my @tasks; my @rows; - if ($pa_config->{'pandora_master'} != 1) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, last_execution_try FROM tagente, tagente_modulo, tagente_estado diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index fd400225fe..77f0394f52 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -94,7 +94,7 @@ sub data_producer ($) { my @tasks; my @rows; - if ($pa_config->{'pandora_master'} != 1) { + if (pandora_is_master($pa_config) == 0) { @rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try FROM tagente, tagente_modulo, tagente_estado WHERE server_name = ? From ee0d48bb1423a14a6939fd09f72c83960d5a15f9 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 13 Jan 2015 11:34:12 +0100 Subject: [PATCH 12/41] Fixed small error in translation. --- pandora_console/include/help/en/help_inventory_tab.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/help/en/help_inventory_tab.php b/pandora_console/include/help/en/help_inventory_tab.php index 7980773254..83150650ea 100644 --- a/pandora_console/include/help/en/help_inventory_tab.php +++ b/pandora_console/include/help/en/help_inventory_tab.php @@ -9,7 +9,7 @@ Next are described the fields that you should complete to add an Inventory Modul
    Module: Combo where you can choose the Inventory Module that you want to add. It will only show the modules which Operative System will match up with that from the agent.
    Target: IP or servername from you want to get the inventory.
    Interval: Combo where you choose the time interval in which the Inventory Module will ve executed.
-
    Username: User that will ve used to execute the Inventory Module.
+
    Username: User that will be used to execute the Inventory Module.
    Password: User Password that will be used to execute the Inventory Module.

You can apply changes in all modules clicking in "Update all" when update any module. From bb2ef17a0359e9ed1d90cd3374e7e2f98f8a5298 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 13 Jan 2015 11:37:22 +0100 Subject: [PATCH 13/41] Added new tooltip to the field filter in SNMP-> SNMP Filters-> create --- pandora_console/godmode/snmpconsole/snmp_filters.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index 42f378c9b6..d81a2a23c3 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -94,7 +94,8 @@ if ($edit_filter > -2) { $table->data[0][1] = html_print_input_text ('description', $description, '', 60, 100, true); $table->data[1][0] = __('Filter'); $table->data[1][1] = html_print_input_text ('filter', $filter, '', 60, 100, true); - + $table->data[1][1] .= ui_print_help_tip (__("This field contains a substring, could be part of a IP address, a numeric OID, or a plain substring") . SEPARATOR_COLUMN, true); + echo '

'; html_print_input_hidden ('update_filter', $edit_filter); html_print_table ($table); From 512bedda451f5d558c51cdae86c870e0d52cb3a4 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 13 Jan 2015 12:03:03 +0100 Subject: [PATCH 14/41] Added support for policies tags into the function 'tags_get_module_tags'. INCIDENT: #1644 --- pandora_console/include/functions_tags.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index ba74a5f6cc..cb34668f7f 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -461,7 +461,8 @@ function tags_insert_policy_module_tag ($id_agent_module, $tags) { $values['id_tag'] = $tag; $values['id_policy_module'] = $id_agent_module; - $result_tag = db_process_sql_insert('ttag_policy_module', $values, false); + $result_tag = db_process_sql_insert('ttag_policy_module', + $values, false); if ($result_tag === false) $errn++; } @@ -556,12 +557,20 @@ function tags_update_policy_module_tag ($id_policy_module, $tags, $autocommit = * * @return mixed Array with module tags or false if something goes wrong. */ -function tags_get_module_tags ($id_agent_module) { - if (empty($id_agent_module)) +function tags_get_module_tags ($id, $policy = false) { + if (empty($id)) return false; - $tags = db_get_all_rows_filter('ttag_module', - array('id_agente_modulo' => $id_agent_module), false); + html_debug_print(func_get_args()); + + if ($policy) { + $tags = db_get_all_rows_filter('ttag_policy_module', + array('id_policy_module' => $id), false); + } + else { + $tags = db_get_all_rows_filter('ttag_module', + array('id_agente_modulo' => $id), false); + } if ($tags === false) return array(); From 8baceb483ac8724f3830f35f4e6f60d64896f851 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 13 Jan 2015 12:40:46 +0100 Subject: [PATCH 15/41] Fixed typo bug in the function 'visual_map_get_layout_status' --- pandora_console/include/functions_visual_map.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 3ddcd6eb18..ce9845a0d5 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1931,7 +1931,7 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) { foreach ($result as $data) { switch ($data['type']) { case GROUP_ITEM: - if (($data["id_layout_linked"] == 0) { + if ($data["id_layout_linked"] == 0) { $group_status = groups_get_status($data['id_group']); switch ($group_status) { case AGENT_STATUS_ALERT_FIRED: From 9f12469edf938bc99ed40e32b400b02c7537acd5 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 13 Jan 2015 12:50:13 +0100 Subject: [PATCH 16/41] Fixed the item group in visual consoles that links other visualmap. TICKET: #1647 --- .../include/functions_visual_map.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index ce9845a0d5..79f578268f 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -335,10 +335,10 @@ function visual_map_print_item($mode = "read", $layoutData, } else if ($is_a_link_to_other_visualconsole) { if (empty($layout_data['id_metaconsole'])) { - $url_vc = $config['homeurl'] . "index.php?sec=reporting&sec2=operation/visual_console/render_view&pure=" . $config["pure"] . "&id=" . $layout_data["id_layout_linked"]; + $url = $config['homeurl'] . "index.php?sec=reporting&sec2=operation/visual_console/render_view&pure=" . $config["pure"] . "&id=" . $layoutData["id_layout_linked"]; } else { - $url_vc = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layout_data["id_layout_linked"] . "&refr=0"; + $url = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layoutData["id_layout_linked"] . "&refr=0"; } } else { @@ -371,9 +371,24 @@ function visual_map_print_item($mode = "read", $layoutData, break; case GROUP_ITEM: - $url = $config['homeurl'] . - 'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . - $layoutData['id_group']; + $is_a_link_to_other_visualconsole = false; + if ($layoutData['id_layout_linked'] != 0) { + $is_a_link_to_other_visualconsole = true; + } + + if ($is_a_link_to_other_visualconsole) { + if (empty($layout_data['id_metaconsole'])) { + $url = $config['homeurl'] . "index.php?sec=reporting&sec2=operation/visual_console/render_view&pure=" . $config["pure"] . "&id=" . $layoutData["id_layout_linked"]; + } + else { + $url = "index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=1&id_visualmap=" . $layoutData["id_layout_linked"] . "&refr=0"; + } + } + else { + $url = $config['homeurl'] . + 'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . + $layoutData['id_group']; + } break; case LABEL: if ($layoutData['id_layout_linked'] != 0) { From 3a7ffddfbecc1a604604928f5af9e897a68bc0cd Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 13 Jan 2015 15:46:46 +0100 Subject: [PATCH 17/41] Forgot to add the updated .conf to the previous commit. --- pandora_server/conf/pandora_server.conf.new | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 8bc4010ac4..7aacaa11d6 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -78,8 +78,9 @@ dbhost 127.0.0.1 verbosity 3 -# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup) - +# Master Server priority. The running server with the highest master value will +# be the master. Ties are broken at random. If set to 0, this server will +# never become master. master 1 # Activate Pandora SNMP console (depending on snmptrapd) From 696fc0ef41f179c55176795f108af2d0346d277e Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 14 Jan 2015 00:01:09 +0100 Subject: [PATCH 18/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 9f8ce8e040..195812cd85 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150113 +Version: 6.0dev-150114 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 5c49f2d4c8..f4cdcb7e5d 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="6.0dev-150113" +pandora_version="6.0dev-150114" 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/pandora_agent b/pandora_agents/unix/pandora_agent index fc622e294a..3874ae6ade 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150113'; +use constant AGENT_BUILD => '150114'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 51666f6598..8f1ca8caae 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150113 +%define release 150114 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 5c14d225bc..6b1ead76dd 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150113 +%define release 150114 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 173d69dcd3..e791f5f09d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150113} +{150114} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 3ae4c2e6c1..c0f4ebcffd 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 ("6.0dev(Build 150113)") +#define PANDORA_VERSION ("6.0dev(Build 150114)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index dd0c322f31..7fb9d6610c 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", "(6.0dev(Build 150113))" + VALUE "ProductVersion", "(6.0dev(Build 150114))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index f74d5f7981..9ea04c720f 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150113 +Version: 6.0dev-150114 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 a0ae325323..56b2077d7f 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="6.0dev-150113" +pandora_version="6.0dev-150114" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index bdd04f0b83..4612a47eab 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150113'; +$build_version = 'PC150114'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index b1a71280bc..6ccb132556 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Wed, 14 Jan 2015 12:11:33 +0100 Subject: [PATCH 19/41] Changed text 'Module macros' to 'Custom macros' --- pandora_console/godmode/agentes/module_manager_editor.php | 2 +- .../godmode/agentes/module_manager_editor_common.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 015a22ac70..021afe527e 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -462,7 +462,7 @@ html_print_table ($table_simple); ui_toggle(html_print_table ($table_advanced, true), __('Advanced options')); ui_toggle(html_print_table ($table_macros, true), - __('Module macros') . ui_print_help_icon ('module_macros', true)); + __('Custom macros') . ui_print_help_icon ('module_macros', true)); ui_toggle(html_print_table ($table_new_relations, true) . html_print_table ($table_relations, true), __('Module relations')); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 412e194349..f68d410fe8 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -574,7 +574,7 @@ if (isset($module_macros)) { } } } -$table_macros->data[$macro_count][0] = ''.__('Add module macro').' '.html_print_image('images/add.png',true).''; +$table_macros->data[$macro_count][0] = ''.__('Custom macros').' '.html_print_image('images/add.png',true).''; $table_macros->colspan[$macro_count][0] = 5; $macro_count++; From af6bf6833ec11d37193d4d312bab642ee15cf7dd Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Wed, 14 Jan 2015 15:43:23 +0100 Subject: [PATCH 20/41] has been added to select other ips agent and improved form. --- pandora_console/extensions/net_tools.php | 54 ++++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index 4c5f77a2f7..4da4d88fad 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -83,37 +83,75 @@ function whereis_the_command ($command) { function main_net_tools () { $id_agente = get_parameter ("id_agente"); - $ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); - if ($ip == "") { + $principal_ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); + + $list_address = db_get_all_rows_sql ("select id_a from taddress_agent where id_agent = " . $id_agente); + foreach ($list_address as $address){ + $ids []= join(",",$address); + } + $ids_address = implode(",",$ids); + $ips = db_get_all_rows_sql ("select ip from taddress where id_a in (" . $ids_address . ")"); + + if ($ips == "") { echo "
" . __('The agent hasn\'t got IP') . "
"; return; } + echo " + "; + echo "
"; echo ""; - echo ""; + echo "
"; echo ""; echo ""; + echo ""; echo "
"; echo __("Operation"); ui_print_help_tip(__('You can set the command path in the menu Administration -> Extensions -> Config Network Tools')); - echo ""; - echo ""; + echo ""; + echo ""; - echo __("SNMP Community"); - echo ""; + echo __("IP address"); + echo ""; + echo ""; + echo ""; + echo __("SNMP Community") . " "; echo ""; - echo ""; + echo ""; echo ""; + echo "
"; echo ""; $operation = get_parameter ("operation", 0); $community = get_parameter ("community", "public"); + $ip = get_parameter("select_ips"); switch($operation) { case 1: From 76f9bae8374202ff848c35d1b0bf28b9a16a5948 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Wed, 14 Jan 2015 16:44:59 +0100 Subject: [PATCH 21/41] changed visual form --- pandora_console/extensions/vnc_view.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora_console/extensions/vnc_view.php b/pandora_console/extensions/vnc_view.php index 130d422344..36c027583e 100644 --- a/pandora_console/extensions/vnc_view.php +++ b/pandora_console/extensions/vnc_view.php @@ -20,10 +20,14 @@ function vnc_view() { $display = get_parameter("display", 0); echo "
"; - echo __("VNC Display (:0 by default)"); + echo ""; + echo ""; + echo "
"; + echo __("VNC Display (:0 by default)") . " "; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo "
"; $port = 5800 + $display; echo ""; From 825eef49ed8b616be45921b897b02b019d64b4fb Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 15 Jan 2015 00:01:10 +0100 Subject: [PATCH 22/41] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 195812cd85..f6446a4c0c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 6.0dev-150114 +Version: 6.0dev-150115 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 f4cdcb7e5d..9b6b21cf88 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="6.0dev-150114" +pandora_version="6.0dev-150115" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 3874ae6ade..55d54dfe89 100644 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '6.0dev'; -use constant AGENT_BUILD => '150114'; +use constant AGENT_BUILD => '150115'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 8f1ca8caae..0717325b2a 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150114 +%define release 150115 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 6b1ead76dd..067781eded 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 6.0dev -%define release 150114 +%define release 150115 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index e791f5f09d..330c9654ec 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{150114} +{150115} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index c0f4ebcffd..05fde126e2 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 ("6.0dev(Build 150114)") +#define PANDORA_VERSION ("6.0dev(Build 150115)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7fb9d6610c..cb7dbafb3a 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", "(6.0dev(Build 150114))" + VALUE "ProductVersion", "(6.0dev(Build 150115))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 9ea04c720f..1d08cb5514 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 6.0dev-150114 +Version: 6.0dev-150115 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 56b2077d7f..48d1bf7a4d 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="6.0dev-150114" +pandora_version="6.0dev-150115" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 4612a47eab..fceeae4118 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC150114'; +$build_version = 'PC150115'; $pandora_version = 'v6.0dev'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 6ccb132556..0b3ae7925b 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -63,7 +63,7 @@
Date: Thu, 15 Jan 2015 10:34:55 +0100 Subject: [PATCH 23/41] Fixed permissions error when validating alerts. --- pandora_console/operation/agentes/alerts_status.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index b4e02e65b8..a8a7472680 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -68,7 +68,7 @@ $url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr . '&filter=' . $filter . '&filter_standby=' . $filter_standby . '&ag_group=' . $id_group .'&tag_filter=' .$tag_filter; -if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) { +if (($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) || ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "LM"))) { forceExecution($id_group); } @@ -130,11 +130,11 @@ else { } if ($alert_validate) { - if (check_acl ($config["id_user"], $id_group, "AW") == 0) { - ui_print_error_message(__('Insufficient permissions to validate alerts')); + if (check_acl ($config["id_user"], $id_group, "AW") || check_acl ($config["id_user"], $id_group, "LM") ) { + validateAlert(); } else { - validateAlert(); + ui_print_error_message(__('Insufficient permissions to validate alerts')); } } @@ -554,7 +554,7 @@ if (!empty ($table->data)) { html_print_table ($table); if (!defined('METACONSOLE')) { - if (check_acl ($config["id_user"], $id_group, "AW")) { + if (check_acl ($config["id_user"], $id_group, "AW") || check_acl ($config["id_user"], $id_group, "LM") ) { if (count($alerts['alerts_simple']) > 0) { echo '
'; html_print_submit_button (__('Validate'), 'alert_validate', false, 'class="sub ok"', false); From f88359f90abace83dabcc5ebc44149ad79e7a7ef Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 15 Jan 2015 15:11:26 +0100 Subject: [PATCH 24/41] Revert "Strict ACLs" This reverts commit 3d251fd035d765db648b52cebf821fa89e20a908. --- .../pandoradb_migrate_5.1_to_6.0.mysql.sql | 4 - .../pandoradb_migrate_5.1_to_6.0.oracle.sql | 5 - ...andoradb_migrate_5.1_to_6.0.postgreSQL.sql | 5 - .../godmode/users/configure_user.php | 31 - .../include/ajax/template_wizard.ajax.php | 65 -- pandora_console/include/functions_agents.php | 25 +- pandora_console/include/functions_alerts.php | 40 +- pandora_console/include/functions_groups.php | 889 ++++-------------- pandora_console/include/functions_html.php | 44 +- pandora_console/include/functions_tags.php | 551 +---------- pandora_console/include/functions_users.php | 13 +- .../agentes/alerts_status.functions.php | 21 +- .../operation/agentes/alerts_status.php | 126 ++- .../operation/agentes/status_monitor.php | 162 ++-- pandora_console/pandoradb.oracle.sql | 1 - pandora_console/pandoradb.postgreSQL.sql | 3 +- pandora_console/pandoradb.sql | 1 - 17 files changed, 441 insertions(+), 1545 deletions(-) delete mode 100644 pandora_console/include/ajax/template_wizard.ajax.php diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql index 23ba9562fa..05977d3052 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql @@ -49,7 +49,3 @@ CREATE TABLE IF NOT EXISTS `tuser_double_auth` ( -- ---------------------------------------------------------------------- INSERT INTO `ttipo_modulo` VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); --- --------------------------------------------------------------------- --- Table `tusuario` --- --------------------------------------------------------------------- -ALTER TABLE `tusuario` ADD COLUMN `strict_acl` tinyint(1) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql index 0f2d7a21f8..dcf223f6cc 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql @@ -36,8 +36,3 @@ CREATE OR REPLACE TRIGGER tuser_double_auth_inc BEFORE INSERT ON tuser_double_au -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); - --- --------------------------------------------------------------------- --- Table `tusuario` --- --------------------------------------------------------------------- -ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5,0) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql index f6fd488be9..a0b2640837 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql @@ -34,8 +34,3 @@ CREATE TABLE "tuser_double_auth" ( -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- INSERT INTO "ttipo_modulo" VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); - --- --------------------------------------------------------------------- --- Table `tusuario` --- --------------------------------------------------------------------- -ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT NOT NULL default 0; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 9558f40003..66fa34af2a 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -123,7 +123,6 @@ if ($new_user && $config['admin_can_add_user']) { $user_info['is_admin'] = 0; $user_info['language'] = 'default'; $user_info["not_login"] = false; - $user_info["strict_acl"] = false; if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { $user_info['id_skin'] = ''; } @@ -173,7 +172,6 @@ if ($create_user) { } } $values["not_login"] = (bool)get_parameter ('not_login', false); - $values["strict_acl"] = (bool)get_parameter ('strict_acl', false); if ($id == '') { ui_print_error_message (__('User ID cannot be empty')); @@ -237,11 +235,6 @@ if ($create_user) { $password_confirm = ''; if($result) { - if ($values["strict_acl"]) { - if ($values['is_admin']) { - ui_print_info_message (__('Strict ACL is not recommended for admin users because performance could be affected.')); - } - } $user_info = get_user_info ($id); $new_user = false; } @@ -276,7 +269,6 @@ if ($update_user) { $values['metaconsole_access_node'] = get_parameter ('metaconsole_access_node', '0'); } $values["not_login"] = (bool)get_parameter ('not_login', false); - $values["strict_acl"] = (bool)get_parameter ('strict_acl', false); $res1 = update_user ($id, $values); @@ -344,25 +336,6 @@ if ($update_user) { __('Error updating user info (no change?)')); } - if ($values['strict_acl']) { - $count_groups = 0; - $count_tags = 0; - - $profiles = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); - if ($profiles === false) { - $profiles = array (); - } - foreach ($profiles as $profile) { - $count_groups = $count_groups+1; - $arr_tags = explode(',', $profile['tags']); - $count_tags = $count_tags + count($arr_tags); - } - - if (($count_groups > 3) && ($count_tags > 10)) { - ui_print_info_message(__('Strict ACL is not recommended for this user. Performance could be affected.')); - } - } - $user_info = $values; } @@ -523,10 +496,6 @@ $table->data[13][0] = __('Not Login'); $table->data[13][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); $table->data[13][1] = html_print_checkbox('not_login', 1, $user_info["not_login"], true); -$table->data[14][0] = __('Strict ACL'); -$table->data[14][0] .= ui_print_help_tip(__('With this option enabled, the user will can access to accurate information. It is not recommended for admin users because performance could be affected'), true); -$table->data[14][1] = html_print_checkbox('strict_acl', 1, $user_info["strict_acl"], true); - if($meta) { enterprise_include('include/functions_metaconsole.php'); $data = array(); diff --git a/pandora_console/include/ajax/template_wizard.ajax.php b/pandora_console/include/ajax/template_wizard.ajax.php deleted file mode 100644 index 46e4da34f0..0000000000 --- a/pandora_console/include/ajax/template_wizard.ajax.php +++ /dev/null @@ -1,65 +0,0 @@ - $v) { - $agents_aux[$keys_prefix . $k] = $v; - //unset($agents[$k]); - } - } - $agents = $agents_aux; - } - - echo json_encode ($agents); - return; -} -?> diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 72d37f44a2..c7e5fcc551 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -114,7 +114,8 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values * @return array All simple alerts defined for an agent. Empty array if no * alerts found. */ -function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, $idGroup = false, $count = false, $strict_user = false, $tag = false) { +function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', + $allModules = false, $orderby = false, $idGroup = false, $count = false) { global $config; if (is_array($filter)) { @@ -148,10 +149,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f $filter .= ''; break; } - - if ($tag) { - $filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))'; - } + if (is_array ($options)) { $filter .= db_format_array_where_clause_sql ($options); } @@ -159,7 +157,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f if (($id_agent !== false) && ($idGroup !== false)) { $groups = users_get_groups($config["id_user"]); - //$where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); + $where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); if ($idGroup != 0) { //All group $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo @@ -170,15 +168,12 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f FROM tagente_modulo WHERE delete_pending = 0'; } - if ($strict_user) { - $where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); - // If there are any errors add imposible condition - if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { - $subQuery .= ' AND 1 = 0'; - } - else { - $subQuery .= $where_tags; - } + // If there are any errors add imposible condition + if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { + $subQuery .= ' AND 1 = 0'; + } + else { + $subQuery .= $where_tags; } } else if ($id_agent === false) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 44feff82a0..97b4dc0145 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1521,8 +1521,8 @@ function get_alert_fires_in_period ($id_alert_module, $period, $date = 0) { */ function get_group_alerts($id_group, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, - $idGroup = false, $count = false, $strict_user = false, $tag = false) { - + $idGroup = false, $count = false) { + global $config; $group_query = ''; @@ -1561,20 +1561,18 @@ function get_group_alerts($id_group, $filter = '', $options = false, $filter .= ''; break; } - - if ($tag) { - $filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))'; - } + if (is_array ($options)) { $filter .= db_format_array_where_clause_sql ($options); } if ($id_group !== false) { - $groups = users_get_groups($config["id_user"], "AR"); - - //$where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); - + $groups = users_get_groups($config["id_user"]); + + $where_tags = tags_get_acl_tags($config['id_user'], + array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); + if ($id_group != 0) { if (is_array($id_group)) { if (in_array(0, $id_group)) { @@ -1611,23 +1609,13 @@ function get_group_alerts($id_group, $filter = '', $options = false, $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0'; } - - if ($strict_user) { - $groups = users_get_groups($config["id_user"]); - - if ($idGroup !== 0) { - $where_tags = tags_get_acl_tags($config['id_user'], $idGroup, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); - } else { - $where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); - } - // If there are any errors add imposible condition - if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { - $subQuery .= ' AND 1 = 0'; - } - else { - $subQuery .= $where_tags; - } + // If there are any errors add imposible condition + if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { + $subQuery .= ' AND 1 = 0'; + } + else { + $subQuery .= $where_tags; } } else { diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index e5ee57fc7c..c07aae0ae0 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1125,7 +1125,7 @@ function groups_create_group($group_name, $rest_values){ // Get agents NOT INIT -function groups_agent_not_init ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_not_init ($group_array) { // If there are not groups to query, we jump to nextone @@ -1140,28 +1140,14 @@ function groups_agent_not_init ($group_array, $strict_user = false, $id_group_st $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count = 0 - AND warning_count = 0 - AND unknown_count = 0 - AND (notinit_count > 0 OR total_count = 0) - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) - FROM tagente - WHERE disabled = 0 - AND critical_count = 0 - AND warning_count = 0 - AND unknown_count = 0 - AND (notinit_count > 0 OR total_count = 0) - AND id_grupo IN $group_clause"); - } + $count = db_get_sql ("SELECT COUNT(*) + FROM tagente + WHERE disabled = 0 + AND critical_count = 0 + AND warning_count = 0 + AND unknown_count = 0 + AND (notinit_count > 0 OR total_count = 0) + AND id_grupo IN $group_clause"); return $count > 0 ? $count : 0; } @@ -1169,7 +1155,7 @@ function groups_agent_not_init ($group_array, $strict_user = false, $id_group_st // Get unknown agents by using the status code in modules. -function groups_agent_unknown ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_unknown ($group_array) { if (empty ($group_array)) { return 0; @@ -1181,24 +1167,12 @@ function groups_agent_unknown ($group_array, $strict_user = false, $id_group_str $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count=0 - AND warning_count=0 AND unknown_count>0 - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); - } + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); return $count > 0 ? $count : 0; } -function groups_agent_total($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_total($group_array) { if (empty ($group_array)) { return 0; @@ -1210,30 +1184,19 @@ function groups_agent_total($group_array, $strict_user = false, $id_group_strict $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente - WHERE tagente.disabled = 0 - AND id_grupo = ".$id_group_strict . - $tags_clause; - - $count = db_get_sql($sql); - - } else { - $count = db_get_sql ("SELECT COUNT(*) + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled = 0 - AND id_grupo IN $group_clause"); - } + AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; } // Get ok agents by using the status code in modules. -function groups_agent_ok ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_ok ($group_array) { if (empty ($group_array)) { return 0; @@ -1246,30 +1209,179 @@ function groups_agent_ok ($group_array, $strict_user = false, $id_group_strict = $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count=0 - AND warning_count=0 AND normal_count = total_count - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) - FROM tagente - WHERE tagente.disabled = 0 - AND normal_count = total_count - AND id_grupo IN $group_clause"); - } - + $count = db_get_sql ("SELECT COUNT(*) + FROM tagente + WHERE tagente.disabled = 0 + AND normal_count = total_count + AND id_grupo IN $group_clause"); + + + return $count > 0 ? $count : 0; } // Get critical agents by using the status code in modules. -function groups_agent_critical ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_agent_critical ($group_array) { + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get warning agents by using the status code in modules. + +function groups_agent_warning ($group_array) { + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + + +// Get monitor NOT INIT, except disabled AND async modules + +function groups_monitor_not_init ($group_array) { + + // If there are not groups to query, we jump to nextone + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get monitor OK, except disabled and non-init + +function groups_monitor_ok ($group_array) { + + // If there are not groups to query, we jump to nextone + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get monitor CRITICAL, except disabled and non-init + +function groups_monitor_critical ($group_array) { + + // If there are not groups to query, we jump to nextone + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get monitor WARNING, except disabled and non-init + +function groups_monitor_warning ($group_array) { + + // If there are not groups to query, we jump to nextone + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get monitor UNKNOWN, except disabled and non-init + +function groups_monitor_unknown ($group_array) { + + // If there are not groups to query, we jump to nextone + + if (empty ($group_array)) { + return 0; + + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + + $group_clause = implode (",", $group_array); + $group_clause = "(" . $group_clause . ")"; + + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + return $count > 0 ? $count : 0; +} + +// Get alerts defined for a given group, except disabled + +function groups_monitor_alerts ($group_array) { + + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { return 0; @@ -1284,281 +1396,18 @@ function groups_agent_critical ($group_array, $strict_user = false, $id_group_st //TODO REVIEW ORACLE AND POSTGRES - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count>0 - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get warning agents by using the status code in modules. - -function groups_agent_warning ($group_array, $strict_user = false, $id_group_strict = false) { - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo - WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; - $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 - AND id_grupo=$id_group_strict - AND critical_count=0 - AND warning_count>0 - $tags_clause"; - - $count = db_get_sql ($sql); - } else { - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - - -// Get monitor NOT INIT, except disabled AND async modules - -function groups_monitor_not_init ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 5 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get monitor OK, except disabled and non-init - -function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - - if ($strict_user) { - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 0 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get monitor CRITICAL, except disabled and non-init - -function groups_monitor_critical ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 1 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get monitor WARNING, except disabled and non-init - -function groups_monitor_warning ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 2 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get monitor UNKNOWN, except disabled and non-init - -function groups_monitor_unknown ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 3 - AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente - WHERE disabled = 0 - AND tagente.id_grupo = $id_group_strict - ) ". $tags_clause); - } else { - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); - } - - return $count > 0 ? $count : 0; -} - -// Get alerts defined for a given group, except disabled - -function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_strict = false) { - - // If there are not groups to query, we jump to nextone - - if (empty ($group_array)) { - return 0; - - } - else if (!is_array ($group_array)) { - $group_array = array($group_array); - } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - $sql = "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - $tags_clause"; - $count = db_get_sql ($sql); - return $count; - - } else { - - //TODO REVIEW ORACLE AND POSTGRES - return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); - } + return db_get_sql ("SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); } // Get alert configured currently FIRED, except disabled -function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_group_strict = false) { +function groups_monitor_fired_alerts ($group_array) { // If there are not groups to query, we jump to nextone @@ -1573,33 +1422,16 @@ function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_gr $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - if ($strict_user) { - - $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; - - $sql = "SELECT COUNT(talert_template_modules.id) + //TODO REVIEW ORACLE AND POSTGRES + + return db_get_sql ("SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente + WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0 ".$tags_clause; - - $count = db_get_sql ($sql); - return $count; - } else { - //TODO REVIEW ORACLE AND POSTGRES - return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0"); - } - + AND times_fired > 0"); } /** @@ -1798,6 +1630,8 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + + function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { global $config; @@ -1812,10 +1646,12 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); if ($propagate == 1) { + //$childrens_ids_parent = array($parent); $hierarchy[] = $parent; $childrens = groups_get_childrens($parent); if (!empty($childrens)) { foreach ($childrens as $child) { + //$childrens_ids_parent[] = (int)$child['id_grupo']; $hierarchy[] = (int)$child['id_grupo']; } } @@ -1826,325 +1662,4 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { } return $hierarchy; } - -function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group') { - global $config; - - if ($id_user == false) { - $id_user = $config['id_user']; - } - - $user_groups = array(); - $user_tags = array(); - foreach ($acltags as $group => $tags) { - if ($user_strict) { //Remove groups with tags - if ($tags == '') { - $groups_without_tags[$group] = $group; - } - } - $user_groups[$group] = groups_get_name($group); - if ($tags != '') { - $tags_group = explode(',', $tags); - - foreach ($tags_group as $tag) { - $user_tags[$tag] = tags_get_name($tag); - } - } - } - - if ($user_strict) { - $user_groups_ids = implode(',',array_keys($groups_without_tags)); - } else { - $user_groups_ids = implode(',',array_keys($acltags)); - } - - if ($user_groups_ids == '') { - $user_groups_ids == -1; - } - - switch ($config["dbtype"]) { - case "mysql": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - ORDER BY nombre COLLATE utf8_general_ci ASC"); - - break; - case "postgresql": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - ORDER BY nombre ASC"); - break; - case "oracle": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - ORDER BY nombre COLLATE utf8_general_ci ASC"); - break; - } - - if ($list_groups == false) { - $list_groups = array(); - } - - if ($returnAllGroup) { - $i = 1; - $list[0]['_id_'] = 0; - $list[0]['_name_'] = __('All'); - } else { - $i = 0; - } - foreach ($list_groups as $key => $item) { - $id = $item['id_grupo']; - - if (($config["realtimestats"] == 0) && !$user_strict) { - $group_stat = db_get_all_rows_sql ("SELECT * - FROM tgroup_stat, tgrupo - WHERE tgrupo.id_grupo = tgroup_stat.id_group - AND tgroup_stat.id_group = $id - ORDER BY nombre"); - - $list[$i]['_id_'] = $id; - $list[$i]['_name_'] = $item['nombre']; - $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;')); - - $list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"]; - $list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; - $list[$i]['_total_agents_'] = $group_stat[0]["agents"]; - - if ($mode == 'tactical') { - $list[$i]['_agents_ok_'] = $group_stat[0]["normal"]; - $list[$i]['_agents_warning_'] = $group_stat[0]["warning"]; - $list[$i]['_agents_critical_'] = $group_stat[0]["critical"]; - $list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"]; - } - - // This fields are not in database - $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); - $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); - $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); - $list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id); - $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); - $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); - - if ($returnAllGroup) { - $list[0]['_agents_unknown_'] += $group_stat[0]["unknown"]; - $list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"]; - $list[0]['_total_agents_'] += $group_stat[0]["agents"]; - $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; - $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; - $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; - $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; - $list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_']; - $list[0]['_agents_not_init'] += $list[$i]['_agents_not_init']; - - if ($mode == 'tactical') { - $list[0]['_agents_ok_'] += $group_stat[0]["normal"]; - $list[0]['_agents_warning_'] += $group_stat[0]["warning"]; - $list[0]['_agents_critical_'] += $group_stat[0]["critical"]; - $list[0]['_monitors_alerts_'] += $group_stat[0]["alerts"]; - } - } - - if ($mode == 'group') { - if (! defined ('METACONSOLE')) { - if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) { - unset($list[$i]); - } - } else { - if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) { - unset($list[$i]); - } - } - } - - } else { - $list[$i]['_id_'] = $id; - $list[$i]['_name_'] = $item['nombre']; - $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;')); - - $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); - $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); - $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); - $list[$i]['_agents_unknown_'] = groups_agent_unknown ($id, $user_strict, $id); - $list[$i]['_monitors_alerts_fired_'] = groups_monitor_fired_alerts ($id, $user_strict, $id); - $list[$i]['_total_agents_'] = groups_agent_total ($id, $user_strict, $id); - $list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id); - $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); - $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); - - if ($mode == 'tactical') { - $list[$i]['_agents_ok_'] = groups_agent_ok ($id, $user_strict, $id); - $list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id); - $list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id); - $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id); - } - - if ($returnAllGroup) { - $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; - $list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_']; - $list[0]['_total_agents_'] += $list[$i]['_total_agents_']; - $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; - $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; - $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; - $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; - $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; - $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init']; - - if ($mode == 'tactical') { - $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; - $list[0]['_agents_warning_'] += $list[$i]['_agents_warning_']; - $list[0]['_agents_critical_'] += $list[$i]['_agents_critical_']; - $list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_']; - } - } - - if ($mode == 'group') { - if (! defined ('METACONSOLE')) { - if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) { - unset($list[$i]); - } - } else { - if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) { - unset($list[$i]); - } - } - } - } - $i++; - } - - if ($user_strict) { - foreach ($user_tags as $group_id => $tag_name) { - $id = db_get_value('id_tag', 'ttag', 'name', $tag_name); - - $list[$i]['_id_'] = $id; - $list[$i]['_name_'] = $tag_name; - $list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;')); - $list[$i]['_is_tag_'] = 1; - - $list[$i]['_total_agents_'] = tags_total_agents ($id, $acltags); - $list[$i]['_agents_unknown_'] = tags_get_unknown_agents ($id, $acltags); - $list[$i]['_monitors_ok_'] = tags_monitors_ok ($id, $acltags); - $list[$i]['_monitors_critical_'] = tags_monitors_critical ($id, $acltags); - $list[$i]['_monitors_warning_'] = tags_monitors_warning ($id, $acltags); - $list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags); - - if ($mode == 'tactical') { - $list[$i]['_agents_ok_'] = tags_agent_ok ($id, $acltags); - $list[$i]['_agents_warning_'] = tags_agent_warning ($id, $acltags); - $list[$i]['_agents_critical_'] = tags_get_critical_agents ($id, $acltags); - $list[$i]['_monitors_alerts_'] = tags_get_monitors_alerts ($id, $acltags); - } - - - if ($returnAllGroup) { - $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; - $list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_']; - $list[0]['_total_agents_'] += $list[$i]['_total_agents_']; - $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; - $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; - $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; - $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; - $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; - - if ($mode == 'tactical') { - $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; - $list[0]['_agents_warning_'] += $list[$i]['_agents_warning_']; - $list[0]['_agents_critical_'] += $list[$i]['_agents_critical_']; - $list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_']; - } - } - - if ($mode == 'group') { - if (! defined ('METACONSOLE')) { - if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) { - unset($list[$i]); - } - } else { - if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) { - unset($list[$i]); - } - } - } - $i++; - } - } - - return $list; -} - -function group_get_groups_list($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false, $mode = 'group') { - global $config; - - if ($id_user == false) { - $id_user = $config['id_user']; - } - - $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); - - if (! defined ('METACONSOLE')) { - $result_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode); - return $result_list; - } else { - $servers = db_get_all_rows_sql (" - SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0"); - - if ($servers === false) { - $servers = array(); - } - - $result_list = array (); - foreach ($servers as $server) { - if (metaconsole_connect($server) != NOERR) { - continue; - } - $server_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode); - - foreach ($server_list as $server_item) { - if (! isset ($result_list[$server_item['_name_']])) { - $result_list[$server_item['_name_']] = $server_item; - } - else { - $result_list[$server_item['_name_']]['_monitors_ok_'] += $server_item['_monitors_ok_']; - $result_list[$server_item['_name_']]['_monitors_critical_'] += $server_item['_monitors_critical_']; - $result_list[$server_item['_name_']]['_monitors_warning_'] += $server_item['_monitors_warning_']; - $result_list[$server_item['_name_']]['_agents_unknown_'] += $server_item['_agents_unknown_']; - $result_list[$server_item['_name_']]['_total_agents_'] += $server_item['_total_agents_']; - $result_list[$server_item['_name_']]['_monitors_alerts_fired_'] += $server_item['_monitors_alerts_fired_']; - - if ($mode == 'tactical') { - $result_list[$server_item['_name_']]['_agents_ok_'] += $server_item['_agents_ok_']; - $result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_']; - $result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_']; - $result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_']; - } - } - } - metaconsole_restore_db(); - - } - - return $result_list; - } -} - -function groups_get_group_deep ($id_group) { - global $config; - $parents = groups_get_parents($id_group, false); - - if (empty($parents)) { - $deep = ""; - } else { - $deep = str_repeat("    ", count($parents)); - } - - return $deep; -} ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 357a1f54c6..4360409e56 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -368,36 +368,13 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false, - $keys_field = 'id_grupo', $strict_user = false) { + $keys_field = 'id_grupo') { global $config; $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group, $keys_field); - - if ($strict_user) { - foreach ($fields as $id => $group_name) { - $sql = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id"; - $group_has_tag = db_get_value_sql ($sql); - if (!$group_has_tag) { - - $sql_parent = "SELECT parent FROM tgrupo WHERE id_grupo = $id AND propagate = 1"; - $id_parent = db_get_value_sql($sql_parent); - - if ($id_parent) { - $sql_parent_aux = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id_parent"; - $parent_has_tag = db_get_value_sql ($sql_parent_aux); - - if ($parent_has_tag) { - unset($fields[$id]); - } - } - } else { - unset($fields[$id]); - } - } - } - + $output = html_print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, false, $class, $disabled, $style, $option_style); @@ -1489,13 +1466,22 @@ function html_print_table (&$table, $return = false) { if (!isset ($style[$key])) { $style[$key] = ''; } - - $output .= '
'. $item .'' . + $item . '
'."\n"; + $output .= '' . "\n"; if ($return) return $output; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index cb34668f7f..039229cab7 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -62,40 +62,18 @@ function tags_agent_unknown ($id_tag) { * * @return mixed Returns count of agents with this tag or false if they aren't. */ -function tags_total_agents ($id_tag, $groups_and_tags = array()) { +function tags_total_agents ($id_tag) { // Avoid mysql error if (empty($id_tag)) return; - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . - $groups_clause; - + AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo + AND ttag_module.id_tag = " . $id_tag; + return db_get_sql ($total_agents); } @@ -106,37 +84,15 @@ function tags_total_agents ($id_tag, $groups_and_tags = array()) { * * @return mixed Returns count of agents in normal status or false if they aren't. */ -function tags_agent_ok ($id_tag, $groups_and_tags = array()) { +function tags_agent_ok ($id_tag) { - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente.disabled=0 AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = $id_tag - AND normal_count=total_count - $groups_clause"); + AND normal_count=total_count"); } /** @@ -146,7 +102,7 @@ function tags_agent_ok ($id_tag, $groups_and_tags = array()) { * * @return mixed Returns count of agents in warning status or false if they aren't. */ -function tags_agent_warning ($id_tag, $groups_and_tags = array()) { +function tags_agent_warning ($id_tag) { return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module @@ -241,13 +197,13 @@ function tags_create_tag($values) { if (empty($values)) { return false; } - - //No create tag if the tag exists + + //No create tag if the tag exists if (tags_get_id($values["name"])) { return false; } - return db_process_sql_insert('ttag',$values); + return db_process_sql_insert('ttag', $values); } /** @@ -710,7 +666,10 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) { * @return mixed/string Tag ids */ -function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '', $meta = false, $childrens_ids = array(), $force_group_and_tag = false) { +function tags_get_acl_tags($id_user, $id_group, $access = 'AR', + $return_mode = 'module_condition', $query_prefix = '', + $query_table = '', $meta = false, $childrens_ids = array(), + $force_group_and_tag = false) { global $config; @@ -730,10 +689,6 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = ' } } - if ($id_group[0] != 0) { - $id_group = groups_get_all_hierarchy_group ($id_group[0]); - } - if ((string)$id_group === "0") { $id_group = array_keys(users_get_groups($id_user, $access, false)); @@ -748,6 +703,10 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = ' $id_group = (array) $id_group; } + if ($id_group[0] != 0) { + $id_group = groups_get_all_hierarchy_group ($id_group[0]); + } + $acl_column = get_acl_column($access); if (empty($acl_column)) { @@ -762,7 +721,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = ' (tusuario_perfil.id_grupo IN (%s) OR tusuario_perfil.id_grupo = 0) ORDER BY id_grupo", $id_user, $acl_column, implode(',',$id_group)); $tags = db_get_all_rows_sql($query); - + // If not profiles returned, the user havent acl permissions if (empty($tags)) { return ERR_ACL; @@ -827,7 +786,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = ' break; case 'module_condition': // Return the condition of the tags for tagente_modulo table - $condition = tags_get_acl_tags_module_condition($acltags, $query_table, true); + $condition = tags_get_acl_tags_module_condition($acltags, $query_table); if (!empty($condition)) { return " $query_prefix " . $condition; } @@ -868,7 +827,11 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) if ($i == 0) - $condition .= ' ( '; + $condition .= ' ( '; + + + + // Group condition (The module belongs to an agent of the group X) // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition @@ -880,22 +843,21 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { //Avoid the user profiles with all group access. $group_condition = " 1 = 1 "; } - + + //When the acl is only group without tags if (empty($group_tags)) { $condition .= "($group_condition)\n"; } else { - if (is_array($group_tags)) { - $group_tags_query = implode(',',$group_tags); - } else { - $group_tags_query = $group_tags; - } // Tags condition (The module has at least one of the restricted tags) - $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query); + $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags)); $condition .= "($group_condition AND \n$tags_condition)\n"; - } + } + + + $i++; } @@ -943,10 +905,6 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group if (empty($group_tags)) { $tags_condition = "id_grupo = ".$group_id; } else { - if (!is_array($group_tags)) { - $group_tags = explode(',', $group_tags); - } - foreach ($group_tags as $tag) { // If the tag ID doesnt exist, ignore if (!isset($all_tags[$tag])) { @@ -1052,14 +1010,14 @@ function tags_has_user_acl_tags($id_user = false) { */ function tags_get_user_tags($id_user = false, $access = 'AR') { global $config; - + if ($id_user === false) { $id_user = $config['id_user']; } // Get all tags to have the name of all of them $all_tags = tags_get_all_tags(); - + // If at least one of the profiles of this access flag hasent // tags restrictions, the user can see all tags $acl_column = get_acl_column($access); @@ -1072,18 +1030,18 @@ function tags_get_user_tags($id_user = false, $access = 'AR') { FROM tusuario_perfil, tperfil WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND tusuario_perfil.id_usuario = '%s' AND - tperfil.%s = 1 AND tags <> ''", + tperfil.%s = 1 AND tags = ''", $id_user, $acl_column); $profiles_without_tags = db_get_value_sql($query); - - if ($profiles_without_tags == 0) { + + if ($profiles_without_tags > 0) { return $all_tags; } - + // Get the tags of the required access flag for each group - $tags = tags_get_acl_tags($id_user, 0, $access, 'data','','', true, array(), true); - + $tags = tags_get_acl_tags($id_user, 0, $access, 'data'); + // Merge the tags to get an array with all of them $user_tags_id = array(); @@ -1104,7 +1062,8 @@ function tags_get_user_tags($id_user = false, $access = 'AR') { } $user_tags[$id] = $all_tags[$id]; } - + + return $user_tags; } @@ -1401,430 +1360,4 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c return false; } - -/** - * Get unknown agents filtering by id_tag. - * - * @param int $id_tag Id of the tag to search unknown agents - * - * @return mixed Returns count of unknown agents with this tag or false if they aren't. - */ -function tags_get_unknown_agents ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . " - AND tagente.critical_count=0 - AND tagente.warning_count=0 - AND tagente.unknown_count>0 - $groups_clause"; - - return db_get_sql ($total_agents); -} - -function tags_monitors_ok ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 0 - AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente - WHERE disabled = 0 - $groups_clause) - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = " . $id_tag .")"; - - $count = db_get_sql ($sql); - - return $count; -} - -function tags_monitors_critical ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 1 - AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente - WHERE disabled = 0 - $groups_clause) - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = " . $id_tag .")"; - - $count = db_get_sql ($sql); - - return $count; -} - -function tags_monitors_warning ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado - WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo - AND tagente_estado.estado = 2 - AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente - WHERE disabled = 0 - $groups_clause) - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag = " . $id_tag .")"; - - $count = db_get_sql ($sql); - - return $count; -} - -function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0 - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) - $groups_clause"; - - $count = db_get_sql ($sql); - - return $count; -} - -/* Return array with groups and their tags */ -function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) { - - global $config; - - if ($id_user == false) { - $id_user = $config['id_user']; - } - - $acl_column = get_acl_column($access); - - $query = sprintf("SELECT tags, id_grupo - FROM tusuario_perfil, tperfil - WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND - tusuario_perfil.id_usuario = '%s' AND - tperfil.%s = 1 - ORDER BY id_grupo", $id_user, $acl_column); - $tags_and_groups = db_get_all_rows_sql($query); - - if ($tags_and_groups == false) { - $tags_and_groups = array(); - } - - $acltags = array(); - - if ((count($tags_and_groups) == 1) && ($tags_and_groups[0]['id_grupo'] == 0) && ($tags_and_groups[0]['tags'] == '')){ //user with all groups without tags - $all_groups = groups_get_all(); - - foreach ($all_groups as $id => $name) { - $acltags[$id] = ''; - } - } else { - foreach ($tags_and_groups as $group_tag) { - $acltags[$group_tag['id_grupo']] = $group_tag['tags']; - $propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group_tag['id_grupo']); - - if ($propagate) { - $sql = "SELECT id_grupo FROM tgrupo WHERE parent = " .$group_tag['id_grupo']; - $children = db_get_all_rows_sql($sql); - - if ($children == false) { - $children = array(); - } - foreach ($children as $group) { - $acltags[$group['id_grupo']] = $group_tag['tags']; - } - } - } - } - - return $acltags; -} - -/** - * Get unknown agents filtering by id_tag. - * - * @param int $id_tag Id of the tag to search unknown agents - * - * @return mixed Returns count of unknown agents with this tag or false if they aren't. - */ -function tags_get_critical_agents ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . " - AND tagente.critical_count>0 - $groups_clause"; - - return db_get_sql ($total_agents); -} - -function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) { - - // Avoid mysql error - if (empty($id_tag)) - return; - - $groups_clause = ""; - if (!empty($groups_and_tags)) { - $i = 0; - foreach ($groups_and_tags as $group_id => $tags) { - if ($tags != "") { - $tags_arr = explode(',', $tags); - foreach ($tags_arr as $tag) { - if ($tag == $id_tag) { - if ($i == 0) { - $groups_id = $group_id; - } else { - $groups_id .= ','.$group_id; - } - $i++; - } - } - } - } - $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; - } - - $sql = "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) - $groups_clause"; - - $count = db_get_sql ($sql); - - return $count; -} - -/** - * Get agents filtering by id_tag. - * - * @param int $id_tag Id of the tag to search total agents - * - * @return mixed Returns count of agents with this tag or false if they aren't. - */ -function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) { - - global $config; - - // Avoid mysql error - if (empty($id_tag)) - return; - - if (empty($id_user)) { - $id_user = $config['id_user']; - } - - if (!is_array ($fields)) { - $fields = array (); - $fields[0] = "id_agente"; - $fields[1] = "nombre"; - } - $select_fields = implode(',',$fields); - - $groups_clause = ""; - if ($strict_user) { - if (!empty($groups_and_tags)) { - $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); - } - } else { - $groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")"; - } - - $search_sql = ""; - $void_agents = ""; - if ($filter) { - if (($filter['search']) != "") { - $string = io_safe_input ($filter['search']); - $search_sql = ' AND (tagente.nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")'; - } - - if (isset($filter['show_void_agents'])) { - if (!$filter['show_void_agents']) { - $void_agents = " AND tagente_modulo.delete_pending = 0"; - } - } - } - - $user_agents_sql = "SELECT ".$select_fields ." - FROM tagente, tagente_modulo, ttag_module - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag . - $groups_clause . $search_sql . $void_agents . - " ORDER BY tagente.nombre ASC"; - - $user_agents = db_get_all_rows_sql($user_agents_sql); - - if (!$meta){ - $user_agents_aux = array(); - if ($user_agents === false) { - $user_agents = array(); - } - foreach ($user_agents as $ua) { - $user_agents_aux[$ua['id_agente']] = $ua['nombre']; - } - return $user_agents_aux; - } - return $user_agents; -} ?> diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 3808debb93..04d992d16f 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -140,13 +140,13 @@ function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGro function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null, $keys_field = 'id_grupo') { if (empty ($id_user)) { global $config; - + $id_user = null; if (isset($config['id_user'])) { $id_user = $config['id_user']; } } - + if (isset($id_groups)) { //Get recursive id groups $list_id_groups = array(); @@ -161,12 +161,11 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup else { $groups = db_get_all_rows_in_table ('tgrupo', 'parent, nombre'); } - + $user_groups = array (); - if (!$groups) { + if (!$groups) return $user_groups; - } if ($returnAllGroup) { //All group if ($returnAllColumns) { @@ -181,7 +180,7 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup // Add the All group to the beginning to be always the first array_unshift($groups, $groupall); } - + foreach ($groups as $group) { if ($privilege === false) { if ($returnAllColumns) { @@ -200,7 +199,7 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup } } } - + return $user_groups; } diff --git a/pandora_console/operation/agentes/alerts_status.functions.php b/pandora_console/operation/agentes/alerts_status.functions.php index fd3dbca8a7..d60cbb1379 100755 --- a/pandora_console/operation/agentes/alerts_status.functions.php +++ b/pandora_console/operation/agentes/alerts_status.functions.php @@ -34,17 +34,13 @@ function validateAlert() { } } -function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $tag_filter = false, $return = false, $strict_user = false) { - - global $config; - require_once ($config['homedir'] . "/include/functions_tags.php"); - +function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $return = false) { $table->width = '100%'; $table->data = array (); $table->style = array (); $table->data[0][0] = __('Group'); - $table->data[0][1] = html_print_select_groups($config['id_user'], "AR", true, "ag_group", $id_group, '', '', '', true, false, false, '', false, '', false, false, 'id_grupo', $strict_user); + $table->data[0][1] = html_print_select_groups(false, "AR", true, "ag_group", $id_group, '', '', '', true); $alert_status_filter = array(); $alert_status_filter['all_enabled'] = __('All (Enabled)'); @@ -60,18 +56,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st $table->data[0][2] = __('Status'); $table->data[0][3] = html_print_select ($alert_status_filter, "filter", $filter, '', '', '', true); - - $table->data[0][4] = __('Tags') . ui_print_help_tip(__('Only it is show tags in use.'), true); - - $tags = tags_get_user_tags(); - - if (empty($tags)) { - $table->data[0][4] .= __('No tags'); - } - else { - $table->data[0][4] .= html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;'); - } - + $table->data[0][4] = ''; $table->data[1][0] = __('Free text for search') . ui_print_help_tip( __("Filter by agent name, module name, template name or action name"), diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index a8a7472680..a66c846c1b 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -38,19 +38,11 @@ require_once ($config['homedir'] . '/include/functions_users.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); -$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); - $filter = get_parameter ("filter", "all_enabled"); $filter_standby = get_parameter ("filter_standby", "all"); $offset_simple = (int) get_parameter_get ("offset_simple", 0); $id_group = (int) get_parameter ("ag_group", 0); //0 is the All group (selects all groups) $free_search = get_parameter("free_search", ''); -$tag_filter = get_parameter("tag_filter", 0); -if ($tag_filter) { - if ($id_group && $strict_user) { - $tag_filter = 0; - } -} $sec2 = get_parameter_get ('sec2'); $sec2 = safe_url_extraclean ($sec2); @@ -66,7 +58,7 @@ $refr = (int)get_parameter('refr', 0); $pure = get_parameter('pure', 0); $url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr . '&filter=' . $filter . '&filter_standby=' . $filter_standby . - '&ag_group=' . $id_group .'&tag_filter=' .$tag_filter; + '&ag_group=' . $id_group; if (($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) || ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "LM"))) { forceExecution($id_group); @@ -333,33 +325,48 @@ else { if (defined('METACONSOLE')) { require_once ($config['homedir'] . '/enterprise/meta/include/functions_alerts_meta.php'); if ($idAgent != 0) { - $alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user); - - $countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user); + $alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, + $filter_alert, $options_simple, $whereAlertSimple, false, false, + $idGroup); + + $countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, + false, $whereAlertSimple, false, false, $idGroup, true); } else { $id_groups = array_keys( users_get_groups($config["id_user"], 'AR', false)); - $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); + $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, + $filter_alert, $options_simple, $whereAlertSimple, false, + false, $idGroup); - $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); + $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, + $filter_alert, false, $whereAlertSimple, false, false, + $idGroup, true); } } else { if ($idAgent != 0) { - $alerts['alerts_simple'] = agents_get_alerts_simple ($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); + $alerts['alerts_simple'] = agents_get_alerts_simple ($idAgent, + $filter_alert, $options_simple, $whereAlertSimple, false, false, + $idGroup); - $countAlertsSimple = agents_get_alerts_simple ($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); + $countAlertsSimple = agents_get_alerts_simple ($idAgent, + $filter_alert, false, $whereAlertSimple, false, false, + $idGroup, true); } else { $id_groups = array_keys( users_get_groups($config["id_user"], 'AR', false)); - $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); + $alerts['alerts_simple'] = get_group_alerts($id_groups, + $filter_alert, $options_simple, $whereAlertSimple, false, + false, $idGroup); - $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); + $countAlertsSimple = get_group_alerts($id_groups, + $filter_alert, false, $whereAlertSimple, false, false, + $idGroup, true); } } @@ -374,7 +381,10 @@ if ($pure) { // Filter form if ($print_agent) { echo '
'; - ui_toggle(printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby, $tag_filter, true, $strict_user),__('Alert control filter'), __('Toggle filter(s)')); + ui_toggle( + printFormFilterAlert( + $id_group, $filter, $free_search, $url, $filter_standby, true), + __('Alert control filter'), __('Toggle filter(s)')); } $table->width = '100%'; @@ -418,14 +428,26 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { // Sort buttons are only for normal console if (!defined('METACONSOLE')) { $table->head[3] .= ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectAgentUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectAgentDown)) . ''; + '' . + html_print_image("images/sort_up.png", true, + array("style" => $selectAgentUp)) . '' . + '' . + html_print_image("images/sort_down.png", true, + array("style" => $selectAgentDown)) . ''; $table->head[4] .= ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" =>$selectModuleUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . ''; + '' . + html_print_image("images/sort_up.png", true, + array("style" =>$selectModuleUp)) . '' . + '' . + html_print_image("images/sort_down.png", true, + array("style" => $selectModuleDown)) . ''; $table->head[5] .= ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" =>$selectTemplateUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . ''; + '' . + html_print_image("images/sort_up.png", true, + array("style" =>$selectTemplateUp)) . '' . + '' . + html_print_image("images/sort_down.png", true, + array("style" => $selectTemplateDown)) . ''; } } else { @@ -455,11 +477,19 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { // Sort buttons are only for normal console if (!defined('METACONSOLE')) { $table->head[3] .= ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectModuleUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . ''; + '' . + html_print_image("images/sort_up.png", true, + array("style" => $selectModuleUp)) . '' . + '' . + html_print_image("images/sort_down.png", true, + array("style" => $selectModuleDown)) . ''; $table->head[4] .= ' ' . - '' . html_print_image("images/sort_up.png", true, array("style" => $selectTemplateUp)) . '' . - '' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . ''; + '' . + html_print_image("images/sort_up.png", true, + array("style" => $selectTemplateUp)) . '' . + '' . + html_print_image("images/sort_down.png", true, + array("style" => $selectTemplateDown)) . ''; } } } @@ -569,17 +599,6 @@ else { echo '
'.__('No alerts found').'
'; } -//strict user hidden -echo ''; - enterprise_hook('close_meta_frame'); @@ -596,32 +615,5 @@ $(document).ready (function () { }).click (function () { return false; }); - - if ($('#ag_group').val() != 0) { - $("#tag_filter").css('display', 'none'); - $("#table2-0-4").css('display', 'none'); - } -}); - - -$('#ag_group').change (function (){ - strict_user = $("#text-strict_user_hidden").val(); - is_meta = $("#text-is_meta_hidden").val(); - - if (($("#ag_group").val() != 0) && (strict_user != 0)) { - $("#tag_filter").css('display', 'none'); - if (is_meta) { - $("#table1-0-4").css('display', 'none'); - } else { - $("#table2-0-4").css('display', 'none'); - } - } else { - $("#tag_filter").css('display', ''); - if (is_meta) { - $("#table1-0-4").css('display', ''); - } else { - $("#table2-0-4").css('display', ''); - } - } }); diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 755ee8e2a3..15c81ec908 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -34,8 +34,6 @@ enterprise_include_once ('include/functions_metaconsole.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); -$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); - if (! defined ('METACONSOLE')) { //Header ui_print_page_header (__("Monitor detail"), "images/brick.png", false); @@ -45,6 +43,8 @@ else { ui_meta_print_header(__("Monitor view")); } + + $ag_freestring = get_parameter ('ag_freestring'); $ag_modulename = (string) get_parameter ('ag_modulename'); if (!defined('METACONSOLE')) { @@ -68,11 +68,6 @@ $offset = (int) get_parameter ('offset', 0); $status = (int) get_parameter ('status', 4); $modulegroup = get_parameter ('modulegroup', -1); $tag_filter = get_parameter('tag_filter', 0); -if ($tag_filter) { - if ($ag_group && $strict_user) { - $tag_filter = 0; - } -} $refr = get_parameter('refr', 0); // Sort functionality @@ -113,7 +108,6 @@ else { $id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group); } - // Agent group selector if (!defined('METACONSOLE')) { if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) { @@ -125,9 +119,8 @@ if (!defined('METACONSOLE')) { } } else { - if ($ag_group != "0" && check_acl ($config["id_user"], $id_ag_group, "AR")) { - $sql_conditions_group = sprintf (" AND tagente.id_grupo IN (%s) ", $ag_group); + $sql_conditions_group = sprintf (" AND tagente.id_grupo IN ( SELECT id_grupo FROM tgrupo where nombre = '%s') ", $ag_group); } elseif ($user_groups != '') { // User has explicit permission on group 1 ? @@ -207,7 +200,7 @@ if ($tag_filter !== 0) { $sql_conditions .= " AND tagente_modulo.id_agente_modulo IN ( SELECT ttag_module.id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag IN ($tag_filter) + WHERE ttag_module.id_tag IN (SELECT id_tag FROM ttag where name LIKE '%" . $tag_filter . "%') )"; } else { @@ -220,13 +213,14 @@ if ($tag_filter !== 0) { } } +if (defined('METACONSOLE') && $ag_group !== 0) { + $ag_group = groups_get_id($ag_group); +} + // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) $groups = users_get_groups($config["id_user"]); -if ($ag_group !== 0) { - $sql_conditions_tags = tags_get_acl_tags($config['id_user'], $ag_group, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); -} else { - $sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); -} + +$sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); if (is_numeric($sql_conditions_tags)) { $sql_conditions_tags = ' AND 1 = 0'; @@ -236,11 +230,6 @@ if (is_numeric($sql_conditions_tags)) { $sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields; $sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields; -if (!$strict_user) { - $sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_custom_fields; - $sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_custom_fields; -} - // Get count to paginate if (!defined('METACONSOLE')) $count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) " . $sql_from . $sql_conditions_all); @@ -345,7 +334,22 @@ if (defined('METACONSOLE')) { // Get all info for filters of all nodes $modules_temp = db_get_all_rows_sql($sql); + + # Fix : only user tags have to be shown in these component + $_tags = tags_get_user_tags(); + + + if (!empty($_tags)) { + foreach ($_tags as $_tag) { + + $tags_temp[]['name'] = $_tag; + + } + + } + + $rows_temp = db_get_all_rows_sql("SELECT distinct name FROM tmodule_group ORDER BY name"); @@ -373,6 +377,8 @@ if (defined('METACONSOLE')) { if (!empty($modules_temp)) $modules = array_merge($modules, $modules_temp); + if (!empty($tags_temp)) + $tags = array_merge($tags, $tags_temp); metaconsole_restore_db(); } @@ -382,17 +388,28 @@ if (defined('METACONSOLE')) { unset($groups_select[$key_group_all]); } -echo ' -' . __('Group') . ' -' . - html_print_select_groups($config['id_user'], "AR", true, "ag_group", - $ag_group, '', '', '0', true, false, false, 'w130', - false, 'width:150px;', false, false, - 'id_grupo', $strict_user) . ' -'; - +if (!defined('METACONSOLE')) { + echo ' + ' . __('Group') . ' + ' . + html_print_select_groups(false, "AR", true, "ag_group", + $ag_group, '', '', '0', true, false, false, 'w130', + false, 'width:150px;') . ' + '; +} +else { + echo ' + ' . __('Group') . ' + ' . + html_print_select($groups_select, "ag_group", + io_safe_output($ag_group_metaconsole), '', __('All'), '0', true, false, false, 'w130', + false, 'width:150px;') . ' + '; +} echo '' . __('Monitor status') . ""; + + echo ""; $fields = array (); @@ -404,9 +421,11 @@ $fields[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal'); //default $fields[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); html_print_select ($fields, "status", $status, '', __('All'), -1, - false, false, true, '', false, 'width: 150px;'); + false, false, true, '', false, 'width: 125px;'); echo ''; + + echo '' . __('Module group') . ''; echo ''; if (!defined('METACONSOLE')) { @@ -421,13 +440,17 @@ if (!defined('METACONSOLE')) { $rows_select[0] = __('Not assigned'); -html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'),-1,false, false, true, '', false, 'width: 120px;'); +html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1); echo ''; + + echo ''; echo ''; + + echo '' . __('Module name') . ''; echo ''; @@ -440,6 +463,32 @@ html_print_select (index_array ($modules, 'nombre', 'nombre'), "ag_modulename", echo ''; + +echo '' . + __('Tags') . + ui_print_help_tip(__('Only it is show tags in use.'), true) . + ''; +echo ''; + +if (!defined('METACONSOLE')) { + $tags = tags_get_user_tags(); +} + +if (empty($tags)) { + echo __('No tags'); +} +else { + if (!defined('METACONSOLE')) + html_print_select ($tags, "tag_filter", + $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); + else + html_print_select (index_array($tags, 'name', 'name'), "tag_filter", + $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); +} +echo ''; + + + echo '' . __('Search') . ''; @@ -447,21 +496,7 @@ echo ''; html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false); echo ''; -echo '' . - __('Tags') . - ui_print_help_tip(__('Only it is show tags in use.'), true); -echo ''; -$tags = tags_get_user_tags(); - -if (empty($tags)) { - echo __('No tags'); -} -else { - - html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); -} -echo ''; echo ''; html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"'); @@ -697,7 +732,6 @@ switch ($config["dbtype"]) { $sql_from . $sql_conditions_all . " ORDER BY " . $order['field'] . " " . $order['order'] . " LIMIT ".$offset.",".$limit_sql; - break; case "postgresql": if (strstr($config['dbversion'], "8.4") !== false) { @@ -807,7 +841,7 @@ else { WHERE disabled = 0"); if ($servers === false) $servers = array(); - + $result = array(); $count_modules = 0; foreach ($servers as $server) { @@ -907,6 +941,10 @@ if (! defined ('METACONSOLE')) { '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown, "alt" => "down")) . ''; } +/* +$table->head[4] = __('Tags'); +*/ + $table->head[5] = __('Interval'); if (! defined ('METACONSOLE')) { $table->head[5] .= ' ' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '' . @@ -1150,6 +1188,7 @@ foreach ($result as $row) { $data[7] = '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . ''; if (defined('METACONSOLE')) + //$data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; $data[7] .= "". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . ""; else $data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; @@ -1218,6 +1257,8 @@ foreach ($result as $row) { } } + + if ($module_value == $sub_string) { $salida = $module_value; } @@ -1266,37 +1307,12 @@ else { echo "
"; -//strict user hidden -echo ''; - - enterprise_hook('close_meta_frame'); ui_require_javascript_file('pandora_modules'); ?> \ No newline at end of file + From 5c44a4d7e0684c639288097bf4e8071013702f8a Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Thu, 15 Jan 2015 16:30:50 +0100 Subject: [PATCH 26/41] fixed little problem --- pandora_console/operation/agentes/networkmap_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/agentes/networkmap_list.php b/pandora_console/operation/agentes/networkmap_list.php index 1fd66c7106..5c716e38d6 100644 --- a/pandora_console/operation/agentes/networkmap_list.php +++ b/pandora_console/operation/agentes/networkmap_list.php @@ -81,7 +81,7 @@ $delete_networkmap = get_parameter ('delete_networkmap', 0); if ($delete_networkmap) { if (check_acl ($config['id_user'], 0, "RW")) { - $result = networkmap_delete_user_networkmap($id_networkmap); + $result = networkmap_delete_user_networkmap($config['id_user'], $id_networkmap); }else{ if (check_acl ($config['id_user'], 0, "RM")) { $result = networkmap_delete_networkmap($id_networkmap); From e8daa908b9f048b331e2ea4fddf764a535b9d3bf Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 13 Jan 2015 18:08:56 +0100 Subject: [PATCH 27/41] Removed old debug trace --- pandora_console/include/functions_tags.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 039229cab7..c7ad68050e 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -517,8 +517,6 @@ function tags_get_module_tags ($id, $policy = false) { if (empty($id)) return false; - html_debug_print(func_get_args()); - if ($policy) { $tags = db_get_all_rows_filter('ttag_policy_module', array('id_policy_module' => $id), false); From 534a8cd0074de40d60f0e65df5210b18f60a7722 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 15 Jan 2015 16:36:22 +0100 Subject: [PATCH 28/41] Fixed ha Perl Warning that maybe gave problems with parse the output --- pandora_server/util/pandora_manage.pl | 43 ++++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index dfc5e8f889..6a91bf484d 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -2997,7 +2997,7 @@ sub cli_get_agent_modules() { exist_check($id_agent,'agent',$agent_name); my $modules = pandora_get_agent_modules ($dbh, $id_agent); - + if(scalar(@{$modules}) == 0) { print_log "[INFO] The agent '$agent_name' have not modules\n\n"; } @@ -3008,49 +3008,56 @@ sub cli_get_agent_modules() { } } -############################################################################## +######################################################################## # Show all the modules of a policy # Related option: --get_policy_modules -############################################################################## +######################################################################## sub cli_get_policy_modules() { my $policy_name = @ARGV[2]; - my $policy_id = enterprise_hook('get_policy_id',[$dbh, safe_input($policy_name)]); - exist_check($policy_id,'policy',$policy_name); + my $policy_id = enterprise_hook('get_policy_id', + [$dbh, safe_input($policy_name)]); + exist_check($policy_id, 'policy', $policy_name); - my $policy_modules = enterprise_hook('get_policy_modules',[$dbh, $policy_id]); - exist_check(scalar(@{$policy_modules})-1,'modules in policy',$policy_name); + my $policy_modules = enterprise_hook( + 'get_policy_modules', [$dbh, $policy_id]); + + if (defined($policy_modules)) { + exist_check(scalar(@{$policy_modules}) - 1, 'modules in policy', + $policy_name); + } print "id_policy_module, module_name\n"; foreach my $module (@{$policy_modules}) { - print $module->{'id'}.",".safe_output($module->{'name'})."\n"; + print $module->{'id'} . "," . safe_output($module->{'name'}) . "\n"; } } -############################################################################## -# Show all the policies (without parameters) or the policies of given agent +######################################################################## +# Show all the policies (without parameters) or the policies of given +# agent. # Related option: --get_policies -############################################################################## +######################################################################## sub cli_get_policies() { my $agent_name = @ARGV[2]; my $policies; - - if(defined($agent_name)) { + + if (defined($agent_name)) { my $id_agent = get_agent_id($dbh,$agent_name); exist_check($id_agent,'agent',$agent_name); - $policies = enterprise_hook('get_agent_policies',[$dbh,$id_agent]); - - if(scalar(@{$policies}) == 0) { + $policies = enterprise_hook('get_agent_policies', [$dbh,$id_agent]); + + if (scalar(@{$policies}) == 0) { print_log "[INFO] No policies found on agent '$agent_name'\n\n"; exit; } } else { - $policies = enterprise_hook('get_policies',[$dbh]); - if(scalar(@{$policies}) == 0) { + $policies = enterprise_hook('get_policies', [$dbh]); + if (scalar(@{$policies}) == 0) { print_log "[INFO] No policies found\n\n"; exit; } From 36e7b29a04d870f5ed0054112c52d4a69aa68ac5 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 15 Jan 2015 16:39:05 +0100 Subject: [PATCH 29/41] Fixed the get data of module data list view with historic data base set on. TICKET: #1668 --- pandora_console/include/ajax/module.php | 184 +++++++----------------- 1 file changed, 51 insertions(+), 133 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 15b228f954..db2ab3e94d 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -70,14 +70,16 @@ if ($get_module_detail) { ui_include_time_picker(); - ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); + ui_require_jquery_file("ui.datepicker-" . get_user_language(), + "include/javascript/i18n/"); ui_require_jquery_file ("ui-timepicker-addon"); // This script is included manually to be included after jquery and avoid error echo ''; - ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); + ui_require_jquery_file("ui.datepicker-" . get_user_language(), + "include/javascript/i18n/"); $module_id = get_parameter ('id_module'); $period = get_parameter ("period", 86400); @@ -87,7 +89,8 @@ if ($get_module_detail) { if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); - $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']); + $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], + $server['dbpass']); $select_db = mysql_select_db ($server['dbname'], $conexion); } else { @@ -120,25 +123,33 @@ if ($get_module_detail) { SECONDS_2YEARS =>__('2 years'), SECONDS_3YEARS =>__('3 years')); - $formtable->data[0][0] = html_print_radio_button_extended ("selection_mode", 'fromnow', '', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Choose a time from now"); + $formtable->data[0][0] = html_print_radio_button_extended ( + "selection_mode", 'fromnow', '', $selection_mode, false, '', + 'style="margin-right: 15px;"', true) . __("Choose a time from now"); $formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false); $formtable->data[0][2] = ''; $formtable->data[0][3] = "". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; $formtable->rowspan[0][3] = 2; $formtable->cellstyle[0][3] = 'vertical-align: middle;'; - $formtable->data[1][0] = html_print_radio_button_extended ("selection_mode", 'range','', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Specify time range"); + $formtable->data[1][0] = html_print_radio_button_extended( + "selection_mode", 'range','', $selection_mode, false, '', + 'style="margin-right: 15px;"', true) . __("Specify time range"); $formtable->data[1][1] = __('Timestamp from:'); - $formtable->data[1][2] = html_print_input_text ('date_from', $date_from, '', 10, 10, true); - $formtable->data[1][2] .= html_print_input_text ('time_from', $time_from, '', 9, 7, true); + $formtable->data[1][2] = html_print_input_text('date_from', + $date_from, '', 10, 10, true); + $formtable->data[1][2] .= html_print_input_text('time_from', + $time_from, '', 9, 7, true); $formtable->data[1][1] .= '
'; $formtable->data[1][1] .= __('Timestamp to:'); $formtable->data[1][2] .= '
'; - $formtable->data[1][2] .= html_print_input_text ('date_to', $date_to, '', 10, 10, true); - $formtable->data[1][2] .= html_print_input_text ('time_to', $time_to, '', 9, 7, true); + $formtable->data[1][2] .= html_print_input_text('date_to', $date_to, + '', 10, 10, true); + $formtable->data[1][2] .= html_print_input_text('time_to', $time_to, + '', 9, 7, true); html_print_table($formtable); @@ -153,136 +164,43 @@ if ($get_module_detail) { $datetime_from = strtotime ($date_from . ' ' . $time_from); $datetime_to = strtotime ($date_to . ' ' . $time_to); - if ($moduletype_name == "log4x") { - $table->width = "100%"; - - if ($selection_mode == "fromnow") { - $sql_body = sprintf ("FROM tagente_datos_log4x - WHERE id_agente_modulo = %d AND utimestamp > %d - ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - } - else { - $sql_body = sprintf ("FROM tagente_datos_log4x - WHERE id_agente_modulo = %d AND utimestamp >= %d - AND utimestamp <= %d - ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); - } - $columns = array( - "Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ), - "Sev" => array("severity", "modules_format_data", "align" => "center", "width" => "70px"), - "Message"=> array("message", "modules_format_verbatim", "align" => "left", "width" => "45%"), - "StackTrace" => array("stacktrace", "modules_format_verbatim", "align" => "left", "width" => "50%") - ); - } - else if (preg_match ("/string/", $moduletype_name)) { - - if ($selection_mode == "fromnow") { - $sql_body = sprintf (" FROM tagente_datos_string - WHERE id_agente_modulo = %d AND utimestamp > %d - ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - } - else { - $sql_body = sprintf (" FROM tagente_datos_string - WHERE id_agente_modulo = %d AND utimestamp >= %d - AND utimestamp <= %d - ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); - } - - $columns = array( - "Timestamp" => array( - "utimestamp", - "modules_format_timestamp", - "align" => "left"), - "Data" => array( - "datos", - "modules_format_data", - "align" => "left"), - "Time" => array( - "utimestamp", - "modules_format_time", - "align" => "center") - ); + $columns = array( + "Timestamp" => array( + "utimestamp", + "modules_format_timestamp", + "align" => "left"), + "Data" => array( + "datos", + "modules_format_data", + "align" => "left"), + "Time" => array( + "utimestamp", + "modules_format_time", + "align" => "center") + ); + + if ($selection_mode == "fromnow") { + $date = get_system_time(); + $period = $period; } else { - if ($selection_mode == "fromnow") { - $sql_body = sprintf (" FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp > %d - ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - } - else { - $sql_body = sprintf (" FROM tagente_datos - WHERE id_agente_modulo = %d - AND utimestamp >= %d AND utimestamp <= %d - ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); - } - - $columns = array( - "Timestamp" => array( - "utimestamp", - "modules_format_timestamp", - "align" => "left"), - "Data" => array( - "datos", - "modules_format_data", - "align" => "left"), - "Time" => array( - "utimestamp", - "modules_format_time", - "align" => "center") - ); + $date = $datetime_from; + $period = $datetime_to - $datetime_from; } + $count = modules_get_agentmodule_data ($module_id, $period, + $date, true, $conexion); - $sql_body = io_safe_output($sql_body); - // Clean all codification characters + $module_data = modules_get_agentmodule_data ($module_id, $period, + $date, false, $conexion, 'DESC'); - $sql = "SELECT * " . $sql_body; - - switch ($config['dbtype']) { - case "mysql": - $sql_count = "SELECT count(*) " . $sql_body; - break; - case "postgresql": - $sql_body = str_replace("ORDER BY utimestamp DESC", - "GROUP BY utimestamp ORDER BY utimestamp DESC", - $sql_body); - $sql_count = "SELECT count(DISTINCT utimestamp) " . $sql_body; - break; - case "oracle": - $sql_count = "SELECT count(*) " . $sql_body; - break; + if (empty($module_data)) { + $result = array(); } - - $count = db_get_value_sql ($sql_count, $conexion); - - - switch ($config["dbtype"]) { - case "mysql": - $sql .= " LIMIT " . $offset . "," . $block_size; - break; - case "postgresql": - $sql .= " LIMIT " . $block_size . " OFFSET " . $offset; - break; - case "oracle": - $set = array(); - $set['limit'] = $block_size; - $set['offset'] = $offset; - $sql = oracle_recode_query ($sql, $set); - break; - } - - $result = db_get_all_rows_sql ($sql, false, true, $conexion); - - if ($result === false) { - $result = array (); - } - - if (($config['dbtype'] == 'oracle') && ($result !== false)) { - for ($i=0; $i < count($result); $i++) { - unset($result[$i]['rnum']); - } + else { + // Paginate the result + $result = array_slice($module_data, $offset, $block_size); } $table->width = '98%'; @@ -301,8 +219,8 @@ if ($get_module_detail) { $index++; } - $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', - 'nombre', 'web_content_string'); + $id_type_web_content_string = db_get_value('id_tipo', + 'ttipo_modulo', 'nombre', 'web_content_string'); foreach ($result as $row) { $data = array (); From 1e9501b58ea2a33aa4ceaa9f25d876f8de27241b Mon Sep 17 00:00:00 2001 From: Vanessa Gil Date: Thu, 15 Jan 2015 18:08:58 +0100 Subject: [PATCH 30/41] Added Stric ACL mode. --- .../pandoradb_migrate_5.1_to_6.0.mysql.sql | 4 + .../pandoradb_migrate_5.1_to_6.0.oracle.sql | 5 + ...andoradb_migrate_5.1_to_6.0.postgreSQL.sql | 5 + .../godmode/users/configure_user.php | 32 + pandora_console/include/functions_agents.php | 29 +- pandora_console/include/functions_alerts.php | 41 +- pandora_console/include/functions_graph.php | 8 +- pandora_console/include/functions_groups.php | 710 ++++++++++++++++-- pandora_console/include/functions_html.php | 46 +- .../include/functions_reporting.php | 271 ++++++- pandora_console/include/functions_tags.php | 550 +++++++++++++- pandora_console/include/functions_users.php | 13 +- .../agentes/alerts_status.functions.php | 21 +- .../operation/agentes/alerts_status.php | 140 ++-- .../operation/agentes/group_view.php | 291 +++++-- .../operation/agentes/status_monitor.php | 158 ++-- .../operation/agentes/tactical.php | 41 +- pandora_console/pandoradb.oracle.sql | 1 + pandora_console/pandoradb.postgreSQL.sql | 3 +- pandora_console/pandoradb.sql | 1 + 20 files changed, 1974 insertions(+), 396 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql index 05977d3052..23ba9562fa 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql @@ -49,3 +49,7 @@ CREATE TABLE IF NOT EXISTS `tuser_double_auth` ( -- ---------------------------------------------------------------------- INSERT INTO `ttipo_modulo` VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); +-- --------------------------------------------------------------------- +-- Table `tusuario` +-- --------------------------------------------------------------------- +ALTER TABLE `tusuario` ADD COLUMN `strict_acl` tinyint(1) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql index dcf223f6cc..cf63cd06b5 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.oracle.sql @@ -36,3 +36,8 @@ CREATE OR REPLACE TRIGGER tuser_double_auth_inc BEFORE INSERT ON tuser_double_au -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- INSERT INTO ttipo_modulo VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); + +-- --------------------------------------------------------------------- +-- Table `tusuario` +-- --------------------------------------------------------------------- +ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5, 0) DEFAULT 0; diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql index a0b2640837..25b7e250b3 100755 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.postgreSQL.sql @@ -34,3 +34,8 @@ CREATE TABLE "tuser_double_auth" ( -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- INSERT INTO "ttipo_modulo" VALUES (5,'generic_data_inc_abs',0,'Generic numeric incremental (absolute)','mod_data_inc_abs.png'); + +-- --------------------------------------------------------------------- +-- Table `tusuario` +-- --------------------------------------------------------------------- +ALTER TABLE "tusuario" ADD COLUMN "strict_acl" SMALLINT DEFAULT 0; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 66fa34af2a..74bb401c11 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -123,6 +123,7 @@ if ($new_user && $config['admin_can_add_user']) { $user_info['is_admin'] = 0; $user_info['language'] = 'default'; $user_info["not_login"] = false; + $user_info["strict_acl"] = false; if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { $user_info['id_skin'] = ''; } @@ -172,6 +173,7 @@ if ($create_user) { } } $values["not_login"] = (bool)get_parameter ('not_login', false); + $values["strict_acl"] = (bool)get_parameter ('strict_acl', false); if ($id == '') { ui_print_error_message (__('User ID cannot be empty')); @@ -235,6 +237,11 @@ if ($create_user) { $password_confirm = ''; if($result) { + if ($values["strict_acl"]) { + if ($values['is_admin']) { + ui_print_info_message (__('Strict ACL is not recommended for admin users because performance could be affected.')); + } + } $user_info = get_user_info ($id); $new_user = false; } @@ -269,6 +276,7 @@ if ($update_user) { $values['metaconsole_access_node'] = get_parameter ('metaconsole_access_node', '0'); } $values["not_login"] = (bool)get_parameter ('not_login', false); + $values["strict_acl"] = (bool)get_parameter ('strict_acl', false); $res1 = update_user ($id, $values); @@ -336,6 +344,25 @@ if ($update_user) { __('Error updating user info (no change?)')); } + if ($values['strict_acl']) { + $count_groups = 0; + $count_tags = 0; + + $profiles = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); + if ($profiles === false) { + $profiles = array (); + } + foreach ($profiles as $profile) { + $count_groups = $count_groups+1; + $arr_tags = explode(',', $profile['tags']); + $count_tags = $count_tags + count($arr_tags); + } + + if (($count_groups > 3) && ($count_tags > 10)) { + ui_print_info_message(__('Strict ACL is not recommended for this user. Performance could be affected.')); + } + } + $user_info = $values; } @@ -496,6 +523,10 @@ $table->data[13][0] = __('Not Login'); $table->data[13][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); $table->data[13][1] = html_print_checkbox('not_login', 1, $user_info["not_login"], true); +$table->data[14][0] = __('Strict ACL'); +$table->data[14][0] .= ui_print_help_tip(__('With this option enabled, the user will can access to accurate information. It is not recommended for admin users because performance could be affected'), true); +$table->data[14][1] = html_print_checkbox('strict_acl', 1, $user_info["strict_acl"], true); + if($meta) { enterprise_include('include/functions_metaconsole.php'); $data = array(); @@ -570,6 +601,7 @@ if (!empty ($id) && !$new_user) { */ $result = db_get_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); + if ($result === false) { $result = array (); } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index c7e5fcc551..144cf08a2a 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -114,8 +114,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values * @return array All simple alerts defined for an agent. Empty array if no * alerts found. */ -function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', - $allModules = false, $orderby = false, $idGroup = false, $count = false) { +function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, $idGroup = false, $count = false, $strict_user = false, $tag = false) { global $config; if (is_array($filter)) { @@ -149,7 +148,10 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f $filter .= ''; break; } - + + if ($tag) { + $filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))'; + } if (is_array ($options)) { $filter .= db_format_array_where_clause_sql ($options); } @@ -157,7 +159,6 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f if (($id_agent !== false) && ($idGroup !== false)) { $groups = users_get_groups($config["id_user"]); - $where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); if ($idGroup != 0) { //All group $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo @@ -168,12 +169,15 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f FROM tagente_modulo WHERE delete_pending = 0'; } - // If there are any errors add imposible condition - if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { - $subQuery .= ' AND 1 = 0'; - } - else { - $subQuery .= $where_tags; + if ($strict_user) { + $where_tags = tags_get_acl_tags($config['id_user'], $groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); + // If there are any errors add imposible condition + if(in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { + $subQuery .= ' AND 1 = 0'; + } + else { + $subQuery .= $where_tags; + } } } else if ($id_agent === false) { @@ -210,7 +214,6 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f $selectText = 'COUNT(talert_template_modules.id) AS count'; } - $sql = sprintf ("SELECT %s FROM talert_template_modules INNER JOIN tagente_modulo t2 @@ -222,7 +225,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f WHERE id_agent_module in (%s) %s %s %s", $selectText, $subQuery, $where, $filter, $orderbyText); $alerts = db_get_all_rows_sql ($sql); - + if ($alerts === false) return array (); @@ -1177,8 +1180,6 @@ function agents_get_modules ($id_agent = null, $details = false, break; } - //html_debug_print($sql); - $result = db_get_all_rows_sql ($sql); if (empty ($result)) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 97b4dc0145..47ba471751 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1521,8 +1521,8 @@ function get_alert_fires_in_period ($id_alert_module, $period, $date = 0) { */ function get_group_alerts($id_group, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, - $idGroup = false, $count = false) { - + $idGroup = false, $count = false, $strict_user = false, $tag = false) { + global $config; $group_query = ''; @@ -1561,18 +1561,18 @@ function get_group_alerts($id_group, $filter = '', $options = false, $filter .= ''; break; } - + + if ($tag) { + $filter .= ' AND (id_agent_module IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN ('.$tag.')))'; + } if (is_array ($options)) { $filter .= db_format_array_where_clause_sql ($options); } if ($id_group !== false) { - $groups = users_get_groups($config["id_user"]); - - $where_tags = tags_get_acl_tags($config['id_user'], - array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); - + $groups = users_get_groups($config["id_user"], "AR"); + if ($id_group != 0) { if (is_array($id_group)) { if (in_array(0, $id_group)) { @@ -1594,6 +1594,7 @@ function get_group_alerts($id_group, $filter = '', $options = false, FROM tagente WHERE id_grupo IN (' . implode(',', $id_group) . '))'; + } } else { @@ -1609,13 +1610,23 @@ function get_group_alerts($id_group, $filter = '', $options = false, $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0'; } + + if ($strict_user) { + $groups = users_get_groups($config["id_user"]); + + if ($idGroup !== 0) { + $where_tags = tags_get_acl_tags($config['id_user'], $idGroup, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); + } else { + $where_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); + } - // If there are any errors add imposible condition - if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { - $subQuery .= ' AND 1 = 0'; - } - else { - $subQuery .= $where_tags; + // If there are any errors add imposible condition + if (in_array($where_tags, array(ERR_WRONG_PARAMETERS, ERR_ACL))) { + $subQuery .= ' AND 1 = 0'; + } + else { + $subQuery .= $where_tags; + } } } else { @@ -1654,7 +1665,7 @@ function get_group_alerts($id_group, $filter = '', $options = false, WHERE id_agent_module in (%s) %s %s %s", $selectText, $subQuery, $where, $filter, $orderbyText); $alerts = db_get_all_rows_sql ($sql); - + if ($alerts === false) return array (); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 1506d1c262..5abbf7e7d2 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2369,7 +2369,9 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = } // Add tags condition to filter - $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); + $user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + $acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict); + $tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")"; //This will give the distinct id_agente, give the id_grupo that goes //with it and then the number of times it occured. GROUP BY statement @@ -2463,7 +2465,9 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200) { $filter = str_replace ( "\\" , "", $filter); // Add tags condition to filter - $tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND'); + $user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + $acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict); + $tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")"; $filter .= $tags_condition; $data = array (); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index c07aae0ae0..c8ef5a51cb 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1125,7 +1125,7 @@ function groups_create_group($group_name, $rest_values){ // Get agents NOT INIT -function groups_agent_not_init ($group_array) { +function groups_agent_not_init ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1140,14 +1140,28 @@ function groups_agent_not_init ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - $count = db_get_sql ("SELECT COUNT(*) - FROM tagente - WHERE disabled = 0 - AND critical_count = 0 - AND warning_count = 0 - AND unknown_count = 0 - AND (notinit_count > 0 OR total_count = 0) - AND id_grupo IN $group_clause"); + if ($strict_user) { + $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo + WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; + $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 + AND id_grupo=$id_group_strict + AND critical_count = 0 + AND warning_count = 0 + AND unknown_count = 0 + AND (notinit_count > 0 OR total_count = 0) + $tags_clause"; + + $count = db_get_sql ($sql); + } else { + $count = db_get_sql ("SELECT COUNT(*) + FROM tagente + WHERE disabled = 0 + AND critical_count = 0 + AND warning_count = 0 + AND unknown_count = 0 + AND (notinit_count > 0 OR total_count = 0) + AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } @@ -1155,7 +1169,7 @@ function groups_agent_not_init ($group_array) { // Get unknown agents by using the status code in modules. -function groups_agent_unknown ($group_array) { +function groups_agent_unknown ($group_array, $strict_user = false, $id_group_strict = false) { if (empty ($group_array)) { return 0; @@ -1167,12 +1181,24 @@ function groups_agent_unknown ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); + if ($strict_user) { + $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo + WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; + $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 + AND id_grupo=$id_group_strict + AND critical_count=0 + AND warning_count=0 AND unknown_count>0 + $tags_clause"; + + $count = db_get_sql ($sql); + } else { + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } -function groups_agent_total($group_array) { +function groups_agent_total($group_array, $strict_user = false, $id_group_strict = false) { if (empty ($group_array)) { return 0; @@ -1184,19 +1210,28 @@ function groups_agent_total($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - $count = db_get_sql ("SELECT COUNT(*) + if ($strict_user) { + $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo + WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; + $sql = "SELECT COUNT(*) FROM tagente + WHERE tagente.disabled = 0 + AND id_grupo = ".$id_group_strict . + $tags_clause; + $count = db_get_sql($sql); + + } else { + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled = 0 - AND id_grupo IN $group_clause"); - - + AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get ok agents by using the status code in modules. -function groups_agent_ok ($group_array) { +function groups_agent_ok ($group_array, $strict_user = false, $id_group_strict = false) { if (empty ($group_array)) { return 0; @@ -1209,20 +1244,30 @@ function groups_agent_ok ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - $count = db_get_sql ("SELECT COUNT(*) - FROM tagente - WHERE tagente.disabled = 0 - AND normal_count = total_count - AND id_grupo IN $group_clause"); - - - + if ($strict_user) { + $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo + WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; + $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 + AND id_grupo=$id_group_strict + AND critical_count=0 + AND warning_count=0 AND normal_count = total_count + $tags_clause"; + + $count = db_get_sql ($sql); + } else { + $count = db_get_sql ("SELECT COUNT(*) + FROM tagente + WHERE tagente.disabled = 0 + AND normal_count = total_count + AND id_grupo IN $group_clause"); + } + return $count > 0 ? $count : 0; } // Get critical agents by using the status code in modules. -function groups_agent_critical ($group_array) { +function groups_agent_critical ($group_array, $strict_user = false, $id_group_strict = false) { if (empty ($group_array)) { return 0; @@ -1236,14 +1281,26 @@ function groups_agent_critical ($group_array) { $group_clause = "(" . $group_clause . ")"; //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); + + if ($strict_user) { + $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo + WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; + $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 + AND id_grupo=$id_group_strict + AND critical_count>0 + $tags_clause"; + + $count = db_get_sql ($sql); + } else { + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get warning agents by using the status code in modules. -function groups_agent_warning ($group_array) { +function groups_agent_warning ($group_array, $strict_user = false, $id_group_strict = false) { if (empty ($group_array)) { return 0; @@ -1256,7 +1313,19 @@ function groups_agent_warning ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); + if ($strict_user) { + $tags_clause = " AND tagente.id_agente IN (SELECT id_agente FROM tagente_modulo + WHERE id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module))"; + $sql = "SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 + AND id_grupo=$id_group_strict + AND critical_count=0 + AND warning_count>0 + $tags_clause"; + + $count = db_get_sql ($sql); + } else { + $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } @@ -1264,7 +1333,7 @@ function groups_agent_warning ($group_array) { // Get monitor NOT INIT, except disabled AND async modules -function groups_monitor_not_init ($group_array) { +function groups_monitor_not_init ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1279,15 +1348,29 @@ function groups_monitor_not_init ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + if ($strict_user) { + + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + + $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 5 + AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente + WHERE disabled = 0 + AND tagente.id_grupo = $id_group_strict + ) ". $tags_clause); + + } else { + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get monitor OK, except disabled and non-init -function groups_monitor_ok ($group_array) { +function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1302,15 +1385,27 @@ function groups_monitor_ok ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + if ($strict_user) { + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 0 + AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente + WHERE disabled = 0 + AND tagente.id_grupo = $id_group_strict + ) ". $tags_clause); + } else { + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get monitor CRITICAL, except disabled and non-init -function groups_monitor_critical ($group_array) { +function groups_monitor_critical ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1325,15 +1420,27 @@ function groups_monitor_critical ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + + if ($strict_user) { + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 1 + AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente + WHERE disabled = 0 + AND tagente.id_grupo = $id_group_strict + ) ". $tags_clause); + } else { + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get monitor WARNING, except disabled and non-init -function groups_monitor_warning ($group_array) { +function groups_monitor_warning ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1348,15 +1455,26 @@ function groups_monitor_warning ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + if ($strict_user) { + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 2 + AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente + WHERE disabled = 0 + AND tagente.id_grupo = $id_group_strict + ) ". $tags_clause); + } else { + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get monitor UNKNOWN, except disabled and non-init -function groups_monitor_unknown ($group_array) { +function groups_monitor_unknown ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1371,15 +1489,27 @@ function groups_monitor_unknown ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + if ($strict_user) { + + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + $count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 3 + AND tagente_modulo.id_agente IN ( SELECT id_agente FROM tagente + WHERE disabled = 0 + AND tagente.id_grupo = $id_group_strict + ) ". $tags_clause); + } else { + //TODO REVIEW ORACLE AND POSTGRES + $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); + } return $count > 0 ? $count : 0; } // Get alerts defined for a given group, except disabled -function groups_monitor_alerts ($group_array) { +function groups_monitor_alerts ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1394,20 +1524,33 @@ function groups_monitor_alerts ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - - return db_get_sql ("SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 - AND talert_template_modules.disabled = 0 - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); + if ($strict_user) { + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + $sql = "SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo + $tags_clause"; + $count = db_get_sql ($sql); + return $count; + } else { + //TODO REVIEW ORACLE AND POSTGRES + return db_get_sql ("SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); + } } // Get alert configured currently FIRED, except disabled -function groups_monitor_fired_alerts ($group_array) { +function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_group_strict = false) { // If there are not groups to query, we jump to nextone @@ -1422,16 +1565,32 @@ function groups_monitor_fired_alerts ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - //TODO REVIEW ORACLE AND POSTGRES - - return db_get_sql ("SELECT COUNT(talert_template_modules.id) + if ($strict_user) { + $tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)"; + + $sql = "SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente + WHERE tagente.id_grupo = $id_group_strict AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0"); + AND times_fired > 0 ".$tags_clause; + + $count = db_get_sql ($sql); + return $count; + } else { + //TODO REVIEW ORACLE AND POSTGRES + return db_get_sql ("SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo + AND times_fired > 0"); + } + } /** @@ -1662,4 +1821,435 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { } return $hierarchy; } + +function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group') { + global $config; + + if ($id_user == false) { + $id_user = $config['id_user']; + } + + $user_groups = array(); + $user_tags = array(); + foreach ($acltags as $group => $tags) { + if ($user_strict) { //Remove groups with tags + if ($tags == '') { + $groups_without_tags[$group] = $group; + } + } + $user_groups[$group] = groups_get_name($group); + if ($tags != '') { + $tags_group = explode(',', $tags); + + foreach ($tags_group as $tag) { + $user_tags[$tag] = tags_get_name($tag); + } + } + } + + if ($user_strict) { + $user_groups_ids = implode(',',array_keys($groups_without_tags)); + } else { + $user_groups_ids = implode(',',array_keys($acltags)); + } + + if ($user_groups_ids == '') { + $user_groups_ids == -1; + } + + switch ($config["dbtype"]) { + case "mysql": + $list_groups = db_get_all_rows_sql(" + SELECT * + FROM tgrupo + WHERE id_grupo IN (" . $user_groups_ids . ") + ORDER BY nombre COLLATE utf8_general_ci ASC"); + + break; + case "postgresql": + $list_groups = db_get_all_rows_sql(" + SELECT * + FROM tgrupo + WHERE id_grupo IN (" . $user_groups_ids . ") + ORDER BY nombre ASC"); + break; + case "oracle": + $list_groups = db_get_all_rows_sql(" + SELECT * + FROM tgrupo + WHERE id_grupo IN (" . $user_groups_ids . ") + ORDER BY nombre COLLATE utf8_general_ci ASC"); + break; + } + + if ($list_groups == false) { + $list_groups = array(); + } + + if ($returnAllGroup) { + $i = 1; + $list[0]['_id_'] = 0; + $list[0]['_name_'] = __('All'); + } else { + $i = 0; + } + foreach ($list_groups as $key => $item) { + $id = $item['id_grupo']; + + if (($config["realtimestats"] == 0) && !$user_strict) { + $group_stat = db_get_all_rows_sql ("SELECT * + FROM tgroup_stat, tgrupo + WHERE tgrupo.id_grupo = tgroup_stat.id_group + AND tgroup_stat.id_group = $id + ORDER BY nombre"); + + $list[$i]['_id_'] = $id; + $list[$i]['_name_'] = $item['nombre']; + $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;')); + + $list[$i]['_agents_unknown_'] = $group_stat[0]["unknown"]; + $list[$i]['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; + $list[$i]['_total_agents_'] = $group_stat[0]["agents"]; + + // This fields are not in database + $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); + $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); + $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); + $list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id); + $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); + $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); + + if ($mode == 'tactical') { + $list[$i]['_agents_ok_'] = $group_stat[0]["normal"]; + $list[$i]['_agents_warning_'] = $group_stat[0]["warning"]; + $list[$i]['_agents_critical_'] = $group_stat[0]["critical"]; + $list[$i]['_monitors_alerts_'] = $group_stat[0]["alerts"]; + + $list[$i]["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"]; + $list[$i]["_total_checks_"] = $group_stat[0]["modules"]; + $list[$i]["_total_alerts_"] = $group_stat[0]["alerts"]; + + // Get total count of monitors for this group, except disabled. + $list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"]; + + // Calculate not_normal monitors + $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; + + if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_monitor_health_"] = 100; + } + + if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_module_sanity_"] = 100; + } + + if (isset($list[$i]["_alerts_"])) { + if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) { + $list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1); + } + else { + $list[$i]["_alert_level_"] = 100; + } + } + else { + $list[$i]["_alert_level_"] = 100; + $list[$i]["_alerts_"] = 0; + } + + $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; + + if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_global_health_"] = 100; + } + + $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); + } + + if ($returnAllGroup) { + $list[0]['_agents_unknown_'] += $group_stat[0]["unknown"]; + $list[0]['_monitors_alerts_fired_'] += $group_stat[0]["alerts_fired"]; + $list[0]['_total_agents_'] += $group_stat[0]["agents"]; + $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; + $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; + $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; + $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; + $list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_']; + $list[0]['_agents_not_init'] += $list[$i]['_agents_not_init']; + + if ($mode == 'tactical') { + $list[0]['_agents_ok_'] += $group_stat[0]["normal"]; + $list[0]['_agents_warning_'] += $group_stat[0]["warning"]; + $list[0]['_agents_critical_'] += $group_stat[0]["critical"]; + $list[0]['_monitors_alerts_'] += $group_stat[0]["alerts"]; + } + } + + if ($mode == 'group') { + if (! defined ('METACONSOLE')) { + if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) { + unset($list[$i]); + } + } else { + if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) { + unset($list[$i]); + } + } + } + + } else { + $list[$i]['_id_'] = $id; + $list[$i]['_name_'] = $item['nombre']; + $list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;')); + + $list[$i]['_monitors_ok_'] = groups_monitor_ok($id, $user_strict, $id); + $list[$i]['_monitors_critical_'] = groups_monitor_critical($id, $user_strict, $id); + $list[$i]['_monitors_warning_'] = groups_monitor_warning($id, $user_strict, $id); + $list[$i]['_agents_unknown_'] = groups_agent_unknown ($id, $user_strict, $id); + $list[$i]['_monitors_alerts_fired_'] = groups_monitor_fired_alerts ($id, $user_strict, $id); + $list[$i]['_total_agents_'] = groups_agent_total ($id, $user_strict, $id); + $list[$i]['_monitors_unknown_'] = groups_monitor_unknown($id, $user_strict, $id); + $list[$i]['_monitors_not_init_'] = groups_monitor_not_init($id, $user_strict, $id); + $list[$i]['_agents_not_init_'] = groups_agent_not_init ($id, $user_strict, $id); + + if ($mode == 'tactical') { + $list[$i]['_agents_ok_'] = groups_agent_ok ($id, $user_strict, $id); + $list[$i]['_agents_warning_'] = groups_agent_warning ($id, $user_strict, $id); + $list[$i]['_agents_critical_'] = groups_agent_critical ($id, $user_strict, $id); + $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id); + + //~ $list[$i]["_total_checks_"] + //~ $list[$i]["_total_alerts_"] + + // Get total count of monitors for this group, except disabled. + $list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"]; + + // Calculate not_normal monitors + $list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"]; + + if ($list[$i]["_monitors_unknown_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_monitor_health_"] = 100; + } + + if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_module_sanity_"] = 100; + } + + if (isset($list[$i]["_alerts_"])) { + if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) { + $list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1); + } + else { + $list[$i]["_alert_level_"] = 100; + } + } + else { + $list[$i]["_alert_level_"] = 100; + $list[$i]["_alerts_"] = 0; + } + + $list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"]; + + if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) { + $list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1); + } + else { + $list[$i]["_global_health_"] = 100; + } + + $list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1); + } + + if ($returnAllGroup) { + $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; + $list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_']; + $list[0]['_total_agents_'] += $list[$i]['_total_agents_']; + $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; + $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; + $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; + $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; + $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; + $list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init']; + + if ($mode == 'tactical') { + $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; + $list[0]['_agents_warning_'] += $list[$i]['_agents_warning_']; + $list[0]['_agents_critical_'] += $list[$i]['_agents_critical_']; + $list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_']; + } + } + + if ($mode == 'group') { + if (! defined ('METACONSOLE')) { + if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) { + unset($list[$i]); + } + } else { + if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) { + unset($list[$i]); + } + } + } + } + $i++; + } + + if ($user_strict) { + foreach ($user_tags as $group_id => $tag_name) { + $id = db_get_value('id_tag', 'ttag', 'name', $tag_name); + + $list[$i]['_id_'] = $id; + $list[$i]['_name_'] = $tag_name; + $list[$i]['_iconImg_'] = html_print_image ("images/tag_red.png", true, array ("style" => 'vertical-align: middle;')); + $list[$i]['_is_tag_'] = 1; + + $list[$i]['_total_agents_'] = tags_total_agents ($id, $acltags); + $list[$i]['_agents_unknown_'] = tags_get_unknown_agents ($id, $acltags); + $list[$i]['_monitors_ok_'] = tags_monitors_ok ($id, $acltags); + $list[$i]['_monitors_critical_'] = tags_monitors_critical ($id, $acltags); + $list[$i]['_monitors_warning_'] = tags_monitors_warning ($id, $acltags); + $list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags); + + if ($mode == 'tactical') { + $list[$i]['_agents_ok_'] = tags_agent_ok ($id, $acltags); + $list[$i]['_agents_warning_'] = tags_agent_warning ($id, $acltags); + $list[$i]['_agents_critical_'] = tags_get_critical_agents ($id, $acltags); + $list[$i]['_monitors_alerts_'] = tags_get_monitors_alerts ($id, $acltags); + } + + + if ($returnAllGroup) { + $list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_']; + $list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_']; + $list[0]['_total_agents_'] += $list[$i]['_total_agents_']; + $list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_']; + $list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_']; + $list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_']; + $list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_']; + $list[0]['_monitors_not_init_'] = $list[$i]['_monitors_not_init_']; + + if ($mode == 'tactical') { + $list[0]['_agents_ok_'] += $list[$i]['_agents_ok_']; + $list[0]['_agents_warning_'] += $list[$i]['_agents_warning_']; + $list[0]['_agents_critical_'] += $list[$i]['_agents_critical_']; + $list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_']; + } + } + + if ($mode == 'group') { + if (! defined ('METACONSOLE')) { + if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) { + unset($list[$i]); + } + } else { + if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) { + unset($list[$i]); + } + } + } + $i++; + } + } + + return $list; +} + +function group_get_groups_list($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false, $mode = 'group') { + global $config; + + if ($id_user == false) { + $id_user = $config['id_user']; + } + + $acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict); + + if (! defined ('METACONSOLE')) { + $result_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode); + return $result_list; + } else { + $servers = db_get_all_rows_sql (" + SELECT * + FROM tmetaconsole_setup + WHERE disabled = 0"); + + if ($servers === false) { + $servers = array(); + } + + $result_list = array (); + foreach ($servers as $server) { + + if (metaconsole_connect($server) != NOERR) { + continue; + } + $server_list = group_get_data ($id_user, $user_strict, $acltags, $returnAllGroup, $mode); + + foreach ($server_list as $server_item) { + if (! isset ($result_list[$server_item['_name_']])) { + + $result_list[$server_item['_name_']] = $server_item; + } + else { + $result_list[$server_item['_name_']]['_monitors_ok_'] += $server_item['_monitors_ok_']; + $result_list[$server_item['_name_']]['_monitors_critical_'] += $server_item['_monitors_critical_']; + $result_list[$server_item['_name_']]['_monitors_warning_'] += $server_item['_monitors_warning_']; + $result_list[$server_item['_name_']]['_agents_unknown_'] += $server_item['_agents_unknown_']; + $result_list[$server_item['_name_']]['_total_agents_'] += $server_item['_total_agents_']; + $result_list[$server_item['_name_']]['_monitors_alerts_fired_'] += $server_item['_monitors_alerts_fired_']; + + if ($mode == 'tactical') { + $result_list[$server_item['_name_']]['_agents_ok_'] += $server_item['_agents_ok_']; + $result_list[$server_item['_name_']]['_agents_critical_'] += $server_item['_agents_critical_']; + $result_list[$server_item['_name_']]['_agents_warning_'] += $server_item['_agents_warning_']; + $result_list[$server_item['_name_']]['_monitors_alerts_'] += $server_item['_monitors_alerts_']; + + $result_list[$server_item['_name_']]["_monitor_checks_"] += $server_item["_monitor_checks_"]; + $result_list[$server_item['_name_']]["_monitor_not_normal_"] += $server_item["_monitor_not_normal_"]; + $result_list[$server_item['_name_']]["_monitor_health_"] += $server_item["_monitor_health_"]; + $result_list[$server_item['_name_']]["_module_sanity_"] += $server_item["_module_sanity_"]; + $result_list[$server_item['_name_']]["_alerts_"] += $server_item["_alerts_"]; + $result_list[$server_item['_name_']]["_alert_level_"] += $server_item["_alert_level_"]; + $result_list[$server_item['_name_']]["_monitor_bad_"] += $server_item["_monitor_bad_"]; + $result_list[$server_item['_name_']]["_global_health_"] += $server_item["_global_health_"]; + $result_list[$server_item['_name_']]["_server_sanity_"] += $server_item["_server_sanity_"]; + $result_list[$server_item['_name_']]["_monitor_alerts_fire_count_"] += $server_item["_monitor_alerts_fire_count_"]; + $result_list[$server_item['_name_']]["_total_checks_"] += $server_item["_total_checks_"]; + $result_list[$server_item['_name_']]["_total_alerts_"] += $server_item["_total_alerts_"]; + } + } + } + metaconsole_restore_db(); + + } + + return $result_list; + } +} + +function groups_get_group_deep ($id_group) { + global $config; + $parents = groups_get_parents($id_group, false); + + if (empty($parents)) { + $deep = ""; + } else { + $deep = str_repeat("    ", count($parents)); + } + + return $deep; +} ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 4360409e56..101e75a6cf 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -368,13 +368,36 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false, - $keys_field = 'id_grupo') { + $keys_field = 'id_grupo', $strict_user = false) { global $config; - + $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group, $keys_field); - + + if ($strict_user) { + foreach ($fields as $id => $group_name) { + $sql = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id"; + $group_has_tag = db_get_value_sql ($sql); + if (!$group_has_tag) { + + $sql_parent = "SELECT parent FROM tgrupo WHERE id_grupo = $id AND propagate = 1"; + $id_parent = db_get_value_sql($sql_parent); + + if ($id_parent) { + $sql_parent_aux = "SELECT tags FROM tusuario_perfil WHERE id_usuario = '$id_user' AND id_grupo = $id_parent"; + $parent_has_tag = db_get_value_sql ($sql_parent_aux); + + if ($parent_has_tag) { + unset($fields[$id]); + } + } + } else { + unset($fields[$id]); + } + } + } + $output = html_print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, false, $class, $disabled, $style, $option_style); @@ -1466,22 +1489,13 @@ function html_print_table (&$table, $return = false) { if (!isset ($style[$key])) { $style[$key] = ''; } - - $output .= '' . - $item . '' . "\n"; + + $output .= ''. $item .''."\n"; } - $output .= '' . "\n"; + $output .= ''."\n"; } } - $output .= '' . "\n"; + $output .= ''."\n"; if ($return) return $output; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 9f3bcb8853..c96f4e8808 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1563,7 +1563,7 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height) { return $output; } -function reporting_get_stats_alerts($data) { +function reporting_get_stats_alerts($data, $links = false) { global $config; // Link URLS @@ -1581,8 +1581,13 @@ function reporting_get_stats_alerts($data) { } else { $urls = array(); - $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; - $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + if ($links) { + $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&pure=" . $config['pure']; + $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure=" . $config['pure']; + } else { + $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; + $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; + } } // Alerts table @@ -8019,4 +8024,262 @@ function reporting_network_interfaces_table ($content, $report, $mini, $item_tit } } } -?> \ No newline at end of file + +function reporting_get_agents_by_status ($data, $graph_width = 250, $graph_height = 150, $links = false) { + global $config; + + if ($links == false) { + $links = array(); + } + + $table_agent = html_get_predefined_table(); + + $agent_data = array(); + $agent_data[0] = html_print_image('images/agent_critical.png', true, array('title' => __('Agents critical'))); + $agent_data[1] = "".format_numeric($data['agent_critical']).""; + $agent_data[2] = html_print_image('images/agent_warning.png', true, array('title' => __('Agents warning'))); + $agent_data[3] = "".format_numeric($data['agent_warning']).""; + + $table_agent->data[] = $agent_data; + + $agent_data = array(); + $agent_data[0] = html_print_image('images/agent_ok.png', true, array('title' => __('Agents ok'))); + $agent_data[1] = "".format_numeric($data['agent_ok']).""; + $agent_data[2] = html_print_image('images/agent_unknown.png', true, array('title' => __('Agents unknown'))); + $agent_data[3] = "".format_numeric($data['agent_unknown']).""; + $table_agent->data[] = $agent_data; + + $agent_data = array(); + $agent_data[0] = html_print_image('images/agent_notinit.png', true, array('title' => __('Agents not init'))); + $agent_data[1] = "".format_numeric($data['agent_not_init']).""; + $table_agent->data[] = $agent_data; + + $agents_data = '
+ ' . + __('Agents by status') . + '' . + html_print_table($table_agent, true) . '
'; + + return $agents_data; +} + +function reporting_get_total_agents_and_monitors ($data, $graph_width = 250, $graph_height = 150) { + global $config; + + $total_agent = $data['agent_ok'] + $data['agent_warning'] + $data['agent_critical'] + $data['gent_unknown'] + $data['agent_not_init']; + $total_module = $data['monitor_ok'] + $data['monitor_warning'] + $data['monitor_critical'] + $data['monitor_unknown'] + $data['monitor_not_init']; + + $table_total = html_get_predefined_table(); + + $total_data = array(); + $total_data[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents'))); + $total_data[1] = $total_agent <= 0 ? '-' : $total_agent; + $total_data[2] = html_print_image('images/module.png', true, array('title' => __('Monitor checks'))); + $total_data[3] = $total_module <= 0 ? '-' : $total_module; + $table_total->data[] = $total_data; + $total_agent_module = '
+ ' . + __('Total agents and monitors') . + '' . + html_print_table($table_total, true) . '
'; + + return $total_agent_module; +} + +function reporting_get_total_servers ($num_servers) { + global $config; + + $table_node = html_get_predefined_table(); + + $node_data = array(); + $node_data[0] = html_print_image('images/server_export.png', true, array('title' => __('Nodes'))); + $node_data[1] = "".format_numeric($num_servers).""; + $table_node->data[] = $node_data; + $node_overview = '
+ ' . + __('Node overview') . + '' . + html_print_table($table_node, true) . '
'; + return $node_overview; +} + +function reporting_get_events ($data, $links = false) { + global $config; + + $table_events->width = "100%"; + + $table_events->data[0][0] = html_print_image('images/agent_critical.png', true, array('title' => __('Critical events'))); + $table_events->data[0][0] .= "   "."".format_numeric($data['critical']).""; + + $table_events->data[0][1] = html_print_image('images/agent_warning.png', true, array('title' => __('Warning events'))); + $table_events->data[0][1] .= "   "."".format_numeric($data['warning']).""; + $table_events->data[0][2] = html_print_image('images/agent_ok.png', true, array('title' => __('OK events'))); + $table_events->data[0][2] .= "   "."".format_numeric($data['normal']).""; + $table_events->data[0][3] = html_print_image('images/agent_unknown.png', true, array('title' => __('Unknown events'))); + $table_events->data[0][3] .= "   "."".format_numeric($data['unknown']).""; + $table_events->data[0][4] = html_print_image('images/agent_notinit.png', true, array('title' => __('Not init events'))); + $table_events->data[0][4] .= "   "."".format_numeric($data['not_init']).""; + + $event_view = '
+ ' . + __('Events by criticity') . + '' . + html_print_table($table_events, true) . '
'; + + return $event_view; +} + +function reporting_get_last_activity() { + global $config; + + // Show last activity from this user + + $table->width = '100%'; + $table->data = array (); + $table->size = array (); + $table->size[2] = '150px'; + $table->size[3] = '130px'; + $table->size[5] = '200px'; + $table->head = array (); + $table->head[0] = __('User'); + $table->head[1] = ''; + $table->head[2] = __('Action'); + $table->head[3] = __('Date'); + $table->head[4] = __('Source IP'); + $table->head[5] = __('Comments'); + $table->title = '' . __('Last activity in Pandora FMS console') . ''; + + switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ("SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp + FROM tsesion + WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - " . SECONDS_1WEEK . ") + AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 5", $config["id_user"]); + break; + case "postgresql": + $sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion, utimestamp + FROM tsesion + WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . ") + AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 5", $config["id_user"]); + break; + case "oracle": + $sql = sprintf ("SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp + FROM tsesion + WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_1WEEK . ") + AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]); + break; + } + + $sessions = db_get_all_rows_sql ($sql); + + if ($sessions === false) + $sessions = array (); + + foreach ($sessions as $session) { + $data = array (); + + switch ($config["dbtype"]) { + case "mysql": + case "oracle": + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; + break; + case "postgresql": + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; + break; + } + + + $data[0] = '' . $session_id_usuario . ''; + $data[1] = ui_print_session_action_icon ($session['accion'], true); + $data[2] = $session['accion']; + $data[3] = ui_print_help_tip($session['fecha'], true) . human_time_comparation($session['utimestamp'], 'tiny'); + $data[4] = $session_ip_origen; + $data[5] = io_safe_output ($session['descripcion']); + + array_push ($table->data, $data); + } + + return html_print_table ($table, true); + +} + +function reporting_get_event_histogram ($events) { + global $config; + include_once ('../../include/graphs/functions_gd.php'); + $max_value = count($events); + + $ttl = 1; + $urlImage = ui_get_full_url(false, true, false, false); + + $colors = array( + EVENT_CRIT_MAINTENANCE => COL_MAINTENANCE, + EVENT_CRIT_INFORMATIONAL => COL_INFORMATIONAL, + EVENT_CRIT_NORMAL => COL_MINOR, + EVENT_CRIT_MINOR => COL_NORMAL, + EVENT_CRIT_WARNING => COL_WARNING, + EVENT_CRIT_MAJOR => COL_MAJOR, + EVENT_CRIT_CRITICAL => COL_CRITICAL + ); + + foreach ($events as $data) { + + switch ($data['criticity']) { + case 0: + $color = EVENT_CRIT_MAINTENANCE; + break; + case 1: + $color = EVENT_CRIT_INFORMATIONAL; + break; + case 2: + $color = EVENT_CRIT_NORMAL; + break; + case 3: + $color = EVENT_CRIT_WARNING; + break; + case 4: + $color = EVENT_CRIT_CRITICAL; + break; + case 5: + $color = EVENT_CRIT_MINOR; + break; + case 6: + $color = EVENT_CRIT_MAJOR; + break; + case 20: + $color = EVENT_CRIT_NOT_NORMAL; + break; + case 34: + $color = EVENT_CRIT_WARNING_OR_CRITICAL; + break; + } + $graph_data[] = array( + 'data' => $color, + 'utimestamp' => 1 + ); + } + + $table->width = '100%'; + $table->data = array (); + $table->size = array (); + $table->head = array (); + $table->title = '' . __('Events info (1hr.)') . ''; + $table->data[0][0] = "" ; + + if (!empty($graph_data)) { + $slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl); + $table->data[0][0] = $slicebar; + } else { + $table->data[0][0] = __('No events'); + } + + $event_graph = '
+ ' . + __('Events info (1hr)') . + '' . + html_print_table($table, true) . '
'; + + return $event_graph; +} +?> diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index c7ad68050e..809f366a1f 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -62,18 +62,40 @@ function tags_agent_unknown ($id_tag) { * * @return mixed Returns count of agents with this tag or false if they aren't. */ -function tags_total_agents ($id_tag) { +function tags_total_agents ($id_tag, $groups_and_tags = array()) { // Avoid mysql error if (empty($id_tag)) return; + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + } + $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo - AND ttag_module.id_tag = " . $id_tag; - + AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo + AND ttag_module.id_tag = " . $id_tag . + $groups_clause; + return db_get_sql ($total_agents); } @@ -84,15 +106,37 @@ function tags_total_agents ($id_tag) { * * @return mixed Returns count of agents in normal status or false if they aren't. */ -function tags_agent_ok ($id_tag) { - +function tags_agent_ok ($id_tag, $groups_and_tags = array()) { + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + } + return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente.disabled=0 AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = $id_tag - AND normal_count=total_count"); + AND normal_count=total_count + $groups_clause"); } /** @@ -102,7 +146,7 @@ function tags_agent_ok ($id_tag) { * * @return mixed Returns count of agents in warning status or false if they aren't. */ -function tags_agent_warning ($id_tag) { +function tags_agent_warning ($id_tag, $groups_and_tags = array()) { return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module @@ -197,13 +241,13 @@ function tags_create_tag($values) { if (empty($values)) { return false; } - - //No create tag if the tag exists + + //No create tag if the tag exists if (tags_get_id($values["name"])) { return false; } - return db_process_sql_insert('ttag', $values); + return db_process_sql_insert('ttag',$values); } /** @@ -417,8 +461,7 @@ function tags_insert_policy_module_tag ($id_agent_module, $tags) { $values['id_tag'] = $tag; $values['id_policy_module'] = $id_agent_module; - $result_tag = db_process_sql_insert('ttag_policy_module', - $values, false); + $result_tag = db_process_sql_insert('ttag_policy_module', $values, false); if ($result_tag === false) $errn++; } @@ -664,10 +707,7 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) { * @return mixed/string Tag ids */ -function tags_get_acl_tags($id_user, $id_group, $access = 'AR', - $return_mode = 'module_condition', $query_prefix = '', - $query_table = '', $meta = false, $childrens_ids = array(), - $force_group_and_tag = false) { +function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '', $meta = false, $childrens_ids = array(), $force_group_and_tag = false) { global $config; @@ -687,6 +727,10 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', } } + if ($id_group[0] != 0) { + $id_group = groups_get_all_hierarchy_group ($id_group[0]); + } + if ((string)$id_group === "0") { $id_group = array_keys(users_get_groups($id_user, $access, false)); @@ -701,10 +745,6 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $id_group = (array) $id_group; } - if ($id_group[0] != 0) { - $id_group = groups_get_all_hierarchy_group ($id_group[0]); - } - $acl_column = get_acl_column($access); if (empty($acl_column)) { @@ -719,7 +759,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', (tusuario_perfil.id_grupo IN (%s) OR tusuario_perfil.id_grupo = 0) ORDER BY id_grupo", $id_user, $acl_column, implode(',',$id_group)); $tags = db_get_all_rows_sql($query); - + // If not profiles returned, the user havent acl permissions if (empty($tags)) { return ERR_ACL; @@ -784,7 +824,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', break; case 'module_condition': // Return the condition of the tags for tagente_modulo table - $condition = tags_get_acl_tags_module_condition($acltags, $query_table); + $condition = tags_get_acl_tags_module_condition($acltags, $query_table, true); if (!empty($condition)) { return " $query_prefix " . $condition; } @@ -827,10 +867,6 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { if ($i == 0) $condition .= ' ( '; - - - - // Group condition (The module belongs to an agent of the group X) // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition if (!array_key_exists(0, $acltags)) { @@ -841,21 +877,23 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { //Avoid the user profiles with all group access. $group_condition = " 1 = 1 "; } - - + //When the acl is only group without tags if (empty($group_tags)) { $condition .= "($group_condition)\n"; } else { + if (is_array($group_tags)) { + $group_tags_query = implode(',',$group_tags); + } else { + $group_tags_query = $group_tags; + } // Tags condition (The module has at least one of the restricted tags) - $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags)); + $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query); $condition .= "($group_condition AND \n$tags_condition)\n"; } - - - + $i++; } @@ -903,6 +941,10 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group if (empty($group_tags)) { $tags_condition = "id_grupo = ".$group_id; } else { + if (!is_array($group_tags)) { + $group_tags = explode(',', $group_tags); + } + foreach ($group_tags as $tag) { // If the tag ID doesnt exist, ignore if (!isset($all_tags[$tag])) { @@ -1008,14 +1050,14 @@ function tags_has_user_acl_tags($id_user = false) { */ function tags_get_user_tags($id_user = false, $access = 'AR') { global $config; - + if ($id_user === false) { $id_user = $config['id_user']; } // Get all tags to have the name of all of them $all_tags = tags_get_all_tags(); - + // If at least one of the profiles of this access flag hasent // tags restrictions, the user can see all tags $acl_column = get_acl_column($access); @@ -1023,23 +1065,23 @@ function tags_get_user_tags($id_user = false, $access = 'AR') { if(empty($acl_column)) { return array(); } - + $query = sprintf("SELECT count(*) FROM tusuario_perfil, tperfil WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND tusuario_perfil.id_usuario = '%s' AND - tperfil.%s = 1 AND tags = ''", + tperfil.%s = 1 AND tags <> ''", $id_user, $acl_column); $profiles_without_tags = db_get_value_sql($query); - if ($profiles_without_tags > 0) { + if ($profiles_without_tags == 0) { return $all_tags; } - + // Get the tags of the required access flag for each group - $tags = tags_get_acl_tags($id_user, 0, $access, 'data'); - + $tags = tags_get_acl_tags($id_user, 0, $access, 'data','','', true, array(), true); + // Merge the tags to get an array with all of them $user_tags_id = array(); @@ -1358,4 +1400,430 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c return false; } + +/** + * Get unknown agents filtering by id_tag. + * + * @param int $id_tag Id of the tag to search unknown agents + * + * @return mixed Returns count of unknown agents with this tag or false if they aren't. + */ +function tags_get_unknown_agents ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + } + + $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) + FROM tagente, tagente_modulo, ttag_module + WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo + AND ttag_module.id_tag = " . $id_tag . " + AND tagente.critical_count=0 + AND tagente.warning_count=0 + AND tagente.unknown_count>0 + $groups_clause"; + + return db_get_sql ($total_agents); +} + +function tags_monitors_ok ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND id_grupo IN ($groups_id)"; + } + + $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 0 + AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente + WHERE disabled = 0 + $groups_clause) + AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module + WHERE ttag_module.id_tag = " . $id_tag .")"; + + $count = db_get_sql ($sql); + + return $count; +} + +function tags_monitors_critical ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND id_grupo IN ($groups_id)"; + } + + $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 1 + AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente + WHERE disabled = 0 + $groups_clause) + AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module + WHERE ttag_module.id_tag = " . $id_tag .")"; + + $count = db_get_sql ($sql); + + return $count; +} + +function tags_monitors_warning ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND id_grupo IN ($groups_id)"; + } + + $sql = "SELECT COUNT(*) FROM tagente_modulo, tagente_estado + WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo + AND tagente_estado.estado = 2 + AND tagente_modulo.id_agente IN (SELECT id_agente FROM tagente + WHERE disabled = 0 + $groups_clause) + AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module + WHERE ttag_module.id_tag = " . $id_tag .")"; + + $count = db_get_sql ($sql); + + return $count; +} + +function tags_monitors_fired_alerts ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + } + + $sql = "SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo + AND times_fired > 0 + AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) + $groups_clause"; + + $count = db_get_sql ($sql); + + return $count; +} + +/* Return array with groups and their tags */ +function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $strict_user = false) { + global $config; + + if ($id_user == false) { + $id_user = $config['id_user']; + } + + $acl_column = get_acl_column($access); + + $query = sprintf("SELECT tags, id_grupo + FROM tusuario_perfil, tperfil + WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND + tusuario_perfil.id_usuario = '%s' AND + tperfil.%s = 1 + ORDER BY id_grupo", $id_user, $acl_column); + $tags_and_groups = db_get_all_rows_sql($query); + + if ($tags_and_groups == false) { + $tags_and_groups = array(); + } + + $acltags = array(); + + if ((count($tags_and_groups) == 1) && ($tags_and_groups[0]['id_grupo'] == 0) && ($tags_and_groups[0]['tags'] == '')){ //user with all groups without tags + $all_groups = groups_get_all(); + + foreach ($all_groups as $id => $name) { + $acltags[$id] = ''; + } + } else { + foreach ($tags_and_groups as $group_tag) { + $acltags[$group_tag['id_grupo']] = $group_tag['tags']; + $propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group_tag['id_grupo']); + + if ($propagate) { + $sql = "SELECT id_grupo FROM tgrupo WHERE parent = " .$group_tag['id_grupo']; + $children = db_get_all_rows_sql($sql); + + if ($children == false) { + $children = array(); + } + foreach ($children as $group) { + $acltags[$group['id_grupo']] = $group_tag['tags']; + } + } + } + } + + return $acltags; +} + +/** + * Get unknown agents filtering by id_tag. + * + * @param int $id_tag Id of the tag to search unknown agents + * + * @return mixed Returns count of unknown agents with this tag or false if they aren't. + */ +function tags_get_critical_agents ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + } + + $total_agents = "SELECT COUNT(DISTINCT tagente.id_agente) + FROM tagente, tagente_modulo, ttag_module + WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo + AND ttag_module.id_tag = " . $id_tag . " + AND tagente.critical_count>0 + $groups_clause"; + + return db_get_sql ($total_agents); +} + +function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) { + + // Avoid mysql error + if (empty($id_tag)) + return; + + $groups_clause = ""; + if (!empty($groups_and_tags)) { + $i = 0; + foreach ($groups_and_tags as $group_id => $tags) { + if ($tags != "") { + $tags_arr = explode(',', $tags); + foreach ($tags_arr as $tag) { + if ($tag == $id_tag) { + if ($i == 0) { + $groups_id = $group_id; + } else { + $groups_id .= ','.$group_id; + } + $i++; + } + } + } + } + $groups_clause = " AND tagente.id_grupo IN ($groups_id)"; + } + + $sql = "SELECT COUNT(talert_template_modules.id) + FROM talert_template_modules, tagente_modulo, tagente_estado, tagente + WHERE tagente_modulo.id_agente = tagente.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND talert_template_modules.disabled = 0 + AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo + AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) + $groups_clause"; + + $count = db_get_sql ($sql); + + return $count; +} + +/** + * Get agents filtering by id_tag. + * + * @param int $id_tag Id of the tag to search total agents + * + * @return mixed Returns count of agents with this tag or false if they aren't. + */ +function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) { + + global $config; + + // Avoid mysql error + if (empty($id_tag)) + return; + + if (empty($id_user)) { + $id_user = $config['id_user']; + } + + if (!is_array ($fields)) { + $fields = array (); + $fields[0] = "id_agente"; + $fields[1] = "nombre"; + } + $select_fields = implode(',',$fields); + + $groups_clause = ""; + if ($strict_user) { + if (!empty($groups_and_tags)) { + $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); + } + } else { + $groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")"; + } + + $search_sql = ""; + $void_agents = ""; + if ($filter) { + if (($filter['search']) != "") { + $string = io_safe_input ($filter['search']); + $search_sql = ' AND (tagente.nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")'; + } + + if (isset($filter['show_void_agents'])) { + if (!$filter['show_void_agents']) { + $void_agents = " AND tagente_modulo.delete_pending = 0"; + } + } + } + + $user_agents_sql = "SELECT ".$select_fields ." + FROM tagente, tagente_modulo, ttag_module + WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo + AND ttag_module.id_tag = " . $id_tag . + $groups_clause . $search_sql . $void_agents . + " ORDER BY tagente.nombre ASC"; + + //return db_get_sql ($user_agents); + $user_agents = db_get_all_rows_sql($user_agents_sql); + + if (!$meta){ + $user_agents_aux = array(); + if ($user_agents === false) { + $user_agents = array(); + } + foreach ($user_agents as $ua) { + $user_agents_aux[$ua['id_agente']] = $ua['nombre']; + } + return $user_agents_aux; + } + return $user_agents; +} ?> diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 04d992d16f..3808debb93 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -140,13 +140,13 @@ function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGro function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null, $keys_field = 'id_grupo') { if (empty ($id_user)) { global $config; - + $id_user = null; if (isset($config['id_user'])) { $id_user = $config['id_user']; } } - + if (isset($id_groups)) { //Get recursive id groups $list_id_groups = array(); @@ -161,11 +161,12 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup else { $groups = db_get_all_rows_in_table ('tgrupo', 'parent, nombre'); } - + $user_groups = array (); - if (!$groups) + if (!$groups) { return $user_groups; + } if ($returnAllGroup) { //All group if ($returnAllColumns) { @@ -180,7 +181,7 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup // Add the All group to the beginning to be always the first array_unshift($groups, $groupall); } - + foreach ($groups as $group) { if ($privilege === false) { if ($returnAllColumns) { @@ -199,7 +200,7 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup } } } - + return $user_groups; } diff --git a/pandora_console/operation/agentes/alerts_status.functions.php b/pandora_console/operation/agentes/alerts_status.functions.php index d60cbb1379..fd3dbca8a7 100755 --- a/pandora_console/operation/agentes/alerts_status.functions.php +++ b/pandora_console/operation/agentes/alerts_status.functions.php @@ -34,13 +34,17 @@ function validateAlert() { } } -function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $return = false) { +function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $tag_filter = false, $return = false, $strict_user = false) { + + global $config; + require_once ($config['homedir'] . "/include/functions_tags.php"); + $table->width = '100%'; $table->data = array (); $table->style = array (); $table->data[0][0] = __('Group'); - $table->data[0][1] = html_print_select_groups(false, "AR", true, "ag_group", $id_group, '', '', '', true); + $table->data[0][1] = html_print_select_groups($config['id_user'], "AR", true, "ag_group", $id_group, '', '', '', true, false, false, '', false, '', false, false, 'id_grupo', $strict_user); $alert_status_filter = array(); $alert_status_filter['all_enabled'] = __('All (Enabled)'); @@ -56,7 +60,18 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st $table->data[0][2] = __('Status'); $table->data[0][3] = html_print_select ($alert_status_filter, "filter", $filter, '', '', '', true); - $table->data[0][4] = ''; + + $table->data[0][4] = __('Tags') . ui_print_help_tip(__('Only it is show tags in use.'), true); + + $tags = tags_get_user_tags(); + + if (empty($tags)) { + $table->data[0][4] .= __('No tags'); + } + else { + $table->data[0][4] .= html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', true, false, true, '', false, 'width: 150px;'); + } + $table->data[1][0] = __('Free text for search') . ui_print_help_tip( __("Filter by agent name, module name, template name or action name"), diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index a66c846c1b..3754eecd0f 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -38,11 +38,19 @@ require_once ($config['homedir'] . '/include/functions_users.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); +$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + $filter = get_parameter ("filter", "all_enabled"); $filter_standby = get_parameter ("filter_standby", "all"); $offset_simple = (int) get_parameter_get ("offset_simple", 0); $id_group = (int) get_parameter ("ag_group", 0); //0 is the All group (selects all groups) $free_search = get_parameter("free_search", ''); +$tag_filter = get_parameter("tag_filter", 0); +if ($tag_filter) { + if ($id_group && $strict_user) { + $tag_filter = 0; + } +} $sec2 = get_parameter_get ('sec2'); $sec2 = safe_url_extraclean ($sec2); @@ -56,11 +64,12 @@ $tab = get_parameter_get ("tab", null); $refr = (int)get_parameter('refr', 0); $pure = get_parameter('pure', 0); + $url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr . '&filter=' . $filter . '&filter_standby=' . $filter_standby . - '&ag_group=' . $id_group; + '&ag_group=' . $id_group .'&tag_filter=' .$tag_filter; -if (($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) || ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "LM"))) { +if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, "AW")) { forceExecution($id_group); } @@ -122,11 +131,11 @@ else { } if ($alert_validate) { - if (check_acl ($config["id_user"], $id_group, "AW") || check_acl ($config["id_user"], $id_group, "LM") ) { - validateAlert(); + if (check_acl ($config["id_user"], $id_group, "AW") == 0) { + ui_print_error_message(__('Insufficient permissions to validate alerts')); } else { - ui_print_error_message(__('Insufficient permissions to validate alerts')); + validateAlert(); } } @@ -325,48 +334,32 @@ else { if (defined('METACONSOLE')) { require_once ($config['homedir'] . '/enterprise/meta/include/functions_alerts_meta.php'); if ($idAgent != 0) { - $alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, - $filter_alert, $options_simple, $whereAlertSimple, false, false, - $idGroup); - - - $countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, - false, $whereAlertSimple, false, false, $idGroup, true); + $alerts['alerts_simple'] = alerts_meta_get_alerts ($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user); + + $countAlertsSimple = alerts_meta_get_alerts ($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user); } else { $id_groups = array_keys( users_get_groups($config["id_user"], 'AR', false)); + + $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); - $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, - $filter_alert, $options_simple, $whereAlertSimple, false, - false, $idGroup); - - $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, - $filter_alert, false, $whereAlertSimple, false, false, - $idGroup, true); + $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); } } else { if ($idAgent != 0) { - $alerts['alerts_simple'] = agents_get_alerts_simple ($idAgent, - $filter_alert, $options_simple, $whereAlertSimple, false, false, - $idGroup); + $alerts['alerts_simple'] = agents_get_alerts_simple ($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); - $countAlertsSimple = agents_get_alerts_simple ($idAgent, - $filter_alert, false, $whereAlertSimple, false, false, - $idGroup, true); + $countAlertsSimple = agents_get_alerts_simple ($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); } else { $id_groups = array_keys( users_get_groups($config["id_user"], 'AR', false)); - $alerts['alerts_simple'] = get_group_alerts($id_groups, - $filter_alert, $options_simple, $whereAlertSimple, false, - false, $idGroup); + $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); - $countAlertsSimple = get_group_alerts($id_groups, - $filter_alert, false, $whereAlertSimple, false, false, - $idGroup, true); + $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); } } @@ -381,10 +374,7 @@ if ($pure) { // Filter form if ($print_agent) { echo '
'; - ui_toggle( - printFormFilterAlert( - $id_group, $filter, $free_search, $url, $filter_standby, true), - __('Alert control filter'), __('Toggle filter(s)')); + ui_toggle(printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby, $tag_filter, true, $strict_user),__('Alert control filter'), __('Toggle filter(s)')); } $table->width = '100%'; @@ -428,26 +418,14 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { // Sort buttons are only for normal console if (!defined('METACONSOLE')) { $table->head[3] .= ' ' . - '' . - html_print_image("images/sort_up.png", true, - array("style" => $selectAgentUp)) . '' . - '' . - html_print_image("images/sort_down.png", true, - array("style" => $selectAgentDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectAgentUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectAgentDown)) . ''; $table->head[4] .= ' ' . - '' . - html_print_image("images/sort_up.png", true, - array("style" =>$selectModuleUp)) . '' . - '' . - html_print_image("images/sort_down.png", true, - array("style" => $selectModuleDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" =>$selectModuleUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . ''; $table->head[5] .= ' ' . - '' . - html_print_image("images/sort_up.png", true, - array("style" =>$selectTemplateUp)) . '' . - '' . - html_print_image("images/sort_down.png", true, - array("style" => $selectTemplateDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" =>$selectTemplateUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . ''; } } else { @@ -477,19 +455,11 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { // Sort buttons are only for normal console if (!defined('METACONSOLE')) { $table->head[3] .= ' ' . - '' . - html_print_image("images/sort_up.png", true, - array("style" => $selectModuleUp)) . '' . - '' . - html_print_image("images/sort_down.png", true, - array("style" => $selectModuleDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectModuleUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleDown)) . ''; $table->head[4] .= ' ' . - '' . - html_print_image("images/sort_up.png", true, - array("style" => $selectTemplateUp)) . '' . - '' . - html_print_image("images/sort_down.png", true, - array("style" => $selectTemplateDown)) . ''; + '' . html_print_image("images/sort_up.png", true, array("style" => $selectTemplateUp)) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectTemplateDown)) . ''; } } } @@ -584,7 +554,7 @@ if (!empty ($table->data)) { html_print_table ($table); if (!defined('METACONSOLE')) { - if (check_acl ($config["id_user"], $id_group, "AW") || check_acl ($config["id_user"], $id_group, "LM") ) { + if (check_acl ($config["id_user"], $id_group, "AW")) { if (count($alerts['alerts_simple']) > 0) { echo '
'; html_print_submit_button (__('Validate'), 'alert_validate', false, 'class="sub ok"', false); @@ -599,6 +569,17 @@ else { echo '
'.__('No alerts found').'
'; } +//strict user hidden +echo ''; + enterprise_hook('close_meta_frame'); @@ -615,5 +596,32 @@ $(document).ready (function () { }).click (function () { return false; }); + + if ($('#ag_group').val() != 0) { + $("#tag_filter").css('display', 'none'); + $("#table2-0-4").css('display', 'none'); + } +}); + + +$('#ag_group').change (function (){ + strict_user = $("#text-strict_user_hidden").val(); + is_meta = $("#text-is_meta_hidden").val(); + + if (($("#ag_group").val() != 0) && (strict_user != 0)) { + $("#tag_filter").css('display', 'none'); + if (is_meta) { + $("#table1-0-4").css('display', 'none'); + } else { + $("#table2-0-4").css('display', 'none'); + } + } else { + $("#tag_filter").css('display', ''); + if (is_meta) { + $("#table1-0-4").css('display', ''); + } else { + $("#table2-0-4").css('display', ''); + } + } }); diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 00a027de51..e9aa423179 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -52,93 +52,228 @@ if (isset ($_GET["update_netgroup"])) { } } -// Get group list that user has access -$groups_full = users_get_groups ($config['id_user'], "AR", true, true); - -$groups = array(); -foreach ($groups_full as $group) { - $groups[$group['id_grupo']]['name'] = $group['nombre']; - $groups[$group['id_grupo']]['parent'] = $group['parent']; - - if ($group['id_grupo'] != 0) { - $groups[$group['parent']]['childs'][] = $group['id_grupo']; - $groups[$group['id_grupo']]['prefix'] = $groups[$group['parent']]['prefix'].'   '; - } - else { - $groups[$group['id_grupo']]['prefix'] = ''; - } - - if (!isset($groups[$group['id_grupo']]['childs'])) { - $groups[$group['id_grupo']]['childs'] = array(); - } -} - -if ($config["realtimestats"] == 0) { - $updated_time = __('Last update') . " : " . - ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); -} -else { - $updated_time = __("Updated at realtime"); -} - // Header ui_print_page_header (__("Group view"), "images/group.png", false, "", false, $updated_time ); -if (tags_has_user_acl_tags()) { - ui_print_tags_warning(); + +$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); +//Groups and tags +$result_groups = group_get_groups_list($config['id_user'], $strict_user, 'AR', true, true); + +$count = count($result_groups); + +if ($count == 1) { + if ($result_groups[0]['_id_'] == 0) { + unset($result_groups[0]); + } } +ui_pagination($count); -// Init vars -$groups_info = array (); -$counter = 1; +if (!empty($result_groups)) { -$agents = agents_get_group_agents(array_keys($groups)); - -$offset = (int)get_parameter('offset', 0); - -if (count($agents) > 0) { - $groups_get_groups_with_agent = groups_get_groups_with_agent($config['id_user'], "AR", true, true); - ui_pagination(count($groups_get_groups_with_agent)); - echo ''; - echo ""; - echo ""; - //echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - $printed_groups = array(); - - // For each valid group for this user, take data from agent and modules - $table_rows = array(); - foreach ($groups as $id_group => $group) { - $rows = groups_get_group_row($id_group, $groups, $group, $printed_groups); - if (!is_array_empty($rows)) { - $table_rows += $rows; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + foreach ($result_groups as $data) { + + // Calculate entire row color + if ($data["_monitors_alerts_fired_"] > 0){ + $color_class = 'group_view_alrm'; + $status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true); + } + elseif ($data["_monitors_critical_"] > 0) { + $color_class = 'group_view_crit'; + $status_image = ui_print_status_image ('agent_critical_ball.png', "", true); + } + elseif ($data["_monitors_warning_"] > 0) { + $color_class = 'group_view_warn'; + $status_image = ui_print_status_image ('agent_warning_ball.png', "", true); + } + elseif (($data["_monitors_unknown_"] > 0) || ($data["_agents_unknown_"] > 0)) { + $color_class = 'group_view_unk'; + $status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true); + } + elseif ($data["_monitors_ok_"] > 0) { + $color_class = 'group_view_ok'; + $status_image = ui_print_status_image ('agent_ok_ball.png', "", true); + } + else { + $color_class = ''; + $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true); + } + + echo ""; + + // Force + echo ""; + + $prefix = ""; + if (!isset($data['_is_tag_'])) { + if ($data['_id_'] != 0) { + $prefix = '    '; + } + } + + // Groupname + echo ""; + + // Total agents + echo ""; + + // Agents unknown + echo ""; + + // Agents not init + echo ""; + + // Monitors unknown + echo ""; + + // Monitors not init + echo ""; + + // Monitors OK + echo ""; + + // Monitors Warning + echo ""; + + // Monitors Critical + echo ""; + + // Alerts fired + echo "'; + + echo ""; } - } - - $table_rows = array_slice($table_rows, $offset, $config['block_size']); - foreach ($table_rows as $row) { - echo $row; - } - - echo "
" . __("Force") . "" . __("Status") . "" . __("Group") . "" . __("Agents") . "" . __("Agent unknown") . "" . __("Agents not init") . "" . __("Unknown") . "" . __("Not Init") . "" . __("Normal") . "" . __("Warning") . "" . __("Critical") . "" . __("Alert fired") . "
" . __("Force") . "" . __("Group") . "" . __("Agents") . "" . __("Agent unknown") . "" . __("Agents not init") . "" . __("Unknown") . "" . __("Not Init") . "" . __("Normal") . "" . __("Warning") . "" . __("Critical") . "" . __("Alert fired") . "
"; + if (check_acl ($config['id_user'], $id_group, "AW")) { + echo '' . + html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . ''; + } + echo ""; + if (isset($data['_is_tag_'])) { + $deep = ""; + $link = ""; + } else { + $deep = groups_get_group_deep ($data['_id_']); + $link = ""; + } + + $group_name = "" . ui_print_truncate_text($data['_name_'], 50) . ""; + + echo $link . $deep . $data['_iconImg_'] ." " . $group_name . ""; + + echo ""; + if (isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_total_agents_"] > 0) { + echo $link . $data["_total_agents_"] . ""; + } + echo ""; + if (isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_agents_unknown_"] > 0) { + echo $link . $data["_agents_unknown_"] . ""; + } + echo ""; + if (isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_agents_not_init_"] > 0) { + echo $link . $data["_agents_not_init_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_unknown_"] > 0) { + echo $link . $data["_monitors_unknown_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_not_init_"] > 0) { + echo $link . $data["_monitors_not_init_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_ok_"] > 0) { + echo $link . $data["_monitors_ok_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_warning_"] > 0) { + echo $link . $data["_monitors_warning_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_critical_"] > 0) { + echo $link . $data["_monitors_critical_"] . ""; + } + echo ""; + if (!isset($data['_is_tag_'])) { + $link = ""; + } else { + $link = ""; + } + if ($data["_monitors_alerts_fired_"] > 0){ + echo $link . $data["_monitors_alerts_fired_"] . ""; + } + echo '
"; - - ui_pagination(count($groups_get_groups_with_agent)); -} -else { + echo ''; +} else { echo "
" . __('There are no defined agents') . "
"; } - ?> - diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 15c81ec908..03d1e855c1 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -34,6 +34,8 @@ enterprise_include_once ('include/functions_metaconsole.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); +$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + if (! defined ('METACONSOLE')) { //Header ui_print_page_header (__("Monitor detail"), "images/brick.png", false); @@ -43,8 +45,6 @@ else { ui_meta_print_header(__("Monitor view")); } - - $ag_freestring = get_parameter ('ag_freestring'); $ag_modulename = (string) get_parameter ('ag_modulename'); if (!defined('METACONSOLE')) { @@ -68,6 +68,11 @@ $offset = (int) get_parameter ('offset', 0); $status = (int) get_parameter ('status', 4); $modulegroup = get_parameter ('modulegroup', -1); $tag_filter = get_parameter('tag_filter', 0); +if ($tag_filter) { + if ($ag_group && $strict_user) { + $tag_filter = 0; + } +} $refr = get_parameter('refr', 0); // Sort functionality @@ -108,6 +113,7 @@ else { $id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group); } + // Agent group selector if (!defined('METACONSOLE')) { if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) { @@ -119,8 +125,9 @@ if (!defined('METACONSOLE')) { } } else { + if ($ag_group != "0" && check_acl ($config["id_user"], $id_ag_group, "AR")) { - $sql_conditions_group = sprintf (" AND tagente.id_grupo IN ( SELECT id_grupo FROM tgrupo where nombre = '%s') ", $ag_group); + $sql_conditions_group = sprintf (" AND tagente.id_grupo IN (%s) ", $ag_group); } elseif ($user_groups != '') { // User has explicit permission on group 1 ? @@ -200,7 +207,7 @@ if ($tag_filter !== 0) { $sql_conditions .= " AND tagente_modulo.id_agente_modulo IN ( SELECT ttag_module.id_agente_modulo FROM ttag_module - WHERE ttag_module.id_tag IN (SELECT id_tag FROM ttag where name LIKE '%" . $tag_filter . "%') + WHERE ttag_module.id_tag IN ($tag_filter) )"; } else { @@ -213,14 +220,13 @@ if ($tag_filter !== 0) { } } -if (defined('METACONSOLE') && $ag_group !== 0) { - $ag_group = groups_get_id($ag_group); -} - // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) $groups = users_get_groups($config["id_user"]); - -$sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo'); +if ($ag_group !== 0) { + $sql_conditions_tags = tags_get_acl_tags($config['id_user'], $ag_group, 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); +} else { + $sql_conditions_tags = tags_get_acl_tags($config['id_user'], array_keys($groups), 'AR', 'module_condition', 'AND', 'tagente_modulo', true, array(), true); +} if (is_numeric($sql_conditions_tags)) { $sql_conditions_tags = ' AND 1 = 0'; @@ -230,6 +236,11 @@ if (is_numeric($sql_conditions_tags)) { $sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields; $sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_tags . $sql_conditions_custom_fields; +if (!$strict_user) { + $sql_conditions_all = $sql_conditions_base . $sql_conditions . $sql_conditions_group . $sql_conditions_custom_fields; + $sql_conditions_acl = $sql_conditions_base . $sql_conditions_group . $sql_conditions_custom_fields; +} + // Get count to paginate if (!defined('METACONSOLE')) $count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) " . $sql_from . $sql_conditions_all); @@ -334,22 +345,7 @@ if (defined('METACONSOLE')) { // Get all info for filters of all nodes $modules_temp = db_get_all_rows_sql($sql); - - # Fix : only user tags have to be shown in these component - $_tags = tags_get_user_tags(); - - - if (!empty($_tags)) { - foreach ($_tags as $_tag) { - - $tags_temp[]['name'] = $_tag; - - } - - } - - $rows_temp = db_get_all_rows_sql("SELECT distinct name FROM tmodule_group ORDER BY name"); @@ -377,8 +373,6 @@ if (defined('METACONSOLE')) { if (!empty($modules_temp)) $modules = array_merge($modules, $modules_temp); - if (!empty($tags_temp)) - $tags = array_merge($tags, $tags_temp); metaconsole_restore_db(); } @@ -388,28 +382,17 @@ if (defined('METACONSOLE')) { unset($groups_select[$key_group_all]); } -if (!defined('METACONSOLE')) { - echo ' - ' . __('Group') . ' - ' . - html_print_select_groups(false, "AR", true, "ag_group", - $ag_group, '', '', '0', true, false, false, 'w130', - false, 'width:150px;') . ' - '; -} -else { - echo ' - ' . __('Group') . ' - ' . - html_print_select($groups_select, "ag_group", - io_safe_output($ag_group_metaconsole), '', __('All'), '0', true, false, false, 'w130', - false, 'width:150px;') . ' - '; -} +echo ' +' . __('Group') . ' +' . + html_print_select_groups($config['id_user'], "AR", true, "ag_group", + $ag_group, '', '', '0', true, false, false, 'w130', + false, 'width:150px;', false, false, + 'id_grupo', $strict_user) . ' +'; + echo '' . __('Monitor status') . ""; - - echo ""; $fields = array (); @@ -421,11 +404,9 @@ $fields[AGENT_MODULE_STATUS_NOT_NORMAL] = __('Not normal'); //default $fields[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); html_print_select ($fields, "status", $status, '', __('All'), -1, - false, false, true, '', false, 'width: 125px;'); + false, false, true, '', false, 'width: 150px;'); echo ''; - - echo '' . __('Module group') . ''; echo ''; if (!defined('METACONSOLE')) { @@ -440,17 +421,13 @@ if (!defined('METACONSOLE')) { $rows_select[0] = __('Not assigned'); -html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1); +html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'),-1,false, false, true, '', false, 'width: 120px;'); echo ''; - - echo ''; echo ''; - - echo '' . __('Module name') . ''; echo ''; @@ -463,32 +440,6 @@ html_print_select (index_array ($modules, 'nombre', 'nombre'), "ag_modulename", echo ''; - -echo '' . - __('Tags') . - ui_print_help_tip(__('Only it is show tags in use.'), true) . - ''; -echo ''; - -if (!defined('METACONSOLE')) { - $tags = tags_get_user_tags(); -} - -if (empty($tags)) { - echo __('No tags'); -} -else { - if (!defined('METACONSOLE')) - html_print_select ($tags, "tag_filter", - $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); - else - html_print_select (index_array($tags, 'name', 'name'), "tag_filter", - $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); -} -echo ''; - - - echo '' . __('Search') . ''; @@ -496,7 +447,21 @@ echo ''; html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false); echo ''; +echo '' . + __('Tags') . + ui_print_help_tip(__('Only it is show tags in use.'), true); +echo ''; +$tags = tags_get_user_tags(); + +if (empty($tags)) { + echo __('No tags'); +} +else { + + html_print_select ($tags, "tag_filter", $tag_filter, '', __('All'), '', false, false, true, '', false, 'width: 150px;'); +} +echo ''; echo ''; html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"'); @@ -732,6 +697,7 @@ switch ($config["dbtype"]) { $sql_from . $sql_conditions_all . " ORDER BY " . $order['field'] . " " . $order['order'] . " LIMIT ".$offset.",".$limit_sql; + break; case "postgresql": if (strstr($config['dbversion'], "8.4") !== false) { @@ -841,7 +807,7 @@ else { WHERE disabled = 0"); if ($servers === false) $servers = array(); - + $result = array(); $count_modules = 0; foreach ($servers as $server) { @@ -1188,7 +1154,6 @@ foreach ($result as $row) { $data[7] = '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . ''; if (defined('METACONSOLE')) - //$data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; $data[7] .= "". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . ""; else $data[7] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; @@ -1257,8 +1222,6 @@ foreach ($result as $row) { } } - - if ($module_value == $sub_string) { $salida = $module_value; } @@ -1307,12 +1270,37 @@ else { echo "
"; +//strict user hidden +echo ''; + + enterprise_hook('close_meta_frame'); ui_require_javascript_file('pandora_modules'); ?>