mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
implemented services treeview
Former-commit-id: d5d71442d0c6122ba91b160647559cdf03f55625
This commit is contained in:
parent
cd83f324a1
commit
eb56fd566c
BIN
pandora_console/images/tree_events.png
Normal file
BIN
pandora_console/images/tree_events.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 329 B |
BIN
pandora_console/images/tree_service_map.png
Normal file
BIN
pandora_console/images/tree_service_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 401 B |
@ -3,173 +3,163 @@
|
|||||||
// ==================================================
|
// ==================================================
|
||||||
// Copyright (c) 2005-2012 Artica Soluciones Tecnologicas
|
// Copyright (c) 2005-2012 Artica Soluciones Tecnologicas
|
||||||
// Please see http://pandorafms.org for full contribution list
|
// Please see http://pandorafms.org for full contribution list
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
// as published by the Free Software Foundation; version 2
|
// as published by the Free Software Foundation; version 2
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// 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.
|
||||||
|
|
||||||
// Only accesible by ajax
|
// Only accesible by ajax
|
||||||
if (is_ajax()) {
|
if (is_ajax ()) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
enterprise_include_once("include/functions_dashboard.php");
|
||||||
|
|
||||||
enterprise_include_once('include/functions_dashboard.php');
|
$public_hash = get_parameter('hash', 0);
|
||||||
|
|
||||||
$public_hash = get_parameter('hash', 0);
|
// Try to authenticate by hash on public dashboards
|
||||||
|
if ($public_hash == 0) {
|
||||||
|
// Login check
|
||||||
|
check_login();
|
||||||
|
} else {
|
||||||
|
$validate_hash = enterprise_hook(
|
||||||
|
'dasboard_validate_public_hash',
|
||||||
|
array($public_hash, 'tree_view')
|
||||||
|
);
|
||||||
|
if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) {
|
||||||
|
db_pandora_audit("Invalid public hash", "Trying to access report builder");
|
||||||
|
require ("general/noaccess.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once($config['homedir'] . "/include/class/Tree.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeOS.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeModuleGroup.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeModule.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeTag.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeGroup.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeService.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/class/TreeGroupEdition.class.php");
|
||||||
|
enterprise_include_once("include/class/TreePolicies.class.php");
|
||||||
|
enterprise_include_once("include/class/TreeGroupMeta.class.php");
|
||||||
|
require_once($config['homedir'] . "/include/functions_reporting.php");
|
||||||
|
require_once($config['homedir'] . "/include/functions_os.php");
|
||||||
|
|
||||||
|
$getChildren = (bool) get_parameter('getChildren', 0);
|
||||||
|
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
||||||
|
$getDetail = (bool) get_parameter('getDetail');
|
||||||
|
|
||||||
|
if ($getChildren) {
|
||||||
|
$type = get_parameter('type', 'group');
|
||||||
|
$rootType = get_parameter('rootType', '');
|
||||||
|
$id = get_parameter('id', -1);
|
||||||
|
$rootID = get_parameter('rootID', -1);
|
||||||
|
$serverID = get_parameter('serverID', false);
|
||||||
|
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
||||||
|
$hash = get_parameter('hash', false);
|
||||||
|
if ($hash !== false) {
|
||||||
|
enterprise_hook('dasboard_validate_public_hash', array($hash, 'tree_view'));
|
||||||
|
}
|
||||||
|
|
||||||
// Try to authenticate by hash on public dashboards
|
$default_filters = array(
|
||||||
if ($public_hash == 0) {
|
'searchAgent' => '',
|
||||||
// Login check
|
'statusAgent' => AGENT_STATUS_ALL,
|
||||||
check_login();
|
'searchModule' => '',
|
||||||
} else {
|
'statusModule' => -1,
|
||||||
$validate_hash = enterprise_hook(
|
'groupID' => 0,
|
||||||
'dasboard_validate_public_hash',
|
'tagID' => 0,
|
||||||
[
|
);
|
||||||
$public_hash,
|
$filter = get_parameter('filter', $default_filters);
|
||||||
'tree_view',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) {
|
|
||||||
db_pandora_audit('Invalid public hash', 'Trying to access report builder');
|
|
||||||
include 'general/noaccess.php';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once $config['homedir'].'/include/class/Tree.class.php';
|
$agent_a = check_acl ($config['id_user'], 0, "AR");
|
||||||
include_once $config['homedir'].'/include/class/TreeOS.class.php';
|
$agent_w = check_acl ($config['id_user'], 0, "AW");
|
||||||
include_once $config['homedir'].'/include/class/TreeModuleGroup.class.php';
|
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||||
include_once $config['homedir'].'/include/class/TreeModule.class.php';
|
$switch_type = !empty($rootType) ? $rootType : $type;
|
||||||
include_once $config['homedir'].'/include/class/TreeTag.class.php';
|
switch ($switch_type) {
|
||||||
include_once $config['homedir'].'/include/class/TreeGroup.class.php';
|
case 'os':
|
||||||
include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php';
|
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
enterprise_include_once('include/class/TreePolicies.class.php');
|
break;
|
||||||
enterprise_include_once('include/class/TreeGroupMeta.class.php');
|
case 'module_group':
|
||||||
include_once $config['homedir'].'/include/functions_reporting.php';
|
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
include_once $config['homedir'].'/include/functions_os.php';
|
break;
|
||||||
|
case 'module':
|
||||||
|
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
break;
|
||||||
|
case 'tag':
|
||||||
|
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
break;
|
||||||
|
case 'group':
|
||||||
|
if(is_metaconsole()){
|
||||||
|
if (!class_exists('TreeGroupMeta')) break;
|
||||||
|
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'policies':
|
||||||
|
if (!class_exists('TreePolicies')) break;
|
||||||
|
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
break;
|
||||||
|
case 'group_edition':
|
||||||
|
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
break;
|
||||||
|
case 'services':
|
||||||
|
$tree = new TreeService($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// FIXME. No error handler
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$getChildren = (bool) get_parameter('getChildren', 0);
|
$tree->setFilter($filter);
|
||||||
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
ob_clean();
|
||||||
$getDetail = (bool) get_parameter('getDetail');
|
|
||||||
|
|
||||||
if ($getChildren) {
|
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
|
||||||
$type = get_parameter('type', 'group');
|
return;
|
||||||
$rootType = get_parameter('rootType', '');
|
}
|
||||||
$id = get_parameter('id', -1);
|
|
||||||
$rootID = get_parameter('rootID', -1);
|
if ($getDetail) {
|
||||||
$serverID = get_parameter('serverID', false);
|
require_once($config['homedir']."/include/functions_treeview.php");
|
||||||
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
|
||||||
$hash = get_parameter('hash', false);
|
$id = (int) get_parameter('id');
|
||||||
if ($hash !== false) {
|
$type = (string) get_parameter('type');
|
||||||
enterprise_hook('dasboard_validate_public_hash', [$hash, 'tree_view']);
|
|
||||||
}
|
$server = array();
|
||||||
|
if (is_metaconsole()) {
|
||||||
$default_filters = [
|
$server_id = (int) get_parameter('serverID');
|
||||||
'searchAgent' => '',
|
$server = metaconsole_get_servers($server_id);
|
||||||
'statusAgent' => AGENT_STATUS_ALL,
|
}
|
||||||
'searchModule' => '',
|
|
||||||
'statusModule' => -1,
|
ob_clean();
|
||||||
'groupID' => 0,
|
|
||||||
'tagID' => 0,
|
echo '<div class="left_align">';
|
||||||
];
|
if (!empty($id) && !empty($type)) {
|
||||||
$filter = get_parameter('filter', $default_filters);
|
switch ($type) {
|
||||||
|
case 'agent':
|
||||||
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
treeview_printTable($id, $server, true);
|
||||||
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
break;
|
||||||
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
case 'module':
|
||||||
$switch_type = !empty($rootType) ? $rootType : $type;
|
treeview_printModuleTable($id, $server, true);
|
||||||
switch ($switch_type) {
|
break;
|
||||||
case 'os':
|
case 'alert':
|
||||||
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
treeview_printAlertsTable($id, $server, true);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case 'module_group':
|
// Nothing
|
||||||
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
break;
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
case 'module':
|
echo '<br></div>';
|
||||||
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
|
||||||
break;
|
return;
|
||||||
|
}
|
||||||
case 'tag':
|
|
||||||
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
return;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'group':
|
|
||||||
if (is_metaconsole()) {
|
|
||||||
if (!class_exists('TreeGroupMeta')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
|
||||||
} else {
|
|
||||||
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'policies':
|
|
||||||
if (!class_exists('TreePolicies')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'group_edition':
|
|
||||||
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// FIXME. No error handler
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tree->setFilter($filter);
|
|
||||||
ob_clean();
|
|
||||||
echo json_encode(['success' => 1, 'tree' => $tree->getArray()]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($getDetail) {
|
|
||||||
include_once $config['homedir'].'/include/functions_treeview.php';
|
|
||||||
|
|
||||||
$id = (int) get_parameter('id');
|
|
||||||
$type = (string) get_parameter('type');
|
|
||||||
|
|
||||||
$server = [];
|
|
||||||
if (is_metaconsole()) {
|
|
||||||
$server_id = (int) get_parameter('serverID');
|
|
||||||
$server = metaconsole_get_servers($server_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
ob_clean();
|
|
||||||
|
|
||||||
echo '<div class="left_align">';
|
|
||||||
if (!empty($id) && !empty($type)) {
|
|
||||||
switch ($type) {
|
|
||||||
case 'agent':
|
|
||||||
treeview_printTable($id, $server, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'module':
|
|
||||||
treeview_printModuleTable($id, $server, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'alert':
|
|
||||||
treeview_printAlertsTable($id, $server, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Nothing
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<br></div>';
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
?>
|
File diff suppressed because it is too large
Load Diff
@ -1,215 +1,193 @@
|
|||||||
<?php
|
<?php
|
||||||
// Pandora FMS- http://pandorafms.com
|
//Pandora FMS- http://pandorafms.com
|
||||||
// ==================================================
|
// ==================================================
|
||||||
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
||||||
// Please see http://pandorafms.org for full contribution list
|
// Please see http://pandorafms.org for full contribution list
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
// as published by the Free Software Foundation; version 2
|
// as published by the Free Software Foundation; version 2
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// 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.
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
require_once $config['homedir'].'/include/class/Tree.class.php';
|
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||||
|
|
||||||
class TreeGroup extends Tree
|
class TreeGroup extends Tree {
|
||||||
{
|
|
||||||
|
|
||||||
protected $propagateCounters = true;
|
protected $propagateCounters = true;
|
||||||
|
protected $displayAllGroups = false;
|
||||||
|
|
||||||
protected $displayAllGroups = false;
|
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR')
|
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$this->L1fieldName = "id_group";
|
||||||
|
$this->L1extraFields = array(
|
||||||
|
"tg.nombre AS `name`",
|
||||||
|
"tg.icon",
|
||||||
|
"tg.id_grupo AS gid"
|
||||||
|
);
|
||||||
|
|
||||||
$this->L1fieldName = 'id_group';
|
$this->L2conditionInside = "AND (
|
||||||
$this->L1extraFields = [
|
ta.id_grupo = " . $this->id . "
|
||||||
'tg.nombre AS `name`',
|
OR tasg.id_group = " . $this->id . "
|
||||||
'tg.icon',
|
)";
|
||||||
'tg.id_grupo AS gid',
|
}
|
||||||
];
|
|
||||||
|
|
||||||
$this->L2conditionInside = 'AND (
|
public function setPropagateCounters($value) {
|
||||||
ta.id_grupo = '.$this->id.'
|
$this->propagateCounters = (bool)$value;
|
||||||
OR tasg.id_group = '.$this->id.'
|
}
|
||||||
)';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function setDisplayAllGroups($value) {
|
||||||
|
$this->displayAllGroups = (bool)$value;
|
||||||
|
}
|
||||||
|
|
||||||
public function setPropagateCounters($value)
|
protected function getData() {
|
||||||
{
|
if ($this->id == -1) {
|
||||||
$this->propagateCounters = (bool) $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$this->getFirstLevel();
|
||||||
|
|
||||||
public function setDisplayAllGroups($value)
|
} elseif ($this->type == 'group') {
|
||||||
{
|
$this->getSecondLevel();
|
||||||
$this->displayAllGroups = (bool) $value;
|
} elseif ($this->type == 'agent') {
|
||||||
}
|
$this->getThirdLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getGroupSearchFilter() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
protected function getData()
|
protected function getFirstLevel() {
|
||||||
{
|
$processed_items = $this->getProcessedGroups();
|
||||||
if ($this->id == -1) {
|
|
||||||
$this->getFirstLevel();
|
|
||||||
} else if ($this->type == 'group') {
|
|
||||||
$this->getSecondLevel();
|
|
||||||
} else if ($this->type == 'agent') {
|
|
||||||
$this->getThirdLevel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!empty($processed_items)) {
|
||||||
|
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
|
||||||
|
if (!empty($this->filter['searchGroup'])) {
|
||||||
|
// Save the groups which intersect with the user groups
|
||||||
|
$groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%'));
|
||||||
|
if ($groups == false) $groups = array();
|
||||||
|
$userGroupsACL = $this->userGroupsACL;
|
||||||
|
$ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) {
|
||||||
|
$group_id = $group['id_grupo'];
|
||||||
|
if (isset($userGroupsACL[$group_id])) {
|
||||||
|
$userGroups[$group_id] = $userGroupsACL[$group_id];
|
||||||
|
}
|
||||||
|
|
||||||
protected function getGroupSearchFilter()
|
return $userGroups;
|
||||||
{
|
}, array());
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$result = self::extractGroupsWithIDs($processed_items, $ids_hash);
|
||||||
|
|
||||||
protected function getFirstLevel()
|
$processed_items = ($result === false) ? array() : $result;
|
||||||
{
|
}
|
||||||
$processed_items = $this->getProcessedGroups();
|
|
||||||
|
|
||||||
if (!empty($processed_items)) {
|
// groupID filter. To access the view from tactical views f.e.
|
||||||
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
|
if (!empty($this->filter['groupID'])) {
|
||||||
if (!empty($this->filter['searchGroup'])) {
|
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
|
||||||
// Save the groups which intersect with the user groups
|
|
||||||
$groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']);
|
|
||||||
if ($groups == false) {
|
|
||||||
$groups = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$userGroupsACL = $this->userGroupsACL;
|
$processed_items = ($result === false) ? array() : array($result);
|
||||||
$ids_hash = array_reduce(
|
}
|
||||||
$groups,
|
}
|
||||||
function ($userGroups, $group) use ($userGroupsACL) {
|
hd("G-GETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVEL", true);
|
||||||
$group_id = $group['id_grupo'];
|
hd($processed_items, true);
|
||||||
if (isset($userGroupsACL[$group_id])) {
|
$this->tree = $processed_items;
|
||||||
$userGroups[$group_id] = $userGroupsACL[$group_id];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $userGroups;
|
protected function getProcessedGroups () {
|
||||||
},
|
$processed_groups = array();
|
||||||
[]
|
// Index and process the groups
|
||||||
);
|
$groups = $this->getGroupCounters();
|
||||||
|
|
||||||
$result = self::extractGroupsWithIDs($processed_items, $ids_hash);
|
// If user have not permissions in parent, set parent node to 0 (all)
|
||||||
|
// Avoid to do foreach for admins
|
||||||
|
if (!users_can_manage_group_all("AR")) {
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
||||||
|
$groups[$id]['parent'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Build the group hierarchy
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||||
|
$parent = $groups[$id]['parent'];
|
||||||
|
// Parent exists
|
||||||
|
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
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
if (isset($groups[$id]['children'])) {
|
||||||
|
usort($groups[$id]['children'], array("Tree", "cmpSortNames"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Filter groups and eliminates the reference to children groups out of her parent
|
||||||
|
$groups = array_filter($groups, function ($group) {
|
||||||
|
return !$group['have_parent'];
|
||||||
|
});
|
||||||
|
// Propagate child counters to her parents
|
||||||
|
|
||||||
$processed_items = ($result === false) ? [] : $result;
|
if ($this->propagateCounters) {
|
||||||
}
|
TreeGroup::processCounters($groups);
|
||||||
|
// Filter groups and eliminates the reference to empty groups
|
||||||
|
$groups = $this->deleteEmptyGroups($groups);
|
||||||
|
} else {
|
||||||
|
$groups = $this->deleteEmptyGroupsNotPropagate($groups);
|
||||||
|
}
|
||||||
|
|
||||||
// groupID filter. To access the view from tactical views f.e.
|
usort($groups, array("Tree", "cmpSortNames"));
|
||||||
if (!empty($this->filter['groupID'])) {
|
|
||||||
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL);
|
|
||||||
|
|
||||||
$processed_items = ($result === false) ? [] : [$result];
|
return $groups;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->tree = $processed_items;
|
protected function getGroupCounters() {
|
||||||
}
|
$fields = $this->getFirstLevelFields();
|
||||||
|
$inside_fields = $this->getFirstLevelFieldsInside();
|
||||||
|
|
||||||
|
$group_acl = "";
|
||||||
|
$secondary_group_acl = "";
|
||||||
|
if (!users_can_manage_group_all("AR")) {
|
||||||
|
$user_groups_str = implode(",", $this->userGroupsArray);
|
||||||
|
$group_acl = " AND ta.id_grupo 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();
|
||||||
|
|
||||||
protected function getProcessedGroups()
|
$module_search_inner = "";
|
||||||
{
|
$module_search_filter = "";
|
||||||
$processed_groups = [];
|
if (!empty($this->filter['searchModule'])) {
|
||||||
// Index and process the groups
|
$module_search_inner = "
|
||||||
$groups = $this->getGroupCounters();
|
|
||||||
|
|
||||||
// If user have not permissions in parent, set parent node to 0 (all)
|
|
||||||
// Avoid to do foreach for admins
|
|
||||||
if (!users_can_manage_group_all('AR')) {
|
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
|
||||||
$groups[$id]['parent'] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the group hierarchy
|
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
|
||||||
$parent = $groups[$id]['parent'];
|
|
||||||
// Parent exists
|
|
||||||
if (!isset($groups[$parent]['children'])) {
|
|
||||||
$groups[$parent]['children'] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (isset($groups[$id]['children'])) {
|
|
||||||
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter groups and eliminates the reference to children groups out of her parent
|
|
||||||
$groups = array_filter(
|
|
||||||
$groups,
|
|
||||||
function ($group) {
|
|
||||||
return !$group['have_parent'];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// Propagate child counters to her parents
|
|
||||||
if ($this->propagateCounters) {
|
|
||||||
self::processCounters($groups);
|
|
||||||
// Filter groups and eliminates the reference to empty groups
|
|
||||||
$groups = $this->deleteEmptyGroups($groups);
|
|
||||||
} else {
|
|
||||||
$groups = $this->deleteEmptyGroupsNotPropagate($groups);
|
|
||||||
}
|
|
||||||
|
|
||||||
usort($groups, ['Tree', 'cmpSortNames']);
|
|
||||||
return $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function getGroupCounters()
|
|
||||||
{
|
|
||||||
$fields = $this->getFirstLevelFields();
|
|
||||||
$inside_fields = $this->getFirstLevelFieldsInside();
|
|
||||||
|
|
||||||
$group_acl = '';
|
|
||||||
$secondary_group_acl = '';
|
|
||||||
if (!users_can_manage_group_all('AR')) {
|
|
||||||
$user_groups_str = implode(',', $this->userGroupsArray);
|
|
||||||
$group_acl = " AND ta.id_grupo 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
|
INNER JOIN tagente_modulo tam
|
||||||
ON ta.id_agente = tam.id_agente
|
ON ta.id_agente = tam.id_agente
|
||||||
INNER JOIN tagente_estado tae
|
INNER JOIN tagente_estado tae
|
||||||
ON tae.id_agente_modulo = tam.id_agente_modulo';
|
ON tae.id_agente_modulo = tam.id_agente_modulo";
|
||||||
$module_search_filter = "AND tam.disabled = 0
|
$module_search_filter = "AND tam.disabled = 0
|
||||||
AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' ".$this->getModuleStatusFilterFromTestado();
|
AND tam.nombre LIKE '%%" . $this->filter['searchModule'] . "%%' " .
|
||||||
}
|
$this->getModuleStatusFilterFromTestado()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
|
$table = is_metaconsole() ? "tmetaconsole_agent" : "tagente";
|
||||||
$table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group';
|
$table_sec = is_metaconsole() ? "tmetaconsole_agent_secondary_group" : "tagent_secondary_group";
|
||||||
|
|
||||||
$sql_model = "SELECT %s FROM
|
$sql_model = "SELECT %s FROM
|
||||||
(
|
(
|
||||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
|
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
|
||||||
FROM $table ta
|
FROM $table ta
|
||||||
@ -236,294 +214,254 @@ class TreeGroup extends Tree
|
|||||||
$secondary_group_acl
|
$secondary_group_acl
|
||||||
GROUP BY id_group
|
GROUP BY id_group
|
||||||
) x GROUP BY g";
|
) x GROUP BY g";
|
||||||
$sql_array = [];
|
$sql_array = array();
|
||||||
foreach ($inside_fields as $inside_field) {
|
foreach ($inside_fields as $inside_field) {
|
||||||
$sql_array[] = sprintf(
|
$sql_array[] = sprintf(
|
||||||
$sql_model,
|
$sql_model,
|
||||||
$inside_field['header'],
|
$inside_field['header'],
|
||||||
$inside_field['condition'],
|
$inside_field['condition'],
|
||||||
$inside_field['condition']
|
$inside_field['condition']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
$sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2
|
||||||
$sql = "SELECT $fields FROM (".implode(' UNION ALL ', $sql_array).') x2
|
|
||||||
RIGHT JOIN tgrupo tg
|
RIGHT JOIN tgrupo tg
|
||||||
ON x2.g = tg.id_grupo
|
ON x2.g = tg.id_grupo
|
||||||
GROUP BY tg.id_grupo';
|
GROUP BY tg.id_grupo";
|
||||||
$stats = db_get_all_rows_sql($sql);
|
$stats = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
$group_stats = [];
|
$group_stats = array();
|
||||||
foreach ($stats as $group) {
|
|
||||||
$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_unknown_count'] = (int) $group['total_unknown_count'];
|
|
||||||
$group_stats[$group['gid']]['total_warning_count'] = (int) $group['total_warning_count'];
|
|
||||||
$group_stats[$group['gid']]['total_not_init_count'] = (int) $group['total_not_init_count'];
|
|
||||||
$group_stats[$group['gid']]['total_normal_count'] = (int) $group['total_normal_count'];
|
|
||||||
$group_stats[$group['gid']]['total_fired_count'] = (int) $group['total_alerts_count'];
|
|
||||||
$group_stats[$group['gid']]['name'] = $group['name'];
|
|
||||||
$group_stats[$group['gid']]['parent'] = $group['parent'];
|
|
||||||
$group_stats[$group['gid']]['icon'] = $group['icon'];
|
|
||||||
$group_stats[$group['gid']]['id'] = $group['gid'];
|
|
||||||
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $group_stats;
|
hd("STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS ", true);
|
||||||
}
|
hd($stats, true);
|
||||||
|
foreach ($stats as $group) {
|
||||||
|
$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_unknown_count'] = (int)$group['total_unknown_count'];
|
||||||
|
$group_stats[$group['gid']]['total_warning_count'] = (int)$group['total_warning_count'];
|
||||||
|
$group_stats[$group['gid']]['total_not_init_count'] = (int)$group['total_not_init_count'];
|
||||||
|
$group_stats[$group['gid']]['total_normal_count'] = (int)$group['total_normal_count'];
|
||||||
|
$group_stats[$group['gid']]['total_fired_count'] = (int)$group['total_alerts_count'];
|
||||||
|
$group_stats[$group['gid']]['name'] = $group['name'];
|
||||||
|
$group_stats[$group['gid']]['parent'] = $group['parent'];
|
||||||
|
$group_stats[$group['gid']]['icon'] = $group['icon'];
|
||||||
|
$group_stats[$group['gid']]['id'] = $group['gid'];
|
||||||
|
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getFirstLevelFields()
|
|
||||||
{
|
|
||||||
$fields = parent::getFirstLevelFields();
|
|
||||||
$parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent';
|
|
||||||
return "$fields, $parent";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $group_stats;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getProcessedModules($modules_tree)
|
protected function getFirstLevelFields() {
|
||||||
{
|
$fields = parent::getFirstLevelFields();
|
||||||
$groups = [];
|
$parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent';
|
||||||
foreach ($modules_tree as $group) {
|
return "$fields, $parent";
|
||||||
$groups[$group['id']] = $group;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Build the module hierarchy
|
protected function getProcessedModules($modules_tree) {
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
|
||||||
$parent = $groups[$id]['parent'];
|
|
||||||
// Parent exists
|
|
||||||
if (!isset($groups[$parent]['children'])) {
|
|
||||||
$groups[$parent]['children'] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store a reference to the group into the parent
|
$groups = array();
|
||||||
$groups[$parent]['children'][] = &$groups[$id];
|
foreach ($modules_tree as $group) {
|
||||||
// This group was introduced into a parent
|
$groups[$group["id"]] = $group;
|
||||||
$groups[$id]['have_parent'] = true;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort the children groups
|
// Build the module hierarchy
|
||||||
foreach ($groups as $id => $group) {
|
foreach ($groups as $id => $group) {
|
||||||
if (isset($groups[$id]['children'])) {
|
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||||
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
|
$parent = $groups[$id]['parent'];
|
||||||
}
|
// Parent exists
|
||||||
}
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Filter groups and eliminates the reference to children groups out of her parent
|
// Sort the children groups
|
||||||
$groups = array_filter(
|
foreach ($groups as $id => $group) {
|
||||||
$groups,
|
if (isset($groups[$id]['children'])) {
|
||||||
function ($group) {
|
usort($groups[$id]['children'], array("Tree", "cmpSortNames"));
|
||||||
return !$group['have_parent'];
|
}
|
||||||
}
|
}
|
||||||
);
|
//Filter groups and eliminates the reference to children groups out of her parent
|
||||||
|
$groups = array_filter($groups, function ($group) {
|
||||||
|
return !$group['have_parent'];
|
||||||
|
});
|
||||||
|
|
||||||
return array_values($groups);
|
return array_values($groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Hierarchy lops is broken
|
||||||
|
protected function getProcessedModules_old($modules_tree) {
|
||||||
|
|
||||||
// FIXME: Hierarchy lops is broken
|
$tree_modules = array();
|
||||||
protected function getProcessedModules_old($modules_tree)
|
$new_modules_root = array_filter($modules_tree, function ($module) {
|
||||||
{
|
return (isset($module['parent']) && ($module['parent'] == 0));
|
||||||
$tree_modules = [];
|
});
|
||||||
$new_modules_root = array_filter(
|
|
||||||
$modules_tree,
|
|
||||||
function ($module) {
|
|
||||||
return (isset($module['parent']) && ($module['parent'] == 0));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$new_modules_child = array_filter(
|
$new_modules_child = array_filter($modules_tree, function ($module) {
|
||||||
$modules_tree,
|
return (isset($module['parent']) && ($module['parent'] != 0));
|
||||||
function ($module) {
|
});
|
||||||
return (isset($module['parent']) && ($module['parent'] != 0));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while (!empty($new_modules_child)) {
|
while (!empty($new_modules_child)) {
|
||||||
foreach ($new_modules_child as $i => $child) {
|
foreach ($new_modules_child as $i => $child) {
|
||||||
self::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child);
|
TreeGroup::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($new_modules_root as $m) {
|
foreach ($new_modules_root as $m) {
|
||||||
$tree_modules[] = $m;
|
$tree_modules[] = $m;
|
||||||
}
|
}
|
||||||
|
return $tree_modules;
|
||||||
|
}
|
||||||
|
|
||||||
return $tree_modules;
|
// FIXME with getProcessedModules_old
|
||||||
}
|
static function recursive_modules_tree_view (&$new_modules, &$new_modules_child, $i, $child) {
|
||||||
|
foreach ($new_modules as $index => $module) {
|
||||||
|
if ($module['id'] == $child['parent']) {
|
||||||
|
$new_modules[$index]['children'][] = $child;
|
||||||
|
unset($new_modules_child[$i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (isset($new_modules[$index]['children'])) {
|
||||||
|
TreeGroup::recursive_modules_tree_view ($new_modules[$index]['children'], $new_modules_child, $i, $child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function processCounters(&$groups) {
|
||||||
|
$all_counters = array();
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
$child_counters = array();
|
||||||
|
if (!empty($groups[$id]['children'])) {
|
||||||
|
$child_counters = TreeGroup::processCounters($groups[$id]['children']);
|
||||||
|
}
|
||||||
|
if (!empty($child_counters)) {
|
||||||
|
foreach($child_counters as $type => $value) {
|
||||||
|
$groups[$id]['counters'][$type] += $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach($groups[$id]['counters'] as $type => $value) {
|
||||||
|
$all_counters[$type] += $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $all_counters;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME with getProcessedModules_old
|
/**
|
||||||
static function recursive_modules_tree_view(&$new_modules, &$new_modules_child, $i, $child)
|
* @brief Recursive function to remove the empty groups
|
||||||
{
|
*
|
||||||
foreach ($new_modules as $index => $module) {
|
* @param groups All groups structure
|
||||||
if ($module['id'] == $child['parent']) {
|
*
|
||||||
$new_modules[$index]['children'][] = $child;
|
* @return new_groups A new groups structure without empty groups
|
||||||
unset($new_modules_child[$i]);
|
*/
|
||||||
break;
|
protected function deleteEmptyGroups ($groups) {
|
||||||
} else if (isset($new_modules[$index]['children'])) {
|
if($this->displayAllGroups) return $groups;
|
||||||
self::recursive_modules_tree_view($new_modules[$index]['children'], $new_modules_child, $i, $child);
|
$new_groups = array();
|
||||||
}
|
foreach ($groups as $group) {
|
||||||
}
|
// If a group is empty, do not add to new_groups.
|
||||||
}
|
if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Tray to remove the children groups
|
||||||
|
if (!empty($group['children'])) {
|
||||||
|
$children = $this->deleteEmptyGroups ($group['children']);
|
||||||
|
if (empty($children)) unset($group['children']);
|
||||||
|
else $group['children'] = $children;
|
||||||
|
}
|
||||||
|
$new_groups[] = $group;
|
||||||
|
}
|
||||||
|
return $new_groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function deleteEmptyGroupsNotPropagate ($groups) {
|
||||||
|
if($this->displayAllGroups) return $groups;
|
||||||
|
$new_groups = array();
|
||||||
|
foreach ($groups as $group) {
|
||||||
|
// Tray to remove the children groups
|
||||||
|
if (!empty($group['children'])) {
|
||||||
|
$children = $this->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;
|
||||||
|
}
|
||||||
|
|
||||||
static function processCounters(&$groups)
|
private static function extractGroupsWithIDs ($groups, $ids_hash) {
|
||||||
{
|
$result_groups = array();
|
||||||
$all_counters = [];
|
foreach ($groups as $group) {
|
||||||
foreach ($groups as $id => $group) {
|
if (isset($ids_hash[$group['id']])) {
|
||||||
$child_counters = [];
|
$result_groups[] = $group;
|
||||||
if (!empty($groups[$id]['children'])) {
|
}
|
||||||
$child_counters = self::processCounters($groups[$id]['children']);
|
else if (!empty($group['children'])) {
|
||||||
}
|
$result = self::extractGroupsWithIDs($group['children'], $ids_hash);
|
||||||
|
|
||||||
if (!empty($child_counters)) {
|
// Item found on children
|
||||||
foreach ($child_counters as $type => $value) {
|
if (!empty($result)) {
|
||||||
$groups[$id]['counters'][$type] += $value;
|
$result_groups = array_merge($result_groups, $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($groups[$id]['counters'] as $type => $value) {
|
return $result_groups;
|
||||||
$all_counters[$type] += $value;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $all_counters;
|
private static function extractItemWithID ($items, $item_id, $item_type = "group", $strictACL = false) {
|
||||||
}
|
foreach ($items as $item) {
|
||||||
|
if ($item["type"] != $item_type)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Item found
|
||||||
|
if ($strictACL && is_metaconsole()) {
|
||||||
|
foreach ($item["id"] as $server_id => $id) {
|
||||||
|
if ($id == $item_id)
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($item["id"] == $item_id)
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
if ($item["type"] == "group" && !empty($item["children"])) {
|
||||||
* @brief Recursive function to remove the empty groups
|
$result = self::extractItemWithID($item["children"], $item_id, $item_type, $strictACL);
|
||||||
*
|
|
||||||
* @param groups All groups structure
|
|
||||||
*
|
|
||||||
* @return new_groups A new groups structure without empty groups
|
|
||||||
*/
|
|
||||||
protected function deleteEmptyGroups($groups)
|
|
||||||
{
|
|
||||||
if ($this->displayAllGroups) {
|
|
||||||
return $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_groups = [];
|
// Item found on children
|
||||||
foreach ($groups as $group) {
|
if ($result !== false)
|
||||||
// If a group is empty, do not add to new_groups.
|
return $result;
|
||||||
if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) {
|
}
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Tray to remove the children groups
|
// Item not found
|
||||||
if (!empty($group['children'])) {
|
return false;
|
||||||
$children = $this->deleteEmptyGroups($group['children']);
|
}
|
||||||
if (empty($children)) {
|
|
||||||
unset($group['children']);
|
|
||||||
} else {
|
|
||||||
$group['children'] = $children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_groups[] = $group;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $new_groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function deleteEmptyGroupsNotPropagate($groups)
|
|
||||||
{
|
|
||||||
if ($this->displayAllGroups) {
|
|
||||||
return $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_groups = [];
|
|
||||||
foreach ($groups as $group) {
|
|
||||||
// Tray to remove the children groups
|
|
||||||
if (!empty($group['children'])) {
|
|
||||||
$children = $this->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 = [];
|
|
||||||
foreach ($groups as $group) {
|
|
||||||
if (isset($ids_hash[$group['id']])) {
|
|
||||||
$result_groups[] = $group;
|
|
||||||
} else if (!empty($group['children'])) {
|
|
||||||
$result = self::extractGroupsWithIDs($group['children'], $ids_hash);
|
|
||||||
|
|
||||||
// Item found on children
|
|
||||||
if (!empty($result)) {
|
|
||||||
$result_groups = array_merge($result_groups, $result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result_groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static function extractItemWithID($items, $item_id, $item_type='group', $strictACL=false)
|
|
||||||
{
|
|
||||||
foreach ($items as $item) {
|
|
||||||
if ($item['type'] != $item_type) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item found
|
|
||||||
if ($strictACL && is_metaconsole()) {
|
|
||||||
foreach ($item['id'] as $server_id => $id) {
|
|
||||||
if ($id == $item_id) {
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($item['id'] == $item_id) {
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($item['type'] == 'group' && !empty($item['children'])) {
|
|
||||||
$result = self::extractItemWithID($item['children'], $item_id, $item_type, $strictACL);
|
|
||||||
|
|
||||||
// Item found on children
|
|
||||||
if ($result !== false) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item not found
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function getDisplayHierarchy()
|
|
||||||
{
|
|
||||||
return $this->filter['searchHirearchy'] ||
|
|
||||||
(empty($this->filter['searchAgent']) && empty($this->filter['searchModule']));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
protected function getDisplayHierarchy() {
|
||||||
|
return $this->filter['searchHirearchy'] ||
|
||||||
|
(empty($this->filter['searchAgent']) && empty($this->filter['searchModule']));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
@ -1,120 +1,108 @@
|
|||||||
<?php
|
<?php
|
||||||
// Pandora FMS- http://pandorafms.com
|
//Pandora FMS- http://pandorafms.com
|
||||||
// ==================================================
|
// ==================================================
|
||||||
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
||||||
// Please see http://pandorafms.org for full contribution list
|
// Please see http://pandorafms.org for full contribution list
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
// as published by the Free Software Foundation; version 2
|
// as published by the Free Software Foundation; version 2
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// 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.
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
require_once $config['homedir'].'/include/class/Tree.class.php';
|
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||||
|
|
||||||
class TreeGroupEdition extends TreeGroup
|
class TreeGroupEdition extends TreeGroup {
|
||||||
{
|
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
}
|
||||||
|
protected function getData() {
|
||||||
|
if ($this->id == -1) {
|
||||||
|
$this->getFirstLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getProcessedGroups () {
|
||||||
|
$processed_groups = array();
|
||||||
|
// Index and process the groups
|
||||||
|
$groups = $this->getGroupCounters();
|
||||||
|
|
||||||
|
// If user have not permissions in parent, set parent node to 0 (all)
|
||||||
|
// Avoid to do foreach for admins
|
||||||
|
if (!users_can_manage_group_all("AR")) {
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
||||||
|
$groups[$id]['parent'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Build the group hierarchy
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
||||||
|
$parent = $groups[$id]['parent'];
|
||||||
|
// Parent exists
|
||||||
|
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
|
||||||
|
foreach ($groups as $id => $group) {
|
||||||
|
if (isset($groups[$id]['children'])) {
|
||||||
|
usort($groups[$id]['children'], array("Tree", "cmpSortNames"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Filter groups and eliminates the reference to children groups out of her parent
|
||||||
|
$groups = array_filter($groups, function ($group) {
|
||||||
|
return !$group['have_parent'];
|
||||||
|
});
|
||||||
|
|
||||||
|
usort($groups, array("Tree", "cmpSortNames"));
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR')
|
protected function getGroupCounters() {
|
||||||
{
|
$messages = array(
|
||||||
global $config;
|
'confirm' => __('Confirm'),
|
||||||
|
'cancel' => __('Cancel'),
|
||||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
'messg' => __('Are you sure?')
|
||||||
}
|
);
|
||||||
|
$sql = "SELECT id_grupo AS gid,
|
||||||
|
|
||||||
protected function getData()
|
|
||||||
{
|
|
||||||
if ($this->id == -1) {
|
|
||||||
$this->getFirstLevel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function getProcessedGroups()
|
|
||||||
{
|
|
||||||
$processed_groups = [];
|
|
||||||
// Index and process the groups
|
|
||||||
$groups = $this->getGroupCounters();
|
|
||||||
|
|
||||||
// If user have not permissions in parent, set parent node to 0 (all)
|
|
||||||
// Avoid to do foreach for admins
|
|
||||||
if (!users_can_manage_group_all('AR')) {
|
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (!isset($this->userGroups[$groups[$id]['parent']])) {
|
|
||||||
$groups[$id]['parent'] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the group hierarchy
|
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
|
|
||||||
$parent = $groups[$id]['parent'];
|
|
||||||
// Parent exists
|
|
||||||
if (!isset($groups[$parent]['children'])) {
|
|
||||||
$groups[$parent]['children'] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
foreach ($groups as $id => $group) {
|
|
||||||
if (isset($groups[$id]['children'])) {
|
|
||||||
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter groups and eliminates the reference to children groups out of her parent
|
|
||||||
$groups = array_filter(
|
|
||||||
$groups,
|
|
||||||
function ($group) {
|
|
||||||
return !$group['have_parent'];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
usort($groups, ['Tree', 'cmpSortNames']);
|
|
||||||
return $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function getGroupCounters()
|
|
||||||
{
|
|
||||||
$messages = [
|
|
||||||
'confirm' => __('Confirm'),
|
|
||||||
'cancel' => __('Cancel'),
|
|
||||||
'messg' => __('Are you sure?'),
|
|
||||||
];
|
|
||||||
$sql = 'SELECT id_grupo AS gid,
|
|
||||||
nombre as name, parent, icon
|
nombre as name, parent, icon
|
||||||
FROM tgrupo
|
FROM tgrupo
|
||||||
';
|
";
|
||||||
|
|
||||||
$stats = db_get_all_rows_sql($sql);
|
$stats = db_get_all_rows_sql($sql);
|
||||||
$group_stats = [];
|
$group_stats = array();
|
||||||
foreach ($stats as $group) {
|
foreach ($stats as $group) {
|
||||||
$group_stats[$group['gid']]['name'] = $group['name'];
|
$group_stats[$group['gid']]['name'] = $group['name'];
|
||||||
$group_stats[$group['gid']]['parent'] = $group['parent'];
|
$group_stats[$group['gid']]['parent'] = $group['parent'];
|
||||||
$group_stats[$group['gid']]['icon'] = $group['icon'];
|
$group_stats[$group['gid']]['icon'] = $group['icon'];
|
||||||
$group_stats[$group['gid']]['id'] = $group['gid'];
|
$group_stats[$group['gid']]['id'] = $group['gid'];
|
||||||
$group_stats[$group['gid']]['type'] = 'group';
|
$group_stats[$group['gid']]['type'] = 'group';
|
||||||
|
|
||||||
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
|
||||||
$group_stats[$group['gid']]['delete']['messages'] = $messages;
|
|
||||||
$group_stats[$group['gid']]['edit'] = 1;
|
|
||||||
$group_stats[$group['gid']]['alerts'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $group_stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
||||||
|
$group_stats[$group['gid']]['delete']['messages'] = $messages;
|
||||||
|
$group_stats[$group['gid']]['edit'] = 1;
|
||||||
|
$group_stats[$group['gid']]['alerts'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $group_stats;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
342
pandora_console/include/class/TreeService.class.php
Normal file
342
pandora_console/include/class/TreeService.class.php
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
<?php
|
||||||
|
//Pandora FMS- http://pandorafms.com
|
||||||
|
// ==================================================
|
||||||
|
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
||||||
|
// Please see http://pandorafms.org for full contribution list
|
||||||
|
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
|
// as published by the Free Software Foundation; version 2
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
require_once($config['homedir']."/include/class/Tree.class.php");
|
||||||
|
|
||||||
|
class TreeService extends Tree {
|
||||||
|
|
||||||
|
protected $propagateCounters = true;
|
||||||
|
protected $displayAllGroups = false;
|
||||||
|
|
||||||
|
public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand", $access = 'AR') {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
|
||||||
|
$this->L1fieldName = "id_group";
|
||||||
|
$this->L1extraFields = array(
|
||||||
|
"ts.name AS `name`",
|
||||||
|
"ts.id AS `sid`"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->filter['statusAgent'] = AGENT_STATUS_ALL;
|
||||||
|
|
||||||
|
$this->avoid_condition = true;
|
||||||
|
|
||||||
|
$this->L2inner = 'LEFT JOIN tservice_element tse
|
||||||
|
ON tse.id_agent = ta.id_agente';
|
||||||
|
|
||||||
|
$this->L2condition = 'AND tse.id_service='.$this->id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPropagateCounters($value) {
|
||||||
|
$this->propagateCounters = (bool)$value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDisplayAllGroups($value) {
|
||||||
|
$this->displayAllGroups = (bool)$value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getData() {
|
||||||
|
if ($this->id == -1) {
|
||||||
|
$this->getFirstLevel();
|
||||||
|
} elseif ($this->type == 'services') {
|
||||||
|
$this->getSecondLevel();
|
||||||
|
} elseif ($this->type == 'agent') {
|
||||||
|
$this->getThirdLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFirstLevel() {
|
||||||
|
$processed_items = $this->getProcessedServices();
|
||||||
|
$ids = array_keys($processed_items);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$filter=array('id'=>$ids);
|
||||||
|
|
||||||
|
$own_info = get_user_info($config['id_user']);
|
||||||
|
|
||||||
|
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||||
|
$display_all_services = true;
|
||||||
|
} else {
|
||||||
|
$display_all_services = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tree = [];
|
||||||
|
|
||||||
|
$services = services_get_services($filter, false, $display_all_services);
|
||||||
|
|
||||||
|
foreach ($services as $row) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$status = services_get_status($row, true);
|
||||||
|
|
||||||
|
switch ($status) {
|
||||||
|
|
||||||
|
case SERVICE_STATUS_NORMAL:
|
||||||
|
$processed_items[$row['id']]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_ok_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVICE_STATUS_CRITICAL:
|
||||||
|
$processed_items[$row['id']]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_critical_ball.png" data-title="CRITICAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVICE_STATUS_WARNING:
|
||||||
|
$processed_items[$row['id']][$key]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_warning_ball.png" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVICE_STATUS_UNKNOWN:
|
||||||
|
default:
|
||||||
|
$processed_items[$row['id']]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_no_data_ball.png" data-title="UNKNOWN status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tree = $processed_items;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getProcessedServices () {
|
||||||
|
$fields = $this->getFirstLevelFields();
|
||||||
|
|
||||||
|
//hd($this->userGroupsArray, true);
|
||||||
|
|
||||||
|
if (users_can_manage_group_all("AR")){
|
||||||
|
$groups_acl = "";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$groups_acl = "AND ts.id_group IN (".implode(',', $this->userGroupsArray).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = sprintf("SELECT t1.*
|
||||||
|
FROM tservice_element tss
|
||||||
|
RIGHT JOIN
|
||||||
|
(SELECT ts.id, ts.id_agent_module, ts.name, ts.name AS `alias`, ts.id AS `rootID`,
|
||||||
|
'services' AS rootType, 'services' AS type,
|
||||||
|
0 AS quiet,
|
||||||
|
SUM(if((tse.id_agent<>0), 1, 0)) AS `total_agents`,
|
||||||
|
SUM(if((tse.id_agente_modulo<>0), 1, 0)) AS `total_modules`,
|
||||||
|
SUM(if((tse.id_service_child<>0), 1, 0)) AS `total_services`
|
||||||
|
FROM tservice ts
|
||||||
|
LEFT JOIN tservice_element tse
|
||||||
|
ON ts.id=tse.id_service
|
||||||
|
GROUP BY id
|
||||||
|
) as t1
|
||||||
|
ON tss.id_service_child = t1.id
|
||||||
|
WHERE tss.id_service_child IS NULL
|
||||||
|
%s
|
||||||
|
",
|
||||||
|
$groups_acl
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$stats = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$services = array();
|
||||||
|
|
||||||
|
foreach ($stats as $service) {
|
||||||
|
$services[$service['id']] = $this->getProcessedItem($services[$service['id']]);
|
||||||
|
if ($service['total_services']+$service['total_agents']+$service['total_modules'] > 0)
|
||||||
|
$services[$service['id']]['searchChildren'] = 1;
|
||||||
|
else
|
||||||
|
$services[$service['id']]['searchChildren'] = 0;
|
||||||
|
|
||||||
|
$services[$service['id']]['counters'] = array('total_services'=>$service['total_services'], 'total_agents'=>$service['total_agents'], 'total_modules'=>$service['total_modules']);
|
||||||
|
$services[$service['id']]['name'] = $service['name'];
|
||||||
|
$services[$service['id']]['id'] = $service['id'];
|
||||||
|
$services[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
hd("STATS:::::::::::::::::::::::::::::: ", true);
|
||||||
|
hd($services, true);
|
||||||
|
|
||||||
|
return $services;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFirstLevelFields() {
|
||||||
|
$fields = array();
|
||||||
|
|
||||||
|
return implode(",", array_merge($fields, $this->L1extraFields));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSecondLevel() {
|
||||||
|
$data = array();
|
||||||
|
$data_agents = array();
|
||||||
|
$data_modules = array();
|
||||||
|
$data_services = array();
|
||||||
|
|
||||||
|
$sql = $this->getSecondLevelSql();
|
||||||
|
$data_agents = db_process_sql($sql);
|
||||||
|
|
||||||
|
if (empty($data_agents))
|
||||||
|
$data_agents = array();
|
||||||
|
|
||||||
|
$this->processAgents($data_agents);
|
||||||
|
|
||||||
|
foreach ($data_agents as $key => $agent) {
|
||||||
|
$data_agents[$key]['showEventsBtn'] = 1;
|
||||||
|
$data_agents[$key]['eventAgent'] = $agent['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = $this->getSecondLevelModulesSql();
|
||||||
|
$data_modules = db_process_sql($sql);
|
||||||
|
|
||||||
|
if (empty($data_modules))
|
||||||
|
$data_modules = array();
|
||||||
|
else {
|
||||||
|
foreach ($data_modules as $key => $module) {
|
||||||
|
switch ($module['estado']) {
|
||||||
|
case '0':
|
||||||
|
$data_modules[$key]['statusImageHTML'] = '<img src="http://localhost/pandora_console/images/status_sets/default/agent_ok_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
$data_modules[$key]['statusImageHTML'] = '<img src="http://localhost/pandora_console/images/status_sets/default/agent_critical_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$data_modules[$key]['statusImageHTML'] = '<img src="http://localhost/pandora_console/images/status_sets/default/agent_warning_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
$data_modules[$key]['statusImageHTML'] = '<img src="http://localhost/pandora_console/images/status_sets/default/agent_no_data_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
# code...
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_modules[$key]['showEventsBtn'] = 1;
|
||||||
|
$data_modules[$key]['eventModule'] = $module['id_agente_modulo'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hd("MODULESSSS::", true);
|
||||||
|
hd($data_modules, true);
|
||||||
|
|
||||||
|
$sql = $this->getSecondLevelServicesSql();
|
||||||
|
$data_services = db_process_sql($sql);
|
||||||
|
|
||||||
|
|
||||||
|
$service_stats = array();
|
||||||
|
|
||||||
|
foreach ($data_services as $service) {
|
||||||
|
$service_stats[$service['id']]['id'] = (int)$service['id'];
|
||||||
|
$service_stats[$service['id']]['name'] = $service['name'];
|
||||||
|
$service_stats[$service['id']]['alias'] = $service['name'];
|
||||||
|
if ($service['total_services']+$service['total_agents']+$service['total_modules'] > 0)
|
||||||
|
$service_stats[$service['id']]['searchChildren'] = 1;
|
||||||
|
else
|
||||||
|
$services[$service['id']]['searchChildren'] = 0;
|
||||||
|
|
||||||
|
$service_stats[$service['id']]['rootID'] = $service['rootID'];
|
||||||
|
$service_stats[$service['id']]['rootType'] = $service['rootType'];
|
||||||
|
$service_stats[$service['id']]['type'] = 'services';
|
||||||
|
$service_stats[$service['id']]['children']=array();
|
||||||
|
$service_stats[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id'];
|
||||||
|
$service_stats[$service['id']]['counters']=array('total_services'=>$service['total_services'], 'total_agents'=>$service['total_agents'], 'total_modules'=>$service['total_modules']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$own_info = get_user_info($config['id_user']);
|
||||||
|
|
||||||
|
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||||
|
$display_all_services = true;
|
||||||
|
} else {
|
||||||
|
$display_all_services = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$services = services_get_services($filter, false, $display_all_services);
|
||||||
|
|
||||||
|
foreach ($services as $row) {
|
||||||
|
|
||||||
|
if (!array_key_exists($row['id'], $service_stats))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$status = services_get_status($row, true);
|
||||||
|
|
||||||
|
|
||||||
|
switch ($status) {
|
||||||
|
|
||||||
|
case SERVICE_STATUS_NORMAL:
|
||||||
|
$service_stats[$row['id']]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_ok_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVICE_STATUS_CRITICAL:
|
||||||
|
$service_stats[$row['id']]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_critical_ball.png" data-title="CRITICAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVICE_STATUS_WARNING:
|
||||||
|
$service_stats[$row['id']][$key]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_warning_ball.png" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVICE_STATUS_UNKNOWN:
|
||||||
|
default:
|
||||||
|
$service_stats[$row['id']]['statusImageHTML']='<img src="http://localhost/pandora_console/images/status_sets/default/agent_no_data_ball.png" data-title="UNKNOWN status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_services = array_values($service_stats);
|
||||||
|
|
||||||
|
$data = array_merge($data_services, $data_agents, $data_modules);
|
||||||
|
|
||||||
|
if (empty($data)) {
|
||||||
|
$this->tree = array();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tree = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSecondLevelServicesSql() {
|
||||||
|
$group_acl = $this->getGroupAclCondition();
|
||||||
|
|
||||||
|
$sql = "SELECT ts.id, ts.name, tse1.id_service AS `rootID`, 'services' AS rootType, 'services' AS type, 0 AS quiet, SUM(if((tse2.id_agent<>0), 1, 0)) AS `total_agents`, SUM(if((tse2.id_agente_modulo<>0), 1, 0)) AS `total_modules`, SUM(if((tse2.id_service_child<>0), 1, 0)) AS `total_services`, 0 AS fired_count, 0 AS normal_count, 0 AS warning_count, 0 AS critical_count, 0 AS unknown_count, 0 AS notinit_count, 0 AS state_critical, 0 AS state_warning, 0 AS state_unknown, 0 AS state_notinit, 0 AS state_normal, 0 AS state_total, '' AS statusImageHTML, '' AS alertImageHTML
|
||||||
|
FROM tservice_element tse1
|
||||||
|
LEFT JOIN tservice_element tse2 ON tse1.id_service_child=tse2.id_service
|
||||||
|
LEFT JOIN tservice ts ON tse1.id_service_child=ts.id
|
||||||
|
WHERE tse1.id_service=$this->id AND tse1.id_service_child<>0
|
||||||
|
GROUP BY tse1.id_service_child
|
||||||
|
";
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getSecondLevelModulesSql() {
|
||||||
|
|
||||||
|
$sql = "SELECT tse.id_agente_modulo, nombre AS `name`, nombre AS `alias`, tse.id_service AS `rootID`, 'services' AS `rootType`, 'modules' AS `type`, estado
|
||||||
|
FROM tservice_element tse
|
||||||
|
INNER JOIN tagente_modulo tam ON tse.id_agente_modulo=tam.id_agente_modulo
|
||||||
|
INNER JOIN tagente_estado tae ON tam.id_agente_modulo=tae.id_agente_estado
|
||||||
|
WHERE tse.id_service=$this->id AND tse.id_agente_modulo<>0
|
||||||
|
";
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getAgentStatusFilter ($status = self::TV_DEFAULT_AGENT_STATUS) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -21,8 +21,8 @@ Description: The default Pandora FMS theme layout
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Tree view styles */
|
/* Tree view styles */
|
||||||
/*@import url(tree.css);
|
@import url(tree.css);
|
||||||
@import url(fixed-bottom-box.css);*/
|
@import url(fixed-bottom-box.css);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ---------------------------------------------------------------------
|
* ---------------------------------------------------------------------
|
||||||
|
@ -314,6 +314,7 @@ if ($id_agent != 0) {
|
|||||||
|
|
||||||
$text_module = (string) get_parameter('module_search', '');
|
$text_module = (string) get_parameter('module_search', '');
|
||||||
$id_agent_module = get_parameter('module_search_hidden', get_parameter('id_agent_module', 0));
|
$id_agent_module = get_parameter('module_search_hidden', get_parameter('id_agent_module', 0));
|
||||||
|
hd("------------------------------------>>>>>>> ".$id_agent_module." y id_agent: ".$id_agent, true);
|
||||||
if ($id_agent_module != 0) {
|
if ($id_agent_module != 0) {
|
||||||
$text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module);
|
$text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module);
|
||||||
if ($text_module == false) {
|
if ($text_module == false) {
|
||||||
|
@ -278,226 +278,228 @@ enterprise_hook('close_meta_frame');
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var treeController = TreeController.getController();
|
var treeController = TreeController.getController();
|
||||||
|
|
||||||
processTreeSearch();
|
processTreeSearch();
|
||||||
|
|
||||||
$("form#tree_search").submit(function(e) {
|
$("form#tree_search").submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
processTreeSearch();
|
processTreeSearch();
|
||||||
});
|
});
|
||||||
|
|
||||||
function processTreeSearch () {
|
function processTreeSearch () {
|
||||||
// Clear the tree
|
// Clear the tree
|
||||||
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)
|
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)
|
||||||
treeController.recipient.empty();
|
treeController.recipient.empty();
|
||||||
|
|
||||||
$(".loading_tree").show();
|
$(".loading_tree").show();
|
||||||
|
|
||||||
var parameters = {};
|
|
||||||
parameters['page'] = "include/ajax/tree.ajax";
|
|
||||||
parameters['getChildren'] = 1;
|
|
||||||
parameters['type'] = "<?php echo $tab; ?>";
|
|
||||||
parameters['filter'] = {};
|
|
||||||
parameters['filter']['searchGroup'] = $("input#text-search_group").val();
|
|
||||||
parameters['filter']['searchAgent'] = $("input#text-search_agent").val();
|
|
||||||
parameters['filter']['statusAgent'] = $("select#status_agent").val();
|
|
||||||
parameters['filter']['searchModule'] = $("input#text-search_module").val();
|
|
||||||
parameters['filter']['statusModule'] = $("select#status_module").val();
|
|
||||||
parameters['filter']['groupID'] = $("input#hidden-group-id").val();
|
|
||||||
parameters['filter']['tagID'] = $("input#hidden-tag-id").val();
|
|
||||||
|
|
||||||
if($("#checkbox-serach_hirearchy").is(':checked')){
|
|
||||||
parameters['filter']['searchHirearchy'] = 1;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
parameters['filter']['searchHirearchy'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($("#checkbox-show_not_init_agents").is(':checked')){
|
|
||||||
parameters['filter']['show_not_init_agents'] = 1;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
parameters['filter']['show_not_init_agents'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($("#checkbox-show_not_init_modules").is(':checked')){
|
|
||||||
parameters['filter']['show_not_init_modules'] = 1;
|
|
||||||
$('#hidden-show_not_init_modules_hidden').val(1);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
parameters['filter']['show_not_init_modules'] = 0;
|
|
||||||
$('#hidden-show_not_init_modules_hidden').val(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
var parameters = {};
|
||||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
parameters['page'] = "include/ajax/tree.ajax";
|
||||||
data: parameters,
|
parameters['getChildren'] = 1;
|
||||||
success: function(data) {
|
parameters['type'] = "<?php echo $tab; ?>";
|
||||||
if (data.success) {
|
parameters['filter'] = {};
|
||||||
$(".loading_tree").hide();
|
parameters['filter']['searchGroup'] = $("input#text-search_group").val();
|
||||||
|
parameters['filter']['searchAgent'] = $("input#text-search_agent").val();
|
||||||
treeController.init({
|
parameters['filter']['statusAgent'] = $("select#status_agent").val();
|
||||||
recipient: $("div#tree-controller-recipient"),
|
parameters['filter']['searchModule'] = $("input#text-search_module").val();
|
||||||
detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }),
|
parameters['filter']['statusModule'] = $("select#status_module").val();
|
||||||
page: parameters['page'],
|
parameters['filter']['groupID'] = $("input#hidden-group-id").val();
|
||||||
emptyMessage: "<?php echo __('No data found'); ?>",
|
parameters['filter']['tagID'] = $("input#hidden-tag-id").val();
|
||||||
foundMessage: "<?php echo __('Found groups'); ?>",
|
|
||||||
tree: data.tree,
|
if($("#checkbox-serach_hirearchy").is(':checked')){
|
||||||
baseURL: "<?php echo ui_get_full_url(false, false, false, is_metaconsole()); ?>",
|
parameters['filter']['searchHirearchy'] = 1;
|
||||||
ajaxURL: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
}
|
||||||
filter: parameters['filter'],
|
else{
|
||||||
counterTitles: {
|
parameters['filter']['searchHirearchy'] = 0;
|
||||||
total: {
|
}
|
||||||
agents: "<?php echo __('Total agents'); ?>",
|
|
||||||
modules: "<?php echo __('Total modules'); ?>",
|
if($("#checkbox-show_not_init_agents").is(':checked')){
|
||||||
none: "<?php echo __('Total'); ?>"
|
parameters['filter']['show_not_init_agents'] = 1;
|
||||||
},
|
}
|
||||||
alerts: {
|
else{
|
||||||
agents: "<?php echo __('Fired alerts'); ?>",
|
parameters['filter']['show_not_init_agents'] = 0;
|
||||||
modules: "<?php echo __('Fired alerts'); ?>",
|
}
|
||||||
none: "<?php echo __('Fired alerts'); ?>"
|
|
||||||
},
|
if($("#checkbox-show_not_init_modules").is(':checked')){
|
||||||
critical: {
|
parameters['filter']['show_not_init_modules'] = 1;
|
||||||
agents: "<?php echo __('Critical agents'); ?>",
|
$('#hidden-show_not_init_modules_hidden').val(1);
|
||||||
modules: "<?php echo __('Critical modules'); ?>",
|
}
|
||||||
none: "<?php echo __('Critical'); ?>"
|
else{
|
||||||
},
|
parameters['filter']['show_not_init_modules'] = 0;
|
||||||
warning: {
|
$('#hidden-show_not_init_modules_hidden').val(0);
|
||||||
agents: "<?php echo __('Warning agents'); ?>",
|
}
|
||||||
modules: "<?php echo __('Warning modules'); ?>",
|
|
||||||
none: "<?php echo __('Warning'); ?>"
|
$.ajax({
|
||||||
},
|
type: "POST",
|
||||||
unknown: {
|
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
agents: "<?php echo __('Unknown agents'); ?>",
|
data: parameters,
|
||||||
modules: "<?php echo __('Unknown modules'); ?>",
|
success: function(data) {
|
||||||
none: "<?php echo __('Unknown'); ?>"
|
if (data.success) {
|
||||||
},
|
$(".loading_tree").hide();
|
||||||
not_init: {
|
|
||||||
agents: "<?php echo __('Not init agents'); ?>",
|
treeController.init({
|
||||||
modules: "<?php echo __('Not init modules'); ?>",
|
recipient: $("div#tree-controller-recipient"),
|
||||||
none: "<?php echo __('Not init'); ?>"
|
detailRecipient: $.fixedBottomBox({ width: 400, height: window.innerHeight * 0.9 }),
|
||||||
},
|
page: parameters['page'],
|
||||||
ok: {
|
emptyMessage: "<?php echo __('No data found'); ?>",
|
||||||
agents: "<?php echo __('Normal agents'); ?>",
|
foundMessage: "<?php echo __('Found groups'); ?>",
|
||||||
modules: "<?php echo __('Normal modules'); ?>",
|
tree: data.tree,
|
||||||
none: "<?php echo __('Normal'); ?>"
|
baseURL: "<?php echo ui_get_full_url(false, false, false, is_metaconsole()); ?>",
|
||||||
}
|
ajaxURL: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
}
|
filter: parameters['filter'],
|
||||||
});
|
counterTitles: {
|
||||||
}
|
total: {
|
||||||
},
|
agents: "<?php echo __('Total agents'); ?>",
|
||||||
dataType: "json"
|
modules: "<?php echo __('Total modules'); ?>",
|
||||||
});
|
none: "<?php echo __('Total'); ?>"
|
||||||
}
|
},
|
||||||
|
alerts: {
|
||||||
// Show the modal window of an module
|
agents: "<?php echo __('Fired alerts'); ?>",
|
||||||
var moduleDetailsWindow = $("<div></div>");
|
modules: "<?php echo __('Fired alerts'); ?>",
|
||||||
moduleDetailsWindow
|
none: "<?php echo __('Fired alerts'); ?>"
|
||||||
.hide()
|
},
|
||||||
.prop("id", "module_details_window")
|
critical: {
|
||||||
.appendTo('body');
|
agents: "<?php echo __('Critical agents'); ?>",
|
||||||
|
modules: "<?php echo __('Critical modules'); ?>",
|
||||||
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period, module_name) {
|
none: "<?php echo __('Critical'); ?>"
|
||||||
var params = {};
|
},
|
||||||
var f = new Date();
|
warning: {
|
||||||
period = $('#period').val();
|
agents: "<?php echo __('Warning agents'); ?>",
|
||||||
|
modules: "<?php echo __('Warning modules'); ?>",
|
||||||
params.selection_mode = $('input[name=selection_mode]:checked').val();
|
none: "<?php echo __('Warning'); ?>"
|
||||||
if (!params.selection_mode) {
|
},
|
||||||
params.selection_mode='fromnow';
|
unknown: {
|
||||||
}
|
agents: "<?php echo __('Unknown agents'); ?>",
|
||||||
|
modules: "<?php echo __('Unknown modules'); ?>",
|
||||||
params.date_from = $('#text-date_from').val();
|
none: "<?php echo __('Unknown'); ?>"
|
||||||
if (!params.date_from) {
|
},
|
||||||
params.date_from = f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate();
|
not_init: {
|
||||||
}
|
agents: "<?php echo __('Not init agents'); ?>",
|
||||||
|
modules: "<?php echo __('Not init modules'); ?>",
|
||||||
params.time_from = $('#text-time_from').val();
|
none: "<?php echo __('Not init'); ?>"
|
||||||
if (!params.time_from) {
|
},
|
||||||
params.time_from = f.getHours() + ":" + f.getMinutes();
|
ok: {
|
||||||
}
|
agents: "<?php echo __('Normal agents'); ?>",
|
||||||
|
modules: "<?php echo __('Normal modules'); ?>",
|
||||||
params.date_to = $('#text-date_to').val();
|
none: "<?php echo __('Normal'); ?>"
|
||||||
if (!params.date_to) {
|
}
|
||||||
params.date_to =f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate();
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
params.time_to = $('#text-time_to').val();
|
},
|
||||||
if (!params.time_to) {
|
dataType: "json"
|
||||||
params.time_to = f.getHours() + ":" + f.getMinutes();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
params.page = "include/ajax/module";
|
// Show the modal window of an module
|
||||||
params.get_module_detail = 1;
|
var moduleDetailsWindow = $("<div></div>");
|
||||||
params.server_name = server_name;
|
moduleDetailsWindow
|
||||||
params.id_agent = id_agent;
|
.hide()
|
||||||
params.id_module = module_id;
|
.prop("id", "module_details_window")
|
||||||
params.offset = offset;
|
.appendTo('body');
|
||||||
params.period = period;
|
|
||||||
title = <?php echo "'".__('Module: ')."'"; ?> ;
|
function show_module_detail_dialog(module_id, id_agent, server_name, offset, period, module_name) {
|
||||||
$.ajax({
|
var params = {};
|
||||||
type: "POST",
|
var f = new Date();
|
||||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
period = $('#period').val();
|
||||||
data: params,
|
|
||||||
dataType: "html",
|
params.selection_mode = $('input[name=selection_mode]:checked').val();
|
||||||
success: function(data) {
|
if (!params.selection_mode) {
|
||||||
$("#module_details_window").hide ()
|
params.selection_mode='fromnow';
|
||||||
.empty ()
|
}
|
||||||
.append (data)
|
|
||||||
.dialog ({
|
params.date_from = $('#text-date_from').val();
|
||||||
resizable: true,
|
if (!params.date_from) {
|
||||||
draggable: true,
|
params.date_from = f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate();
|
||||||
modal: true,
|
}
|
||||||
title: title + module_name,
|
|
||||||
overlay: {
|
params.time_from = $('#text-time_from').val();
|
||||||
opacity: 0.5,
|
if (!params.time_from) {
|
||||||
background: "black"
|
params.time_from = f.getHours() + ":" + f.getMinutes();
|
||||||
},
|
}
|
||||||
width: 650,
|
|
||||||
height: 500
|
params.date_to = $('#text-date_to').val();
|
||||||
})
|
if (!params.date_to) {
|
||||||
.show ();
|
params.date_to =f.getFullYear() + "/" + (f.getMonth() +1) + "/" + f.getDate();
|
||||||
refresh_pagination_callback(module_id, id_agent, server_name, module_name);
|
}
|
||||||
datetime_picker_callback();
|
|
||||||
forced_title_callback();
|
params.time_to = $('#text-time_to').val();
|
||||||
}
|
if (!params.time_to) {
|
||||||
});
|
params.time_to = f.getHours() + ":" + f.getMinutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
function datetime_picker_callback() {
|
params.page = "include/ajax/module";
|
||||||
$("#text-time_from, #text-time_to").timepicker({
|
params.get_module_detail = 1;
|
||||||
showSecond: true,
|
params.server_name = server_name;
|
||||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
params.id_agent = id_agent;
|
||||||
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
|
params.id_module = module_id;
|
||||||
timeText: '<?php echo __('Time'); ?>',
|
params.offset = offset;
|
||||||
hourText: '<?php echo __('Hour'); ?>',
|
params.period = period;
|
||||||
minuteText: '<?php echo __('Minute'); ?>',
|
title = <?php echo "'" . __("Module: ") . "'" ?> ;
|
||||||
secondText: '<?php echo __('Second'); ?>',
|
$.ajax({
|
||||||
currentText: '<?php echo __('Now'); ?>',
|
type: "POST",
|
||||||
closeText: '<?php echo __('Close'); ?>'});
|
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
|
data: params,
|
||||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
dataType: "html",
|
||||||
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
success: function(data) {
|
||||||
|
$("#module_details_window").hide ()
|
||||||
}
|
.empty ()
|
||||||
|
.append (data)
|
||||||
function refresh_pagination_callback (module_id, id_agent, server_name,module_name) {
|
.dialog ({
|
||||||
|
resizable: true,
|
||||||
$(".binary_dialog").click( function() {
|
draggable: true,
|
||||||
|
modal: true,
|
||||||
var classes = $(this).attr('class');
|
title: title + module_name,
|
||||||
classes = classes.split(' ');
|
overlay: {
|
||||||
var offset_class = classes[2];
|
opacity: 0.5,
|
||||||
offset_class = offset_class.split('_');
|
background: "black"
|
||||||
var offset = offset_class[1];
|
},
|
||||||
|
width: 650,
|
||||||
var period = $('#period').val();
|
height: 500
|
||||||
|
})
|
||||||
show_module_detail_dialog(module_id, id_agent, server_name, offset, period,module_name);
|
.show ();
|
||||||
return false;
|
refresh_pagination_callback(module_id, id_agent, server_name, module_name);
|
||||||
});
|
datetime_picker_callback();
|
||||||
}
|
forced_title_callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function datetime_picker_callback() {
|
||||||
|
$("#text-time_from, #text-time_to").timepicker({
|
||||||
|
showSecond: true,
|
||||||
|
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||||
|
timeOnlyTitle: '<?php echo __('Choose time');?>',
|
||||||
|
timeText: '<?php echo __('Time');?>',
|
||||||
|
hourText: '<?php echo __('Hour');?>',
|
||||||
|
minuteText: '<?php echo __('Minute');?>',
|
||||||
|
secondText: '<?php echo __('Second');?>',
|
||||||
|
currentText: '<?php echo __('Now');?>',
|
||||||
|
closeText: '<?php echo __('Close');?>'});
|
||||||
|
|
||||||
|
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||||
|
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh_pagination_callback (module_id, id_agent, server_name,module_name) {
|
||||||
|
|
||||||
|
$(".binary_dialog").click( function() {
|
||||||
|
|
||||||
|
var classes = $(this).attr('class');
|
||||||
|
classes = classes.split(' ');
|
||||||
|
var offset_class = classes[2];
|
||||||
|
offset_class = offset_class.split('_');
|
||||||
|
var offset = offset_class[1];
|
||||||
|
|
||||||
|
var period = $('#period').val();
|
||||||
|
|
||||||
|
show_module_detail_dialog(module_id, id_agent, server_name, offset, period,module_name);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user