Merge remote-tracking branch 'origin/develop' into 2078-ue-cmdb-integration

This commit is contained in:
fbsanchez 2018-09-06 11:39:58 +02:00
commit d0a82c436a
26 changed files with 129 additions and 145 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.726-180905 Version: 7.0NG.726-180906
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.726-180905" pandora_version="7.0NG.726-180906"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.726'; use constant AGENT_VERSION => '7.0NG.726';
use constant AGENT_BUILD => '180905'; use constant AGENT_BUILD => '180906';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.726 %define version 7.0NG.726
%define release 180905 %define release 180906
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.726 %define version 7.0NG.726
%define release 180905 %define release 180906
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.726" PI_VERSION="7.0NG.726"
PI_BUILD="180905" PI_BUILD="180906"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{180905} {180906}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.726(Build 180905)") #define PANDORA_VERSION ("7.0NG.726(Build 180906)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.726(Build 180905))" VALUE "ProductVersion", "(7.0NG.726(Build 180906))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.726-180905 Version: 7.0NG.726-180906
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.726-180905" pandora_version="7.0NG.726-180906"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -950,7 +950,7 @@ class Tree {
SUM(if(%s, 1, 0)) as state_unknown, SUM(if(%s, 1, 0)) as state_unknown,
SUM(if(%s, 1, 0)) as state_notinit, SUM(if(%s, 1, 0)) as state_notinit,
SUM(if(%s, 1, 0)) as state_normal, SUM(if(%s, 1, 0)) as state_normal,
SUM(if(%s, 1, 0)) as state_total SUM(if(%s AND tae.estado IS NOT NULL, 1, 0)) as state_total
", ",
$this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true), $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true),
$this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true), $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true),
@ -977,7 +977,8 @@ class Tree {
FROM tagente ta FROM tagente ta
$inner_or_left JOIN tagente_modulo tam $inner_or_left JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
INNER JOIN tagente_estado tae AND tam.disabled = 0
$inner_or_left JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo ON tae.id_agente_modulo = tam.id_agente_modulo
$inner $inner
WHERE ta.id_agente IN WHERE ta.id_agente IN
@ -992,14 +993,13 @@ class Tree {
$group_search_filter $group_search_filter
$condition_inside $condition_inside
) )
AND ta.disabled = 0 AND tam.disabled = 0 AND ta.disabled = 0
$condition $condition
$agent_search_filter $agent_search_filter
$agent_status_filter $agent_status_filter
$module_search_filter $module_search_filter
$module_status_filter $module_status_filter
GROUP BY ta.id_agente GROUP BY ta.id_agente
HAVING state_total > 0
ORDER BY ta.alias ASC, ta.id_agente ASC ORDER BY ta.alias ASC, ta.id_agente ASC
"; ";

View File

@ -28,7 +28,6 @@ class TreeGroup extends Tree {
$this->L1fieldName = "id_group"; $this->L1fieldName = "id_group";
$this->L1extraFields = array( $this->L1extraFields = array(
"tg.nombre AS `name`", "tg.nombre AS `name`",
$this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent',
"tg.icon", "tg.icon",
"tg.id_grupo AS gid" "tg.id_grupo AS gid"
); );
@ -56,42 +55,42 @@ class TreeGroup extends Tree {
protected function getFirstLevel() { protected function getFirstLevel() {
$processed_items = $this->getProcessedGroups(); $processed_items = $this->getProcessedGroups();
if (!empty($processed_items)) { if (!empty($processed_items)) {
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
if (!empty($this->filter['searchGroup'])) { if (!empty($this->filter['searchGroup'])) {
// Save the groups which intersect with the user groups // Save the groups which intersect with the user groups
$groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%')); $groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%'));
if ($groups == false) $groups = array(); if ($groups == false) $groups = array();
$userGroupsACL = $this->userGroupsACL; $userGroupsACL = $this->userGroupsACL;
$ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) { $ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) {
$group_id = $group['id_grupo']; $group_id = $group['id_grupo'];
if (isset($userGroupsACL[$group_id])) { if (isset($userGroupsACL[$group_id])) {
$userGroups[$group_id] = $userGroupsACL[$group_id]; $userGroups[$group_id] = $userGroupsACL[$group_id];
} }
return $userGroups; return $userGroups;
}, array()); }, array());
$result = self::extractGroupsWithIDs($processed_items, $ids_hash); $result = self::extractGroupsWithIDs($processed_items, $ids_hash);
$processed_items = ($result === false) ? array() : $result; $processed_items = ($result === false) ? array() : $result;
}
// groupID filter. To access the view from tactical views f.e.
if (!empty($this->filter['groupID'])) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
$processed_items = ($result === false) ? array() : array($result);
}
} }
// groupID filter. To access the view from tactical views f.e.
if (!empty($this->filter['groupID'])) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
$processed_items = ($result === false) ? array() : array($result);
}
}
$this->tree = $processed_items; $this->tree = $processed_items;
} }
protected function getProcessedGroups () { protected function getProcessedGroups () {
$processed_groups = array(); $processed_groups = array();
// Index and process the groups // Index and process the groups
$groups = $this->getGroupCounters(0); $groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all) // If user have not permissions in parent, set parent node to 0 (all)
// Avoid to do foreach for admins // Avoid to do foreach for admins
@ -136,98 +135,81 @@ class TreeGroup extends Tree {
} }
protected function getGroupCounters() { protected function getGroupCounters() {
//FIXME PLEASE $fields = $this->getFirstLevelFields();
if (true) { $inside_fields = $this->getFirstLevelFieldsInside();
$fields = $this->getFirstLevelFields();
$inside_fields = $this->getFirstLevelFieldsInside();
$group_acl = ""; $group_acl = "";
$secondary_group_acl = ""; $secondary_group_acl = "";
if (!users_can_manage_group_all("AR")) { if (!users_can_manage_group_all("AR")) {
$user_groups_str = implode(",", $this->userGroupsArray); $user_groups_str = implode(",", $this->userGroupsArray);
$group_acl = " AND ta.id_grupo IN ($user_groups_str)"; $group_acl = " AND ta.id_grupo IN ($user_groups_str)";
$secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)"; $secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)";
}
$agent_search_filter = $this->getAgentSearchFilter();
$agent_search_filter = preg_replace("/%/", "%%", $agent_search_filter);
$agent_status_filter = $this->getAgentStatusFilter();
$module_status_filter = $this->getModuleStatusFilter();
$module_search_inner = "";
$module_search_filter = "";
if (!empty($this->filter['searchModule'])) {
$module_search_inner = "
INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente
INNER JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo";
$module_search_filter = "AND tam.disabled = 0
AND tam.nombre LIKE '%%" . $this->filter['searchModule'] . "%%' " .
$this->getModuleStatusFilterFromTestado()
;
}
$table = is_metaconsole() ? "tmetaconsole_agent" : "tagente";
$table_sec = is_metaconsole() ? "tmetaconsole_agent_secondary_group" : "tagent_secondary_group";
$sql_model = "SELECT %s FROM
(
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
FROM $table ta
$module_search_inner
WHERE ta.disabled = 0
%s
$agent_search_filter
$agent_status_filter
$module_status_filter
$module_search_filter
$group_acl
GROUP BY id_grupo
UNION ALL
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g
FROM $table ta INNER JOIN $table_sec tasg
ON ta.id_agente = tasg.id_agent
$module_search_inner
WHERE ta.disabled = 0
%s
$agent_search_filter
$agent_status_filter
$module_status_filter
$module_search_filter
$secondary_group_acl
GROUP BY id_group
) x GROUP BY g";
$sql_array = array();
foreach ($inside_fields as $inside_field) {
$sql_array[] = sprintf(
$sql_model,
$inside_field['header'],
$inside_field['condition'],
$inside_field['condition']
);
}
$sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2
RIGHT JOIN tgrupo tg
ON x2.g = tg.id_grupo
GROUP BY tg.id_grupo";
$stats = db_get_all_rows_sql($sql);
} }
else{ $agent_search_filter = $this->getAgentSearchFilter();
$stats = db_get_all_rows_sql( $agent_search_filter = preg_replace("/%/", "%%", $agent_search_filter);
'SELECT tgs.agents AS total_count, tgs.critical AS total_critical_count, $agent_status_filter = $this->getAgentStatusFilter();
tgs.unknown AS total_unknown_count, tgs.warning AS total_warning_count, $module_status_filter = $this->getModuleStatusFilter();
`non-init` AS total_not_init_count, tgs.normal AS total_normal_count,
tgs.alerts_fired AS total_alerts_count, $module_search_inner = "";
tg.nombre AS name, tg.parent, tg.icon, tg.id_grupo AS gid $module_search_filter = "";
FROM tgroup_stat tgs if (!empty($this->filter['searchModule'])) {
INNER JOIN tgrupo tg $module_search_inner = "
ON tg.id_grupo = tgs.id_group INNER JOIN tagente_modulo tam
'); ON ta.id_agente = tam.id_agente
INNER JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo";
$module_search_filter = "AND tam.disabled = 0
AND tam.nombre LIKE '%%" . $this->filter['searchModule'] . "%%' " .
$this->getModuleStatusFilterFromTestado()
;
} }
# Update the group cache (from db or calculated). $table = is_metaconsole() ? "tmetaconsole_agent" : "tagente";
$table_sec = is_metaconsole() ? "tmetaconsole_agent_secondary_group" : "tagent_secondary_group";
$sql_model = "SELECT %s FROM
(
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
FROM $table ta
$module_search_inner
WHERE ta.disabled = 0
%s
$agent_search_filter
$agent_status_filter
$module_status_filter
$module_search_filter
$group_acl
GROUP BY id_grupo
UNION ALL
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g
FROM $table ta INNER JOIN $table_sec tasg
ON ta.id_agente = tasg.id_agent
$module_search_inner
WHERE ta.disabled = 0
%s
$agent_search_filter
$agent_status_filter
$module_status_filter
$module_search_filter
$secondary_group_acl
GROUP BY id_group
) x GROUP BY g";
$sql_array = array();
foreach ($inside_fields as $inside_field) {
$sql_array[] = sprintf(
$sql_model,
$inside_field['header'],
$inside_field['condition'],
$inside_field['condition']
);
}
$sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2
RIGHT JOIN tgrupo tg
ON x2.g = tg.id_grupo
GROUP BY tg.id_grupo";
$stats = db_get_all_rows_sql($sql);
$group_stats = array(); $group_stats = array();
foreach ($stats as $group) { foreach ($stats as $group) {
$group_stats[$group['gid']]['total_count'] = (int)$group['total_count']; $group_stats[$group['gid']]['total_count'] = (int)$group['total_count'];
$group_stats[$group['gid']]['total_critical_count'] = (int)$group['total_critical_count']; $group_stats[$group['gid']]['total_critical_count'] = (int)$group['total_critical_count'];
@ -243,13 +225,15 @@ class TreeGroup extends Tree {
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
} }
if (isset($group_stats[$group_id])) {
return $group_stats[$group_id];
}
return $group_stats; return $group_stats;
} }
protected function getFirstLevelFields() {
$fields = parent::getFirstLevelFields();
$parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent';
return "$fields, $parent";
}
protected function getProcessedModules($modules_tree) { protected function getProcessedModules($modules_tree) {
$groups = array(); $groups = array();

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC180905'; $build_version = 'PC180906';
$pandora_version = 'v7.0NG.726'; $pandora_version = 'v7.0NG.726';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -71,7 +71,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.726'; $version = '7.0NG.726';
$build = '180905'; $build = '180906';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.726 %define version 7.0NG.726
%define release 180905 %define release 180906
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.726 %define version 7.0NG.726
%define release 180905 %define release 180906
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.726-180905 Version: 7.0NG.726-180906
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.726-180905" pandora_version="7.0NG.726-180906"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -45,7 +45,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.726"; my $pandora_version = "7.0NG.726";
my $pandora_build = "180905"; my $pandora_build = "180906";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.726"; my $pandora_version = "7.0NG.726";
my $pandora_build = "180905"; my $pandora_build = "180906";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.726 %define version 7.0NG.726
%define release 180905 %define release 180906
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.726 %define version 7.0NG.726
%define release 180905 %define release 180906
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.726" PI_VERSION="7.0NG.726"
PI_BUILD="180905" PI_BUILD="180906"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.726 PS180905"; my $version = "7.0NG.726 PS180906";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.726 PS180905"; my $version = "7.0NG.726 PS180906";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);