From f4551faff0885e6abef2150f4ae4b62f33aafa60 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Mon, 3 Sep 2018 18:02:18 +0200 Subject: [PATCH 01/44] Add intracom generic functions - #2541 --- pandora_console/include/functions_api.php | 275 ++++++++++++++++++++++ 1 file changed, 275 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 76968e1e75..189cc4203b 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -30,6 +30,7 @@ include_once($config['homedir'] . "/include/functions_network_components.php"); include_once($config['homedir'] . "/include/functions_netflow.php"); include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); +include_once($config['homedir'] . "/include/functions_db.php"); enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_agents.php'); @@ -11397,8 +11398,282 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access = return false; } +function api_get_user_info($thrash1, $thrash2, $other, $returnType) { + if (defined ('METACONSOLE')) { + return; + } + + $separator = ';'; + + $other = json_decode(base64_decode($other['data']),true); + + $sql = 'select * from tusuario where id_user = "'.$other[0]['id_user'].'" and password = "'.$other[0]['password'].'"'; + + $user_info = db_get_all_rows_sql($sql); + + if (count($user_info) > 0 and $user_info !== false) { + $data = array('type' => 'array', 'data' => $user_info); + returnData($returnType, $data, $separator); + } + else { + return 0; + } +} +/* + +This function receives different parameters to process one of these actions the logging process in our application from the records in the audit of pandora fms, to avoid concurrent access of administrator users, and optionally to prohibit access to non-administrator users: + +Parameter 0 + +The User ID that attempts the action is used to check the status of the application for access. + +Parameter 1 + +Login, logout, exclude, browse. + +These requests receive a response that we can treat as we consider, this function only sends answers, does not perform any action in your application, you must customize them. + +Login action: free (register our access), taken, denied (if you are not an administrator user and parameter four is set to 1, register the expulsion). + +Browse action: It has the same answers as login, but does not register anything in the audit. + +Logout action: It records the deslogeo but does not send a response. + +All other actions do not return a response, + +Parameter 2 + +IP address of the application is also used to check the status of the application for access. + +Parameter 3 + +Name of the application, it is also used to check the status of the application for access. + +Parameter 4 + +If you mark 1 you will avoid the access to the non-administrators users, returning the response `denied' and registering that expulsion in the audit of pandora fms. + +*/ + + + +function api_set_access_process($thrash1, $thrash2, $other, $returnType) { + if (defined ('METACONSOLE')) { + return; + } + + $other['data'] = explode('|',$other['data']); + + $sql = 'select id_usuario,utimestamp from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logon%" and id_usuario IN (select id_user from tusuario where is_admin = 1) and id_usuario != "'.$other['data'][0].'" order by utimestamp DESC limit 1'; + $audit_concurrence = db_get_all_rows_sql($sql); + $sql_user = 'select id_usuario,utimestamp from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logon%" and id_usuario IN (select id_user from tusuario where is_admin = 1) and id_usuario = "'.$other['data'][0].'" order by utimestamp DESC limit 1'; + $audit_concurrence_user = db_get_all_rows_sql($sql_user); + $sql2 = 'select id_usuario,utimestamp,accion from tsesion where descripcion like "%'.$other['data'][2].'%" and accion like "%'.$other['data'][3].' Logoff%" and id_usuario = "'.$audit_concurrence[0]['id_usuario'].'" order by utimestamp DESC limit 1'; + $audit_concurrence_2 = db_get_all_rows_sql($sql2); + + //The user trying to log in is an administrator + if(users_is_admin($other['data'][0])){ + //The admin user is trying to login + if($other['data'][1] == 'login'){ + // Check if there is an administrator user logged in prior to our last login + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_user[0]['utimestamp']){ + // Check if the administrator user logged in later to us has unlogged and left the node free + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_2[0]['utimestamp']){ + // The administrator user logged in later has not yet unlogged + returnData('string', array('type' => 'string', 'data' => 'taken')); + } + else{ + // The administrator user logged in later has already unlogged + returnData('string', array('type' => 'string', 'data' => 'free')); + } + } + else{ + // There is no administrator user who has logged in since then to log us in. + db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'free')); + } + + } + elseif ($other['data'][1] == 'logout') { + // The administrator user wants to log out + db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2], $other['data'][0]); + } + elseif ($other['data'][1] == 'exclude') { + // The administrator user has ejected another administrator user who was logged in + db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2] , $audit_concurrence[0]['id_usuario']); + + } + //The admin user is trying to browse + elseif ($other['data'][1] == 'browse') { + // Check if there is an administrator user logged in prior to our last login + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_user[0]['utimestamp']){ + // Check if the administrator user logged in later to us has unlogged and left the node free + if($audit_concurrence[0]['utimestamp'] > $audit_concurrence_2[0]['utimestamp']){ + // The administrator user logged in later has not yet unlogged + returnData('string', array('type' => 'string', 'data' => $audit_concurrence[0]['id_usuario'])); + } + else{ + // The administrator user logged in later has already unlogged + returnData('string', array('type' => 'string', 'data' => 'free')); + } + } + else{ + // There is no administrator user who has logged in since then to log us in. + returnData('string', array('type' => 'string', 'data' => 'free')); + } + + } + elseif ($other['data'][1] == 'cancelled'){ + //The administrator user tries to log in having another administrator logged in, but instead of expelling him he cancels his log in. + db_pandora_audit($other['data'][3].' cancelled access', 'Cancelled access in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'cancelled')); + } + +} +else{ + + if($other['data'][4] == 1){ + //The user trying to log in is not an administrator and is not allowed no admin access + db_pandora_audit($other['data'][3].' denied access', 'Denied access to non-admin user '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'denied')); + } + else{ + //The user trying to log in is not an administrator and is allowed no admin access + if($other['data'][1] == 'login'){ + //The user trying to login is not admin, can enter without concurrent use filter + db_pandora_audit($other['data'][3].' Logon', 'Logged in '.$other['data'][3].' node '.$other['data'][2] , $other['data'][0]); + returnData('string', array('type' => 'string', 'data' => 'free')); + + } + elseif ($other['data'][1] == 'logout') { + //The user trying to logoff is not admin + db_pandora_audit($other['data'][3].' Logoff', 'Logout from '.$other['data'][3].' node '.$other['data'][2], $other['data'][0]); + } + elseif ($other['data'][1] == 'browse'){ + //The user trying to browse in an app page is not admin, can enter without concurrent use filter + returnData('string', array('type' => 'string', 'data' => 'free')); + } + } + } +} + + +function api_get_traps($thrash1, $thrash2, $other, $returnType) { + + if (defined ('METACONSOLE')) { + return; + } + + $other['data'] = explode('|',$other['data']); + + $other['data'][1] = date("Y-m-d H:i:s",$other['data'][1]); + + $sql = 'SELECT * from ttrap where timestamp >= "'.$other['data'][1].'"'; + + // $sql = 'SELECT * from ttrap where source = "'.$other['data'][0].'" and timestamp >= "'.$other['data'][1].'"'; + + if($other['data'][4]){ + $other['data'][4] = date("Y-m-d H:i:s",$other['data'][4]); + $sql .= ' and timestamp <= "'.$other['data'][4].'"'; + } + + if($other['data'][2]){ + $sql .= ' limit '.$other['data'][2]; + } + + if($other['data'][3]){ + $sql .= ' offset '.$other['data'][3]; + } + + if($other['data'][5]){ + $sql .= ' and status = 0'; + } + + if(sizeof($other['data']) == 0){ + $sql = 'SELECT * from ttrap'; + } + + + $traps = db_get_all_rows_sql($sql); + + if($other['data'][6]){ + + foreach ($traps as $key => $value) { + + if(!strpos($value['oid_custom'],$other['data'][6]) && $other['data'][7] == 'false'){ + unset($traps[$key]); + } + + if(strpos($value['oid_custom'],$other['data'][6]) && $other['data'][7] == 'true'){ + unset($traps[$key]); + } + + } + + } + + $traps_json = json_encode($traps); + + if (count($traps) > 0 and $traps !== false) { + returnData('string', array('type' => 'string', 'data' => $traps_json)); + } + else { + return 0; + } + +} + +function api_set_validate_traps ($id, $thrash2, $other, $thrash3) { + + if (defined ('METACONSOLE')) { + return; + } + + if($id == 'all'){ + $result = db_process_sql_update('ttrap',array('status' => 1)); + } + else{ + $result = db_process_sql_update('ttrap', + array('status' => 1), array('id_trap' => $id)); + } + + if (is_error($result)) { + // TODO: Improve the error returning more info + returnError('error_update_trap', __('Error in trap update.')); + } + else { + returnData('string', + array('type' => 'string', + 'data' => __('Validated traps.'))); + } + } + + function api_set_delete_traps ($id, $thrash2, $other, $thrash3) { + + if (defined ('METACONSOLE')) { + return; + } + + if($id == 'all'){ + $result = db_process_sql ('delete from ttrap'); + } + else{ + $result = db_process_sql_delete('ttrap',array('id_trap' => $id)); + } + + if (is_error($result)) { + // TODO: Improve the error returning more info + returnError('error_delete_trap', __('Error in trap delete.')); + } + else { + returnData('string', + array('type' => 'string', + 'data' => __('Deleted traps.'))); + } + } ?> From fb68f3f9b683e00627148bad50ccaee82c0a37d3 Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 7 Sep 2018 00:01:31 +0200 Subject: [PATCH 02/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index fdde8ca429..a100de916d 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180906 +Version: 7.0NG.726-180907 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 881279ccb8..3471b19125 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180906" +pandora_version="7.0NG.726-180907" 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 28daa08a50..c9dd17ffdb 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180906'; +use constant AGENT_BUILD => '180907'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 3e6e805bfd..caf59d316f 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 7.0NG.726 -%define release 180906 +%define release 180907 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 ffc7adbada..9a9a2a9bfe 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 7.0NG.726 -%define release 180906 +%define release 180907 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index bdb3b3b1ce..47054d8618 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180906" +PI_BUILD="180907" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b81e5470d8..6a08c3d696 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180906} +{180907} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 1796ee2ade..ffa141f0ee 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180906)") +#define PANDORA_VERSION ("7.0NG.726(Build 180907)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 62b4acd567..edac8ed017 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180906))" + VALUE "ProductVersion", "(7.0NG.726(Build 180907))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 4509a38ac8..0e34a99d3a 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180906 +Version: 7.0NG.726-180907 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 932e5bea71..cfb0c41813 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180906" +pandora_version="7.0NG.726-180907" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 5a985fae32..f7dc3c3bc4 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 = 'PC180906'; +$build_version = 'PC180907'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 091becd2b7..de0ff5f208 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index c4acf995e2..fec4c458eb 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180906 +%define release 180907 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 7f338028c0..3f44b270da 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180906 +%define release 180907 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 74036a3011..f61dd06c49 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180906" +PI_BUILD="180907" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 052fb836db..f3645ddd5e 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180906"; +my $version = "7.0NG.726 PS180907"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b9cb771727..ae23b1eb03 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180906"; +my $version = "7.0NG.726 PS180907"; # save program name for logging my $progname = basename($0); From ac0f0536c74ef1d81588d2957fbc5a79b238b659 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 7 Sep 2018 14:19:01 +0200 Subject: [PATCH 03/44] performance improve view groups --- pandora_console/include/class/Tree.class.php | 101 +--- .../include/class/TreeGroup.class.php | 42 +- .../include/functions_groupview.php | 528 +++++------------- .../operation/agentes/group_view.php | 12 +- 4 files changed, 185 insertions(+), 498 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index cc80ac1686..a450c53c4e 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -278,7 +278,7 @@ class Tree { : " AND $filter "; } - protected function getGroupAclCondition() { + static function getGroupAclCondition() { if (users_can_manage_group_all("AR")) return ""; $groups_str= implode(",", $this->userGroupsArray); @@ -301,105 +301,6 @@ class Tree { return " AND tg.nombre LIKE '%" . $this->filter['searchGroup'] . "%'"; } - protected function getAgentCounterColumnsSql ($agent_table) { - // Add the agent counters to the columns - - if ($this->filter['statusAgent'] == -1) { - // Critical - $agent_critical_filter = $this->getAgentStatusFilter(AGENT_STATUS_CRITICAL); - $agents_critical_count = "($agent_table - $agent_critical_filter) AS total_critical_count"; - // Warning - $agent_warning_filter = $this->getAgentStatusFilter(AGENT_STATUS_WARNING); - $agents_warning_count = "($agent_table - $agent_warning_filter) AS total_warning_count"; - // Unknown - $agent_unknown_filter = $this->getAgentStatusFilter(AGENT_STATUS_UNKNOWN); - $agents_unknown_count = "($agent_table - $agent_unknown_filter) AS total_unknown_count"; - // Normal - $agent_normal_filter = $this->getAgentStatusFilter(AGENT_STATUS_NORMAL); - $agents_normal_count = "($agent_table - $agent_normal_filter) AS total_normal_count"; - // Not init - if($this->filter['show_not_init_agents']){ - $agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT); - $agents_not_init_count = "($agent_table - $agent_not_init_filter) AS total_not_init_count"; - } - else{ - $agent_not_init_filter = 0; - $agents_not_init_count = 0; - } - - // Alerts fired - $agents_fired_count = "($agent_table - AND ta.fired_count > 0) AS total_fired_count"; - // Total - $agents_total_count = "($agent_table) AS total_count"; - - $columns = "$agents_critical_count, $agents_warning_count, " - . "$agents_unknown_count, $agents_normal_count, $agents_not_init_count, " - . "$agents_fired_count, $agents_total_count"; - } - else { - // Alerts fired - $agents_fired_count = "($agent_table - AND ta.fired_count > 0) AS total_fired_count"; - // Total - $agents_total_count = "($agent_table) AS total_count"; - - switch ($this->filter['statusAgent']) { - case AGENT_STATUS_NOT_INIT: - // Not init - $agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT); - $agents_not_init_count = "($agent_table - $agent_not_init_filter) AS total_not_init_count"; - $columns = "$agents_not_init_count, $agents_fired_count, $agents_total_count"; - break; - case AGENT_STATUS_CRITICAL: - // Critical - $agent_critical_filter = $this->getAgentStatusFilter(AGENT_STATUS_CRITICAL); - $agents_critical_count = "($agent_table - $agent_critical_filter) AS total_critical_count"; - $columns = "$agents_critical_count, $agents_fired_count, $agents_total_count"; - break; - case AGENT_STATUS_WARNING: - // Warning - $agent_warning_filter = $this->getAgentStatusFilter(AGENT_STATUS_WARNING); - $agents_warning_count = "($agent_table - $agent_warning_filter) AS total_warning_count"; - $columns = "$agents_warning_count, $agents_fired_count, $agents_total_count"; - break; - case AGENT_STATUS_UNKNOWN: - // Unknown - $agent_unknown_filter = $this->getAgentStatusFilter(AGENT_STATUS_UNKNOWN); - $agents_unknown_count = "($agent_table - $agent_unknown_filter) AS total_unknown_count"; - $columns = "$agents_unknown_count, $agents_fired_count, $agents_total_count"; - break; - case AGENT_STATUS_NORMAL: - // Normal - $agent_normal_filter = $this->getAgentStatusFilter(AGENT_STATUS_NORMAL); - $agents_normal_count = "($agent_table - $agent_normal_filter) AS total_normal_count"; - $columns = "$agents_normal_count, $agents_fired_count, $agents_total_count"; - break; - } - } - - return $columns; - } - - protected function getAgentCountersSql ($agent_table) { - global $config; - - $columns = $this->getAgentCounterColumnsSql($agent_table); - $columns = "SELECT $columns FROM dual LIMIT 1"; - - return $columns; - } - static function cmpSortNames($a, $b) { return strcmp($a["name"], $b["name"]); } diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index d3c4f8f506..af5542e396 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -19,6 +19,8 @@ require_once($config['homedir']."/include/class/Tree.class.php"); class TreeGroup extends Tree { + protected $propagateCounters = true; + public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') { global $config; @@ -38,6 +40,10 @@ class TreeGroup extends Tree { )"; } + public function setPropagateCounters($value) { + $this->propagateCounters = (bool)$value; + } + protected function getData() { if ($this->id == -1) { $this->getFirstLevel(); @@ -126,9 +132,13 @@ class TreeGroup extends Tree { return !$group['have_parent']; }); // Propagate child counters to her parents - TreeGroup::processCounters($groups); - // Filter groups and eliminates the reference to empty groups - $groups = TreeGroup::deleteEmptyGroups($groups); + if ($this->propagateCounters) { + TreeGroup::processCounters($groups); + // Filter groups and eliminates the reference to empty groups + $groups = TreeGroup::deleteEmptyGroups($groups); + } else { + $groups = TreeGroup::deleteEmptyGroupsNotPropagate($groups); + } usort($groups, array("Tree", "cmpSortNames")); return $groups; @@ -353,6 +363,32 @@ class TreeGroup extends Tree { return $new_groups; } + protected static function deleteEmptyGroupsNotPropagate ($groups) { + $new_groups = array(); + foreach ($groups as $group) { + // Tray to remove the children groups + if (!empty($group['children'])) { + $children = TreeGroup::deleteEmptyGroupsNotPropagate ($group['children']); + if (empty($children)) { + unset($group['children']); + // If a group is empty, do not add to new_groups. + if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { + $new_groups[] = $group; + } + } else { + $group['children'] = $children; + $new_groups[] = $group; + } + } else { + // If a group is empty, do not add to new_groups. + if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { + $new_groups[] = $group; + } + } + } + return $new_groups; + } + private static function extractGroupsWithIDs ($groups, $ids_hash) { $result_groups = array(); foreach ($groups as $group) { diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index 0e45341ea4..f1568d788a 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -16,6 +16,8 @@ include_once ($config['homedir'] . "/include/functions_groups.php"); include_once ($config['homedir'] . "/include/functions_tags.php"); +include_once ($config['homedir'] . "/include/class/Tree.class.php"); +include_once ($config['homedir'] . "/include/class/TreeGroup.class.php"); function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array(), $access = 'AR') { global $config; @@ -411,406 +413,158 @@ function groupview_monitor_fired_alerts ($group_array, $strict_user = false, $id AND times_fired > 0"); } +function groupview_plain_groups($groups) { + $group_result = array(); + foreach ($groups as $group) { + $plain_child = array(); + if (!empty($group['children'])) { + $plain_child = groupview_plain_groups($group['children']); + unset($group['children']); + } + $group_result[] = $group; + $group_result = array_merge($group_result, $plain_child); + } + return $group_result; +} + +function groupview_get_modules_counters($groups_ids = false) { + $groups_ids = implode(',', $groups_ids); + + $fields = array ( + "g" , + "SUM(module_normal) AS total_module_normal", + "SUM(module_critical) AS total_module_critical", + "SUM(module_warning) AS total_module_warning", + "SUM(module_unknown) AS total_module_unknown", + "SUM(module_not_init) AS total_module_not_init", + "SUM(module_alerts) AS total_module_alerts", + "SUM(module_total) AS total_module" + ); + + $fields_impl = implode(',', $fields); + $sql = "SELECT $fields_impl FROM + ( + SELECT SUM(ta.normal_count) AS module_normal, + SUM(ta.critical_count) AS module_critical, + SUM(ta.warning_count) AS module_warning, + SUM(ta.unknown_count) AS module_unknown, + SUM(ta.notinit_count) AS module_not_init, + SUM(ta.fired_count) AS module_alerts, + SUM(ta.total_count) AS module_total, + ta.id_grupo AS g + FROM tagente ta + WHERE ta.id_grupo IN ($groups_ids) + GROUP BY ta.id_grupo + UNION ALL + SELECT SUM(ta.normal_count) AS module_normal, + SUM(ta.critical_count) AS module_critical, + SUM(ta.warning_count) AS module_warning, + SUM(ta.unknown_count) AS module_unknown, + SUM(ta.notinit_count) AS module_not_init, + SUM(ta.fired_count) AS module_alerts, + SUM(ta.total_count) AS module_total, + tasg.id_group AS g + FROM tagente ta + INNER JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE tasg.id_group IN ($groups_ids) + GROUP BY tasg.id_group + ) x GROUP BY g"; + return db_get_all_rows_sql($sql); +} + +function groupview_get_all_counters() { + $all_name = __("All"); + $group_acl = Tree::getGroupAclCondition(); + $sql = + "SELECT SUM(ta.normal_count) AS _monitors_ok_, + SUM(ta.critical_count) AS _monitors_critical_, + SUM(ta.warning_count) AS _monitors_warning_, + SUM(ta.unknown_count) AS _monitors_unknown_, + SUM(ta.notinit_count) AS _monitors_not_init_, + SUM(ta.fired_count) AS _monitors_alerts_fired_, + SUM(ta.total_count) AS _monitor_checks_, + SUM(IF(ta.critical_count > 0, 1, 0)) AS _agents_critical_, + SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS _agents_unknown_, + SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS _agents_not_init_, + COUNT(ta.id_agente) AS _total_agents_, + '$all_name' AS _name_, + 0 AS _id_, + '' AS _icon_ + FROM tagente ta + WHERE ta.id_agente + IN ( + SELECT ta.id_agente FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE 1=1 $group_acl + ) + "; + $data = db_get_row_sql($sql); + $data["_monitor_not_normal_"] = $data["_monitor_checks_"] - $data["_monitors_ok_"]; + return $data; +} + function groupview_get_groups_list($id_user = false, $access = 'AR') { global $config; if ($id_user == false) { $id_user = $config['id_user']; } - $user_groups = users_get_groups($id_user, $access, true, false); + $tree_group = new TreeGroup("group", "group"); + $tree_group->setPropagateCounters(false); + $tree_group->setFilter( array( + 'searchAgent' => '', + 'statusAgent' => AGENT_STATUS_ALL, + 'searchModule' => '', + 'statusModule' => -1, + 'groupID' => 0, + 'tagID' => 0, + )); + $info = $tree_group->getArray(); + $info = groupview_plain_groups($info); + $counter = count($info); - $groups_with_privileges = implode(',', array_keys($user_groups)); + $offset = get_parameter('offset', 0); + $groups_view = array_slice($info, $offset, $config['block_size']); + $agents_counters = array_reduce($groups_view, function($carry, $item){ + $carry[$item['id']] = $item; + return $carry; + }, array()); - //change ALL for 0 - $user_groups[0] = 0; + $modules_counters = groupview_get_modules_counters(array_keys($agents_counters)); + $modules_counters = array_reduce($modules_counters, function($carry, $item){ + $carry[$item['g']] = $item; + return $carry; + }, array()); - $user_groups_ids = implode(',', array_keys($user_groups)); + $total_counters = array(); - if (!empty($user_groups_ids)) { - $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; - $table_secondary = is_metaconsole() - ? 'tmetaconsole_agent_secondary_group' - : 'tagent_secondary_group'; + foreach ($agents_counters as $id_group => $agent_counter) { + $list[$id_group]['_name_'] = $agent_counter['name']; + $list[$id_group]['_id_'] = $agent_counter['id']; + $list[$id_group]['icon'] = $agent_counter['icon']; - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN ($user_groups_ids) - AND ( - id_grupo IN (SELECT id_grupo FROM $table WHERE disabled = 0) - OR id_grupo IN (SELECT id_group FROM $table_secondary WHERE id_group IN ($user_groups_ids)) - ) - ORDER BY nombre COLLATE utf8_general_ci ASC" - ); + $list[$id_group]['_agents_not_init_'] = $agent_counter['counters']['not_init']; + $list[$id_group]['_agents_unknown_'] = $agent_counter['counters']['unknown']; + $list[$id_group]['_agents_critical_'] = $agent_counter['counters']['critical']; + $list[$id_group]['_total_agents_'] = $agent_counter['counters']['total']; + + $list[$id_group]['_monitors_critical_'] = (int)$modules_counters[$id_group]['total_module_critical']; + $list[$id_group]['_monitors_warning_'] = (int)$modules_counters[$id_group]['total_module_warning']; + $list[$id_group]['_monitors_unknown_'] = (int)$modules_counters[$id_group]['total_module_unknown']; + $list[$id_group]['_monitors_not_init_'] = (int)$modules_counters[$id_group]['total_module_not_init']; + $list[$id_group]['_monitors_ok_'] = (int)$modules_counters[$id_group]['total_module_normal']; + $list[$id_group]["_monitor_checks_"] = (int)$modules_counters[$id_group]['total_module']; + $list[$id_group]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]['_monitors_ok_']; + $list[$id_group]['_monitors_alerts_fired_'] = (int)$modules_counters[$id_group]['total_module_alerts']; } - //Add the group "All" at first - $group_all = array('id_grupo'=>0, 'nombre'=>'All', 'icon'=>'', 'parent'=>'', 'propagate'=>0, 'disabled'=>0, - 'custom_id'=>'', 'id_skin'=>0, 'description'=>'', 'contact'=>'', 'other'=>'', 'password'=>''); - if ($list_groups !== false) { - array_unshift($list_groups, $group_all); - } else { - $list_groups = array($group_all); - } - - //Takes the parents even without agents, first ids - $fathers_id = ''; - $list_father_groups = array(); - foreach ($list_groups as $group) { - if ($group['parent'] != '') { - $grup = $group['parent']; - while ($grup != 0) { - $recursive_fathers = db_get_row_sql ("SELECT parent FROM tgrupo - WHERE id_grupo = " . $grup); - $grup = $recursive_fathers['parent']; - if (!strpos($fathers_id, $grup)) { - $fathers_id .= ',' . $grup; - } - } - if (!strpos($fathers_id, $group['parent'])) { - $fathers_id .= ',' . $group['parent']; - } - } - } - //Eliminate the first comma - $fathers_id = substr($fathers_id, 1); - while ($fathers_id{0} == ',') { - $fathers_id = substr($fathers_id, 1); - } - //Takes the parents even without agents, complete groups - if ($fathers_id) { - $list_father_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $fathers_id . ") - AND id_grupo IN (" . $groups_with_privileges . ") - ORDER BY nombre COLLATE utf8_general_ci ASC"); - if (!empty($list_father_groups)) { - //Merges the arrays and eliminates the duplicates groups - $list_groups = array_merge($list_groups, $list_father_groups); - } - } - $list_groups = groupview_array_unique_multidim($list_groups, 'id_grupo'); - //Order groups (Father-children) - $ordered_groups = groupview_order_groups_for_parents($list_groups); - $ordered_ids = array(); - $ordered_ids = groupview_order_group_ids($ordered_groups, $ordered_ids); - $final_list = array(); - array_push($final_list, $group_all); - - foreach ($ordered_ids as $key) { - if ($key == 'All') { - continue; - } - $complete_group = db_get_row_sql(" - SELECT * - FROM tgrupo - WHERE nombre = '" . $key . "'"); - array_push($final_list, $complete_group); - } - - $list_groups = $final_list; - - $list = array(); - foreach ($list_groups as $group) { - $list[$group['id_grupo']]['_name_'] = $group['nombre']; - $list[$group['id_grupo']]['_id_'] = $group['id_grupo']; - $list[$group['id_grupo']]['icon'] = $group['icon']; - $list[$group['id_grupo']]['_monitors_critical_'] = 0; - $list[$group['id_grupo']]['_monitors_warning_'] = 0; - $list[$group['id_grupo']]['_monitors_unknown_'] = 0; - $list[$group['id_grupo']]['_monitors_not_init_'] = 0; - $list[$group['id_grupo']]['_monitors_ok_'] = 0; - $list[$group['id_grupo']]['_agents_not_init_'] = 0; - $list[$group['id_grupo']]['_agents_unknown_'] = 0; - $list[$group['id_grupo']]['_agents_critical_'] = 0; - $list[$group['id_grupo']]['_total_agents_'] = 0; - $list[$group['id_grupo']]["_monitor_checks_"] = 0; - $list[$group['id_grupo']]["_monitor_not_normal_"] = 0; - $list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0; - } - - if ($list_groups == false) { - $list_groups = array(); - } - - if (is_metaconsole() || ($config["realtimestats"] == 0)) { // Agent cache - $list = group_view_get_cache_stats ($list, $list_groups, $user_groups_ids); - } else { - foreach ($list_groups as $group) { - // If id group is 0 get all accesses groups - $group_id = $group['id_grupo'] == 0 - ? $user_groups_ids - : $group['id_grupo']; - $agent_not_init = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo'], - 'status' => AGENT_STATUS_NOT_INIT), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0; - $agent_unknown = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo'], - 'status' => AGENT_STATUS_UNKNOWN), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0; - $agent_critical = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo'], - 'status' => AGENT_STATUS_CRITICAL), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_agents_critical_'] = isset ($agent_critical[0]['total']) ? $agent_critical[0]['total'] : 0; - $agent_total = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo']), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0; - $list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"]; - $list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"]; - $list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,$group['id_grupo']); - $result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado - FROM tagente_estado tae INNER JOIN tagente ta - ON tae.id_agente = ta.id_agente - AND ta.disabled = 0 - LEFT JOIN tagent_secondary_group tasg - ON tasg.id_agent = ta.id_agente - INNER JOIN tagente_modulo tam - ON tae.id_agente_modulo = tam.id_agente_modulo - AND tam.disabled = 0 - WHERE tae.utimestamp > 0 - AND ( - ta.id_grupo IN (" . $group_id . ") - OR tasg.id_group IN (" . $group_id . ") - ) - GROUP BY estado"); - if ($result_list) { - foreach ($result_list as $result) { - switch ($result['estado']) { - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $list[$group['id_grupo']]['_monitors_critical_'] = (int)$result['contado']; - break; - case AGENT_MODULE_STATUS_WARNING_ALERT: - break; - case AGENT_MODULE_STATUS_WARNING: - $list[$group['id_grupo']]['_monitors_warning_'] = (int)$result['contado']; - break; - case AGENT_MODULE_STATUS_UNKNOWN: - $list[$group['id_grupo']]['_monitors_unknown_'] = (int)$result['contado']; - break; - } - } - } - - $result_normal = db_get_row_sql("SELECT COUNT(*) as contado - FROM tagente_estado tae INNER JOIN tagente ta - ON tae.id_agente = ta.id_agente - AND ta.disabled = 0 - LEFT JOIN tagent_secondary_group tasg - ON tasg.id_agent = ta.id_agente - INNER JOIN tagente_modulo tam - ON tae.id_agente_modulo = tam.id_agente_modulo - AND tam.disabled = 0 - WHERE tae.estado = 0 - AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100)) - AND ( - ta.id_grupo IN (" . $group_id . ") - OR tasg.id_group IN (" . $group_id . ") - ) - GROUP BY estado"); - $list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0; - - $result_not_init = db_get_row_sql("SELECT COUNT(*) as contado - FROM tagente_estado tae INNER JOIN tagente ta - ON tae.id_agente = ta.id_agente - AND ta.disabled = 0 - LEFT JOIN tagent_secondary_group tasg - ON tasg.id_agent = ta.id_agente - INNER JOIN tagente_modulo tam - ON tae.id_agente_modulo = tam.id_agente_modulo - AND tam.disabled = 0 - WHERE tae.utimestamp = 0 AND - tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." ) - AND tam.id_tipo_modulo NOT IN (21,22,23,100) - AND ( - ta.id_grupo IN (" . $group_id . ") - OR tasg.id_group IN (" . $group_id . ") - ) - GROUP BY estado"); - $list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0; - } - } - - return $list; -} - -//Order the groups by parents -function groupview_order_groups_for_parents ($view_groups) { - $final_groups = array(); - // Index the groups - $groups = array(); - foreach ($view_groups as $item) { - $groups[$item['id_grupo']] = $item; - } - // Build the group hierarchy - foreach ($groups as $id => $group) { - $groups[$id]['have_parent'] = false; - if (!isset($groups[$id]['parent'])) - continue; - $parent = $groups[$id]['parent']; - // Parent exists - if (isset($groups[$parent])) { - if (!isset($groups[$parent]['children'])) - $groups[$parent]['children'] = array(); - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } - - // Sort the children groups - for ($i = 0; $i < count($groups); $i++) { - if (isset($groups[$i]['children'])) - usort($groups[$i]['children'], function ($a, $b) { - return strcmp($a["nombre"], $b["nombre"]); - }); - } - // Extract the root groups - foreach ($groups as $group) { - if (!$group['have_parent']) - $final_groups[] = $group; - } - // Sort the root groups - usort($final_groups, function ($a, $b) { - return strcmp($a["name"], $b["name"]); - }); - - return $final_groups; -} - -function groupview_order_group_ids($groups, $ordered_ids){ - foreach ($groups as $group) { - if (!empty($group['children'])) { - $ordered_ids[$group['id_grupo']] = $group['nombre']; - $ordered_ids = groupview_order_group_ids($group['children'], $ordered_ids); - } - else { - $ordered_ids[$group['id_grupo']] = $group['nombre']; - } - } - return $ordered_ids; -} - -//Function to eliminate duplicates groups in multidimensional array -function groupview_array_unique_multidim($groups, $key){ - $temp_group = array(); - $i = 0; - $key_group = array(); - foreach($groups as $group){ - if(!in_array($group[$key],$key_group)){ - $key_group[$i] = $group[$key]; - $temp_group[$i] = $group; - } - $i++; - } - return $temp_group; -} - -/** - * Get the stats to group view using the cache - * - * @param array Skeleton to fill with the group information - * @param array Groups information - * @param string Groups that user has access separated by commas - */ -function group_view_get_cache_stats ($list, $list_groups, $user_groups_ids) { - - $table_agent = 'tagente'; - $table_secondary = 'tagent_secondary_group'; - // Change the metaconsole tables - if (is_metaconsole()) { - $table_agent = 'tmetaconsole_agent'; - $table_secondary = 'tmetaconsole_agent_secondary_group'; - } - - // Walk for each group - foreach ($list_groups as $group) { - // If id group is 0 get all accesses groups - $group_id = $group['id_grupo'] == 0 - ? $user_groups_ids - : $group['id_grupo']; - $group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_, - SUM(critical_count) AS _monitors_critical_, - SUM(normal_count) AS _monitors_ok_, - SUM(unknown_count) AS _monitors_unknown_, - SUM(notinit_count) AS _monitors_not_init_, - SUM(fired_count) AS _monitors_alerts_fired_, - COUNT(*) AS _total_agents_, id_grupo, intervalo, - ultimo_contacto, disabled - FROM $table_agent ta - LEFT JOIN $table_secondary tasg - ON tasg.id_agent = ta.id_agente - WHERE ( - ta.id_grupo IN (" . $group_id . ") - OR tasg.id_group IN (" . $group_id . ") - ) - AND disabled = 0"); - - $list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_']; - $list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_']; - $list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_']; - $list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_']; - $list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_']; - $list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_']; - $list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_']; - $list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] - + $list[$group['id_grupo']]["_monitors_unknown_"] - + $list[$group['id_grupo']]["_monitors_warning_"] - + $list[$group['id_grupo']]["_monitors_critical_"] - + $list[$group['id_grupo']]["_monitors_ok_"]; - - if ($group['icon']) - $list[$group['id_grupo']]["_iconImg_"] = html_print_image ("images/".$group['icon'].".png", true, array ("style" => 'vertical-align: middle;')); - - // Calculate not_normal monitors - $list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"]; - - $total_agents = $list[$group['id_grupo']]['_total_agents_']; - - if ($total_agents > 0) { - $agents = db_get_all_rows_sql(sprintf ("SELECT warning_count, - critical_count, - normal_count, - unknown_count, - notinit_count, - fired_count, - disabled - FROM $table_agent ta - LEFT JOIN $table_secondary tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.id_grupo IN (%s) OR tasg.id_group IN (%s)", - $group_id, $group_id)); - foreach ($agents as $agent) { - if ($agent['critical_count'] > 0) { - $list[$group['id_grupo']]['_agents_critical_'] += 1; - } - else { - if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) { - if ($agent['unknown_count'] > 0) { - $list[$group['id_grupo']]['_agents_unknown_'] += 1; - } - } - if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) { - if ($agent['notinit_count'] > 0) { - $list[$group['id_grupo']]['_agents_not_init_'] += 1; - } - } - } - } - } - } - return $list; + array_unshift($list, groupview_get_all_counters()); + return array( + 'groups' => $list, + 'counter' => $counter + ); } ?> diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 1c6a8d49e3..abc31b4ea4 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -30,7 +30,6 @@ if (!$agent_a && !$agent_w) { require ("general/noaccess.php"); exit; } -$offset = get_parameter('offset', 0); // Update network modules for this group // Check for Network FLAG change request // Made it a subquery, much faster on both the database and server side @@ -81,12 +80,12 @@ $agents_notinit = 0; $all_alerts_fired = 0; //Groups and tags -$result_groups = groupview_get_groups_list( +$result_groups_info = groupview_get_groups_list( $config['id_user'], ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR') ); - -$count = count($result_groups); +$result_groups = $result_groups_info['groups']; +$count = $result_groups_info['counter']; if ($result_groups[0]["_id_"] == 0) { $total_agentes = $result_groups[0]["_total_agents_"]; @@ -187,10 +186,7 @@ if (!empty($result_groups)) { echo "" . __("Alert fired") . ""; echo ""; - $result_groups = array_slice($result_groups, $offset, $config['block_size']); - foreach ($result_groups as $data) { - $groups_id = $data["_id_"]; // Calculate entire row color @@ -454,4 +450,4 @@ if (!empty($result_groups)) { } else { ui_print_info_message ( __('There are no defined agents')); } -?> \ No newline at end of file +?> From 3fa4f44d68859e04bf265cbeda40c93ceef4f006 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 7 Sep 2018 14:37:22 +0200 Subject: [PATCH 04/44] fixed group view --- .../include/functions_groupview.php | 400 +----------------- pandora_console/mobile/operation/groups.php | 25 +- 2 files changed, 9 insertions(+), 416 deletions(-) diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index f1568d788a..61299a1ec8 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -19,400 +19,6 @@ include_once ($config['homedir'] . "/include/functions_tags.php"); include_once ($config['homedir'] . "/include/class/Tree.class.php"); include_once ($config['homedir'] . "/include/class/TreeGroup.class.php"); -function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array(), $access = 'AR') { - global $config; - if ($id_user == false) { - $id_user = $config['id_user']; - } - - $user_groups = array(); - $user_tags = array(); - - foreach ($acltags as $item) { - $user_groups[$item["id_grupo"]] = $item["nombre"]; - - if ($item["tags"] != '') { - $tags_group = explode(',', $item["tags"]); - - foreach ($tags_group as $tag) { - $user_tags[$tag] = tags_get_name($tag); - } - } - } - - $user_groups_ids = implode(',', array_keys($acltags)); - - if (!empty($user_groups_ids)) { - if (is_metaconsole()) { - switch ($config["dbtype"]) { - case "mysql": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0) - 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 . ") - AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0) - ORDER BY nombre ASC"); - break; - case "oracle": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - AND id_grupo IN (SELECT id_grupo FROM tmetaconsole_agent WHERE disabled = 0) - ORDER BY nombre ASC"); - break; - } - } - else { - switch ($config["dbtype"]) { - case "mysql": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0) - 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 . ") - AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0) - ORDER BY nombre ASC"); - break; - case "oracle": - $list_groups = db_get_all_rows_sql(" - SELECT * - FROM tgrupo - WHERE id_grupo IN (" . $user_groups_ids . ") - AND id_grupo IN (SELECT id_grupo FROM tagente WHERE disabled = 0) - ORDER BY nombre ASC"); - break; - } - } - } - - foreach ($list_groups as $group) { - $list[$group['id_grupo']]['_name_'] = $group['nombre']; - $list[$group['id_grupo']]['_id_'] = $group['id_grupo']; - $list[$group['id_grupo']]['_monitors_critical_'] = 0; - $list[$group['id_grupo']]['_monitors_warning_'] = 0; - $list[$group['id_grupo']]['_monitors_unknown_'] = 0; - $list[$group['id_grupo']]['_monitors_not_init_'] = 0; - $list[$group['id_grupo']]['_monitors_ok_'] = 0; - $list[$group['id_grupo']]['_agents_not_init_'] = 0; - $list[$group['id_grupo']]['_agents_unknown_'] = 0; - $list[$group['id_grupo']]['_agents_critical_'] = 0; - $list[$group['id_grupo']]['_total_agents_'] = 0; - $list[$group['id_grupo']]["_monitor_checks_"] = 0; - $list[$group['id_grupo']]["_monitor_not_normal_"] = 0; - $list[$group['id_grupo']]['_monitors_alerts_fired_'] = 0; - } - if ($list_groups == false) { - $list_groups = array(); - } - - /* - * Agent cache for metaconsole. - * Retrieve the statistic data from the cache table. - */ - if (is_metaconsole()) { - foreach ($list_groups as $group) { - $group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_, - SUM(critical_count) AS _monitors_critical_, - SUM(normal_count) AS _monitors_ok_, - SUM(unknown_count) AS _monitors_unknown_, - SUM(notinit_count) AS _monitors_not_init_, - SUM(fired_count) AS _monitors_alerts_fired_, - COUNT(*) AS _total_agents_, id_grupo, intervalo, - ultimo_contacto, disabled - FROM tmetaconsole_agent ta - LEFT JOIN tmetaconsole_agent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ( - ta.id_grupo = " . $group['id_grupo'] . " - OR tasg.id_group = " . $group['id_grupo'] . " - ) AND disabled = 0 GROUP BY id_grupo"); - $list[$group['id_grupo']]['_monitors_critical_'] = (int)$group_agents['_monitors_critical_']; - $list[$group['id_grupo']]['_monitors_warning_'] = (int)$group_agents['_monitors_warning_']; - $list[$group['id_grupo']]['_monitors_unknown_'] = (int)$group_agents['_monitors_unknown_']; - $list[$group['id_grupo']]['_monitors_not_init_'] = (int)$group_agents['_monitors_not_init_']; - $list[$group['id_grupo']]['_monitors_ok_'] = (int)$group_agents['_monitors_ok_']; - - $list[$group['id_grupo']]['_monitors_alerts_fired_'] = (int)$group_agents['_monitors_alerts_fired_']; - - $list[$group['id_grupo']]['_total_agents_'] = (int)$group_agents['_total_agents_']; - - $list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"]; - - // Calculate not_normal monitors - $list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"]; - - $total_agents = $list[$group['id_grupo']]['_total_agents_']; - - if (($group['id_grupo'] != 0) && ($total_agents > 0)) { - $agents = db_get_all_rows_sql("SELECT warning_count, - critical_count, - normal_count, - unknown_count, - notinit_count, - fired_count, - disabled - FROM tmetaconsole_agent - WHERE id_grupo = " . $group['id_grupo'] ); - foreach ($agents as $agent) { - if ($agent['critical_count'] > 0) { - $list[$group['id_grupo']]['_agents_critical_'] += 1; - } - else { - if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0)) { - if ($agent['unknown_count'] > 0) { - $list[$group['id_grupo']]['_agents_unknown_'] += 1; - } - } - if (($agent['critical_count'] == 0) && ($agent['warning_count'] == 0) && ($group_agents['disabled'] == 0) && ($agent['normal_count'] == 0) && ($agent['unknown_count'] == 0)) { - if ($agent['notinit_count'] > 0) { - $list[$group['id_grupo']]['_agents_not_init_'] += 1; - } - } - } - } - } - } - } - else if (false) { //FIXME: The cached group view is wasted. Avoid to reach this code. - - $group_stat = db_get_all_rows_sql ("SELECT - SUM(ta.normal_count) as normal, SUM(ta.critical_count) as critical, - SUM(ta.warning_count) as warning,SUM(ta.unknown_count) as unknown, - SUM(ta.notinit_count) as not_init, SUM(fired_count) as alerts_fired - FROM tagente ta - WHERE id_grupo IN ($user_groups_ids)"); - - $list['_agents_unknown_'] = $group_stat[0]["unknown"]; - $list['_monitors_alerts_fired_'] = $group_stat[0]["alerts_fired"]; - - $list['_monitors_ok_'] = $group_stat[0]["normal"]; - $list['_monitors_warning_'] = $group_stat[0]["warning"]; - $list['_monitors_critical_'] = $group_stat[0]["critical"]; - $list['_monitors_unknown_'] = $group_stat[0]["unknown"]; - $list['_monitors_not_init_'] = $group_stat[0]["not_init"]; - $total_agentes = agents_get_agents (false, array('count(*) as total_agents'), $access,false, false); - $list['_total_agents_'] = $total_agentes[0]['total_agents']; - $list["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"]; - - $list['_monitors_alerts_'] = groupview_monitor_alerts (explode(',',$user_groups_ids), $user_strict,explode(',',$user_groups_ids)); - // Get total count of monitors for this group, except disabled. - $list["_monitor_checks_"] = $list["_monitors_not_init_"] + $list["_monitors_unknown_"] + $list["_monitors_warning_"] + $list["_monitors_critical_"] + $list["_monitors_ok_"]; - - // Calculate not_normal monitors - $list["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"]; - - if ($list["_monitor_not_normal_"] > 0 && $list["_monitor_checks_"] > 0) { - $list["_monitor_health_"] = format_numeric (100 - ($list["_monitor_not_normal_"] / ($list["_monitor_checks_"] / 100)), 1); - } - else { - $list["_monitor_health_"] = 100; - } - - if ($list["_monitors_not_init_"] > 0 && $list["_monitor_checks_"] > 0) { - $list["_module_sanity_"] = format_numeric (100 - ($list["_monitors_not_init_"] / ($list["_monitor_checks_"] / 100)), 1); - } - else { - $list["_module_sanity_"] = 100; - } - - if (isset($list["_alerts_"])) { - if ($list["_monitors_alerts_fired_"] > 0 && $list["_alerts_"] > 0) { - $list["_alert_level_"] = format_numeric (100 - ($list["_monitors_alerts_fired_"] / ($list["_alerts_"] / 100)), 1); - } - else { - $list["_alert_level_"] = 100; - } - } - else { - $list["_alert_level_"] = 100; - $list["_alerts_"] = 0; - } - - $list["_monitor_bad_"] = $list["_monitors_critical_"] + $list["_monitors_warning_"]; - - if ($list["_monitor_bad_"] > 0 && $list["_monitor_checks_"] > 0) { - $list["_global_health_"] = format_numeric (100 - ($list["_monitor_bad_"] / ($list["_monitor_checks_"] / 100)), 1); - } - else { - $list["_global_health_"] = 100; - } - - $list["_server_sanity_"] = format_numeric (100 - $list["_module_sanity_"], 1); - } - else { - foreach ($list_groups as $group) { - $agent_not_init = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo'], - 'status' => AGENT_STATUS_NOT_INIT), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_agents_not_init_'] = isset ($agent_not_init[0]['total']) ? $agent_not_init[0]['total'] : 0; - $agent_unknown = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo'], - 'status' => AGENT_STATUS_UNKNOWN), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_agents_unknown_'] = isset ($agent_unknown[0]['total']) ? $agent_unknown[0]['total'] : 0; - $agent_critical = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo'], - 'status' => AGENT_STATUS_CRITICAL), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_agents_critical_'] = isset ($agent_critical[0]['total']) ? $agent_critical[0]['total'] : 0; - $agent_total = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $group['id_grupo']), - array ('COUNT(DISTINCT id_agente) as total'), $access, false); - $list[$group['id_grupo']]['_total_agents_'] = isset ($agent_total[0]['total']) ? $agent_total[0]['total'] : 0; - $list[$group['id_grupo']]["_monitor_not_normal_"] = $list[$group['id_grupo']]["_monitor_checks_"] - $list[$group['id_grupo']]["_monitors_ok_"]; - $list[$group['id_grupo']]['_monitors_alerts_fired_'] = groupview_monitor_fired_alerts ($group['id_grupo'], $user_strict,array($group['id_grupo'])); - $result_list = db_get_all_rows_sql("SELECT COUNT(*) as contado, estado - FROM tagente_estado tae INNER JOIN tagente ta - ON tae.id_agente = ta.id_agente - AND ta.disabled = 0 - AND ta.id_grupo = " . $group['id_grupo'] . " - INNER JOIN tagente_modulo tam - ON tae.id_agente_modulo = tam.id_agente_modulo - AND tam.disabled = 0 - WHERE tae.utimestamp > 0 - GROUP BY estado"); - if ($result_list) { - foreach ($result_list as $result) { - switch ($result['estado']) { - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $list[$group['id_grupo']]['_monitors_critical_'] = (int)$result['contado']; - break; - case AGENT_MODULE_STATUS_WARNING_ALERT: - break; - case AGENT_MODULE_STATUS_WARNING: - $list[$group['id_grupo']]['_monitors_warning_'] = (int)$result['contado']; - break; - case AGENT_MODULE_STATUS_UNKNOWN: - $list[$group['id_grupo']]['_monitors_unknown_'] = (int)$result['contado']; - break; - } - } - } - $result_normal = db_get_row_sql("SELECT COUNT(*) as contado - FROM tagente_estado tae INNER JOIN tagente ta - ON tae.id_agente = ta.id_agente - AND ta.disabled = 0 - AND ta.id_grupo = " . $group['id_grupo'] . " - INNER JOIN tagente_modulo tam - ON tae.id_agente_modulo = tam.id_agente_modulo - AND tam.disabled = 0 - WHERE tae.estado = 0 - AND (tae.utimestamp > 0 OR tam.id_tipo_modulo IN(21,22,23,100)) - GROUP BY estado"); - $list[$group['id_grupo']]['_monitors_ok_'] = isset ($result_normal['contado']) ? $result_normal['contado'] : 0; - - $result_not_init = db_get_row_sql("SELECT COUNT(*) as contado - FROM tagente_estado tae INNER JOIN tagente ta - ON tae.id_agente = ta.id_agente - AND ta.disabled = 0 - AND ta.id_grupo = " . $group['id_grupo'] . " - INNER JOIN tagente_modulo tam - ON tae.id_agente_modulo = tam.id_agente_modulo - AND tam.disabled = 0 - WHERE tae.utimestamp = 0 - AND tae.estado IN (".AGENT_MODULE_STATUS_NO_DATA.",".AGENT_MODULE_STATUS_NOT_INIT." ) - AND tam.id_tipo_modulo NOT IN (21,22,23,100) - GROUP BY estado"); - $list[$group['id_grupo']]['_monitors_not_init_'] = isset ($result_not_init['contado']) ? $result_not_init['contado'] : 0; - } - } - return $list; -} - -function groupview_status_modules_agents($id_user = false, $user_strict = false, $access = 'AR', $force_group_and_tag = true, $returnAllGroup = false) { - global $config; - - if ($id_user == false) { - $id_user = $config['id_user']; - } - - //$acltags = tags_get_user_groups_and_tags ($id_user, $access, $user_strict); - $acltags = users_get_groups ($id_user, $access, true, true); - - $result_list = groupview_get_all_data ($id_user, $user_strict, - $acltags, false, array(), array(), $access); - return $result_list; -} - -function groupview_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) { - $group_clause_strict = implode (",", $id_group_strict); - $group_clause_strict = "(" . $group_clause_strict . ")"; - if ($group_clause_strict !== '()') { - $sql = "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente_estado, tagente - WHERE tagente.id_grupo IN $group_clause_strict AND tagente_modulo.id_agente = tagente.id_agente - AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"; - } - $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 talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo"); - } -} - -function groupview_monitor_fired_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 . ")"; - - 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 talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo - AND times_fired > 0"); -} - function groupview_plain_groups($groups) { $group_result = array(); foreach ($groups as $group) { @@ -505,7 +111,7 @@ function groupview_get_all_counters() { return $data; } -function groupview_get_groups_list($id_user = false, $access = 'AR') { +function groupview_get_groups_list($id_user = false, $access = 'AR', $is_not_paginated = false) { global $config; if ($id_user == false) { $id_user = $config['id_user']; @@ -526,7 +132,9 @@ function groupview_get_groups_list($id_user = false, $access = 'AR') { $counter = count($info); $offset = get_parameter('offset', 0); - $groups_view = array_slice($info, $offset, $config['block_size']); + $groups_view = $is_not_paginated + ? $info + : array_slice($info, $offset, $config['block_size']); $agents_counters = array_reduce($groups_view, function($carry, $item){ $carry[$item['id']] = $item; return $carry; diff --git a/pandora_console/mobile/operation/groups.php b/pandora_console/mobile/operation/groups.php index 14567cc2b5..e371c56986 100644 --- a/pandora_console/mobile/operation/groups.php +++ b/pandora_console/mobile/operation/groups.php @@ -179,29 +179,14 @@ class Groups { $ui->endContent(); $ui->showPage(); } - + private function getListGroups() { $return = array(); - + $system = System::getInstance(); $user = User::getInstance(); - - $all_data = groupview_status_modules_agents ($system->getConfig('id_user'), false, 'AR', false); - $result_groups = groupview_get_groups_list($system->getConfig('id_user'),'AR'); - - foreach ($all_data as $group_all_data) { - $result_groups[0]['_total_agents_'] += $group_all_data["_total_agents_"]; - $result_groups[0]['_monitors_ok_'] += $group_all_data["_monitors_ok_"]; - $result_groups[0]['_monitors_warning_'] += $group_all_data["_monitors_warning_"]; - $result_groups[0]['_monitors_critical_'] += $group_all_data["_monitors_critical_"]; - $result_groups[0]['_monitors_unknown_'] += $group_all_data["_monitors_unknown_"]; - $result_groups[0]['_monitors_not_init_'] += $group_all_data["_monitors_not_init_"]; - $result_groups[0]['_agents_unknown_'] += $group_all_data["_agents_unknown_"]; - $result_groups[0]['_agents_not_init_'] += $group_all_data["_agents_not_init_"]; - $result_groups[0]['_agents_critical_'] += $group_all_data["_agents_critical_"]; - $result_groups[0]['_monitors_alerts_fired_'] += $group_all_data["_monitors_alerts_fired_"]; - } - - return $result_groups; + $result_groups = groupview_get_groups_list($system->getConfig('id_user'),'AR', true); + + return $result_groups['groups']; } } From cc4de37515189a85ae2cd5fd3e63e6d363bc20fb Mon Sep 17 00:00:00 2001 From: artica Date: Sat, 8 Sep 2018 00:01:53 +0200 Subject: [PATCH 05/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a100de916d..c3bb7a0809 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180907 +Version: 7.0NG.726-180908 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 3471b19125..1e52556231 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180907" +pandora_version="7.0NG.726-180908" 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 c9dd17ffdb..736a63306a 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180907'; +use constant AGENT_BUILD => '180908'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index caf59d316f..15dabab4c6 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 7.0NG.726 -%define release 180907 +%define release 180908 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 9a9a2a9bfe..64d6d9418e 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 7.0NG.726 -%define release 180907 +%define release 180908 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 47054d8618..b54be99f75 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180907" +PI_BUILD="180908" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 6a08c3d696..9bf644ba8c 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180907} +{180908} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index ffa141f0ee..9b3b9454cc 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180907)") +#define PANDORA_VERSION ("7.0NG.726(Build 180908)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index edac8ed017..5f5e8afe03 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180907))" + VALUE "ProductVersion", "(7.0NG.726(Build 180908))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0e34a99d3a..35e0f3c746 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180907 +Version: 7.0NG.726-180908 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 cfb0c41813..5804ef9e88 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180907" +pandora_version="7.0NG.726-180908" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index f7dc3c3bc4..35fddd0adb 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 = 'PC180907'; +$build_version = 'PC180908'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index de0ff5f208..b43dbc408c 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index fec4c458eb..6a4f62fb8c 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180907 +%define release 180908 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 3f44b270da..d45d246b18 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180907 +%define release 180908 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index f61dd06c49..3ebe0bbf41 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180907" +PI_BUILD="180908" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index f3645ddd5e..cb85ca4573 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180907"; +my $version = "7.0NG.726 PS180908"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ae23b1eb03..867947d1c6 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180907"; +my $version = "7.0NG.726 PS180908"; # save program name for logging my $progname = basename($0); From 6ae51b5e344edfaa00ae8f8785437cc20c8f821e Mon Sep 17 00:00:00 2001 From: artica Date: Sun, 9 Sep 2018 00:01:23 +0200 Subject: [PATCH 06/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index c3bb7a0809..b4570cc528 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180908 +Version: 7.0NG.726-180909 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 1e52556231..f9bd8ed083 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180908" +pandora_version="7.0NG.726-180909" 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 736a63306a..ee69174cf2 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180908'; +use constant AGENT_BUILD => '180909'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 15dabab4c6..56a480b92c 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 7.0NG.726 -%define release 180908 +%define release 180909 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 64d6d9418e..3ac1e4f424 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 7.0NG.726 -%define release 180908 +%define release 180909 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index b54be99f75..300e3c805c 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180908" +PI_BUILD="180909" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 9bf644ba8c..9bf66bfb5e 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180908} +{180909} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 9b3b9454cc..53450492a1 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180908)") +#define PANDORA_VERSION ("7.0NG.726(Build 180909)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5f5e8afe03..4b9f72d00e 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180908))" + VALUE "ProductVersion", "(7.0NG.726(Build 180909))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 35e0f3c746..5c1369d3d1 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180908 +Version: 7.0NG.726-180909 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 5804ef9e88..9cebcc7f81 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180908" +pandora_version="7.0NG.726-180909" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 35fddd0adb..323ffdb40c 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 = 'PC180908'; +$build_version = 'PC180909'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index b43dbc408c..c923d1e8c8 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 6a4f62fb8c..6e663ee3ce 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180908 +%define release 180909 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index d45d246b18..638038c523 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180908 +%define release 180909 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3ebe0bbf41..74ef61621d 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180908" +PI_BUILD="180909" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index cb85ca4573..7bdb1740e0 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180908"; +my $version = "7.0NG.726 PS180909"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 867947d1c6..0d59eb8715 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180908"; +my $version = "7.0NG.726 PS180909"; # save program name for logging my $progname = basename($0); From 003b734f4e271425a57168c3349918b1926a64cc Mon Sep 17 00:00:00 2001 From: artica Date: Mon, 10 Sep 2018 00:01:22 +0200 Subject: [PATCH 07/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index b4570cc528..0dbe02903e 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180909 +Version: 7.0NG.726-180910 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 f9bd8ed083..43c22cb319 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180909" +pandora_version="7.0NG.726-180910" 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 ee69174cf2..3e3e71074f 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180909'; +use constant AGENT_BUILD => '180910'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 56a480b92c..7eec1a3e8f 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 7.0NG.726 -%define release 180909 +%define release 180910 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 3ac1e4f424..950b1346eb 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 7.0NG.726 -%define release 180909 +%define release 180910 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 300e3c805c..8aec97fb31 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180909" +PI_BUILD="180910" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 9bf66bfb5e..5952952252 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180909} +{180910} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 53450492a1..c69feb1038 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180909)") +#define PANDORA_VERSION ("7.0NG.726(Build 180910)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 4b9f72d00e..7cfe34e396 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180909))" + VALUE "ProductVersion", "(7.0NG.726(Build 180910))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 5c1369d3d1..876b96b26a 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180909 +Version: 7.0NG.726-180910 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 9cebcc7f81..d6cdbf764f 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180909" +pandora_version="7.0NG.726-180910" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 323ffdb40c..50d5e5d4c4 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 = 'PC180909'; +$build_version = 'PC180910'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index c923d1e8c8..ee9dc50dc8 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 6e663ee3ce..af7939b5d5 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180909 +%define release 180910 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 638038c523..bd8afee116 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180909 +%define release 180910 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 74ef61621d..0c085a434a 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180909" +PI_BUILD="180910" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 7bdb1740e0..dc7c2af092 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180909"; +my $version = "7.0NG.726 PS180910"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 0d59eb8715..59a56e027f 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180909"; +my $version = "7.0NG.726 PS180910"; # save program name for logging my $progname = basename($0); From 68627e80b0ad569dcb83e6f82d031e0ef4a4de50 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 10 Sep 2018 09:55:31 +0200 Subject: [PATCH 08/44] fixed metaconsole group view --- .../include/functions_groupview.php | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index 61299a1ec8..e51d0ad5ce 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -35,6 +35,10 @@ function groupview_plain_groups($groups) { function groupview_get_modules_counters($groups_ids = false) { $groups_ids = implode(',', $groups_ids); + $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; + $table_sec = is_metaconsole() + ? 'tmetaconsole_agent_secondary_group' + : 'tagent_secondary_group'; $fields = array ( "g" , @@ -58,7 +62,7 @@ function groupview_get_modules_counters($groups_ids = false) { SUM(ta.fired_count) AS module_alerts, SUM(ta.total_count) AS module_total, ta.id_grupo AS g - FROM tagente ta + FROM $table ta WHERE ta.id_grupo IN ($groups_ids) GROUP BY ta.id_grupo UNION ALL @@ -70,8 +74,8 @@ function groupview_get_modules_counters($groups_ids = false) { SUM(ta.fired_count) AS module_alerts, SUM(ta.total_count) AS module_total, tasg.id_group AS g - FROM tagente ta - INNER JOIN tagent_secondary_group tasg + FROM $table ta + INNER JOIN $table_sec tasg ON ta.id_agente = tasg.id_agent WHERE tasg.id_group IN ($groups_ids) GROUP BY tasg.id_group @@ -82,6 +86,10 @@ function groupview_get_modules_counters($groups_ids = false) { function groupview_get_all_counters() { $all_name = __("All"); $group_acl = Tree::getGroupAclCondition(); + $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; + $table_sec = is_metaconsole() + ? 'tmetaconsole_agent_secondary_group' + : 'tagent_secondary_group'; $sql = "SELECT SUM(ta.normal_count) AS _monitors_ok_, SUM(ta.critical_count) AS _monitors_critical_, @@ -97,11 +105,11 @@ function groupview_get_all_counters() { '$all_name' AS _name_, 0 AS _id_, '' AS _icon_ - FROM tagente ta + FROM $table ta WHERE ta.id_agente IN ( - SELECT ta.id_agente FROM tagente ta - LEFT JOIN tagent_secondary_group tasg + SELECT ta.id_agente FROM $table ta + LEFT JOIN $table_sec tasg ON ta.id_agente = tasg.id_agent WHERE 1=1 $group_acl ) @@ -151,7 +159,7 @@ function groupview_get_groups_list($id_user = false, $access = 'AR', $is_not_pag foreach ($agents_counters as $id_group => $agent_counter) { $list[$id_group]['_name_'] = $agent_counter['name']; $list[$id_group]['_id_'] = $agent_counter['id']; - $list[$id_group]['icon'] = $agent_counter['icon']; + $list[$id_group]['_iconImg_'] = $agent_counter['icon']; $list[$id_group]['_agents_not_init_'] = $agent_counter['counters']['not_init']; $list[$id_group]['_agents_unknown_'] = $agent_counter['counters']['unknown']; From 3d3670f6f917989063754061255a13af6c874e10 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 10 Sep 2018 11:13:31 +0200 Subject: [PATCH 09/44] fixed minor error no agents group view --- pandora_console/include/functions_groupview.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index e51d0ad5ce..fcca629b77 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -34,6 +34,10 @@ function groupview_plain_groups($groups) { } function groupview_get_modules_counters($groups_ids = false) { + if(empty($groups_ids)){ + return array(); + } + $groups_ids = implode(',', $groups_ids); $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; $table_sec = is_metaconsole() From 40ff7b9042a6f6c485aac02588fd860d07fb16b4 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Mon, 10 Sep 2018 11:25:44 +0200 Subject: [PATCH 10/44] Now is possible to link visual consoles from different nodes to the visual console elements --- pandora_console/extras/mr/20.sql | 2 + .../visual_console_builder.editor.js | 4 + .../ajax/visual_console_builder.ajax.php | 11 ++- .../include/functions_visual_map.php | 74 ++++++++------- .../include/functions_visual_map_editor.php | 89 +++++++++++++++++-- pandora_console/pandoradb.sql | 2 + 6 files changed, 140 insertions(+), 42 deletions(-) diff --git a/pandora_console/extras/mr/20.sql b/pandora_console/extras/mr/20.sql index 94e55dcf83..33ac240498 100644 --- a/pandora_console/extras/mr/20.sql +++ b/pandora_console/extras/mr/20.sql @@ -12,8 +12,10 @@ ALTER TABLE tagente_modulo ALTER COLUMN `parent_module_id` SET default 0; ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default'; ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0; ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default'; ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0; ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; +ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index f23da2d6bd..7d3021bfd2 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -829,6 +829,7 @@ function readFields() { values['bars_graph_type'] = $("select[name=bars_graph_type]").val(); values['parent'] = $("select[name=parent]").val(); values['map_linked'] = $("select[name=map_linked]").val(); + values['linked_map_node_id'] = $("input[name=linked_map_node_id]").val(); values['linked_map_status_calculation_type'] = $("select[name=linked_map_status_calculation_type]").val(); values['map_linked_weight'] = $("input[name=map_linked_weight]").val(); values['linked_map_status_service_critical'] = $("input[name=linked_map_status_service_critical]").val(); @@ -1544,6 +1545,8 @@ function loadFieldsFromDB(item) { $("select[name=linked_map_status_calculation_type]").val(val).change(); if (key == 'id_layout_linked') $("select[name=map_linked]").val(val).change(); + if (key == 'linked_layout_node_id') + $("input[name=linked_map_node_id]").val(val); if (key == 'id_layout_linked_weight') $("input[name=map_linked_weight]").val(val); if (key == 'linked_layout_status_as_service_critical') @@ -1958,6 +1961,7 @@ function cleanFields(item) { $("select[name=parent]").val(''); $("select[name=linked_map_status_calculation_type]").val('default').change(); $("select[name=map_linked]").val('').change(); + $("input[name=linked_map_node_id]").val(0); $("input[name=map_linked_weight]").val(''); $("input[name=linked_map_status_service_critical]").val(''); $("input[name=linked_map_status_service_warning]").val(''); diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index d529721b93..d472542390 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -100,6 +100,7 @@ $width = get_parameter('width', null); $height = get_parameter('height', null); $parent = get_parameter('parent', null); $map_linked = get_parameter('map_linked', null); +$linked_map_node_id = get_parameter('linked_map_node_id', null); $linked_map_status_calculation_type = get_parameter('linked_map_status_calculation_type', 'default'); $map_linked_weight = get_parameter('map_linked_weight', null); @@ -613,6 +614,10 @@ switch ($action) { if ($id_agent !== null) { $values['id_agent'] = $id_agent; } + + if ($linked_map_node_id) { + $values['linked_layout_node_id'] = $linked_map_node_id; + } } else if ($id_agent == 0) { $values['id_agent'] = 0; @@ -1135,6 +1140,11 @@ switch ($action) { } $values['id_agente_modulo'] = $id_module; $values['id_layout_linked'] = $map_linked; + + if (defined('METACONSOLE') && $metaconsole) { + $values['linked_layout_node_id'] = (int) $linked_map_node_id; + } + $values['linked_layout_status_type'] = $linked_map_status_calculation_type; if ($map_linked_weight !== null) { @@ -1419,7 +1429,6 @@ if ($get_element_status) { array('id' => $id_element)); $res = visual_map_get_status_element($layoutData); - html_debug($res, true); echo $res; return; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index dcea41910f..c2ab8f6803 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -803,6 +803,18 @@ function visual_map_print_item($mode = "read", $layoutData, } break; } + + // Override url + if ( + is_metaconsole() && + !empty($layoutData["id_layout_linked"]) && + !empty($layoutData["linked_layout_node_id"]) + ) { + $url = ui_meta_get_url_console_child( + $layoutData['linked_layout_node_id'], + "network", "operation/visual_console/render_view&id=" . (int) $layoutData["id_layout_linked"] + ); + } } // + 1 for to avoid the box and lines items are on the top of @@ -3137,38 +3149,22 @@ function visual_map_get_status_element($layoutData) { WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); //Linked to other layout ?? - Only if not module defined - if ($layoutData['id_layout_linked'] != 0) { - if ($layoutData['id_layout_linked_weight'] != 0) { - $calculate_weight = true; - } - else { - $calculate_weight = false; + if (!empty($layoutData['id_layout_linked'])) { + if (!empty($layoutData['linked_layout_node_id'])) { + //Metaconsole db connection + $connection = db_get_row_filter ('tmetaconsole_setup', + array('id' => $layoutData['linked_layout_node_id'])); + if (metaconsole_load_external_db($connection) != NOERR) return VISUAL_MAP_STATUS_UNKNOWN; } + $status = visual_map_get_layout_status($layoutData['id_layout_linked'], $layoutData); - if ($layoutData['id_layout_linked_weight'] > 0) { - $elements_to_compare = db_get_all_rows_sql("SELECT id, element_group FROM tlayout_data WHERE type = 0 AND id_layout = " . $layoutData['id_layout_linked']); - - $childs_group_acl = array(); - foreach ($elements_to_compare as $c) { - if (check_acl ($config['id_user'], $c['element_group'], "VR")) { - $childs_group_acl[] = $c['id']; - } - } - $elements_to_compare = $childs_group_acl; - - $aux_weight = ($status['elements_in_critical'] / count($elements_to_compare)) * 100; - - if ($aux_weight >= $layoutData['id_layout_linked_weight']) { - $status = $status['temp_total']; - } - else { - $status = VISUAL_MAP_STATUS_NORMAL; - if (count($elements_to_compare) == 0) { - $status = VISUAL_MAP_STATUS_UNKNOWN; - } - } + if (!empty($layoutData['linked_layout_node_id'])) { + //Restore db connection + metaconsole_restore_db(); } + + return $status; } else { switch ($layoutData["type"]) { @@ -3676,7 +3672,7 @@ function visual_map_translate_agent_status ($agent_status) { } function visual_map_translate_module_status ($module_status) { - switch ($agent_status) { + switch ($module_status) { case AGENT_MODULE_STATUS_NORMAL: case AGENT_MODULE_STATUS_NORMAL_ALERT: default: @@ -3717,6 +3713,7 @@ function visual_map_get_layout_status ($layout_id, $status_data = array(), $dept if ($depth > 10) return VISUAL_MAP_STATUS_UNKNOWN; $layout_items = db_get_all_rows_filter("tlayout_data", array("id_layout" => $layout_id)); + if ($layout_items === false) return VISUAL_MAP_STATUS_UNKNOWN; // Check for valid items to retrieve the status for @@ -3769,21 +3766,30 @@ function visual_map_get_layout_status ($layout_id, $status_data = array(), $dept $meta_connected_to = null; foreach ($valid_layout_items as $layout_item_data) { + $node_id = null; + if (is_metaconsole()) { - if (empty($layout_item_data["id_metaconsole"]) && $meta_connected_to) { + $node_id = ( + !empty($layout_item_data["id_layout_linked"]) && + !empty($layout_item_data["linked_layout_node_id"]) + ) + ? $layout_item_data["linked_layout_node_id"] + : $layout_item_data["id_metaconsole"]; + + if (empty($node_id) && $meta_connected_to) { metaconsole_restore_db(); // Restore db connection $meta_connected_to = null; } else if ( - !empty($layout_item_data["id_metaconsole"]) && ( + !empty($node_id) && ( empty($meta_connected_to) || - $meta_connected_to != $layout_item_data["id_metaconsole"] + $meta_connected_to != $node_id ) ) { if (!empty($meta_connected_to)) metaconsole_restore_db(); // Restore db connection - $connection = metaconsole_get_connection_by_id($layout_item_data["id_metaconsole"]); + $connection = metaconsole_get_connection_by_id($node_id); if (metaconsole_load_external_db($connection) != NOERR) continue; - $meta_connected_to = $layout_item_data["id_metaconsole"]; + $meta_connected_to = $node_id; } } diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 3039e0dc97..abbc179c61 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -697,13 +697,88 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'group_item', 'static_graph', 'percentile_bar', 'percentile_item', 'module_graph', 'simple_value', 'icon', 'label', 'datos', 'donut_graph'); - $form_items_advance['map_linked_row']['html'] = ''. - __('Linked map') . '' . - '' . html_print_select_from_sql ( - 'SELECT id, name - FROM tlayout - WHERE id != ' . (int) $visualConsole_id, 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true) . - ''; + $visual_maps = db_get_all_rows_filter("tlayout", "id != " . (int) $visualConsole_id, array("id", "name")); + + $form_items_advance['map_linked_row']['html'] = '' + . __('Linked map') + . '' + . ''; + + if (is_metaconsole()) { + $meta_servers = metaconsole_get_servers(); + foreach ($meta_servers as $server) { + if (metaconsole_load_external_db($server) !== NOERR) { + metaconsole_restore_db(); + continue; + } + + $node_visual_maps = db_get_all_rows_filter("tlayout", array(), array("id", "name")); + + foreach ($node_visual_maps as $node_visual_map) { + $node_visual_map["node_id"] = (int) $server["id"]; + $visual_maps[] = $node_visual_map; + } + + metaconsole_restore_db(); + } + + $meta_servers_by_id = array_reduce($meta_servers, function ($arr, $item) { + $arr[$item["id"]] = $item; + return $arr; + }, array()); + + $form_items_advance['map_linked_row']['html'] .= html_print_select_from_sql( + array(), 'map_linked', 0, 'onLinkedMapChange(event)', __('None'), 0, true + ); + $form_items_advance['map_linked_row']['html'] .= html_print_input_hidden( + "linked_map_node_id", 0, true + ); + + ob_start(); + ?> + + '; $status_type_select_items = array( "weight" => __("By status weight"), diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f8eaf58854..b2282c3685 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1381,6 +1381,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` ( `border_color` varchar(200) DEFAULT "", `fill_color` varchar(200) DEFAULT "", `show_statistics` tinyint(2) NOT NULL default '0', + `linked_layout_node_id` INT(10) NOT NULL default 0, `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', `id_layout_linked_weight` int(10) NOT NULL default '0', `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0, @@ -3315,6 +3316,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `border_color` varchar(200) DEFAULT "", `fill_color` varchar(200) DEFAULT "", `show_statistics` tinyint(2) NOT NULL default '0', + `linked_layout_node_id` INT(10) NOT NULL default 0, `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', `id_layout_linked_weight` int(10) NOT NULL default '0', `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0, From 729fe74758033e78dbc0bef44e290a596b9774f4 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 10 Sep 2018 12:08:38 +0200 Subject: [PATCH 11/44] fixed minor error tree view acl --- pandora_console/include/class/Tree.class.php | 2 +- pandora_console/include/functions_groupview.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index a450c53c4e..bfad143ff0 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -278,7 +278,7 @@ class Tree { : " AND $filter "; } - static function getGroupAclCondition() { + public function getGroupAclCondition() { if (users_can_manage_group_all("AR")) return ""; $groups_str= implode(",", $this->userGroupsArray); diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index fcca629b77..4f86497563 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -87,9 +87,9 @@ function groupview_get_modules_counters($groups_ids = false) { return db_get_all_rows_sql($sql); } -function groupview_get_all_counters() { +function groupview_get_all_counters($tree_group) { $all_name = __("All"); - $group_acl = Tree::getGroupAclCondition(); + $group_acl = $tree_group->getGroupAclCondition(); $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; $table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' @@ -180,7 +180,7 @@ function groupview_get_groups_list($id_user = false, $access = 'AR', $is_not_pag $list[$id_group]['_monitors_alerts_fired_'] = (int)$modules_counters[$id_group]['total_module_alerts']; } - array_unshift($list, groupview_get_all_counters()); + array_unshift($list, groupview_get_all_counters($tree_group)); return array( 'groups' => $list, 'counter' => $counter From f123bac91592536c856a03152dd03b2e0cb29061 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 10 Sep 2018 12:58:10 +0200 Subject: [PATCH 12/44] fixed total counters grouw view --- pandora_console/include/functions_groupview.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index 4f86497563..15b4d577bf 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -110,12 +110,14 @@ function groupview_get_all_counters($tree_group) { 0 AS _id_, '' AS _icon_ FROM $table ta - WHERE ta.id_agente - IN ( + WHERE ta.disabled = 0 + AND ta.id_agente IN ( SELECT ta.id_agente FROM $table ta LEFT JOIN $table_sec tasg ON ta.id_agente = tasg.id_agent - WHERE 1=1 $group_acl + WHERE ta.disabled = 0 + $group_acl + GROUP BY ta.id_agente ) "; $data = db_get_row_sql($sql); @@ -138,6 +140,8 @@ function groupview_get_groups_list($id_user = false, $access = 'AR', $is_not_pag 'statusModule' => -1, 'groupID' => 0, 'tagID' => 0, + 'show_not_init_agents' => 1, + 'show_not_init_modules' => 1 )); $info = $tree_group->getArray(); $info = groupview_plain_groups($info); From 022adeb24d44dd7c30f0e584b50e0b9f34b7b8ad Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 10 Sep 2018 15:35:11 +0200 Subject: [PATCH 13/44] fixed metaconsole tree view popup modules --- pandora_console/include/class/Tree.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index bfad143ff0..1ef7129f9d 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -19,6 +19,7 @@ class Tree { protected $id = -1; protected $rootID = -1; protected $serverID = false; + protected $serverName = ''; protected $tree = array(); protected $filter = array(); protected $childrenMethod = "on_demand"; @@ -50,6 +51,9 @@ class Tree { $this->id = $id; $this->rootID = !empty($rootID) ? $rootID : $id; $this->serverID = $serverID; + if (is_metaconsole()) { + $this->serverName = metaconsole_get_server_by_id($serverID); + } $this->childrenMethod = $childrenMethod; $this->access = $access; @@ -481,9 +485,9 @@ class Tree { $module['status'] = $module['estado']; $module['value'] = $module['datos']; - if (is_metaconsole() && !empty($server)) { - $module['serverID'] = $server['id']; - $module['serverName'] = $server['server_name']; + if (is_metaconsole()) { + $module['serverID'] = $this->serverID; + $module['serverName'] = $this->serverName; } else { $module['serverName'] = false; @@ -576,7 +580,7 @@ class Tree { "refresh" => SECONDS_10MINUTES ); - if (is_metaconsole() && !empty($server)) { + if (is_metaconsole()) { // Set the server id $graph_params["server"] = $module['serverID']; } From f7940908c2ff11c87078f1e8eeca4caaf3f6b8fc Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 11 Sep 2018 00:01:25 +0200 Subject: [PATCH 14/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 0dbe02903e..43295751bd 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180910 +Version: 7.0NG.726-180911 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 43c22cb319..699d6983a2 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180910" +pandora_version="7.0NG.726-180911" 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 3e3e71074f..4151b8cf9d 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180910'; +use constant AGENT_BUILD => '180911'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 7eec1a3e8f..4395e23b53 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 7.0NG.726 -%define release 180910 +%define release 180911 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 950b1346eb..07ed8f5b45 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 7.0NG.726 -%define release 180910 +%define release 180911 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 8aec97fb31..56ad0e21e3 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180910" +PI_BUILD="180911" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 5952952252..3618043df3 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180910} +{180911} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index c69feb1038..bf0ce92929 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180910)") +#define PANDORA_VERSION ("7.0NG.726(Build 180911)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7cfe34e396..564c92a71b 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180910))" + VALUE "ProductVersion", "(7.0NG.726(Build 180911))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 876b96b26a..e859f10076 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180910 +Version: 7.0NG.726-180911 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 d6cdbf764f..9af375045d 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180910" +pandora_version="7.0NG.726-180911" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 50d5e5d4c4..2bf5d83982 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 = 'PC180910'; +$build_version = 'PC180911'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ee9dc50dc8..89d69bd466 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index af7939b5d5..1e35f4fc0e 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180910 +%define release 180911 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index bd8afee116..49462431b2 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180910 +%define release 180911 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 0c085a434a..46eb00f5c0 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180910" +PI_BUILD="180911" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index dc7c2af092..f0f7fa0eb0 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180910"; +my $version = "7.0NG.726 PS180911"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 59a56e027f..9991c5ba9c 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180910"; +my $version = "7.0NG.726 PS180911"; # save program name for logging my $progname = basename($0); From 5c54afe6736516bdd36c3daec2b02e13bb311ce9 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 11 Sep 2018 09:15:48 +0200 Subject: [PATCH 15/44] Fixed secondary groups in alerts details --- pandora_console/include/functions_agents.php | 6 +- pandora_console/include/functions_alerts.php | 14 ++- .../operation/agentes/alerts_status.php | 102 ++++++------------ 3 files changed, 45 insertions(+), 77 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 9199604b75..e0b7f284cd 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -966,12 +966,12 @@ function agents_get_group_agents ( $filter['order'] = 'alias'; if (is_metaconsole()) { - $table_name = 'tmetaconsole_agent LEFT JOIN tmetaconsole_agent_secondary_group ON ta.id_agente = tasg.id_agent'; + $table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent'; $fields = array( - 'id_tagente AS id_agente', + 'ta.id_tagente AS id_agente', 'alias', - 'id_tmetaconsole_setup AS id_server' + 'ta.id_tmetaconsole_setup AS id_server' ); } else { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 4d89dca614..a089f8394f 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -50,7 +50,10 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s $id_groups = array_keys($groups); - $group_query = " AND t3.id_grupo IN (" . implode(',', $id_groups) . ") "; + $group_query = " AND ( + t3.id_grupo IN (" . implode(',', $id_groups) . ") + OR tasg.id_group IN (" . implode(',', $id_groups) . ") + )"; } else { $group_query = ""; @@ -1792,9 +1795,12 @@ function get_group_alerts($id_group, $filter = '', $options = false, FROM tagente_modulo WHERE delete_pending = 0 AND id_agente IN (SELECT id_agente - FROM tagente + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent WHERE - id_grupo IN (' . implode(',', $id_group) . '))'; + id_grupo IN (' . implode(',', $id_group) . ') + OR id_group IN (' . implode(',', $id_group) . '))'; } } @@ -1861,6 +1867,8 @@ function get_group_alerts($id_group, $filter = '', $options = false, ON talert_template_modules.id_agent_module = t2.id_agente_modulo INNER JOIN tagente t3 ON t2.id_agente = t3.id_agente + LEFT JOIN tagent_secondary_group tasg + ON tasg.id_agent = t2.id_agente INNER JOIN talert_templates t4 ON talert_template_modules.id_alert_template = t4.id WHERE id_agent_module in (%s) %s %s %s", diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 12c7fd5d8d..753baf56bb 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -187,77 +187,37 @@ if ($alert_validate) { enterprise_hook('open_meta_frame'); if ($free_search != '') { - switch ($config["dbtype"]) { - case "mysql": - $whereAlertSimple = 'AND (' . - 'id_alert_template IN ( - SELECT id - FROM talert_templates - WHERE name LIKE "%' . $free_search . '%") OR ' . - 'id_alert_template IN ( - SELECT id - FROM talert_templates - WHERE id_alert_action IN ( - SELECT id - FROM talert_actions - WHERE name LIKE "%' . $free_search . '%")) OR ' . - 'talert_template_modules.id IN ( - SELECT id_alert_template_module - FROM talert_template_module_actions - WHERE id_alert_action IN ( - SELECT id - FROM talert_actions - WHERE name LIKE "%' . $free_search . '%")) OR ' . - 'id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE nombre LIKE "%' . $free_search . '%") OR ' . - 'id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_agente IN ( - SELECT id_agente - FROM tagente - WHERE nombre LIKE "%' . $free_search . '%") OR alias LIKE "%' . $free_search . '%")' . - ')'; - - break; - case "postgresql": - case "oracle": - $whereAlertSimple = 'AND (' . - 'id_alert_template IN ( - SELECT id - FROM talert_templates - WHERE name LIKE \'%' . $free_search . '%\') OR ' . - 'id_alert_template IN ( - SELECT id - FROM talert_templates - WHERE id_alert_action IN ( - SELECT id - FROM talert_actions - WHERE name LIKE \'%' . $free_search . '%\')) OR ' . - 'talert_template_modules.id IN ( - SELECT id_alert_template_module - FROM talert_template_module_actions - WHERE id_alert_action IN ( - SELECT id - FROM talert_actions - WHERE name LIKE \'%' . $free_search . '%\')) OR ' . - 'id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE nombre LIKE \'%' . $free_search . '%\') OR ' . - 'id_agent_module IN ( - SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_agente IN ( - SELECT id_agente - FROM tagente - WHERE nombre LIKE \'%' . $free_search . '%\' OR alias LIKE \'%' . $free_search . '%\'))' . - ')'; - - break; - } + $whereAlertSimple = 'AND (' . + 'id_alert_template IN ( + SELECT id + FROM talert_templates + WHERE name LIKE "%' . $free_search . '%") OR ' . + 'id_alert_template IN ( + SELECT id + FROM talert_templates + WHERE id_alert_action IN ( + SELECT id + FROM talert_actions + WHERE name LIKE "%' . $free_search . '%")) OR ' . + 'talert_template_modules.id IN ( + SELECT id_alert_template_module + FROM talert_template_module_actions + WHERE id_alert_action IN ( + SELECT id + FROM talert_actions + WHERE name LIKE "%' . $free_search . '%")) OR ' . + 'id_agent_module IN ( + SELECT id_agente_modulo + FROM tagente_modulo + WHERE nombre LIKE "%' . $free_search . '%") OR ' . + 'id_agent_module IN ( + SELECT id_agente_modulo + FROM tagente_modulo + WHERE id_agente IN ( + SELECT id_agente + FROM tagente + WHERE nombre LIKE "%' . $free_search . '%") OR alias LIKE "%' . $free_search . '%")' . + ')'; } else { $whereAlertSimple = ''; From f117d1af43852f50f8f683bd076118016523a840 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 11 Sep 2018 09:33:24 +0200 Subject: [PATCH 16/44] fixed heigth charts for reports --- .../godmode/setup/setup_visuals.php | 4 ++ pandora_console/include/functions.php | 2 +- pandora_console/include/functions_config.php | 19 +++--- pandora_console/include/functions_graph.php | 4 +- .../include/functions_reporting.php | 62 +++++++++---------- 5 files changed, 48 insertions(+), 43 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 88b2392e14..057c220001 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -709,6 +709,10 @@ $table_chars->data[$row][1] = html_print_select($options_zoom_graphs, 'zoom_grap $row++; $table_chars->data[$row][0] = __('Graph image height'); +$table_chars->data[$row][0] .= ui_print_help_tip( + __('This is the height in pixels of the module graph or custom graph in the reports (both: HTML and PDF)'), + true +); $table_chars->data[$row][1] = html_print_input_text ('graph_image_height', $config['graph_image_height'], '', 20, 20, true); $row++; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7982e62995..be0cb70178 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3274,7 +3274,7 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal $img_url = $config["homeurl"] . "attachment/" . $img_file; $width_img = 500; - $height_img = (isset($config['graph_image_height'])) ? $config['graph_image_height'] : 350; + $height_img = (isset($config['graph_image_height'])) ? $config['graph_image_height'] : 280; $params['height'] = $height_img; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 3bc48f519a..ca94033ef7 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -631,10 +631,10 @@ function config_update_config () { if (!config_update_value ('type_mode_graph', (int) get_parameter('type_mode_graph', 0))) $error_update[] = __('Default soft graphs'); - if (!config_update_value ('zoom_graph', (int) get_parameter('zoom_graph', 0))) + if (!config_update_value ('zoom_graph', (int) get_parameter('zoom_graph', 1))) $error_update[] = __('Default zoom graphs'); - if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 0))) + if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 280))) $error_update[] = __('Default height of the chart image'); if (!config_update_value ('classic_menu', (bool) get_parameter('classic_menu', false))) @@ -667,10 +667,7 @@ function config_update_config () { } } //-------------------------------------------------- - - - - + //-------------------------------------------------- // CUSTOM INTERVAL VALUES //-------------------------------------------------- @@ -1859,11 +1856,15 @@ function config_process_config () { if (!isset($config['render_proc'])) { config_update_value ('render_proc', 0); } - + if (!isset($config['graph_image_height'])) { - config_update_value ('graph_image_height', 320); + config_update_value ('graph_image_height', 280); } - + + if (!isset($config['zoom_graph'])) { + config_update_value ('zoom_graph', 1); + } + if (!isset($config["render_proc_ok"])) { config_update_value ('render_proc_ok', __('Ok') ); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 36b36a345d..2b3c149b99 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -892,7 +892,9 @@ function grafico_modulo_sparse ($params) { } if(!isset($params['zoom'])){ - $params['zoom'] = $config['zoom_graph']; + $params['zoom'] = $config['zoom_graph'] + ? $config['zoom_graph'] + : 1; } if(!isset($params['type_mode_graph'])){ diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index c5e8e53725..bf2dd79126 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -628,7 +628,6 @@ function reporting_make_reporting_data($report = null, $id_report, } $index_content++; } - return reporting_check_structure_report($report); } @@ -2807,18 +2806,17 @@ function agents_get_network_interfaces_array( $row_interface['chart'] = null; $width = null; - $height = null; $params =array( 'period' => $content['period'], 'width' => $width, - 'height' => $height, 'unit_name' => array_fill(0, count($interface['traffic']), __("bytes/s")), 'date' => $report["datetime"], 'only_image'=> $pdf, 'homeurl' => $config['homeurl'], 'fullscale' => $fullscale, - 'server_id' => $id_meta + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'] ); $params_combined = array( @@ -3540,7 +3538,8 @@ function reporting_simple_baseline_graph($report, $content, 'homeurl' => ui_get_full_url(false, false, false, false), 'ttl' => $ttl, 'array_data_create' => $baseline_data, - 'server_id' => $id_meta + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'] ); $return['chart'] = grafico_modulo_sparse ($params); @@ -3645,13 +3644,13 @@ function reporting_projection_graph($report, $content, $params =array( 'period' => $content['period'], 'width' => $width, - 'height' => $height, 'date' => $report["datetime"], 'unit' => '', 'only_image' => $pdf, 'homeurl' => ui_get_full_url(false, false, false, false) . '/', 'ttl' => $ttl, - 'server_id' => $id_meta + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'] ); $params_combined = array( @@ -3884,27 +3883,27 @@ function reporting_value($report, $content, $type,$pdf) { $return['agent_name'] = $agent_name; $return['module_name'] = $module_name; - + if($pdf){ $only_image = 1; } $params =array( - 'agent_module_id' => $content['id_agent_module'], - 'period' => $content['period'], - 'width' => '600px', - 'pure' => false,///true - 'date' => $report["datetime"], - 'only_image' => $only_image, - 'homeurl' => ui_get_full_url(false, false, false, false), - 'ttl' => 1,///2 - 'type_graph' => $config['type_module_charts'], - 'time_interval' => $content['lapse'], - 'server_id' => $id_meta + 'agent_module_id' => $content['id_agent_module'], + 'period' => $content['period'], + 'width' => '600px', + 'pure' => false,///true + 'date' => $report["datetime"], + 'only_image' => $only_image, + 'homeurl' => ui_get_full_url(false, false, false, false), + 'ttl' => 1,///2 + 'type_graph' => $config['type_module_charts'], + 'time_interval' => $content['lapse'], + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'] ); - - switch ($type) { + switch ($type) { case 'max': if($content['lapse_calc'] == 0){ $value = reporting_get_agentmodule_data_max( @@ -6344,24 +6343,23 @@ function reporting_custom_graph($report, $content, $type = 'dinamic', $return['chart'] = ''; $width =null; - $height =null; switch ($type) { case 'dinamic': case 'static': - $params =array( 'period' => $content['period'], 'width' => $width, - 'height' => $height, 'date' => $report["datetime"], 'only_image' => $pdf, 'homeurl' => ui_get_full_url(false, false, false, false), 'ttl' => $ttl, 'percentil' => $graphs[0]["percentil"], 'fullscale' => $graphs[0]["fullscale"], - 'server_id' => $id_meta + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'] ); + $params_combined = array( 'stacked' => $graphs[0]["stacked"], 'summatory' => $graphs[0]["summatory_series"], @@ -6464,7 +6462,8 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', 'show_unknown' => true, 'percentil' => ($content['style']['percentil'] == 1) ? $config['percentil'] : null, 'fullscale' => $fullscale, - 'server_id' => $id_meta + 'server_id' => $id_meta, + 'height' => $config['graph_image_height'] ); $return['chart'] = grafico_modulo_sparse($params); @@ -6491,15 +6490,14 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', function reporting_get_date_text($report = null, $content = null) { global $config; - + $return = array(); $return['date'] = null; $return['period'] = null; $return['from'] = null; $return['to'] = null; - + if (!empty($report) && !empty($content)) { - if ($content['period'] == 0) { $es = json_decode($content['external_source'], true); if ($es['date'] == 0) { @@ -6515,7 +6513,7 @@ function reporting_get_date_text($report = null, $content = null) { $return['to'] = $report["datetime"]; } } - + return $return; } @@ -6531,7 +6529,7 @@ function reporting_check_structure_report($return) { $return['datetime'] = ""; if (!isset($return['period'])) $return['period'] = ""; - + return $return; } @@ -6551,7 +6549,7 @@ function reporting_check_structure_content($report) { $report["date"]['from'] = ""; $report["date"]['to'] = ""; } - + return $report; } From 7eed20933954efcb53f98609726abd642f040c26 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 11 Sep 2018 11:37:11 +0200 Subject: [PATCH 17/44] fixed error size graph in dashboard --- pandora_console/include/graphs/flot/pandora.flot.js | 4 +++- pandora_console/include/graphs/functions_flot.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 7af352cd69..e3abe74681 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1673,7 +1673,9 @@ function pandoraFlotArea( graph_id, values, legend, // Re-calculate the graph height with the legend height if (dashboard || vconsole) { - var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height(); + $acum = 0; + if(dashboard) $acum = 35; + var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height() - $acum; if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){ } else { diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 27b64fdde0..bf423d2267 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -132,9 +132,10 @@ function flot_area_graph ( $params['grid_color'] = '#C1C1C1'; break; } + $padding_vconsole = $params['dashboard'] ? 'padding: 1px 0px 10px 10px;' : ''; // Parent layer - $return = "
"; + $return = "
"; // Set some containers to legend, graph, timestamp tooltip, etc. if($params['show_legend']){ $return .= "

"; From 9c032f4dfe7246b4d570c9d8a8d8315ffa43c878 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 11 Sep 2018 13:22:51 +0200 Subject: [PATCH 18/44] [Secondary groups] Fixed group report --- pandora_console/include/class/Tree.class.php | 52 +---- pandora_console/include/functions_agents.php | 29 +++ pandora_console/include/functions_groups.php | 212 ++++++++++++------ pandora_console/include/functions_modules.php | 35 ++- .../include/functions_reporting.php | 67 +++--- 5 files changed, 242 insertions(+), 153 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 1ef7129f9d..e18cfb599e 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -155,23 +155,23 @@ class Tree { return array( 'warning' => array( 'header' => "0 AS x_critical, SUM(total) AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", - 'condition' => "AND ta.warning_count > 0 AND ta.critical_count = 0" + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_WARNING, $this->filter['show_not_init_agents']) ), 'critical' => array( 'header' => "SUM(total) AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", - 'condition' => "AND ta.critical_count > 0" + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_CRITICAL, $this->filter['show_not_init_agents']) ), 'normal' => array( 'header' => "0 AS x_critical, 0 AS x_warning, SUM(total) AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", - 'condition' => "AND ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count = 0 AND ta.normal_count > 0" + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_NORMAL, $this->filter['show_not_init_agents']) ), 'unknown' => array( 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, SUM(total) AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", - 'condition' => "AND ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0" + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_UNKNOWN, $this->filter['show_not_init_agents']) ), 'not_init' => array( 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, SUM(total) AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", - 'condition' => $this->filter['show_not_init_agents'] ? "AND ta.total_count = ta.notinit_count" : " AND 1=0" + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_NOT_INIT, $this->filter['show_not_init_agents']) ), 'alerts' => array( 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, SUM(total) AS x_alerts, 0 AS x_total, g", @@ -179,7 +179,7 @@ class Tree { ), 'total' => array( 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, SUM(total) AS x_total, g", - 'condition' => $this->filter['show_not_init_agents'] ? "" : "AND ta.total_count <> ta.notinit_count" + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_ALL, $this->filter['show_not_init_agents']) ) ); } @@ -232,43 +232,9 @@ class Tree { ? $state : $this->filter['statusModule']; - $filter = array(); - switch ($selected_status) { - case AGENT_MODULE_STATUS_CRITICAL_ALERT: - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $filter[] = "( - tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_ALERT." - OR tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_BAD." - )"; - break; - case AGENT_MODULE_STATUS_WARNING_ALERT: - case AGENT_MODULE_STATUS_WARNING: - $filter[] = "( - tae.estado = ".AGENT_MODULE_STATUS_WARNING_ALERT." - OR tae.estado = ".AGENT_MODULE_STATUS_WARNING." - )"; - break; - case AGENT_MODULE_STATUS_UNKNOWN: - $filter[] = "tae.estado = ".AGENT_MODULE_STATUS_UNKNOWN." "; - break; - case AGENT_MODULE_STATUS_NO_DATA: - case AGENT_MODULE_STATUS_NOT_INIT: - $filter[] = "( - tae.estado = ".AGENT_MODULE_STATUS_NO_DATA." - OR tae.estado = ".AGENT_MODULE_STATUS_NOT_INIT." - )"; - break; - case AGENT_MODULE_STATUS_NORMAL_ALERT: - case AGENT_MODULE_STATUS_NORMAL: - $filter[] = "( - tae.estado = ".AGENT_MODULE_STATUS_NORMAL_ALERT." - OR tae.estado = ".AGENT_MODULE_STATUS_NORMAL." - )"; - break; - default: - $filter[] = "1=1"; - break; - } + $filter = array( + modules_get_state_condition($selected_status) + ); if (!$this->filter['show_not_init_modules'] && $state === false) { if (!empty($filter)) $filter[] = "( diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index e0b7f284cd..5bdd03a418 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2742,4 +2742,33 @@ function agents_check_access_agent ($id_agent, $access = "AR") { // Return null otherwise return null; } + +function agents_get_status_clause($state, $show_not_init = true) { + switch ($state) { + case AGENT_STATUS_CRITICAL: + return "(ta.critical_count > 0)"; + case AGENT_STATUS_WARNING: + return "(ta.warning_count > 0 AND ta.critical_count = 0)"; + case AGENT_STATUS_UNKNOWN: + return "( + ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0 + )"; + case AGENT_STATUS_NOT_INIT: + return $show_not_init + ? "(ta.total_count = ta.notinit_count)" + : "1=0"; + case AGENT_STATUS_NORMAL: + return "( + ta.critical_count = 0 AND ta.warning_count = 0 + AND ta.unknown_count = 0 AND ta.normal_count > 0 + )"; + case AGENT_STATUS_ALL: + default: + return $show_not_init + ? "1=1" + : "(ta.total_count <> ta.notinit_count)"; + } + // If the state is not an expected state, return no condition + return "1=1"; +} ?> diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 443d84c07f..98c13d5db7 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1956,85 +1956,159 @@ function groups_get_not_init_monitors ($group, $agent_filter = array(), $module_ } // 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) { - $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"; - $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"); - } +function groups_monitor_alerts ($group_array) { + $total = groups_monitor_alerts_total_counters($group_array); + return $total['total']; } // Get alert configured currently FIRED, except disabled +function groups_monitor_fired_alerts ($group_array) { + $total = groups_monitor_alerts_total_counters($group_array); + return $total['fired']; +} -function groups_monitor_fired_alerts ($group_array, $strict_user = false, $id_group_strict = false) { - +function groups_monitor_alerts_total_counters ($group_array) { // If there are not groups to query, we jump to nextone - + $default_total = array('total' => 0, 'fired' => 0); if (empty ($group_array)) { - return 0; - + return $default_total; } else if (!is_array ($group_array)) { $group_array = array($group_array); } - - $group_clause = implode (",", $group_array); - $group_clause = "(" . $group_clause . ")"; - - if ($strict_user) { - $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 - AND times_fired > 0 "; - $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"); + $group_clause = implode (",", $group_array); + $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + + $alerts = db_get_row_sql ("SELECT + COUNT(tatm.id) AS total, + SUM(IF(tatm.times_fired > 0, 1, 0)) AS fired + FROM talert_template_modules tatm + INNER JOIN tagente_modulo tam + ON tatm.id_agent_module = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.id_agente IN ( + SELECT ta.id_agente + FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND $group_clause + ) AND tam.disabled = 0" + ); + + return ($alerts === false) ? $default_total : $alerts; +} + +function groups_monitor_total_counters ($group_array, $search_in_testado = false) { + $default_total = array( + 'ok' => 0, 'critical' => 0, 'warning' => 0, + 'unknown' => 0, 'not_init' => 0, 'total' => 0 + ); + if (empty ($group_array)) { + return $default_total; } - + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + $group_clause = implode (",", $group_array); + $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + + if ($search_in_testado) { + $condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT); + $condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT); + $condition_unknown = modules_get_state_condition(AGENT_MODULE_STATUS_UNKNOWN); + $condition_not_init = modules_get_state_condition(AGENT_MODULE_STATUS_NO_DATA); + $condition_normal = modules_get_state_condition(AGENT_MODULE_STATUS_NORMAL); + $sql = + "SELECT SUM(IF($condition_normal, 1, 0)) AS ok, + SUM(IF($condition_critical, 1, 0)) AS critical, + SUM(IF($condition_warning, 1, 0)) AS warning, + SUM(IF($condition_unknown, 1, 0)) AS unknown, + SUM(IF($condition_not_init, 1, 0)) AS not_init, + COUNT(tam.id_agente_modulo) AS total + FROM tagente ta + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tam.id_agente_modulo = tae.id_agente_modulo + WHERE ta.disabled = 0 AND tam.disabled = 0 + AND ta.id_agente IN ( + SELECT ta.id_agente FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND $group_clause + GROUP BY ta.id_agente + ) + "; + } else { + $sql = + "SELECT SUM(ta.normal_count) AS ok, + SUM(ta.critical_count) AS critical, + SUM(ta.warning_count) AS warning, + SUM(ta.unknown_count) AS unknown, + SUM(ta.notinit_count) AS not_init, + SUM(ta.total_count) AS total + FROM tagente ta + WHERE ta.disabled = 0 + AND ta.id_agente IN ( + SELECT ta.id_agente FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND $group_clause + GROUP BY ta.id_agente + ) + "; + } + $monitors = db_get_row_sql($sql); + + return ($monitors === false) ? $default_total : $monitors; +} + +function groups_agents_total_counters ($group_array) { + $default_total = array( + 'ok' => 0, 'critical' => 0, 'warning' => 0, + 'unknown' => 0, 'not_init' => 0, 'total' => 0 + ); + if (empty ($group_array)) { + return $default_total; + } + else if (!is_array ($group_array)) { + $group_array = array($group_array); + } + $group_clause = implode (",", $group_array); + $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + + $condition_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); + $condition_warning = agents_get_status_clause(AGENT_STATUS_WARNING); + $condition_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); + $condition_not_init = agents_get_status_clause(AGENT_STATUS_NOT_INIT); + $condition_normal = agents_get_status_clause(AGENT_STATUS_NORMAL); + $sql = + "SELECT SUM(IF($condition_normal, 1, 0)) AS ok, + SUM(IF($condition_critical, 1, 0)) AS critical, + SUM(IF($condition_warning, 1, 0)) AS warning, + SUM(IF($condition_unknown, 1, 0)) AS unknown, + SUM(IF($condition_not_init, 1, 0)) AS not_init, + COUNT(ta.id_agente) AS total + FROM tagente ta + WHERE ta.disabled = 0 + AND ta.id_agente IN ( + SELECT ta.id_agente FROM tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND $group_clause + GROUP BY ta.id_agente + ) + "; + + $agents = db_get_row_sql($sql); + + return ($agents === false) ? $default_total : $agents; } /** @@ -2771,7 +2845,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[$i]['_monitors_warning_'] = (int) groups_get_warning_monitors ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); $list[$i]['_monitors_unknown_'] = (int) groups_get_unknown_monitors ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); $list[$i]['_monitors_not_init_'] = (int) groups_get_not_init_monitors ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); - $list[$i]['_monitors_alerts_fired_'] = groups_monitor_fired_alerts ($id, $user_strict, $id); + $list[$i]['_monitors_alerts_fired_'] = groups_monitor_fired_alerts ($id); $list[$i]['_total_agents_'] = (int) groups_get_total_agents ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); $list[$i]['_agents_unknown_'] = (int) groups_get_unknown_agents ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); $list[$i]['_agents_not_init_'] = (int) groups_get_not_init_agents ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); @@ -2780,7 +2854,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu $list[$i]['_agents_ok_'] = (int) groups_get_normal_agents ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); $list[$i]['_agents_warning_'] = (int) groups_get_warning_agents ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); $list[$i]['_agents_critical_'] = (int) groups_get_critical_agents ($id, $agent_filter, $module_filter, $user_strict, $acltags, $config["realtimestats"]); - $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id, $user_strict, $id); + $list[$i]['_monitors_alerts_'] = groups_monitor_alerts ($id); // TODO //~ $list[$i]["_total_checks_"] diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 00e643e7ca..f8e632dad4 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2775,4 +2775,37 @@ function modules_get_counter_by_states($state) { // to not show any data return false; } -?> + +function modules_get_state_condition($state) { + switch ($state) { + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + case AGENT_MODULE_STATUS_CRITICAL_BAD: + return "( + tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_ALERT." + OR tae.estado = ".AGENT_MODULE_STATUS_CRITICAL_BAD." + )"; + case AGENT_MODULE_STATUS_WARNING_ALERT: + case AGENT_MODULE_STATUS_WARNING: + return "( + tae.estado = ".AGENT_MODULE_STATUS_WARNING_ALERT." + OR tae.estado = ".AGENT_MODULE_STATUS_WARNING." + )"; + case AGENT_MODULE_STATUS_UNKNOWN: + return "tae.estado = ".AGENT_MODULE_STATUS_UNKNOWN." "; + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: + return "( + tae.estado = ".AGENT_MODULE_STATUS_NO_DATA." + OR tae.estado = ".AGENT_MODULE_STATUS_NOT_INIT." + )"; + case AGENT_MODULE_STATUS_NORMAL_ALERT: + case AGENT_MODULE_STATUS_NORMAL: + return "( + tae.estado = ".AGENT_MODULE_STATUS_NORMAL_ALERT." + OR tae.estado = ".AGENT_MODULE_STATUS_NORMAL." + )"; + } + // If the state is not an expected state, return no condition + return "1=1"; +} +?> \ No newline at end of file diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index c5e8e53725..642dec50f4 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -7000,54 +7000,41 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') { continue; } } - + if (!empty($group_array)) { + $monitors_info = groups_monitor_total_counters($group_array, true); // Get monitor NOT INIT, except disabled AND async modules - $data["monitor_not_init"] += (int) groups_get_not_init_monitors ($group_array, array(), array(), false, false, true); - - // Get monitor OK, except disabled and non-init - $data["monitor_ok"] += (int) groups_get_normal_monitors ($group_array, array(), array(), false, false, true); - - // Get monitor CRITICAL, except disabled and non-init - $data["monitor_critical"] += (int) groups_get_critical_monitors ($group_array, array(), array(), false, false, true); - - // Get monitor WARNING, except disabled and non-init - $data["monitor_warning"] += (int) groups_get_warning_monitors ($group_array, array(), array(), false, false, true); - - // Get monitor UNKNOWN, except disabled and non-init - $data["monitor_unknown"] += (int) groups_get_unknown_monitors ($group_array, array(), array(), false, false, true); - - // Get alerts configured, except disabled - $data["monitor_alerts"] += groups_monitor_alerts ($group_array) ; - - // Get alert configured currently FIRED, except disabled - $data["monitor_alerts_fired"] += groups_monitor_fired_alerts ($group_array); - - // Calculate totals using partial counts from above - - // Get TOTAL non-init modules, except disabled ones and async modules + $data["monitor_not_init"] += $monitors_info['not_init']; $data["total_not_init"] += $data["monitor_not_init"]; - + // Get monitor OK, except disabled and non-init + $data["monitor_ok"] += $monitors_info['ok']; + // Get monitor CRITICAL, except disabled and non-init + $data["monitor_critical"] += $monitors_info['critical']; + // Get monitor WARNING, except disabled and non-init + $data["monitor_warning"] += $monitors_info['warning']; + // Get monitor UNKNOWN, except disabled and non-init + $data["monitor_unknown"] += $monitors_info['unknown']; + $data["monitor_checks"] += $monitors_info['total']; + + // Get alerts configured, except disabled + $alerts_info = groups_monitor_alerts_total_counters ($group_array); + $data["monitor_alerts"] += $alerts_info['total']; + // Get alert configured currently FIRED, except disabled + $data["monitor_alerts_fired"] += $alerts_info['fired']; + + $agents_info = groups_agents_total_counters($group_array); // Get TOTAL agents in a group - $data["total_agents"] += (int) groups_get_total_agents ($group_array, array(), array(), false, false, true); - + $data["total_agents"] += $agents_info['total']; // Get Agents OK - $data["agent_ok"] += (int) groups_get_normal_agents ($group_array, array(), array(), false, false, true); - - // Get Agents Warning - $data["agent_warning"] += (int) groups_get_warning_agents ($group_array, array(), array(), false, false, true); - + $data["agent_ok"] += $agents_info['ok']; + // Get Agents Warning + $data["agent_warning"] += $agents_info['warning']; // Get Agents Critical - $data["agent_critical"] += (int) groups_get_critical_agents ($group_array, array(), array(), false, false, true); - + $data["agent_critical"] += $agents_info['critical']; // Get Agents Unknown - $data["agent_unknown"] += (int) groups_get_unknown_agents ($group_array, array(), array(), false, false, true); - + $data["agent_unknown"] += $agents_info['unknown']; // Get Agents Not init - $data["agent_not_init"] += (int) groups_get_not_init_agents ($group_array, array(), array(), false, false, true); - - // Get total count of monitors for this group, except disabled. - $data["monitor_checks"] += $data["monitor_not_init"] + $data["monitor_unknown"] + $data["monitor_warning"] + $data["monitor_critical"] + $data["monitor_ok"]; + $data["agent_not_init"] += $agents_info['not_init']; } } // Calculate not_normal monitors From 2fa2d713b8e9f10a98ae88ea2fe7a770b37ebe40 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Tue, 11 Sep 2018 14:54:26 +0200 Subject: [PATCH 19/44] Removed the Static Graph requirement for all the status calculation types of the visual console linked elements --- pandora_console/include/functions_visual_map.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index c2ab8f6803..b92f17e230 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -3735,17 +3735,6 @@ function visual_map_get_layout_status ($layout_id, $status_data = array(), $dept !empty($layout_item_data["id_layout_linked"]) || !empty($layout_item_data["id_agente_modulo"]) || !empty($layout_item_data["id_agent"]) - ) && ( - // Weight and service types for status calculation require STATIC_GRAPH items - ( - $status_data["linked_layout_status_type"] !== "weight" && - $status_data["linked_layout_status_type"] !== "service" - ) || ( - $layout_item_data['type'] == STATIC_GRAPH && ( - $status_data["linked_layout_status_type"] === "weight" || - $status_data["linked_layout_status_type"] === "service" - ) - ) ) && // ACL check check_acl($config["id_user"], $layout_item_data["element_group"], "VR") From ed0d89ec73cc9ce5b3cebe7f4f5370dcc0e41542 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 11 Sep 2018 17:06:35 +0200 Subject: [PATCH 20/44] fixed baseline report --- pandora_console/include/functions_graph.php | 128 +++++++++++++----- .../include/functions_reporting.php | 77 +---------- 2 files changed, 93 insertions(+), 112 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 2b3c149b99..1fc266e8b5 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -265,7 +265,7 @@ function grafico_modulo_sparse_data_chart ( $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || $data_module_graph['id_module_type'] == 100 || - $params['baseline'] || $params['projection'] + $params['projection'] ){ $data = db_get_all_rows_filter ( @@ -966,53 +966,58 @@ function grafico_modulo_sparse ($params) { } if(!$params['array_data_create']){ - if ($params['compare'] !== false) { - $series_suffix = 2; + if($params['baseline']){ + $array_data = get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params); + } + else{ + if ($params['compare'] !== false) { + $series_suffix = 2; - $date_array_prev['final_date'] = $date_array['start_date']; - $date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period']; - $date_array_prev['period'] = $date_array['period']; + $date_array_prev['final_date'] = $date_array['start_date']; + $date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period']; + $date_array_prev['period'] = $date_array['period']; - if ($params['compare'] === 'overlapped') { - $params['flag_overlapped'] = 1; - } - else{ - $params['flag_overlapped'] = 0; + if ($params['compare'] === 'overlapped') { + $params['flag_overlapped'] = 1; + } + else{ + $params['flag_overlapped'] = 0; + } + + $array_data = grafico_modulo_sparse_data( + $agent_module_id, + $date_array_prev, + $data_module_graph, + $params, + $series_suffix + ); + + switch ($params['compare']) { + case 'separated': + case 'overlapped': + // Store the chart calculated + $array_data_prev = $array_data; + $legend_prev = $legend; + break; + } } + $series_suffix = 1; + $params['flag_overlapped'] = 0; + $array_data = grafico_modulo_sparse_data( $agent_module_id, - $date_array_prev, + $date_array, $data_module_graph, $params, $series_suffix ); - switch ($params['compare']) { - case 'separated': - case 'overlapped': - // Store the chart calculated - $array_data_prev = $array_data; - $legend_prev = $legend; - break; - } - } - - $series_suffix = 1; - $params['flag_overlapped'] = 0; - - $array_data = grafico_modulo_sparse_data( - $agent_module_id, - $date_array, - $data_module_graph, - $params, - $series_suffix - ); - - if($params['compare']){ - if ($params['compare'] === 'overlapped') { - $array_data = array_merge($array_data, $array_data_prev); - $legend = array_merge($legend, $legend_prev); + if($params['compare']){ + if ($params['compare'] === 'overlapped') { + $array_data = array_merge($array_data, $array_data_prev); + $legend = array_merge($legend, $legend_prev); + } } } } @@ -5098,4 +5103,53 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { return d3_sunburst_graph ($graph_data, $width, $height, true); } +function get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params){ + $period = $date_array["period"]; + $date = $date_array["final_date"]; + $array_data = array(); + for ($i = 0; $i < 4; $i++) { + $date_array = array(); + $date_array["period"] = $period; + $date_array["final_date"] = $date - $period * $i; + $date_array["start_date"] = $date - $period * ($i + 1); + + $data = grafico_modulo_sparse_data( + $agent_module_id, + $date_array, + $data_module_graph, + $params, + $i + ); + + $array_data[] = $data; + + } + $result = array(); + $array_data[1] = array_reverse($array_data[1]['sum1']['slice_data']); + $array_data[2] = array_reverse($array_data[2]['sum2']['slice_data']); + $array_data[3] = array_reverse($array_data[3]['sum3']['slice_data']); + foreach ($array_data[0]['sum0']['slice_data'] as $key => $value) { + $data1 = array_pop($array_data[1]); + $data2 = array_pop($array_data[2]); + $data3 = array_pop($array_data[3]); + + $result['slice_data'][$key]['min'] = ($data1['min'] + $data2['min'] + $data3['min'] + $value['min']) / 4; + $result['slice_data'][$key]['avg'] = ($data1['avg'] + $data2['avg'] + $data3['avg'] + $value['avg']) / 4; + $result['slice_data'][$key]['max'] = ($data1['max'] + $data2['max'] + $data3['max'] + $value['max']) / 4; + + $result['data'][] = array($key, $result['slice_data'][$key]['avg']); + } + + $result['avg'] = ($array_data[0]['sum0']['avg'] + $array_data[1]['sum1']['avg'] + $array_data[2]['sum2']['avg'] +$array_data[3]['sum3']['avg'])/4; + $result['max'] = max($array_data[0]['sum0']['max'], $array_data[1]['sum1']['max'], $array_data[2]['sum2']['max'], $array_data[3]['sum3']['max']); + $result['min'] = min($array_data[0]['sum0']['min'], $array_data[1]['sum1']['min'], $array_data[2]['sum2']['min'], $array_data[3]['sum3']['min']); + + $result['agent_module_id'] = $array_data[0]['sum0']['agent_module_id']; + $result['id_module_type'] = $array_data[0]['sum0']['id_module_type']; + $result['agent_name'] = $array_data[0]['sum0']['agent_name']; + $result['module_name'] = $array_data[0]['sum0']['module_name']; + $result['agent_alias'] = $array_data[0]['sum0']['agent_alias']; + return array('sum0' => $result); +} + ?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index bf2dd79126..ca5b42dd3d 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -395,7 +395,8 @@ function reporting_make_reporting_data($report = null, $id_report, $content, $type, $force_width_chart, - $force_height_chart); + $force_height_chart + ); break; case 'netflow_area': $report['contents'][] = reporting_netflow( @@ -3481,80 +3482,6 @@ function reporting_netflow($report, $content, $type, return reporting_check_structure_content($return); } -function reporting_simple_baseline_graph($report, $content, - $type = 'dinamic', $force_width_chart = null, - $force_height_chart = null) { - - global $config; - - if ($config['metaconsole']) { - $id_meta = metaconsole_get_id_server($content["server_name"]); - $server = metaconsole_get_connection_by_id ($id_meta); - metaconsole_connect($server); - } - - $return['type'] = 'simple_baseline_graph'; - - if (empty($content['name'])) { - $content['name'] = __('Simple baseline graph'); - } - - $module_name = io_safe_output( - modules_get_agentmodule_name($content['id_agent_module'])); - $agent_name = io_safe_output( - modules_get_agentmodule_agent_alias ($content['id_agent_module'])); - - $return['title'] = $content['name']; - $return['subtitle'] = $agent_name . " - " . $module_name; - $return["description"] = $content["description"]; - $return["date"] = reporting_get_date_text($report, $content); - $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - - // Get chart - reporting_set_conf_charts($width, $height, $only_image, $type, - $content, $ttl); - - $baseline_data = enterprise_hook( - 'reporting_enterprise_get_baseline', - array ( - $content['id_agent_module'], - $content['period'], - $report["datetime"] - ) - ); - - if ($baseline_data === ENTERPRISE_NOT_HOOK) { - $baseline_data = array (); - } - - switch ($type) { - case 'dinamic': - case 'static': - $params =array( - 'agent_module_id' => $content['id_agent_module'], - 'period' => $content['period'], - 'date' => $report["datetime"], - 'only_image' => $only_image, - 'homeurl' => ui_get_full_url(false, false, false, false), - 'ttl' => $ttl, - 'array_data_create' => $baseline_data, - 'server_id' => $id_meta, - 'height' => $config['graph_image_height'] - ); - - $return['chart'] = grafico_modulo_sparse ($params); - break; - case 'data': - break; - } - - if ($config['metaconsole']) { - metaconsole_restore_db(); - } - - return reporting_check_structure_content($return); -} - function reporting_prediction_date($report, $content) { global $config; From cef1b10ade64b706b8698a2d9f6c139c64fb2036 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 12 Sep 2018 00:01:26 +0200 Subject: [PATCH 21/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 43295751bd..ec5945d3af 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180911 +Version: 7.0NG.726-180912 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 699d6983a2..da615f934d 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180911" +pandora_version="7.0NG.726-180912" 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 4151b8cf9d..3c1bf84849 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180911'; +use constant AGENT_BUILD => '180912'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 4395e23b53..d8d2e63ec6 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 7.0NG.726 -%define release 180911 +%define release 180912 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 07ed8f5b45..aed5b14109 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 7.0NG.726 -%define release 180911 +%define release 180912 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 56ad0e21e3..f836607720 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180911" +PI_BUILD="180912" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3618043df3..8688aec952 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180911} +{180912} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index bf0ce92929..b8bc018014 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180911)") +#define PANDORA_VERSION ("7.0NG.726(Build 180912)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 564c92a71b..401b81041a 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180911))" + VALUE "ProductVersion", "(7.0NG.726(Build 180912))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index e859f10076..72e56c6da8 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180911 +Version: 7.0NG.726-180912 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 9af375045d..d58ae90bc0 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180911" +pandora_version="7.0NG.726-180912" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 2bf5d83982..afc2a1dd12 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 = 'PC180911'; +$build_version = 'PC180912'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 89d69bd466..6ef35ed532 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 1e35f4fc0e..ef18213eb0 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180911 +%define release 180912 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 49462431b2..74b099222e 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180911 +%define release 180912 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 46eb00f5c0..0f6ee8f52e 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180911" +PI_BUILD="180912" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index f0f7fa0eb0..864eabe5d7 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180911"; +my $version = "7.0NG.726 PS180912"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 9991c5ba9c..6ff86df8cf 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180911"; +my $version = "7.0NG.726 PS180912"; # save program name for logging my $progname = basename($0); From 006b086366deb4d9e825b6ca910849364e585456 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 12 Sep 2018 09:07:29 +0200 Subject: [PATCH 22/44] [Secondary groups] Fixed tgroup_stat calculation and improve performance. --- pandora_server/lib/PandoraFMS/Core.pm | 164 +++++++++++++------------- 1 file changed, 80 insertions(+), 84 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index a8a26e6ad2..05cd5ab9e1 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4635,97 +4635,93 @@ Process groups statistics for statistics table ########################################################################## sub pandora_group_statistics ($$) { my ($pa_config, $dbh) = @_; - - # Variable init - my $modules = 0; - my $normal = 0; - my $critical = 0; - my $warning = 0; - my $unknown = 0; - my $non_init = 0; - my $alerts = 0; - my $alerts_fired = 0; - my $agents = 0; - my $agents_unknown = 0; - my $utimestamp = 0; - my $group = 0; + my $is_meta = is_metaconsole($pa_config); - # Get all groups - my @groups = get_db_rows ($dbh, 'SELECT id_grupo FROM tgrupo'); - my $table = is_metaconsole($pa_config) ? 'tmetaconsole_agent' : 'tagente'; - my $sec_table = is_metaconsole($pa_config) - ? 'tmetaconsole_agent_secondary_group' - : 'tagent_secondary_group'; + logger($pa_config, "Updating no realtime group stats.", 10); - # For each valid group get the stats: Simple uh? - foreach my $group_row (@groups) { + my $total_alerts_condition = $is_meta + ? "0" + : "COUNT(tatm.id)"; + my $joins_alerts = $is_meta + ? "" + : "LEFT JOIN tagente_modulo tam + ON tam.id_agente = ta.id_agente + INNER JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo"; + my $agent_table = $is_meta + ? "tmetaconsole_agent" + : "tagente"; + my $agent_seconsary_table = $is_meta + ? "tmetaconsole_agent_secondary_group" + : "tagent_secondary_group"; - $group = $group_row->{'id_grupo'}; - - # NOTICE - Calculations done here MUST BE the same than used in PHP code to have - # the same criteria. PLEASE, double check any changes here and in functions_groups.php - $agents_unknown = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND (id_grupo=? OR id_group=?)", $group, $group); - $agents_unknown = 0 unless defined ($agents_unknown); - - $agents = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE(id_grupo=$group OR id_group=$group) AND disabled=0"); - $agents = 0 unless defined ($agents); - - $modules = get_db_value ($dbh, "SELECT SUM(total_count) FROM + # Update the record. + db_do ($dbh, "REPLACE INTO tgroup_stat( + `id_group`, `modules`, `normal`, `critical`, `warning`, `unknown`, + `non-init`, `alerts`, `alerts_fired`, `agents`, + `agents_unknown`, `utimestamp` + ) + SELECT + tg.id_grupo AS id_group, + IF (SUM(modules_total) IS NULL,0,SUM(modules_total)) AS modules, + IF (SUM(modules_ok) IS NULL,0,SUM(modules_ok)) AS normal, + IF (SUM(modules_critical) IS NULL,0,SUM(modules_critical)) AS critical, + IF (SUM(modules_warning) IS NULL,0,SUM(modules_warning)) AS warning, + IF (SUM(modules_unknown) IS NULL,0,SUM(modules_unknown)) AS unknown, + IF (SUM(modules_not_init) IS NULL,0,SUM(modules_not_init)) AS `non-init`, + IF (SUM(alerts_total) IS NULL,0,SUM(alerts_total)) AS alerts, + IF (SUM(alerts_fired) IS NULL,0,SUM(alerts_fired)) AS alerts_fired, + IF (SUM(agents_total) IS NULL,0,SUM(agents_total)) AS agents, + IF (SUM(agents_unknown) IS NULL,0,SUM(agents_unknown)) AS agents_unknown, + UNIX_TIMESTAMP() AS utimestamp + FROM ( - SELECT DISTINCT(id_agente), total_count - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND (id_grupo=? OR id_group=?) - ) AS t1", $group, $group); - $modules = 0 unless defined ($modules); + SELECT SUM(ta.normal_count) AS modules_ok, + SUM(ta.critical_count) AS modules_critical, + SUM(ta.warning_count) AS modules_warning, + SUM(ta.unknown_count) AS modules_unknown, + SUM(ta.notinit_count) AS modules_not_init, + SUM(ta.total_count) AS modules_total, + SUM(ta.fired_count) AS alerts_fired, + $total_alerts_condition AS alerts_total, + SUM(IF(ta.critical_count > 0, 1, 0)) AS agents_critical, + SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS agents_unknown, + SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS agents_not_init, + COUNT(ta.id_agente) AS agents_total, + ta.id_grupo AS g + FROM $agent_table ta + $joins_alerts + WHERE ta.disabled = 0 + GROUP BY g - $normal = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count=0 AND normal_count>0 AND (id_grupo=? OR id_group=?)", $group, $group); - $normal = 0 unless defined ($normal); + UNION ALL - $critical = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND critical_count>0 AND (id_grupo=? OR id_group=?)", $group, $group); - $critical = 0 unless defined ($critical); - - $warning = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND critical_count=0 AND warning_count>0 AND (id_grupo=? OR id_group=?)", $group, $group); - $warning = 0 unless defined ($warning); - - $unknown = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND (id_grupo=? OR id_group=?)", $group, $group); - $unknown = 0 unless defined ($unknown); - - $non_init = get_db_value ($dbh, "SELECT COUNT(DISTINCT(id_agente)) - FROM $table LEFT JOIN $sec_table ON id_agente=id_agent - WHERE disabled=0 AND total_count=notinit_count AND (id_grupo=? OR id_group=?)", $group, $group); - $non_init = 0 unless defined ($non_init); - - # Total alert count not available on the meta console. - if ($table eq 'tagente') { - $alerts = get_db_value ($dbh, "SELECT COUNT(talert_template_modules.id) - FROM talert_template_modules, tagente_modulo, tagente - WHERE tagente.id_grupo = $group AND tagente_modulo.id_agente = tagente.id_agente - 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"); - } - $alerts = 0 unless defined ($alerts); - - $alerts_fired = get_db_value ($dbh, "SELECT SUM(fired_count) FROM $table WHERE disabled=0 AND id_grupo=?", $group); - $alerts_fired = 0 unless defined ($alerts_fired); - - # Update the record. - db_do ($dbh, "REPLACE INTO tgroup_stat (id_group, modules, normal, critical, warning, unknown, " . $PandoraFMS::DB::RDBMS_QUOTE . 'non-init' . $PandoraFMS::DB::RDBMS_QUOTE . ", alerts, alerts_fired, agents, agents_unknown, utimestamp) VALUES ($group, $modules, $normal, $critical, $warning, $unknown, $non_init, $alerts, $alerts_fired, $agents, $agents_unknown, UNIX_TIMESTAMP())"); - - } + SELECT SUM(ta.normal_count) AS modules_ok, + SUM(ta.critical_count) AS modules_critical, + SUM(ta.warning_count) AS modules_warning, + SUM(ta.unknown_count) AS modules_unknown, + SUM(ta.notinit_count) AS modules_not_init, + SUM(ta.total_count) AS modules_total, + SUM(ta.fired_count) AS alerts_fired, + $total_alerts_condition AS alerts_total, + SUM(IF(ta.critical_count > 0, 1, 0)) AS agents_critical, + SUM(IF(ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count > 0, 1, 0)) AS agents_unknown, + SUM(IF(ta.total_count = ta.notinit_count, 1, 0)) AS agents_not_init, + COUNT(ta.id_agente) AS agents_total, + tasg.id_group AS g + FROM $agent_table ta + LEFT JOIN $agent_seconsary_table tasg + ON ta.id_agente = tasg.id_agent + $joins_alerts + WHERE ta.disabled = 0 + GROUP BY g + ) counters + RIGHT JOIN tgrupo tg + ON counters.g = tg.id_grupo + GROUP BY tg.id_grupo" + ); + logger($pa_config, "No realtime group stats updated.", 6); } From 6312d2e38a2324872a3d6e8b4769b0de21320ae8 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 12 Sep 2018 10:34:14 +0200 Subject: [PATCH 23/44] fixed forecast report --- .../include/functions_forecast.php | 98 +++++++------------ pandora_console/include/functions_graph.php | 29 +++--- .../include/functions_reporting.php | 13 +-- 3 files changed, 56 insertions(+), 84 deletions(-) diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index f58e3592e7..fb09624081 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -20,31 +20,29 @@ */ /** - * Create a prediction based on module data with least square method (linear regression) + * Create a prediction based on module data with least square method (linear regression) * * @param int Module id. * @param int Period of the module data. - * @param int Period of the prediction or false to use it in prediction_date function (see below). + * @param int Period of the prediction or false to use it in prediction_date function (see below). * @param int Maximun value using this function for prediction_date. * @param int Minimun value using this function for prediction_date. * @param bool Result data for CSV file exportation. - * + * * @return array Void array or prediction of the module data. */ function forecast_projection_graph($module_id, $period = SECONDS_2MONTHS, $prediction_period, $max_value = false, $min_value = false, $csv = false) { - + global $config; - - $max_exec_time = ini_get('max_execution_time'); - + + $max_exec_time = ini_get('max_execution_time'); + if ($max_exec_time !== false) { - - $max_exec_time = (int)$max_exec_time; - + $max_exec_time = (int)$max_exec_time; } - + $begin_time = time(); $params =array( @@ -54,16 +52,16 @@ function forecast_projection_graph($module_id, 'projection' => true ); - $module_data = grafico_modulo_sparse ($params); - + $module_data = grafico_modulo_sparse($params); + if (empty($module_data)) { - return array(); + return array(); } - // Prevents bad behaviour over image error + // Prevents bad behaviour over image error else if (!is_array($module_data) and preg_match('/^= -1.0 and $linear_coef <= -0.8999 // Function variables have an inverse linear relathionship! - // else - // Function variables don't have an inverse linear relathionship! - + // else + // Function variables don't have an inverse linear relathionship! // Could be a direct correlation coefficient - // else + // else // if ($linear_coef >= 0.8999 and $linear_coef <= 1.0) { // Function variables have a direct linear relathionship! - // else + // else // Function variables don't have a direct linear relathionship! - // 2. Calculation of linear regresion... - + $b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi)); $b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi)); if ($b_den == 0) return; $b = $b_num / $b_den; - + $a_num = ($sum_yi) - ($b * $sum_xi); - + if ($cont != 0) { $a = $a_num / $cont; } else { $a = 0; } - + // Data inicialization $output_data = array(); if ($prediction_period != false) { @@ -188,11 +165,11 @@ function forecast_projection_graph($module_id, $current_ts = $last_timestamp; $in_range = true; $time_format_2 = ''; - + $temp_range = $period; if ($period < $prediction_period) $temp_range = $prediction_period; - + if ($temp_range <= SECONDS_6HOURS) { $time_format = 'H:i:s'; } @@ -206,15 +183,15 @@ function forecast_projection_graph($module_id, elseif ($temp_range <= SECONDS_1MONTH) { $time_format = 'M d'; $time_format_2 = 'H\h'; - } + } else { $time_format = 'M d'; } - - // Aplying linear regression to module data in order to do the prediction - $output_data = array(); + + // Aplying linear regression to module data in order to do the prediction $idx = 0; // Create data in graph format like + while ($in_range) { $now = time(); @@ -242,9 +219,10 @@ function forecast_projection_graph($module_id, if ($current_ts - $last_timestamp >= 94608000) { return false; } - + // Found it - if ($max_value >= $output_data[$idx][0] and $min_value <= $output_data[$idx][0]) { + if (($max_value >= $output_data[$idx][0]) && + ($min_value <= $output_data[$idx][0]) ) { return $current_ts; } } @@ -254,7 +232,6 @@ function forecast_projection_graph($module_id, $current_ts = $current_ts + $agent_interval; $idx++; } - return $output_data; } @@ -264,8 +241,8 @@ function forecast_projection_graph($module_id, * @param int Module id. * @param int Given data period to make the prediction * @param int Max value in the interval. - * @param int Min value in the interval. - * + * @param int Min value in the interval. + * * @return mixed timestamp with the prediction date or false */ function forecast_prediction_date ($module_id, @@ -274,6 +251,5 @@ function forecast_prediction_date ($module_id, if ($min_value > $max_value) { return false; } - return forecast_projection_graph($module_id, $period, false, $max_value, $min_value); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 1fc266e8b5..ad6a9857ba 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -264,9 +264,7 @@ function grafico_modulo_sparse_data_chart ( $data_module_graph['id_module_type'] == 18 || $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || - $data_module_graph['id_module_type'] == 100 || - $params['projection'] - ){ + $data_module_graph['id_module_type'] == 100 ){ $data = db_get_all_rows_filter ( 'tagente_datos', @@ -421,8 +419,7 @@ function grafico_modulo_sparse_data( $data_module_graph['id_module_type'] == 18 || $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || - $data_module_graph['id_module_type'] == 100 || - $params['projection'] ){ + $data_module_graph['id_module_type'] == 100 ){ $array_data = grafico_modulo_sparse_data_chart ( $agent_module_id, $date_array, @@ -924,7 +921,6 @@ function grafico_modulo_sparse ($params) { $legend = array(); $array_events_alerts = array(); - $date_array = array(); $date_array["period"] = $params['period']; $date_array["final_date"] = $params['date']; @@ -1226,7 +1222,7 @@ function graphic_combined_module ( } else{ $params['stacked'] = 'area'; - $params['projection'] = $params_combined['projection']; + $params['projection'] = true; } if(!isset($params_combined['labels'])){ @@ -1519,6 +1515,14 @@ function graphic_combined_module ( $date_array["final_date"] = $params['date']; $date_array["start_date"] = $params['date'] - $params['period']; + if($params_combined['projection']){ + $output_projection = forecast_projection_graph( + $module_list[0], + $params['period'], + $params_combined['projection'] + ); + } + $i=0; $array_data = array(); foreach ($module_list as $key => $agent_module_id) { @@ -1585,10 +1589,13 @@ function graphic_combined_module ( $i++; } - if($params_combined['projection'] && is_array($params_combined['projection'])){ - $date_array_projection = max($params_combined['projection']); - $date_array['final_date'] = $date_array_projection[0] / 1000; - $array_data['projection']['data']= $params_combined['projection']; + if($params_combined['projection']){ + // If projection doesn't have data then don't draw graph + if ($output_projection != NULL) { + $date_array_projection = max($output_projection); + $date_array['final_date'] = $date_array_projection[0] / 1000; + $array_data['projection']['data']= $output_projection; + } } //summatory and average series diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ca5b42dd3d..93fb478f1e 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3557,17 +3557,6 @@ function reporting_projection_graph($report, $content, switch ($type) { case 'dinamic': case 'static': - $output_projection = forecast_projection_graph( - $content['id_agent_module'], - $content['period'], - $content['top_n_value'] - ); - - // If projection doesn't have data then don't draw graph - if ($output_projection == NULL) { - $output_projection = false; - } - $params =array( 'period' => $content['period'], 'width' => $width, @@ -3581,7 +3570,7 @@ function reporting_projection_graph($report, $content, ); $params_combined = array( - 'projection' => $output_projection + 'projection' => $content['top_n_value'], ); $return['chart'] = graphic_combined_module( From b0257eb3f4ab5b84829a5a855795c37227d62ccd Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 12 Sep 2018 11:23:26 +0200 Subject: [PATCH 24/44] fixed minor error refresh graph pie --- pandora_console/include/graphs/flot/pandora.flot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index e3abe74681..0033717955 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -284,7 +284,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, set_watermark(graph_id, plot, $('#watermark_image_' + graph_id).attr('src')); } - +/* window.onresize = function(event) { $.plot($('#' + graph_id), data, conf_pie); if (no_data == data.length) { @@ -319,7 +319,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, $(this).css('transform', "rotate(-35deg)").css('color', 'black'); }); } - +*/ } function pandoraFlotHBars(graph_id, values, labels, water_mark, From 861e25fe4327b3b7724aaf5eea05c6d5ccb81871 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 12 Sep 2018 13:20:46 +0200 Subject: [PATCH 25/44] Added no verify ssl in server daemon --- pandora_server/util/pandora_server | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_server b/pandora_server/util/pandora_server index 601946edf4..89beee8e55 100755 --- a/pandora_server/util/pandora_server +++ b/pandora_server/util/pandora_server @@ -100,7 +100,8 @@ case "$1" in echo "$PANDORA_RB_PRODUCT_NAME Server is currently running on this machine with PID ($PANDORA_PID)." rc_exit # running start on a service already running fi - + + export PERL_LWP_SSL_VERIFY_HOSTNAME=0 $PANDORA_DAEMON $PANDORA_HOME -D sleep 1 From a2b3d6e07f994a05e3b754e8d6acf11359e07f74 Mon Sep 17 00:00:00 2001 From: "manuel.montes" Date: Wed, 12 Sep 2018 13:43:23 +0200 Subject: [PATCH 26/44] Deleted reports from cron --- pandora_console/extras/mr/20.sql | 6 ++++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 6 ++++++ pandora_console/include/functions_reports.php | 2 ++ pandora_console/pandoradb.sql | 1 + 4 files changed, 15 insertions(+) diff --git a/pandora_console/extras/mr/20.sql b/pandora_console/extras/mr/20.sql index 33ac240498..58aa5bf708 100644 --- a/pandora_console/extras/mr/20.sql +++ b/pandora_console/extras/mr/20.sql @@ -18,4 +18,10 @@ ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_ ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; ALTER TABLE `tlayout_template_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; +-- ----------------------------------------------------- +-- Add column in table `treport` +-- ----------------------------------------------------- + +ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 88478f5c9b..dd39b6159f 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1768,3 +1768,9 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( PRIMARY KEY(`id`), FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Add column in table `treport` +-- ----------------------------------------------------- + +ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index dfa3d3d490..b836f534a2 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -95,10 +95,12 @@ function reports_get_reports ($filter = false, $fields = false, $filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")', $config['id_user']); */ + $filter['hidden'] = 0; if (is_array ($fields)) { $fields[] = 'id_group'; $fields[] = 'id_user'; $fields[] = 'id_group_edit'; + $fields[] = 'hidden'; } $reports = array (); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b2282c3685..b6b1511bec 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1242,6 +1242,7 @@ CREATE TABLE IF NOT EXISTS `treport` ( `id_group_edit` mediumint(8) unsigned NULL DEFAULT 0, `metaconsole` tinyint(1) DEFAULT 0, `non_interactive` tinyint(1) UNSIGNED NOT NULL default 0, + `hidden` tinyint(1) DEFAULT 0, PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; From 0ec93011dab778bc9845816a91d93265b431dce1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 12 Sep 2018 15:05:30 +0200 Subject: [PATCH 27/44] Fixed security fail filling the plugin fields --- pandora_console/godmode/servers/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 93ed8841f7..e592fd570d 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -833,7 +833,7 @@ ui_require_javascript_file('pandora_modules'); i++; } - $('#command_preview').html(command+' '+parameters); + $('#command_preview').html(_.escape(command) + ' ' + _.escape(parameters)); } function show_locked_dialog(id_plugin, plugin_name) { From c5b942f13f0bc4a560ee8be61197769c179b78c3 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 12 Sep 2018 15:57:22 +0200 Subject: [PATCH 28/44] fixed minor error legend graph and value avg --- pandora_console/include/functions_graph.php | 6 ++--- .../include/graphs/flot/pandora.flot.js | 22 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index ad6a9857ba..75c08addc2 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4129,7 +4129,7 @@ function fullscale_data ( if($min_value != PHP_INT_MAX) { $data["min" . $series_suffix]['data'][] = array($real_date , $min_value); } - + if($max_value != -PHP_INT_MAX) { $data["max" . $series_suffix]['data'][] = array($real_date , $max_value); } @@ -4155,7 +4155,7 @@ function fullscale_data ( $min_value_total = $min_value; } //avg sum_total - $sum_data_total += $sum_data; + $sum_data_total += $sum_data/$count_data; //avg count_total $count_data_total++; @@ -4203,6 +4203,7 @@ function fullscale_data ( } } } + $data["sum" . $series_suffix]['min'] = $min_value_total; $data["sum" . $series_suffix]['max'] = $max_value_total; $data["sum" . $series_suffix]['avg'] = $sum_data_total/$count_data_total; @@ -4287,7 +4288,6 @@ function fullscale_data ( $last_data = $v["datos"]; } } - $data["sum" . $series_suffix]['min'] = $min_value; $data["sum" . $series_suffix]['max'] = $max_value; $data["sum" . $series_suffix]['avg'] = $sum_data/$count_data; diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 0033717955..a71cb5eb19 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2171,10 +2171,11 @@ function pandoraFlotArea( graph_id, values, legend, } }); - $('#'+graph_id).bind('mouseout',resetInteractivity(vconsole)); - if(!vconsole){ - $('#overview_'+graph_id).bind('mouseout',resetInteractivity); + $('#'+graph_id) + .bind('mouseout', resetInteractivity); + $('#overview_'+graph_id) + .bind('mouseout', resetInteractivity); } if(image_treshold){ @@ -2218,7 +2219,7 @@ function pandoraFlotArea( graph_id, values, legend, } // Reset interactivity styles - function resetInteractivity(vconsole) { + function resetInteractivity() { $('#timestamp_'+graph_id).hide(); dataset = plot.getData(); for (i = 0; i < dataset.length; ++i) { @@ -2227,14 +2228,15 @@ function pandoraFlotArea( graph_id, values, legend, $('#legend_' + graph_id + ' .legendLabel') .eq(i).html(label_aux); } - $('#legend_' + graph_id + ' .legendLabel').css('color', legend_color); - $('#legend_' + graph_id + ' .legendLabel').css('font-size', font_size + 2 +'px'); - $('#legend_' + graph_id + ' .legendLabel').css('font-family', font + 'Font'); + $('#legend_' + graph_id + ' .legendLabel') + .css('color', legend_color); + $('#legend_' + graph_id + ' .legendLabel') + .css('font-size', font_size + 2 +'px'); + $('#legend_' + graph_id + ' .legendLabel') + .css('font-family', font + 'Font'); plot.clearCrosshair(); - if(!vconsole){ - overview.clearCrosshair(); - } + overview.clearCrosshair(); } function yFormatter(v, axis) { From 98b29078574261d637f70395e7a603cd7e3ccd0a Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Wed, 12 Sep 2018 16:16:04 +0200 Subject: [PATCH 29/44] Bug fixes --- .../godmode/reporting/visual_console_builder.editor.js | 9 +++++++-- .../include/ajax/visual_console_builder.ajax.php | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 7d3021bfd2..26e34f80aa 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1543,8 +1543,13 @@ function loadFieldsFromDB(item) { $("select[name=parent]").val(val); if (key == 'linked_layout_status_type') $("select[name=linked_map_status_calculation_type]").val(val).change(); - if (key == 'id_layout_linked') - $("select[name=map_linked]").val(val).change(); + if (key == 'id_layout_linked') { + if (data['linked_layout_node_id'] == null) + $("select[name=map_linked]").val(val).change(); + else + $("select[name=map_linked] > option[data-node-id=" + data['linked_layout_node_id'] + "][value=" + val + "]") + .prop("selected", true).change(); + } if (key == 'linked_layout_node_id') $("input[name=linked_map_node_id]").val(val); if (key == 'id_layout_linked_weight') diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index d472542390..690aa437b8 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -615,8 +615,8 @@ switch ($action) { $values['id_agent'] = $id_agent; } - if ($linked_map_node_id) { - $values['linked_layout_node_id'] = $linked_map_node_id; + if ($linked_map_node_id !== null) { + $values['linked_layout_node_id'] = (int) $linked_map_node_id; } } else if ($id_agent == 0) { From 7930f22dd0bb03c9bee916dc3e100dd7231aaba2 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Wed, 12 Sep 2018 16:54:18 +0200 Subject: [PATCH 30/44] WIP: Improved the linked visual console status help --- .../include/functions_visual_map_editor.php | 8 ++--- .../help/en/help_linked_map_status_calc.php | 36 +++++++++++++++++++ .../help/es/help_linked_map_status_calc.php | 36 +++++++++++++++++++ 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 pandora_console/include/help/en/help_linked_map_status_calc.php create mode 100644 pandora_console/include/help/es/help_linked_map_status_calc.php diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index abbc179c61..675272a7f8 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -700,7 +700,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $visual_maps = db_get_all_rows_filter("tlayout", "id != " . (int) $visualConsole_id, array("id", "name")); $form_items_advance['map_linked_row']['html'] = '' - . __('Linked map') + . __('Linked visual console') . '' . ''; @@ -790,7 +790,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'percentile_item', 'module_graph', 'simple_value', 'icon', 'label', 'datos', 'donut_graph'); $form_items_advance['linked_map_status_calculation_row']['html'] = ''. - __('Type of the status calculation of the linked map') . '' + __('Type of the status calculation of the linked visual console') . '' . '' . html_print_select( $status_type_select_items, @@ -803,6 +803,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { false, false ) + . ui_print_help_icon("linked_map_status_calc", true) . ''; $form_items_advance['map_linked_weight'] = array(); @@ -811,13 +812,12 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { 'percentile_item', 'module_graph', 'simple_value', 'icon', 'label', 'datos', 'donut_graph'); $form_items_advance['map_linked_weight']['html'] = '' - . __('Linked map weight') . '' + . __('Linked visual console weight') . '' . '' . html_print_input_text( 'map_linked_weight', 80, '', 5, 5, true, false, false, "", "type_number percentage" ) . '%' - . ui_print_help_icon("linked_map_weight", true) . ''; $form_items_advance['linked_map_status_service_critical_row'] = array(); diff --git a/pandora_console/include/help/en/help_linked_map_status_calc.php b/pandora_console/include/help/en/help_linked_map_status_calc.php new file mode 100644 index 0000000000..40c5682d7a --- /dev/null +++ b/pandora_console/include/help/en/help_linked_map_status_calc.php @@ -0,0 +1,36 @@ + +

Formas de calcular el estado de la consola visual enlazada

+ +

Por defecto

+

+ Calcula el estado a partir del estado de todos los elementos, como lo haría un agente. +

+ +

Por peso

+

+ Calcula el estado de los elementos que tienen asignados una consola visual, un módulo o un agente en relación a un porcentaje de elementos configurado por el usuario. Este porcentaje es el que tiene que superar el número de elementos de un estado no normal respecto al número de elementos tenidos en cuenta en el cálculo para que el ese estado cambie. +

+ +

+ Por ejemplo, dado un elemento con un porcentaje del 50% y una consola visual enlazada con 5 elementos: +

+
    +
  • 1 critical, 1 warning y 3 normal -> Estado normal.
  • +
  • 2 critical, 2 warning y 1 normal -> Estado normal.
  • +
  • 1 critical, 3 warning y 1 normal -> Estado warning.
  • +
  • 3 critical, 1 warning y 1 normal -> Estado critical.
  • +
  • 1 critical, 1 warning y 3 unknown -> Estado unknown.
  • +
+ +

+ Si varios estados superan el peso, la prioridad es igual que en el resto de cálculo de estados (critical > warning > unknown). Si no hay elementos para realizar el cálculo, el estado pasa a ser unknown. +

+ +

Por elementos críticos

+

+ Calcula el estado usando los elementos en estado critical y los porcentajes de los umbrales definidos por el usuario. Si el número de los elementos en estado critical respecto al número de elementos tenidos en cuenta en el cálculo supera el porcentaje asignado como warning, el estado pasa a ser warning. Lo mismo para el porcentaje asignado como critical, que además tiene preferencia. +

diff --git a/pandora_console/include/help/es/help_linked_map_status_calc.php b/pandora_console/include/help/es/help_linked_map_status_calc.php new file mode 100644 index 0000000000..40c5682d7a --- /dev/null +++ b/pandora_console/include/help/es/help_linked_map_status_calc.php @@ -0,0 +1,36 @@ + +

Formas de calcular el estado de la consola visual enlazada

+ +

Por defecto

+

+ Calcula el estado a partir del estado de todos los elementos, como lo haría un agente. +

+ +

Por peso

+

+ Calcula el estado de los elementos que tienen asignados una consola visual, un módulo o un agente en relación a un porcentaje de elementos configurado por el usuario. Este porcentaje es el que tiene que superar el número de elementos de un estado no normal respecto al número de elementos tenidos en cuenta en el cálculo para que el ese estado cambie. +

+ +

+ Por ejemplo, dado un elemento con un porcentaje del 50% y una consola visual enlazada con 5 elementos: +

+
    +
  • 1 critical, 1 warning y 3 normal -> Estado normal.
  • +
  • 2 critical, 2 warning y 1 normal -> Estado normal.
  • +
  • 1 critical, 3 warning y 1 normal -> Estado warning.
  • +
  • 3 critical, 1 warning y 1 normal -> Estado critical.
  • +
  • 1 critical, 1 warning y 3 unknown -> Estado unknown.
  • +
+ +

+ Si varios estados superan el peso, la prioridad es igual que en el resto de cálculo de estados (critical > warning > unknown). Si no hay elementos para realizar el cálculo, el estado pasa a ser unknown. +

+ +

Por elementos críticos

+

+ Calcula el estado usando los elementos en estado critical y los porcentajes de los umbrales definidos por el usuario. Si el número de los elementos en estado critical respecto al número de elementos tenidos en cuenta en el cálculo supera el porcentaje asignado como warning, el estado pasa a ser warning. Lo mismo para el porcentaje asignado como critical, que además tiene preferencia. +

From a25d4ed166df06b2d7dde269d16de17f997d7ae1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 12 Sep 2018 17:27:09 +0200 Subject: [PATCH 31/44] Fixed alerts_get_alerts function --- pandora_console/include/functions_alerts.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index a089f8394f..322b3a7602 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -106,6 +106,8 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s ON t0.id_agent_module = t2.id_agente_modulo INNER JOIN tagente t3 ON t2.id_agente = t3.id_agente + LEFT JOIN tagent_secondary_group tasg + ON tasg.id_agent = t3.id_agente WHERE 1=1 ' . $status_query . ' ' . $standby_query . ' ' . $group_query . ' AND (t1.name LIKE "%' . $free_search . '%" From 52f89def205e5201d8a965f1d49e65187debc4b6 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 12 Sep 2018 17:30:13 +0200 Subject: [PATCH 32/44] Added .htaccess to avoid external access to attachment files --- pandora_console/attachment/.htaccess | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 pandora_console/attachment/.htaccess diff --git a/pandora_console/attachment/.htaccess b/pandora_console/attachment/.htaccess new file mode 100644 index 0000000000..815f1e1776 --- /dev/null +++ b/pandora_console/attachment/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from All From 583a7475e46c6c8a4a00c9f877c62a0db78b9e26 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 13 Sep 2018 00:01:26 +0200 Subject: [PATCH 33/44] 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/unix/pandora_agent_installer | 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_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index ec5945d3af..1bfec5677b 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180912 +Version: 7.0NG.726-180913 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 da615f934d..e1f14341c1 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180912" +pandora_version="7.0NG.726-180913" 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 3c1bf84849..0113dbdad5 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.726'; -use constant AGENT_BUILD => '180912'; +use constant AGENT_BUILD => '180913'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d8d2e63ec6..66e1cdf4f3 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 7.0NG.726 -%define release 180912 +%define release 180913 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 aed5b14109..a026944246 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 7.0NG.726 -%define release 180912 +%define release 180913 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index f836607720..09f73ce9a8 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180912" +PI_BUILD="180913" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8688aec952..91057d0bba 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180912} +{180913} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index b8bc018014..b88631b74d 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180912)") +#define PANDORA_VERSION ("7.0NG.726(Build 180913)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 401b81041a..980cb12736 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180912))" + VALUE "ProductVersion", "(7.0NG.726(Build 180913))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 72e56c6da8..b91804a770 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180912 +Version: 7.0NG.726-180913 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 d58ae90bc0..0ac2fc719b 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180912" +pandora_version="7.0NG.726-180913" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index afc2a1dd12..fb57e7cf90 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 = 'PC180912'; +$build_version = 'PC180913'; $pandora_version = 'v7.0NG.726'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 6ef35ed532..9159ef1794 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index ef18213eb0..69fb1bbdb1 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180912 +%define release 180913 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 74b099222e..e8372140ef 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.726 -%define release 180912 +%define release 180913 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 0f6ee8f52e..dc93b10ccf 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.726" -PI_BUILD="180912" +PI_BUILD="180913" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 864eabe5d7..e41330601f 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.726 PS180912"; +my $version = "7.0NG.726 PS180913"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 6ff86df8cf..85305a9080 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.726 PS180912"; +my $version = "7.0NG.726 PS180913"; # save program name for logging my $progname = basename($0); From 764b1125bd3739b77b1f98a99d2b05e2d41ce66b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 13 Sep 2018 15:19:08 +0200 Subject: [PATCH 34/44] Generate session csrf code to avoid attacks in user edition --- .../godmode/users/configure_user.php | 15 ++++++------ pandora_console/include/functions.php | 23 +++++++++++++++++++ pandora_console/include/functions_html.php | 20 ++++++++++++++++ pandora_console/operation/users/user_edit.php | 3 +++ 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 080b90a120..f5b7fdc5bc 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -152,7 +152,8 @@ if ($create_user) { ui_print_error_message (__('The current authentication scheme doesn\'t support creating users on %s', get_product_name())); return; } - + if (html_print_csrf_error()) return; + $values = array (); $values['id_user'] = (string) get_parameter ('id_user'); $values['fullname'] = (string) get_parameter ('fullname'); @@ -279,6 +280,8 @@ if ($create_user) { } if ($update_user) { + if (html_print_csrf_error()) return; + $values = array (); $values['id_user'] = (string) get_parameter ('id_user'); $values['fullname'] = (string) get_parameter ('fullname'); @@ -705,14 +708,12 @@ echo '
'; html_print_table ($table); echo '
'; -if ($new_user) { - if ($config['admin_can_add_user']) { +if ($config['admin_can_add_user']) { + html_print_csrf_hidden(); + if ($new_user) { html_print_input_hidden ('create_user', 1); html_print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); - } -} -else { - if ($config['user_can_update_info']) { + } else { html_print_input_hidden ('update_user', 1); html_print_submit_button (__('Update'), 'uptbutton', false, 'class="sub upd"'); } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index be0cb70178..e2c5c742a3 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3344,4 +3344,27 @@ function get_copyright_notice () { return $stored_name; } +/** + * Generate a random code to prevent cross site request fogery attacks + * + * @return string Generated code + */ +function generate_csrf_code() { + // Start session to make this var permanent + session_start(); + $_SESSION['csrf_code'] = md5(uniqid(mt_rand(), true)); + session_write_close(); + return $_SESSION['csrf_code']; +} + +/** + * Validate the CSRF code + * + * @return bool True if code is valid + */ +function validate_csrf_code() { + $code = get_parameter('csrf_code'); + return isset($code) && isset($_SESSION['csrf_code']) + && $_SESSION['csrf_code'] == $code; +} ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 83e49c5b43..783f1a9cab 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2504,4 +2504,24 @@ function html_print_sort_arrows ($params, $order_tag, $up = 'up', $down = 'down' '' ; } + +/** + * Print an input hidden with a new csrf token generated + */ +function html_print_csrf_hidden () { + html_print_input_hidden('csrf_code', generate_csrf_code()); +} + +/** + * Print an error if csrf is incorrect + */ +function html_print_csrf_error () { + if (validate_csrf_code()) return false; + + ui_print_error_message ( + __('%s cannot verify the origin of the request. Try again, please.', + get_product_name()) + ); + return true; +} ?> diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 80826864f4..83b69c85d2 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -66,6 +66,8 @@ else { // Update user info if (isset ($_GET["modified"]) && !$view_mode) { + if (html_print_csrf_error()) return; + $upd_info = array (); $upd_info["fullname"] = get_parameter_post ("fullname", $user_info["fullname"]); $upd_info["firstname"] = get_parameter_post ("firstname", $user_info["firstname"]); @@ -490,6 +492,7 @@ if (!$config["user_can_update_info"]) { echo ''.__('You can not change your user info under the current authentication scheme').''; } else { + html_print_csrf_hidden(); html_print_submit_button (__('Update'), 'uptbutton', $view_mode, 'class="sub upd"'); } echo '
'; From 1096319faf4721b72d1d6c7926c12587ef6263e3 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 13 Sep 2018 15:48:26 +0200 Subject: [PATCH 35/44] Removed Networkmaps on mobile console --- pandora_console/mobile/index.php | 10 - pandora_console/mobile/operation/home.php | 13 - .../mobile/operation/networkmap.php | 246 ----------------- .../mobile/operation/networkmaps.php | 250 ------------------ 4 files changed, 519 deletions(-) delete mode 100755 pandora_console/mobile/operation/networkmap.php delete mode 100755 pandora_console/mobile/operation/networkmaps.php diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 04fc1ff92e..2a8f8ed396 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -34,8 +34,6 @@ require_once('operation/agents.php'); require_once('operation/modules.php'); require_once('operation/module_graph.php'); require_once('operation/agent.php'); -require_once('operation/networkmaps.php'); -require_once('operation/networkmap.php'); require_once('operation/visualmaps.php'); require_once('operation/visualmap.php'); $enterpriseHook = enterprise_include('mobile/include/enterprise.class.php'); @@ -333,14 +331,6 @@ switch ($action) { $agent = new Agent(); $agent->show(); break; - case 'networkmaps': - $networkmaps = new Networkmaps(); - $networkmaps->show(); - break; - case 'networkmap': - $networkmap = new Networkmap(); - $networkmap->show(); - break; case 'visualmaps': $visualmaps = new Visualmaps(); $visualmaps->show(); diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php index 59728010a5..1a1ff12110 100644 --- a/pandora_console/mobile/operation/home.php +++ b/pandora_console/mobile/operation/home.php @@ -73,13 +73,6 @@ class Home { 'menu_item' => true, 'icon' => 'modules' ); - - $items['networkmaps'] = array( - 'name' => __('Networkmaps'), - 'filename' => 'networkmaps.php', - 'menu_item' => true, - 'icon' => 'network_maps' - ); $items['visualmaps'] = array( 'name' => __('Visual consoles'), 'filename' => 'visualmaps.php', @@ -100,12 +93,6 @@ class Home { 'menu_item' => false, 'icon' => '' ); - $items['networkmap'] = array( - 'name' => __('Networkmap'), - 'filename' => 'networkmap.php', - 'menu_item' => false, - 'icon' => '' - ); $items['visualmap'] = array( 'name' => __('Visualmap'), 'filename' => 'visualmap.php', diff --git a/pandora_console/mobile/operation/networkmap.php b/pandora_console/mobile/operation/networkmap.php deleted file mode 100755 index 9595efaa87..0000000000 --- a/pandora_console/mobile/operation/networkmap.php +++ /dev/null @@ -1,246 +0,0 @@ -getFilters(); - else - $this->id = $id; - - $store_group = db_get_value('store_group', - 'tnetwork_map', 'id_networkmap', $this->id); - - if ($store_group !== false - && $system->checkACL($this->acl, $store_group)) - $this->correct_acl = true; - } - - public function ajax($parameter2 = false) { - $system = System::getInstance(); - - if (!$this->correct_acl) { - return; - } - else { - switch ($parameter2) { - case 'xxx': - //$this->getFilters(); - //$page = $system->getRequest('page', 0); - break; - } - } - } - - private function getFilters() { - $system = System::getInstance(); - - $this->id = (int)$system->getRequest('id', 0); - } - - public function show() { - if (!$this->correct_acl) { - $this->show_fail_acl(); - } - else { - $this->getFilters(); - - $this->networkmap = db_get_row('tnetwork_map', - 'id_networkmap', $this->id); - - $this->show_networkmap(); - } - } - - private function show_fail_acl() { - $error['type'] = 'onStart'; - $error['title_text'] = __('You don\'t have access to this page'); - $error['content_text'] = System::getDefaultACLFailText(); - if (class_exists("HomeEnterprise")) - $home = new HomeEnterprise(); - else - $home = new Home(); - $home->show($error); - } - - private function show_networkmap() { - $ui = Ui::getInstance(); - $system = System::getInstance(); - - $ui->createPage(); - $ui->createDefaultHeader( - sprintf("%s", - $this->networkmap['name']), - $ui->createHeaderButton( - array('icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=networkmaps'))); - $ui->showFooter(false); - $ui->beginContent(); - - //Hack for mobile - global $hack_networkmap_mobile; - $hack_networkmap_mobile = true; - - switch ($this->networkmap['type']) { - case 'groups': - $graph = networkmap_generate_dot_groups ( - __('Pandora FMS'), - $this->networkmap['id_group'], - $this->networkmap['simple'], - $this->networkmap['font_size'], - $this->networkmap['layout'], - (bool)$this->networkmap['nooverlap'], - $this->networkmap['zoom'], - $this->networkmap['distance_nodes'], - $this->networkmap['center'], 1, 0, - $this->networkmap['only_modules_with_alerts'], - $this->networkmap['id_module_group'], - $this->networkmap['hide_policy_modules'], - $this->networkmap['depth'], - $this->networkmap['id_networkmap']); - break; - case 'policies': - $enterprise = enterprise_include('/include/functions_policies.php'); - - if ($enterprise != ENTERPRISE_NOT_HOOK) { - $graph = policies_generate_dot_graph (__('Pandora FMS'), - $this->networkmap['id_group'], - $this->networkmap['simple'], - $this->networkmap['font_size'], - $this->networkmap['layout'], - (bool)$this->networkmap['nooverlap'], - $this->networkmap['zoom'], - $this->networkmap['distance_nodes'], - $this->networkmap['center'], 1, 0, - $this->networkmap['only_modules_with_alerts'], - $this->networkmap['id_module_group'], - $this->networkmap['depth'], - $this->networkmap['id_networkmap']); - } - break; - default: - case 'topology': - $graph = networkmap_generate_dot (__('Pandora FMS'), - $this->networkmap['id_group'], - $this->networkmap['simple'], - $this->networkmap['font_size'], - $this->networkmap['layout'], - (bool)$this->networkmap['nooverlap'], - $this->networkmap['zoom'], - $this->networkmap['distance_nodes'], - $this->networkmap['center'], 1, 0, - $this->networkmap['id_networkmap'], - $this->networkmap['show_snmp_modules'], true, - true); - break; - } - - - - if ($graph === false) { - $ui->contentAddHtml('

' . __('No networkmaps') . '

'); - - $ui->endContent(); - $ui->showPage(); - - return; - } - - - $filter = networkmap_get_filter($this->networkmap['layout']); - - // Generate image and map - // If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set - $filename_map = safe_url_extraclean ( - $system->getConfig('attachment_store')) . "/networkmap_" . $filter; - $filename_img = safe_url_extraclean ( - $system->getConfig('attachment_store')) . "/networkmap_" . - $filter . "_" . $this->networkmap['font_size']; - $url_img = "../attachment/networkmap_" . - $filter . "_" . $this->networkmap['font_size']; - $filename_dot = safe_url_extraclean( - $system->getConfig("attachment_store")) . "/networkmap_" . $filter; - if ($this->networkmap['simple']) { - $filename_map .= "_simple"; - $filename_img .= "_simple"; - $url_img .= "_simple"; - $filename_dot .= "_simple"; - } - if ($this->networkmap['nooverlap']) { - $filename_map .= "_nooverlap"; - $filename_img .= "_nooverlap"; - $url_img .= "_nooverlap"; - $filename_dot .= "_nooverlap"; - } - $filename_map .= "_" . $this->networkmap['id_networkmap'] . ".map"; - $filename_img .= "_" . $this->networkmap['id_networkmap'] . ".png"; - $url_img .= "_" . $this->networkmap['id_networkmap'] . ".png"; - $filename_dot .= "_" . $this->networkmap['id_networkmap'] . ".dot"; - - if ($this->networkmap['regenerate'] != 1 && file_exists($filename_img) && filemtime($filename_img) > get_system_time () - 300) { - $result = true; - } - else { - $fh = @fopen ($filename_dot, 'w'); - if ($fh === false) { - $result = false; - } - else { - fwrite ($fh, $graph); - $cmd = $filter . " -Tcmapx -o" . $filename_map." -Tpng -o".$filename_img." ".$filename_dot; - $result = system ($cmd); - fclose ($fh); - //unlink ($filename_dot); - } - } - - if ($result !== false) { - if (! file_exists ($filename_map)) { - $ui->contentAddHtml('

' . __('Map could not be generated') . '

'); - - $ui->endContent(); - $ui->showPage(); - - return; - } - $ui->contentAddHtml('
'); - $ui->contentAddHtml(''); - $ui->contentAddHtml('
'); - } - else { - $ui->contentAddHtml('

' . __('Map could not be generated') . '

'); - - $ui->endContent(); - $ui->showPage(); - - return; - } - - $ui->endContent(); - $ui->showPage(); - } -} -?> diff --git a/pandora_console/mobile/operation/networkmaps.php b/pandora_console/mobile/operation/networkmaps.php deleted file mode 100755 index f8f533cc84..0000000000 --- a/pandora_console/mobile/operation/networkmaps.php +++ /dev/null @@ -1,250 +0,0 @@ -checkACL($this->acl)) { - $this->correct_acl = true; - } - else { - $this->correct_acl = false; - } - } - - public function ajax($parameter2 = false) { - $system = System::getInstance(); - - if (!$this->correct_acl) { - return; - } - else { - switch ($parameter2) { - case 'xxx': - //$this->getFilters(); - //$page = $system->getRequest('page', 0); - break; - } - } - } - - private function getFilters() { - $system = System::getInstance(); - $user = User::getInstance(); - - $this->default_filters['group'] = true; - $this->default_filters['type'] = true; - - $this->group = (int)$system->getRequest('group', __("Group")); - if (!$user->isInGroup($this->acl, $this->group)) { - $this->group = 0; - } - if (($this->group === __("Group")) || ($this->group == 0)) { - $this->group = 0; - } - else { - $this->default = false; - $this->default_filters['group'] = false; - } - - $this->type = $system->getRequest('type', __("Type")); - if (($this->type === __("Type")) || ($this->type === '0')) { - $this->type = '0'; - } - else { - $this->default = false; - $this->default_filters['type'] = false; - } - } - - public function show() { - if (!$this->correct_acl) { - $this->show_fail_acl(); - } - else { - $this->getFilters(); - $this->show_networkmaps(); - } - } - - private function show_fail_acl() { - $error['type'] = 'onStart'; - $error['title_text'] = __('You don\'t have access to this page'); - $error['content_text'] = System::getDefaultACLFailText(); - if (class_exists("HomeEnterprise")) - $home = new HomeEnterprise(); - else - $home = new Home(); - $home->show($error); - } - - private function show_networkmaps() { - $ui = Ui::getInstance(); - - $ui->createPage(); - $ui->createDefaultHeader(__("Networkmaps"), - $ui->createHeaderButton( - array('icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home'))); - $ui->showFooter(false); - $ui->beginContent(); - $filter_title = sprintf(__('Filter Networkmaps by %s'), - $this->filterNetworkmapsGetString()); - $ui->contentBeginCollapsible($filter_title); - $ui->beginForm("index.php?page=networkmaps"); - $system = System::getInstance(); - $groups = users_get_groups_for_select( - $system->getConfig('id_user'), "AR", true, true, false, 'id_grupo'); - $options = array( - 'name' => 'group', - 'title' => __('Group'), - 'label' => __('Group'), - 'items' => $groups, - 'selected' => $this->group - ); - $ui->formAddSelectBox($options); - - $networkmap_types = networkmap_get_filter_types(); - $networkmap_types[0] = __('All'); - $options = array( - 'name' => 'type', - 'title' => __('Type'), - 'label' => __('Type'), - 'items' => $networkmap_types, - 'selected' => $this->type - ); - $ui->formAddSelectBox($options); - - $options = array( - 'icon' => 'refresh', - 'icon_pos' => 'right', - 'text' => __('Apply Filter') - ); - $ui->formAddSubmitButton($options); - $html = $ui->getEndForm(); - $ui->contentCollapsibleAddItem($html); - $ui->contentEndCollapsible(); - $this->listNetworkmapsHtml(); - $ui->endContent(); - $ui->showPage(); - } - - private function listNetworkmapsHtml() { - $system = System::getInstance(); - $ui = Ui::getInstance(); - - // Create filter - $where = array(); - // Order by type field - $where['order'] = 'type'; - - if ($this->group != '0') { - $where['store_group'] = $this->group; - } - else { - $where['store_group'] = array_keys(users_get_groups()); - } - - if ($this->type != '0') - $where['type'] = $this->type; - - $network_maps = db_get_all_rows_filter('tnetwork_map', - $where); - if (empty($network_maps)) { - $network_maps = array(); - } - $list = array(); - foreach ($network_maps as $networkmap) { - // ACL - if (! $system->checkACL("AR", $networkmap['store_group'])) - continue; - - // If enterprise not loaded then skip this code - if ($networkmap['type'] == 'policies' and (!defined('PANDORA_ENTERPRISE'))) - continue; - $row = array(); - $row[__('Name')] = '' . io_safe_output($networkmap['name']) . ''; - $row[__('Type')] = $networkmap['type']; - $row[__('Group')] = ui_print_group_icon($networkmap["store_group"], true, "groups_small", "" , false); - $list[] = $row; - } - - if (count($network_maps) == 0) { - $ui->contentAddHtml('

' . __('No networkmaps') . '

'); - } - else { - $table = new Table(); - $table->id = 'list_networkmaps'; - $table->importFromHash($list); - $ui->contentAddHtml($table->getHTML()); - } - - $ui->contentAddLinkListener('list_networkmaps'); - } - - private function filterNetworkmapsGetString() { - if ($this->default) { - return __("(Default)"); - } - else { - $filters_to_serialize = array(); - - if (!$this->default_filters['group']) { - $filters_to_serialize[] = sprintf(__("Group: %s"), - groups_get_name($this->group, true)); - } - if (!$this->default_filters['type']) { - $networkmap_types = networkmap_get_filter_types(); - $networkmap_types[0] = __('All'); - - $filters_to_serialize[] = sprintf(__("Type: %s"), - $networkmap_types[$this->type]); - } - - $string = '(' . implode(' - ', $filters_to_serialize) . ')'; - - - //~ $networkmap_types = networkmap_get_filter_types(); - //~ $networkmap_types[0] = __('All'); - //~ $type = $networkmap_types[$this->type]; - //~ $group = groups_get_name($this->group, true); - //~ - //~ - //~ $string = sprintf( - //~ __("(Type: %s - Group: %s)"), - //~ $type, $group); - - return $string; - } - } -} -?> From c54f414a733ca1ace582605a3c55c25caad3a4c9 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 13 Sep 2018 15:53:21 +0200 Subject: [PATCH 36/44] Updated version and build strings. --- pandora_agents/pc/AIX/pandora_agent.conf | 2 +- pandora_agents/pc/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/pc/HP-UX/pandora_agent.conf | 2 +- pandora_agents/pc/Linux/pandora_agent.conf | 2 +- pandora_agents/pc/NT4/pandora_agent.conf | 2 +- pandora_agents/pc/SunOS/pandora_agent.conf | 2 +- pandora_agents/pc/Win32/pandora_agent.conf | 2 +- pandora_agents/shellscript/aix/pandora_agent.conf | 2 +- pandora_agents/shellscript/bsd-ipso/pandora_agent.conf | 2 +- pandora_agents/shellscript/hp-ux/pandora_agent.conf | 2 +- pandora_agents/shellscript/linux/pandora_agent.conf | 2 +- pandora_agents/shellscript/mac_osx/pandora_agent.conf | 2 +- pandora_agents/shellscript/openWRT/pandora_agent.conf | 2 +- pandora_agents/shellscript/solaris/pandora_agent.conf | 2 +- pandora_agents/unix/AIX/pandora_agent.conf | 2 +- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/Darwin/pandora_agent.conf | 2 +- pandora_agents/unix/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/unix/HP-UX/pandora_agent.conf | 2 +- pandora_agents/unix/Linux/pandora_agent.conf | 2 +- pandora_agents/unix/NT4/pandora_agent.conf | 2 +- pandora_agents/unix/NetBSD/pandora_agent.conf | 2 +- pandora_agents/unix/SunOS/pandora_agent.conf | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 4 ++-- pandora_agents/unix/pandora_agent.spec | 4 ++-- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/bin/pandora_agent.conf | 2 +- pandora_agents/win32/installer/pandora.mpi | 4 ++-- 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 | 4 ++-- pandora_console/pandora_console.spec | 4 ++-- pandora_console/pandora_console_install | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/conf/pandora_server.conf.new | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 4 ++-- pandora_server/pandora_server.spec | 4 ++-- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 50 files changed, 57 insertions(+), 57 deletions(-) diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index dcfa365e6b..520eaff838 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, AIX version +# Version 7.0NG.727, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index f7d23ab200..c81ad7428b 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, FreeBSD Version +# Version 7.0NG.727, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 532fbe65e4..50fc5ba4be 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, HP-UX Version +# Version 7.0NG.727, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 8fd5498d51..82830cf957 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 5bea10d1fa..ea633488e4 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index d30b3459ac..c8a2153376 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, Solaris Version +# Version 7.0NG.727, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index ed451d9de0..6a01d22b4b 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.726 +# Version 7.0NG.727 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 7f7e1d96f9..27cbee7dfb 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.726, AIX version +# Version 7.0NG.727, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 8fc6f4e1eb..6eaf0415c2 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.726 +# Version 7.0NG.727 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 0e80d51dd9..906269e8bb 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.726, HPUX Version +# Version 7.0NG.727, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 5dd411ecd3..b2cdc0e920 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726 +# Version 7.0NG.727 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index e5dd6122af..82363fdb43 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726 +# Version 7.0NG.727 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 2eee374d68..2b4f58566b 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726 +# Version 7.0NG.727 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 138448fd17..a1c4130f17 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.726, Solaris version +# Version 7.0NG.727, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index ce926a7cac..5f755ae4af 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, AIX version +# Version 7.0NG.727, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 1bfec5677b..55b882a8a0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.726-180913 +Version: 7.0NG.727 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 e1f14341c1..de63328356 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180913" +pandora_version="7.0NG.727" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 6e58735751..bfe673cf6c 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index af429aa2b7..d829dfe933 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, FreeBSD Version +# Version 7.0NG.727, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index 6d4e113c16..29dc961d62 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, HP-UX Version +# Version 7.0NG.727, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 4b86143f9a..c97d6b489f 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index b15043bc67..e493e71850 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, GNU/Linux +# Version 7.0NG.727, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index e26488592f..6954f557e0 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, NetBSD Version +# Version 7.0NG.727, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 5764320b0a..8fe67c12d0 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.726, Solaris Version +# Version 7.0NG.727, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 0113dbdad5..c3fdb9804e 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.726'; +use constant AGENT_VERSION => '7.0NG.727'; use constant AGENT_BUILD => '180913'; # Agent log default file size maximum and instances diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 66e1cdf4f3..fda93a3acf 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.726 -%define release 180913 +%define version 7.0NG.727 +%define release 1 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 a026944246..27c67ebe7b 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.726 -%define release 180913 +%define version 7.0NG.727 +%define release 1 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 09f73ce9a8..483ae6db77 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,7 +9,7 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.726" +PI_VERSION="7.0NG.727" PI_BUILD="180913" OS_NAME=`uname -s` diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 4e9edf8157..e8caadc9c3 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.726 +# Version 7.0NG.727 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 91057d0bba..49a8479e92 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.726} +{Pandora FMS Windows Agent v7.0NG.727} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives {No} Windows,Executable -{<%AppName%>-<%Version%>-Setup<%Ext%>} +{<%AppName%>-Setup<%Ext%>} Windows,FileDescription {<%AppName%> <%Version%> Setup} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index b88631b74d..f4d398ca2b 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.726(Build 180913)") +#define PANDORA_VERSION ("7.0NG.727(Build 180913)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 980cb12736..3045efe943 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.726(Build 180913))" + VALUE "ProductVersion", "(7.0NG.727(Build 180913))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index b91804a770..85868c04a3 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.726-180913 +Version: 7.0NG.727 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 0ac2fc719b..f8d7a26315 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.726-180913" +pandora_version="7.0NG.727" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index fb57e7cf90..dcad6d4aab 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -23,7 +23,7 @@ * Pandora build version and version */ $build_version = 'PC180913'; -$pandora_version = 'v7.0NG.726'; +$pandora_version = 'v7.0NG.727'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/install.php b/pandora_console/install.php index 9159ef1794..1a8188f862 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -70,7 +70,7 @@
Date: Thu, 13 Sep 2018 16:28:08 +0200 Subject: [PATCH 37/44] fixed view manage groups --- pandora_console/godmode/groups/group_list.php | 292 +++---- pandora_console/include/functions_graph.php | 13 +- pandora_console/include/functions_groups.php | 764 +----------------- .../operation/agentes/tactical.php | 1 - 4 files changed, 178 insertions(+), 892 deletions(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 9201e50c18..d6efbc2d5f 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -32,39 +32,38 @@ if (is_ajax ()) { require ("general/noaccess.php"); return; } - + $get_group_json = (bool) get_parameter ('get_group_json'); $get_group_agents = (bool) get_parameter ('get_group_agents'); $get_is_disabled = (bool) get_parameter ('get_is_disabled'); - + if ($get_group_json) { $id_group = (int) get_parameter ('id_group'); - + if ($id_group == 0) { $group = array('id_grupo' => 0, - 'nombre' => 'All', + 'nombre' => 'All', 'icon' => 'world', 'parent' => 0, 'disabled' => 0, 'custom_id' => null); - echo json_encode ($group); return; } - + if (! check_acl ($config['id_user'], $id_group, "AR")) { db_pandora_audit("ACL Violation", "Trying to access Alert Management"); echo json_encode (false); return; } - + $group = db_get_row ('tgrupo', 'id_grupo', $id_group); - + echo json_encode ($group); return; } - + if ($get_group_agents) { ob_clean(); $id_group = (int) get_parameter ('id_group'); @@ -86,33 +85,33 @@ if (is_ajax ()) { $serialized = (bool)get_parameter('serialized', false); $serialized_separator = (string)get_parameter('serialized_separator', "|"); $force_serialized = (bool)get_parameter('force_serialized', false); - + if (! check_acl ($config['id_user'], $id_group, "AR")) { db_pandora_audit("ACL Violation", "Trying to access Alert Management"); echo json_encode (false); return; } - + if ( https_is_running() ) { header('Content-type: application/json'); } - + if ($filter_agents_json != '') { $filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true); } - + if ($all_agents) { $filter['all_agents'] = true; } else { $filter['disabled'] = $disabled; } - + if ($search != '') { $filter['string'] = $search; } - + if ($status_agents != AGENT_STATUS_ALL) { $filter['status'] = $status_agents; } @@ -120,10 +119,8 @@ if (is_ajax ()) { # Juanma (22/05/2014) Fix: If remove void agents setted $_sql_post = ' 1=1 '; if ($show_void_agents == 0) { - $_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\''; $filter[$_sql_post] = '1'; - } $id_groups_get_agents = $id_group; @@ -192,7 +189,7 @@ if (is_ajax ()) { $agents = $all_agents_array; } - + echo json_encode ($agents); return; } @@ -208,11 +205,10 @@ if (is_ajax ()) { echo json_encode($return); return; } - return; } -if (! check_acl($config['id_user'], 0, "AW")) { +if (! check_acl($config['id_user'], 0, "PM")) { db_pandora_audit("ACL Violation", "Trying to access Group Management"); require ("general/noaccess.php"); @@ -221,24 +217,20 @@ if (! check_acl($config['id_user'], 0, "AW")) { // Header if (defined('METACONSOLE')) { - agents_meta_print_header(); $sec = 'advanced'; - echo '
'; echo __("Edit or delete groups can cause problems with synchronization"); echo '
'; - } else { - - ui_print_page_header (__("Groups defined in %s", get_product_name()), - "images/group.png", false, "", true, ""); + ui_print_page_header ( + __("Groups defined in %s", get_product_name()), + "images/group.png", false, "", true, "" + ); $sec = 'gagente'; - } - $create_group = (bool) get_parameter ('create_group'); $update_group = (bool) get_parameter ('update_group'); $delete_group = (bool) get_parameter ('delete_group'); @@ -258,7 +250,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) { $other = (string) get_parameter ('other'); $check = db_get_value('nombre', 'tgrupo', 'nombre', $name); $propagate = (bool) get_parameter('propagate'); - + /*Check if name field is empty*/ if ($name != "") { if (!$check) { @@ -275,7 +267,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, "PM"))) { 'other' => $other, 'password' => io_safe_input($group_pass) ); - + $result = db_process_sql_insert('tgrupo', $values); if ($result) { ui_print_success_message(__('Group successfully created')); @@ -309,7 +301,7 @@ if ($update_group) { $description = (string) get_parameter ('description'); $contact = (string) get_parameter ('contact'); $other = (string) get_parameter ('other'); - + /*Check if name field is empty*/ if ( $name != "") { switch ($config["dbtype"]) { @@ -332,7 +324,7 @@ if ($update_group) { else { $result = false; } - + if ($result !== false) { ui_print_success_message(__('Group successfully updated')); } @@ -344,19 +336,19 @@ if ($update_group) { /* Delete group */ if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) { $id_group = (int) get_parameter ('id_group'); - + $usedGroup = groups_check_used($id_group); - + if (!$usedGroup['return']) { $group = db_get_row_filter('tgrupo', array('id_grupo' => $id_group)); - + db_process_sql_update('tgrupo', array('parent' => $group['parent']), array('parent' => $id_group)); - + $result = db_process_sql_delete('tgroup_stat', array('id_group' => $id_group)); - + $result = db_process_sql_delete('tgrupo', array('id_grupo' => $id_group)); } @@ -364,136 +356,166 @@ if (($delete_group) && (check_acl($config['id_user'], 0, "PM"))) { ui_print_error_message( sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables']))); } - + if ($result && (!$usedGroup['return'])) { ui_print_success_message(__('Group successfully deleted')); - } + } else { ui_print_error_message(__('There was a problem deleting group')); } } -db_clean_cache(); -if ($create_group || $delete_group || $update_group) { - $groups = users_get_groups ($config['id_user'], "AR", true, true, null, 'id_grupo', false); - $groups = groups_get_groups_tree_recursive($groups); -} else { - $groups = users_get_groups_tree ($config['id_user'], "AR", true); +$acl=''; +$search_name = ''; +$offset = (int)get_parameter('offset', 0); +$search = (string)get_parameter('search', ''); +$block_size = $config['block_size']; + +if(!empty($search)){ + $search_name = "AND t.nombre LIKE '%$search%'"; } -$table = new StdClass(); -$table->width = '100%'; +if (!users_can_manage_group_all("AR")){ + $user_groups_acl = users_get_groups(false, "AR"); + $groups_acl = implode(",", $user_groups_ACL); + if(empty($groups_acl)) return ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) ); -$all_parents = array(); -$groups_count = 0; -$sons = array(); - -$groups_count = count($groups); - -foreach ($groups as $k => $g) { - if ($g['parent'] != 0) { - $all_parents[$g['parent']] = $g['parent']; - } -} -krsort($all_parents); -foreach ($all_parents as $parent) { - foreach ($groups as $k => $g) { - if ($g['parent'] == $parent) { - $sons[$g['parent']][] = $g; - unset($groups[$k]); - } - } + $acl = "AND t.id_grupo IN ($groups_acl)"; } +$form = "
"; + $form .= ""; + $form .= ""; + $form .= "
" . __('Search') . ' '; + $form .= html_print_input_text ("search", $search, '', 100, 100, true); + $form .= ""; + $form .= ""; + $form .= "
"; +$form .= "
"; + +echo $form; + +$groups_sql = + "SELECT t.*, + p.nombre AS parent_name, + IF(t.parent=p.id_grupo, 1, 0) AS has_child + FROM tgrupo t + LEFT JOIN tgrupo p + ON t.parent=p.id_grupo + WHERE 1=1 + $acl + $search_name + ORDER BY nombre + LIMIT $offset, $block_size +"; + +$groups = db_get_all_rows_sql($groups_sql); if (!empty($groups)) { + //Count all groups for pagination only saw user and filters + $groups_sql_count = "SELECT count(*) + FROM tgrupo t + WHERE 1=1 + $acl + $search_name + "; + $groups_count = db_get_value_sql($groups_sql_count); + + $table = new StdClass(); + $table->width = '100%'; $table->class = "databox data"; $table->head = array (); - $table->head[0] = __('Name'); - $table->head[1] = __('ID'); + $table->head[0] = __('ID'); + $table->head[1] = __('Name'); $table->head[2] = __('Icon'); $table->head[3] = __('Alerts'); - $table->head[4] = __('Description'); - $table->head[5] = __('Actions'); + $table->head[4] = __('Parent'); + $table->head[5] = __('Description'); + $table->head[6] = __('Actions'); $table->align = array (); + $table->align[0] = 'right'; $table->align[2] = 'left'; - $table->align[5] = 'left'; - $table->size[4] = '30%'; - $table->size[5] = '10%'; + $table->align[6] = 'left'; + $table->size[5] = '30%'; + $table->size[6] = '10%'; $table->data = array (); - - $offset = (int)get_parameter('offset', 0); - $limit = $offset + $config['block_size']; - - - - $pagination = ui_pagination($groups_count, - false, 0, $config['block_size'], true, 'offset', false); - - $n = -1; - $iterator = 0; - $branch_classes = array(); - foreach ($groups as $group) { - $n++; - - // Only print the page range - if ($n < $offset || $n >= $limit) { - continue; + + foreach ($groups as $key => $group) { + $url = "index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group=".$group['id_grupo']; + $url_delete = "index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group=" . $group['id_grupo']; + $table->data[$key][0] = $group['id_grupo']; + $table->data[$key][1] = "" . $group['nombre'] . ""; + $table->data[$key][2] = html_print_image( + "images/groups_small/" . $group['icon'] . ".png", + true, + array( + "style" => '', + "class" => "bot", + "alt" => $group['nombre'], + "title" => $group['nombre'], + false, false, false, true + ) + ); + + //reporting_get_group_stats + $table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled'); + $table->data[$key][4] = $group['parent_name']; + $table->data[$key][5] = $group['description']; + $table->data[$key][6] = "" . + html_print_image( + "images/config.png", + true, + array( + "alt" => __('Edit'), + "title" => __('Edit'), + "border" => '0' + ) + ) . + ""; + + $confirm_message = __('Are you sure?'); + if ($group['has_child']) { + $confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message; } - - $symbolBranchs = ' symbol_branch_' . $group['parent']; - - $has_children = isset($sons[$group['id_grupo']]); - $data = groups_get_group_to_list($group, $groups_count, $symbolBranchs, $has_children); - array_push ($table->data, $data); - $table->rowstyle[$iterator] = ''; - if ($group['id_grupo'] != 0) { - $branch_classes[$group['id_grupo']] = ' branch_0'; - $table->rowclass[$iterator] = 'parent_' . $group['parent'] . ' branch_0'; - } - $iterator++; - - groups_print_group_sons($group, $sons, $branch_classes, - $groups_count, $table, $iterator, $symbolBranchs); + + $table->data[$key][6] .= '  ' . + '' . + html_print_image( + "images/cross.png", + true, + array( + "alt" => __('Delete'), + "title" => __('Delete'), + "border" => '0' + ) + ) . + ""; + } - - echo $pagination; - + + echo ui_pagination( + $groups_count, false, + $offset, $block_size, + true, 'offset', false + ); html_print_table ($table); - - echo $pagination; + echo ui_pagination( + $groups_count, false, + $offset, $block_size, + true, 'offset', true + ); } else { ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no defined groups') ) ); } if (check_acl($config['id_user'], 0, "PM")) { - echo '
'; - echo '
'; - html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); - echo '
'; + echo ''; + echo '
'; + html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); + echo '
'; echo '
'; } enterprise_hook('close_meta_frame'); - ?> - - diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 75c08addc2..33118d39c2 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4268,12 +4268,12 @@ function fullscale_data ( if(isset($v["datos"]) && $v["datos"]){ //max - if($v['datos'] >= $max_value){ - $max_value = $v['datos']; + if((float)$v['datos'] >= $max_value_max){ + $max_value_max = $v['datos']; } //min - if($v['datos'] <= $min_value){ - $min_value = $v['datos']; + if((float)$v['datos'] <= $min_value_min){ + $min_value_min = $v['datos']; } //avg sum $sum_data += $v["datos"]; @@ -4288,8 +4288,9 @@ function fullscale_data ( $last_data = $v["datos"]; } } - $data["sum" . $series_suffix]['min'] = $min_value; - $data["sum" . $series_suffix]['max'] = $max_value; + + $data["sum" . $series_suffix]['min'] = $min_value_min; + $data["sum" . $series_suffix]['max'] = $max_value_max; $data["sum" . $series_suffix]['avg'] = $sum_data/$count_data; } diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 98c13d5db7..2ce647c324 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -270,22 +270,20 @@ function groups_get_childrens($parent, $groups = null, $onlyPropagate = false) { if (empty($groups)) { $groups = db_get_all_rows_in_table('tgrupo'); } - + $return = array(); - + foreach ($groups as $key => $group) { if ($group['id_grupo'] == 0) { continue; } - if ($group['propagate'] || $onlyPropagate) { if ($group['parent'] == $parent) { $return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups, $onlyPropagate); } } - } - + return $return; } @@ -300,23 +298,20 @@ function groups_get_parents($parent, $onlyPropagate = false, $groups = null) { if (empty($groups)) { $groups = db_get_all_rows_in_table('tgrupo'); } - + $return = array(); - foreach ($groups as $key => $group) { if ($group['id_grupo'] == 0) { continue; } - + if (($group['id_grupo'] == $parent) && ($group['propagate'] || !$onlyPropagate)) { - $return = $return + array($group['id_grupo'] => $group) + groups_get_parents($group['parent'], $onlyPropagate, $groups); } } - return $return; } @@ -373,32 +368,6 @@ function groups_give_disabled_group ($id_group) { return (bool) db_get_value ('disabled', 'tgrupo', 'id_grupo', (int) $id_group); } -/** - * Test if the param array is all groups in db. - * - * @param array $id_groups - * - * @return bool It's true when the array is all groups in db. - */ -function groups_is_all_group($idGroups) { - if (!is_array($idGroups)) - $arrayGroups = array($idGroups); - else - $arrayGroups = $idGroups; - - $groupsDB = db_get_all_rows_in_table ('tgrupo'); - - $returnVar = true; - foreach ($groupsDB as $group) { - if (!in_array($group['id_grupo'], $arrayGroups)) { - $returnVar = false; - break; - } - } - - return $returnVar; -} - /** * Get group icon from group. * @@ -632,7 +601,7 @@ function groups_get_id ($group_name, $returnAllGroup = false) { * * @param int $id_group The group id to look for * @param mixed filter array - * @param bool True if users with all permissions in the group are retrieved + * @param bool True if users with all permissions in the group are retrieved * * @return array An array with all the users or an empty array */ @@ -641,7 +610,7 @@ function groups_get_users ($id_group, $filter = false, $return_user_all = false) if (! is_array ($filter)) $filter = array (); - + if($return_user_all){ if (is_array($id_group)){ $filter['id_grupo'] = $id_group; @@ -655,18 +624,18 @@ function groups_get_users ($id_group, $filter = false, $return_user_all = false) $filter['id_grupo'] = $id_group; } - $query = "SELECT tu.* - FROM tusuario tu, tusuario_perfil tup - WHERE tup.id_usuario = tu.id_user" ; + $query = "SELECT tu.* + FROM tusuario tu, tusuario_perfil tup + WHERE tup.id_usuario = tu.id_user" ; if(is_array($filter)){ foreach ($filter as $key => $value) { if($key != 'limit' && $key != 'order' && - $key != 'offset' &&$key != 'group'){ + $key != 'offset' &&$key != 'group'){ $filter_array["tup.".$key] = $value; } else{ - $filter_array[$key] = $value; + $filter_array[$key] = $value; } } $clause_sql = mysql_db_format_array_where_clause_sql($filter_array,'AND',false); @@ -674,451 +643,16 @@ function groups_get_users ($id_group, $filter = false, $return_user_all = false) $query .= " AND " . $clause_sql; } } - + $result = db_get_all_rows_sql($query); if ($result === false){ return array (); } - + return $result; } -/** - * Returning data for a row in the groups view (Recursive function) - * - * @param int $id_group The group id of the row - * @param array $group_all An array of all groups - * @param array $group arrayy The group name and childs - * @param array $printed_groups The printed groups list (by reference) - * - */ -function groups_get_group_row_data($id_group, $group_all, $group, &$printed_groups) { - global $config; - - $rows = array(); - $row = array(); - - if (isset($printed_groups[$id_group])) { - return; - } - - // Store printed group to not print it again - $printed_groups[$id_group] = 1; - - if ($id_group < 0) - return; - - // Get stats for this group - $data = reporting_get_group_stats($id_group); - - if ($data["total_agents"] == 0) - return; // Skip empty groups - - // Calculate entire row color - if ($data["monitor_alerts_fired"] > 0) { - $row["status"] = "group_view_alrm"; - } - elseif ($data["monitor_critical"] > 0) { - $row["status"] = "group_view_crit"; - } - elseif ($data["monitor_warning"] > 0) { - $row["status"] = "group_view_warn"; - } - elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) { - $row["status"] = "group_view_unk"; - } - elseif ($data["monitor_ok"] > 0) { - $row["status"] = "group_view_ok"; - } - else { - $row["status"] = "group_view_normal"; - } - - // Group name - $group_cell = __('Group'); - $row[$group_cell] = $group['prefix']; - $row[$group_cell] .= ""; - $row[$group_cell] .= ui_print_group_icon ($id_group, true, "groups_small", '', false); - $row[$group_cell] .= ui_print_truncate_text($group['name']); - $row[$group_cell] .= ""; - - $row['group_name'] = ui_print_truncate_text($group['name']); - - if ($id_group > 0) - $icon = (string) db_get_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group); - else - $icon = "world"; - - $row['group_icon'] = html_print_image("images/groups_small/" . $icon . ".png", - true, false, true); - - if (!isset($html)) { - $html = false; - } - - //Update network group - if ($html) { - echo ""; - if (check_acl ($config['id_user'], $id_group, "AW")) { - echo '' . - html_print_image("images/target.png", true, array("border" => '0', "alt" => __('Force'))) . ''; - } - echo ""; - } - - // Total agents - if ($id_group != 0) { - $data["total_agents"] = db_get_sql ("SELECT COUNT(id_agente) - FROM tagente - WHERE id_grupo = $id_group AND disabled = 0"); - } - - // Total agents - $row['links'][__('Agents')] = "index.php?" . - "page=agents&group=" . $id_group; - $row['counts'][__('Agents')] = $data["total_agents"]; - - $row[__('Agents')] = ""; - $row[__('Agents')] .= $row['counts'][__('Agents')]; - $row[__('Agents')] .= ""; - - - // Agents unknown - $row['links'][__('Agents unknown')] = "index.php?" . - "page=agents&group=" . $id_group . "&status=" . AGENT_STATUS_UNKNOWN; - $row['counts'][__('Agents unknown')] = $data["agents_unknown"]; - - $row[__('Agents unknown')] = ""; - $row[__('Agents unknown')] .= $row['counts'][__('Agents unknown')]; - $row[__('Agents unknown')] .= ""; - - // Monitors Unknown - $row['links'][__('Unknown')] = "index.php?" . - "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_UNKNOWN; - $row['counts'][__('Unknown')] = $data["monitor_unknown"]; - - $row[__('Unknown')] = ""; - $row[__('Unknown')] .= $row['counts'][__('Unknown')]; - $row[__('Unknown')] .= ""; - - // Monitors Not Init - $row['links'][__('Not init')] = "index.php?" . - "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_NOT_INIT; - $row['counts'][__('Not init')] = $data["monitor_unknown"]; - - $row[__('Not init')] = ""; - $row[__('Not init')] .= $row['counts'][__('Not init')]; - $row[__('Not init')] .= ""; - - // Monitors OK - $row['links'][__('Normal')] = "index.php?" . - "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_NORMAL; - $row['counts'][__('Normal')] = $data["monitor_ok"]; - - $row[__('Normal')] = ""; - $row[__('Normal')] .= $row['counts'][__('Normal')]; - $row[__('Normal')] .= ""; - - // Monitors Warning - $row['links'][__('Warning')] = "index.php?" . - "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_WARNING; - $row['counts'][__('Warning')] = $data["monitor_warning"]; - - $row[__('Warning')] = ""; - $row[__('Warning')] .= $row['counts'][__('Normal')]; - $row[__('Warning')] .= ""; - - // Monitors Critical - $row['links'][__('Critical')] = "index.php?" . - "page=modules&group=" . $id_group . "&status=" . AGENT_MODULE_STATUS_CRITICAL_BAD; - $row['counts'][__('Critical')] = $data["monitor_critical"]; - - $row[__('Critical')] = ""; - $row[__('Critical')] .= $row['counts'][__('Critical')]; - $row[__('Critical')] .= ""; - - // Alerts fired - $row['links'][__('Alerts fired')] = "index.php?" . - "page=alerts&group=" . $id_group . "&status=fired"; - $row['counts'][__('Alerts fired')] = $data["monitor_alerts_fired"]; - - $row[__('Alerts fired')] = ""; - $row[__('Alerts fired')] .= $row['counts'][__('Alerts fired')]; - $row[__('Alerts fired')] .= ""; - - $rows[$id_group] = $row; - - foreach($group['childs'] as $child) { - $sub_rows = groups_get_group_row_data($child, $group_all, - $group_all[$child], $printed_groups); - - if (!$html) { - if (!empty($sub_rows)) - $rows = $rows + $sub_rows; - } - } - - return $rows; -} - -function groups_get_groups_with_agent($id_user = false, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null, $keys_field = 'id_grupo') { - $groups = users_get_groups($id_user, $privilege, $returnAllGroup, $returnAllColumns, $id_groups, $keys_field); - - $return = array(); - foreach ($groups as $group) { - $data = reporting_get_group_stats($group['id_grupo']); - - if ($data["total_agents"] != 0) { - $return[] = $group; - } - } - - return $return; -} - -/** - * Print a row in the groups view (Recursive function) - * - * @param int $id_group The group id of the row - * @param array $group_all An array of all groups - * @param array $group arrayy The group name and childs - * @param array $printed_groups The printed groups list (by reference) - * - */ -function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { - global $config; - - if ($id_group < 0) - return; - - if (isset($printed_groups[$id_group])) { - return; - } - - // Store printed group to not print it again - $printed_groups[$id_group] = 1; - - // Get stats for this group - $data = reporting_get_group_stats($id_group); - - - if ($data["total_agents"] == 0) { - if (!empty($group['childs'])) { - $group_childrens = groups_get_childrens($id_group, null, true); - $group_childrens_agents = groups_total_agents(array_keys($group_childrens)); - - if (empty($group_childrens_agents)) { - return; // Skip empty groups - } - } - else { - return; // Skip empty groups - } - } - - // Calculate entire row color - if ($data["monitor_alerts_fired"] > 0) { - $group_class = 'group_view_alrm'; - $status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true); - } - elseif ($data["monitor_critical"] > 0) { - $group_class = 'group_view_crit'; - $status_image = ui_print_status_image ('agent_critical_ball.png', "", true); - } - elseif ($data["monitor_warning"] > 0) { - $group_class = 'group_view_warn'; - $status_image = ui_print_status_image ('agent_warning_ball.png', "", true); - } - elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) { - $group_class = 'group_view_unk'; - $status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true); - } - elseif ($data["monitor_ok"] > 0) { - $group_class = 'group_view_ok'; - $status_image = ui_print_status_image ('agent_ok_ball.png', "", true); - } - elseif ($data["agent_not_init"] > 0) { - $group_class = 'group_view_not_init'; - $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true); - } - else { - $group_class = 'group_view_normal'; - $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true); - } - - ob_start(); - - echo ""; - - // Force - echo ""; - if (check_acl ($config['id_user'], $id_group, "AW")) { - echo '' . - html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'))) . ''; - } - echo ""; - - // Status - // echo "" . $status_image . ""; - - // Group name - echo "  "; - //echo $group['prefix'] . ui_print_group_icon ($id_group, true, "groups_small", 'font-size: 7.5pt'); - echo " "; - echo $group['prefix'] . ui_print_truncate_text($group['name']); - echo ""; - echo ""; - - // Total agents - echo ""; - if ($data["total_agents"] > 0) - echo ""; - - //Total agent field given by function reporting_get_group_stats return the number of agents - //of this groups and its children. It was done to print empty fathers of children groups. - //We need to recalculate the total agents for this group here to get only the total agents - //for this group. Of course the group All (0) is a special case. - - if ($id_group != 0) { - $data["total_agents"] = db_get_sql ("SELECT COUNT(id_agente) - FROM tagente - WHERE id_grupo = $id_group AND disabled = 0"); - } - - echo $data["total_agents"]; - echo ""; - - // Agents unknown - if ($data["agents_unknown"] > 0) { - echo ""; - echo ""; - echo $data["agents_unknown"]; - echo ""; - echo ""; - } - else { - echo ""; - } - - // Agents not init - if ($data["agent_not_init"] > 0) { - echo ""; - echo ""; - echo $data["agent_not_init"]; - echo ""; - echo ""; - } - else { - echo ""; - } - - // Monitors Unknown - if ($data["monitor_unknown"] > 0) { - echo ""; - echo ""; - echo $data["monitor_unknown"]; - echo ""; - echo ""; - } - else { - echo ""; - } - - - // Monitors Not Init - if ($data["monitor_not_init"] > 0) { - echo ""; - echo ""; - echo $data["monitor_not_init"]; - echo ""; - echo ""; - } - else { - echo ""; - } - - - // Monitors OK - echo ""; - if ($data["monitor_ok"] > 0) { - echo ""; - echo $data["monitor_ok"]; - echo ""; - } - else { - echo " "; - } - echo ""; - - // Monitors Warning - if ($data["monitor_warning"] > 0) { - echo ""; - echo ""; - echo $data["monitor_warning"]; - echo ""; - echo ""; - } - else { - echo ""; - } - - // Monitors Critical - if ($data["monitor_critical"] > 0) { - echo ""; - echo ""; - echo $data["monitor_critical"]; - echo ""; - echo ""; - } - else { - echo ""; - } - // Alerts fired - if ($data["monitor_alerts_fired"] > 0) { - echo ""; - echo ""; - echo $data["monitor_alerts_fired"]; - echo ""; - echo ""; - } - else { - echo ""; - } - - echo ""; - - $row[$id_group] = ob_get_clean(); - - - foreach ($group['childs'] as $child) { - if (array_key_exists($child, $group_all)) { - $row_child = groups_get_group_row($child, $group_all, $group_all[$child], $printed_groups); - - if (!is_array_empty($row_child)) { - $row = $row + $row_child; - } - } - } - - return $row; -} - /** * Gets a group by id_group * @@ -2111,172 +1645,6 @@ function groups_agents_total_counters ($group_array) { return ($agents === false) ? $default_total : $agents; } -/** - * Total agents in a group, (by default except disabled ones) - * - * @param mixed Array or (comma separated) string with groups - * @param bool Whether to count disabled agents - * - * @return mixed Return group count or false if something goes wrong - * - */ -function groups_total_agents ($group_array, $disabled = 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 . ")"; - - $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause"; - - if (!$disabled) - $sql .= " AND disabled = 0"; - - return db_get_sql ($sql); -} - -/** - * Number of disabled agents in a group - * - * @param mixed Array or (comma separated) string with groups - * - * @return mixed Return group count or false if something goes wrong - * - */ -function groups_agent_disabled ($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 . ")"; - - $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1"; - - return db_get_sql ($sql); -} - -/** - * Return a group row for Groups managment list - * - * @param mixed Group info - * @param int total number of groups - * @param string (ref) Concatenation of branches class with the parent classes - * - * @return mixed Row with html_print_table format - * - */ -function groups_get_group_to_list($group, $groups_count, &$symbolBranchs, $has_children = false) { - $tabulation = str_repeat('    ', $group['deep']); - - if ($group['id_grupo'] == 0) { - $symbol = '-'; - } - else { - $symbol = '+'; - } - - $group_hash_branch = false; - if (isset($group['hash_branch'])) { - $group_hash_branch = $group['hash_branch']; - } - - if ($group_hash_branch) { - $data[0] = ''.$tabulation . ' ' . - '' . - $symbol . ' '. ui_print_truncate_text($group['nombre']) . ''; - } - else { - $data[0] = '' . $tabulation . ' ' . ui_print_truncate_text($group['nombre']) . ''; - } - $data[1] = $group['id_grupo']; - $data[2] = ui_print_group_icon($group['id_grupo'], true); - $data[3] = $group['disabled'] ? __('Disabled') : __('Enabled'); - $data[4] = $group['description']; - if ($group['id_grupo'] == 0) { - $data[5] = ''; - } - else { - $data[5] = '' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0')); - //Check if there is only a group to unable delete it - if ($groups_count > 2) { - $confirm_message = __('Are you sure?'); - if ($has_children) { - $confirm_message = __('The child groups will be updated to use the parent id of the deleted group') . ". " . $confirm_message; - } - - $data[5] .= '  ' . - '' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0')); - } - else { - $data[5] .= '  ' . - ui_print_help_tip( - __('You cannot delete the last group. A common installation must have at least one group.'), true); - } - } - - return $data; -} - -/** - * Store to be printed the subgroups rows (Recursive) - * - * @param mixed Group info - * @param mixed Hash list with all the groups of 2nd or higher level - * @param string (ref) Concatenation of branches classes to control the symbols from Javascript - * @param int total number of groups - * @param obj (ref) table object in html_print_table format with the stored groups - * @param int (ref) counter of the row stored - * @param string (ref) Concatenation of branches class with the parent classes - * - */ -function groups_print_group_sons($group, $sons, &$branch_classes, $groups_count, &$table, &$iterator, &$symbolBranchs) { - if (isset($sons[$group['id_grupo']])) { - foreach($sons[$group['id_grupo']] as $key => $g) { - $symbolBranchs .= ' symbol_branch_' . $g['parent']; - - $has_children = isset($sons[$g['id_grupo']]); - - $data = groups_get_group_to_list($g, $groups_count, $symbolBranchs, $has_children); - array_push ($table->data, $data); - - $branch_classes[$g['id_grupo']] = $branch_classes[$g['parent']] . ' branch_' . $g['parent']; - $table->rowclass[$iterator] = 'parent_' . $g['parent'] . $branch_classes[$g['id_grupo']]; - - if ($g['deep'] == 0) { - $table->rowstyle[$iterator] = ''; - } - else { - if ($g['parent'] != 0) { - $table->rowstyle[$iterator] = 'display: none;'; - } - } - - $iterator++; - - groups_print_group_sons($g, $sons, $branch_classes, $groups_count, $table, $iterator, $symbolBranchs); - } - } -} - /** * Return an array with the groups hierarchy (Recursive) * @@ -2369,39 +1737,6 @@ function groups_get_tree_keys ($groups, &$group_keys) { } } -function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { - global $config; - - if ($id_group == 0) { - $hierarchy = groups_get_childrens($id_group); - } - else { - $hierarchy[] = $id_group; - $parent = db_get_value('parent','tgrupo','id_grupo',$id_group); - - if ($parent !== 0) { - $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']; - } - } - - $hierarchy = groups_get_all_hierarchy_group ($parent, $hierarchy); - } - } - } - return $hierarchy; -} - - - function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) { global $config; if ($id_user == false) { @@ -2942,77 +2277,6 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu 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_groups_and_tags ($id_user, $access, $user_strict); - - // If using metaconsole, the strict users will use the agent table of every node - if (is_metaconsole() && $user_strict) { - $servers = metaconsole_get_servers(); - - $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; - } - // If using metaconsole, the not strict users will use the metaconsole's agent cache table - else { - $result_list = group_get_data ($id_user, $user_strict, $acltags, - $returnAllGroup, $mode); - - return $result_list; - } -} - function groups_get_group_deep ($id_group) { global $config; diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 7c41cf8565..578c0c6af4 100755 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -56,7 +56,6 @@ ui_print_page_header (__("Tactical view"), "", false, "", false, $updated_time); //Currently this function makes loading this page is impossible. Change //and create new function. -//$all_data = group_get_groups_list($config['id_user'], $user_strict, 'AR', true, false, 'tactical'); $all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict); From 8601e38eed5d480a7911d11b12c5f178f3cf80e8 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 13 Sep 2018 16:38:17 +0200 Subject: [PATCH 38/44] Minor visual improvements for the GIS views --- .../operation/agentes/gis_view.php | 52 +++++++------------ .../operation/gis_maps/render_view.php | 37 +++++++------ 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/pandora_console/operation/agentes/gis_view.php b/pandora_console/operation/agentes/gis_view.php index c67a97037a..1b7d341917 100644 --- a/pandora_console/operation/agentes/gis_view.php +++ b/pandora_console/operation/agentes/gis_view.php @@ -36,7 +36,6 @@ $agentId = (int)get_parameter('id_agente'); $id_agente = $agentId; $agent_name = agents_get_name($id_agente); $agent_alias = agents_get_alias($id_agente); -$agentData = gis_get_data_last_position_agent($id_agente); //Avoid the agents with characters that fails the div. $agent_name_original = $agent_name; @@ -83,35 +82,22 @@ switch ($config["dbtype"]) { gis_activate_ajax_refresh(null, $timestampLastOperation); gis_activate_select_control(); -if ($agentData === false) { - ui_print_info_message ( - __("There is no GIS data for this agent, so it's positioned in default position of map.") ); -} - -$dataLastPosition = gis_get_data_last_position_agent($agentId); -if ($dataLastPosition !== false) { - echo "" . __("Last position in ") . - $dataLastPosition['start_timestamp'] . ": " . - $dataLastPosition['stored_longitude'] . ", " . $dataLastPosition['stored_latitude'] . ", " . $dataLastPosition['stored_altitude']; -} - +echo "
"; echo "
"; echo ""; -echo "
" . __("Period to show data as path") . ": "; +echo "
" . __("Period to show data as path"); echo ""; html_print_extended_select_for_time ('period', $period, '', '', '0', 10); echo ""; html_print_submit_button(__('Refresh path'), 'refresh', false, 'class = "sub upd" style="margin-top:0px"'); echo "
"; -echo "

" . __("Positional data from the last") . " " . human_time_description_raw ($period) ."

"; /* Get the total number of Elements for the pagination */ $sqlCount = sprintf ("SELECT COUNT(*) FROM tgis_data_history WHERE tagente_id_agente = %d AND end_timestamp > FROM_UNIXTIME(%d) ORDER BY end_timestamp DESC", $agentId, get_system_time () - $period); -$countData = db_get_value_sql($sqlCount); - +$countData = (int) db_get_value_sql($sqlCount); /* Get the elements to present in this page */ switch ($config["dbtype"]) { @@ -141,9 +127,7 @@ switch ($config["dbtype"]) { $result = db_get_all_rows_sql ($sql, true); - if ($result === false) { - $sql2 = sprintf (" SELECT current_longitude AS longitude, current_latitude AS latitude, current_altitude AS altitude, start_timestamp, description, number_of_packages, manual_placement @@ -163,10 +147,11 @@ if ($result === false) { } if ($result !== false) { - if(!$countData){ - $countData = 1; - } - ui_pagination ($countData, false) ; + echo "

" . __("Positional data from the last") . " " . human_time_description_raw($period) ."

"; + + if ($countData > 0) ui_pagination($countData, false); + + $table = new StdClass(); $table->data = array(); foreach ($result as $key => $row) { $distance = 0; @@ -187,9 +172,13 @@ if ($result !== false) { $rowdata = array( $row['longitude'], $row['latitude'], - $row['altitude'], - $row['start_timestamp'], - $row['end_timestamp'], + (int) $row['altitude'] . " m", + is_numeric($row['start_timestamp']) + ? date($config["date_format"], $row['start_timestamp']) + : date_w_fixed_tz($row['start_timestamp']), + is_numeric($row['end_timestamp']) + ? date($config["date_format"], $row['end_timestamp']) + : date_w_fixed_tz($row['end_timestamp']), $row['description'], sprintf(__('%s Km'), $distance), $row['number_of_packages'], @@ -206,13 +195,12 @@ if ($result !== false) { __('Distance'), __("# of Packages"), __("Manual placement")); - $table->class = 'position_data_table'; + $table->class = 'databox data'; $table->id = $agent_name.'_position_data_table'; - $table->title = $agent_alias . " " . __("positional data"); - $table->titlestyle = "background-color:#799E48;"; - html_print_table($table); unset($table); + $table->width = '100%'; + html_print_table($table); + unset($table); - ui_pagination ($countData, false) ; - echo "

" . __('Total') . ' ' . $countData . ' ' . __('Data') . "

"; + if ($countData > 0) ui_pagination($countData, false); } ?> diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index eabefebbfe..de453a5a81 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -108,6 +108,9 @@ $layers = gis_get_layers($idMap); // Render map +$has_management_acl = check_acl($config["id_user"], $map['group_id'], "MW") + || check_acl ($config["id_user"], $map['group_id'], "MM"); + $buttons = array(); if ($config["pure"] == 0) { @@ -119,22 +122,14 @@ else { html_print_image ("images/normalscreen.png", true, array ("title" => __('Back to normal mode'))) . "
"; } -if (check_acl ($config["id_user"], $map['group_id'], "MW") || check_acl ($config["id_user"], $map['group_id'], "MM")) { - $buttons['setup']['text'] = ''.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; - $buttons['setup']['godmode'] = 1; - - +if ($has_management_acl) { $hash = md5($config["dbpass"] . $idMap . $config["id_user"]); - $buttons['public_link']['text'] = ''. html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).''; } -$buttonsString = '' . - html_print_image("images/bricks.png", true, array("class" => "top", "border" => '0')) . '  Agent - test_gis1