mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
Merge branch 'ent-3210-Nueva-vista-de-servicios' into 'develop'
Ent 3210 nueva vista de servicios See merge request artica/pandorafms!2195 Former-commit-id: f29cb46b83ff0fde722f3c5e3eaf26aedf5cf327
This commit is contained in:
commit
441fb979e1
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,18 +3,21 @@
|
|||||||
// ==================================================
|
// ==================================================
|
||||||
// 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);
|
||||||
|
|
||||||
@ -25,29 +28,27 @@ if (is_ajax()) {
|
|||||||
} else {
|
} else {
|
||||||
$validate_hash = enterprise_hook(
|
$validate_hash = enterprise_hook(
|
||||||
'dasboard_validate_public_hash',
|
'dasboard_validate_public_hash',
|
||||||
[
|
array($public_hash, 'tree_view')
|
||||||
$public_hash,
|
|
||||||
'tree_view',
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) {
|
if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) {
|
||||||
db_pandora_audit('Invalid public hash', 'Trying to access report builder');
|
db_pandora_audit("Invalid public hash", "Trying to access report builder");
|
||||||
include 'general/noaccess.php';
|
require ("general/noaccess.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once $config['homedir'].'/include/class/Tree.class.php';
|
require_once($config['homedir'] . "/include/class/Tree.class.php");
|
||||||
include_once $config['homedir'].'/include/class/TreeOS.class.php';
|
require_once($config['homedir'] . "/include/class/TreeOS.class.php");
|
||||||
include_once $config['homedir'].'/include/class/TreeModuleGroup.class.php';
|
require_once($config['homedir'] . "/include/class/TreeModuleGroup.class.php");
|
||||||
include_once $config['homedir'].'/include/class/TreeModule.class.php';
|
require_once($config['homedir'] . "/include/class/TreeModule.class.php");
|
||||||
include_once $config['homedir'].'/include/class/TreeTag.class.php';
|
require_once($config['homedir'] . "/include/class/TreeTag.class.php");
|
||||||
include_once $config['homedir'].'/include/class/TreeGroup.class.php';
|
require_once($config['homedir'] . "/include/class/TreeGroup.class.php");
|
||||||
include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php';
|
require_once($config['homedir'] . "/include/class/TreeService.class.php");
|
||||||
enterprise_include_once('include/class/TreePolicies.class.php');
|
require_once($config['homedir'] . "/include/class/TreeGroupEdition.class.php");
|
||||||
enterprise_include_once('include/class/TreeGroupMeta.class.php');
|
enterprise_include_once("include/class/TreePolicies.class.php");
|
||||||
include_once $config['homedir'].'/include/functions_reporting.php';
|
enterprise_include_once("include/class/TreeGroupMeta.class.php");
|
||||||
include_once $config['homedir'].'/include/functions_os.php';
|
require_once($config['homedir'] . "/include/functions_reporting.php");
|
||||||
|
require_once($config['homedir'] . "/include/functions_os.php");
|
||||||
|
|
||||||
$getChildren = (bool) get_parameter('getChildren', 0);
|
$getChildren = (bool) get_parameter('getChildren', 0);
|
||||||
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
$getGroupStatus = (bool) get_parameter('getGroupStatus', 0);
|
||||||
@ -62,64 +63,55 @@ if (is_ajax()) {
|
|||||||
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
|
||||||
$hash = get_parameter('hash', false);
|
$hash = get_parameter('hash', false);
|
||||||
if ($hash !== false) {
|
if ($hash !== false) {
|
||||||
enterprise_hook('dasboard_validate_public_hash', [$hash, 'tree_view']);
|
enterprise_hook('dasboard_validate_public_hash', array($hash, 'tree_view'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$default_filters = [
|
$default_filters = array(
|
||||||
'searchAgent' => '',
|
'searchAgent' => '',
|
||||||
'statusAgent' => AGENT_STATUS_ALL,
|
'statusAgent' => AGENT_STATUS_ALL,
|
||||||
'searchModule' => '',
|
'searchModule' => '',
|
||||||
'statusModule' => -1,
|
'statusModule' => -1,
|
||||||
'groupID' => 0,
|
'groupID' => 0,
|
||||||
'tagID' => 0,
|
'tagID' => 0,
|
||||||
];
|
);
|
||||||
$filter = get_parameter('filter', $default_filters);
|
$filter = get_parameter('filter', $default_filters);
|
||||||
|
|
||||||
$agent_a = check_acl($config['id_user'], 0, 'AR');
|
$agent_a = check_acl ($config['id_user'], 0, "AR");
|
||||||
$agent_w = check_acl($config['id_user'], 0, 'AW');
|
$agent_w = check_acl ($config['id_user'], 0, "AW");
|
||||||
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
$access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
|
||||||
$switch_type = !empty($rootType) ? $rootType : $type;
|
$switch_type = !empty($rootType) ? $rootType : $type;
|
||||||
switch ($switch_type) {
|
switch ($switch_type) {
|
||||||
case 'os':
|
case 'os':
|
||||||
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'module_group':
|
case 'module_group':
|
||||||
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'module':
|
case 'module':
|
||||||
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tag':
|
case 'tag':
|
||||||
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'group':
|
case 'group':
|
||||||
if (is_metaconsole()) {
|
if(is_metaconsole()){
|
||||||
if (!class_exists('TreeGroupMeta')) {
|
if (!class_exists('TreeGroupMeta')) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'policies':
|
case 'policies':
|
||||||
if (!class_exists('TreePolicies')) {
|
if (!class_exists('TreePolicies')) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'group_edition':
|
case 'group_edition':
|
||||||
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
break;
|
break;
|
||||||
|
case 'services':
|
||||||
|
$tree = new TreeService($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// FIXME. No error handler
|
// FIXME. No error handler
|
||||||
return;
|
return;
|
||||||
@ -127,17 +119,18 @@ if (is_ajax()) {
|
|||||||
|
|
||||||
$tree->setFilter($filter);
|
$tree->setFilter($filter);
|
||||||
ob_clean();
|
ob_clean();
|
||||||
echo json_encode(['success' => 1, 'tree' => $tree->getArray()]);
|
|
||||||
|
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($getDetail) {
|
if ($getDetail) {
|
||||||
include_once $config['homedir'].'/include/functions_treeview.php';
|
require_once($config['homedir']."/include/functions_treeview.php");
|
||||||
|
|
||||||
$id = (int) get_parameter('id');
|
$id = (int) get_parameter('id');
|
||||||
$type = (string) get_parameter('type');
|
$type = (string) get_parameter('type');
|
||||||
|
|
||||||
$server = [];
|
$server = array();
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
$server_id = (int) get_parameter('serverID');
|
$server_id = (int) get_parameter('serverID');
|
||||||
$server = metaconsole_get_servers($server_id);
|
$server = metaconsole_get_servers($server_id);
|
||||||
@ -151,21 +144,17 @@ if (is_ajax()) {
|
|||||||
case 'agent':
|
case 'agent':
|
||||||
treeview_printTable($id, $server, true);
|
treeview_printTable($id, $server, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'module':
|
case 'module':
|
||||||
treeview_printModuleTable($id, $server, true);
|
treeview_printModuleTable($id, $server, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'alert':
|
case 'alert':
|
||||||
treeview_printAlertsTable($id, $server, true);
|
treeview_printAlertsTable($id, $server, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Nothing
|
// Nothing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<br></div>';
|
echo '<br></div>';
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -173,3 +162,4 @@ if (is_ajax()) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
?>
|
File diff suppressed because it is too large
Load Diff
334
pandora_console/include/class/TreeService.class.php
Normal file
334
pandora_console/include/class/TreeService.class.php
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
<?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="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="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="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="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();
|
||||||
|
|
||||||
|
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']='index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
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="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="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="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="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'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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']='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="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="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="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="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
@ -294,6 +294,8 @@ enterprise_hook('close_meta_frame');
|
|||||||
|
|
||||||
$(".loading_tree").show();
|
$(".loading_tree").show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var parameters = {};
|
var parameters = {};
|
||||||
parameters['page'] = "include/ajax/tree.ajax";
|
parameters['page'] = "include/ajax/tree.ajax";
|
||||||
parameters['getChildren'] = 1;
|
parameters['getChildren'] = 1;
|
||||||
@ -436,7 +438,7 @@ enterprise_hook('close_meta_frame');
|
|||||||
params.id_module = module_id;
|
params.id_module = module_id;
|
||||||
params.offset = offset;
|
params.offset = offset;
|
||||||
params.period = period;
|
params.period = period;
|
||||||
title = <?php echo "'".__('Module: ')."'"; ?> ;
|
title = <?php echo "'" . __("Module: ") . "'" ?> ;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
@ -470,13 +472,13 @@ enterprise_hook('close_meta_frame');
|
|||||||
$("#text-time_from, #text-time_to").timepicker({
|
$("#text-time_from, #text-time_to").timepicker({
|
||||||
showSecond: true,
|
showSecond: true,
|
||||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||||
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
|
timeOnlyTitle: '<?php echo __('Choose time');?>',
|
||||||
timeText: '<?php echo __('Time'); ?>',
|
timeText: '<?php echo __('Time');?>',
|
||||||
hourText: '<?php echo __('Hour'); ?>',
|
hourText: '<?php echo __('Hour');?>',
|
||||||
minuteText: '<?php echo __('Minute'); ?>',
|
minuteText: '<?php echo __('Minute');?>',
|
||||||
secondText: '<?php echo __('Second'); ?>',
|
secondText: '<?php echo __('Second');?>',
|
||||||
currentText: '<?php echo __('Now'); ?>',
|
currentText: '<?php echo __('Now');?>',
|
||||||
closeText: '<?php echo __('Close'); ?>'});
|
closeText: '<?php echo __('Close');?>'});
|
||||||
|
|
||||||
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
|
||||||
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user