Changes and fixes
This commit is contained in:
parent
606d2128ce
commit
a9eb533a9b
|
@ -68,7 +68,6 @@ class Tree {
|
||||||
private function getRecursiveGroup($parent, $limit = null) {
|
private function getRecursiveGroup($parent, $limit = null) {
|
||||||
$filter = array();
|
$filter = array();
|
||||||
|
|
||||||
|
|
||||||
$filter['parent'] = $parent;
|
$filter['parent'] = $parent;
|
||||||
|
|
||||||
if (!empty($this->filter['search'])) {
|
if (!empty($this->filter['search'])) {
|
||||||
|
@ -82,30 +81,28 @@ class Tree {
|
||||||
if (empty($groups))
|
if (empty($groups))
|
||||||
$groups = array();
|
$groups = array();
|
||||||
|
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
$status = AGENT_STATUS_ALL;
|
$filter_status = AGENT_STATUS_ALL;
|
||||||
if (!empty($this->filter['status'])) {
|
if (!empty($this->filter['status'])) {
|
||||||
$status = $this->filter['status'];
|
$filter_status = $this->filter['status'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($groups as $iterator => $group) {
|
||||||
|
$groups[$iterator]['counters'] = array();
|
||||||
if ($status != AGENT_STATUS_ALL) {
|
$groups[$iterator]['counters']['ok'] =
|
||||||
foreach ($groups as $iterator => $group) {
|
groups_monitor_ok(array($group['id_grupo']));
|
||||||
$groups[$iterator]['count_ok'] =
|
$groups[$iterator]['counters']['critical'] =
|
||||||
groups_monitor_ok(array($group['id_grupo']));
|
groups_monitor_critical(array($group['id_grupo']));
|
||||||
$groups[$iterator]['count_critical'] =
|
$groups[$iterator]['counters']['warning'] =
|
||||||
groups_monitor_critical(array($group['id_grupo']));
|
groups_monitor_warning(array($group['id_grupo']));
|
||||||
$groups[$iterator]['count_warning'] =
|
$groups[$iterator]['counters']['unknown'] =
|
||||||
groups_monitor_warning(array($group['id_grupo']));
|
groups_monitor_unknown(array($group['id_grupo']));
|
||||||
$groups[$iterator]['count_unknown'] =
|
$groups[$iterator]['counters']['not_init'] =
|
||||||
groups_monitor_unknown(array($group['id_grupo']));
|
groups_monitor_not_init(array($group['id_grupo']));
|
||||||
$groups[$iterator]['count_not_init'] =
|
|
||||||
groups_monitor_not_init(array($group['id_grupo']));
|
if ($filter_status != AGENT_STATUS_ALL) {
|
||||||
|
|
||||||
$remove_group = true;
|
$remove_group = true;
|
||||||
switch ($status) {
|
switch ($filter_status) {
|
||||||
case AGENT_STATUS_NORMAL:
|
case AGENT_STATUS_NORMAL:
|
||||||
if (($count_critical == 0) &&
|
if (($count_critical == 0) &&
|
||||||
($count_warning == 0) &&
|
($count_warning == 0) &&
|
||||||
|
@ -132,38 +129,21 @@ class Tree {
|
||||||
$remove_group = false;
|
$remove_group = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($remove_group)
|
if ($remove_group)
|
||||||
unset($groups[$iterator]);
|
unset($groups[$iterator]);
|
||||||
else {
|
}
|
||||||
if (is_null($limit)) {
|
|
||||||
$groups[$iterator]['children'] =
|
if (is_null($limit)) {
|
||||||
$this->getRecursiveGroup($group['id_grupo']);
|
$groups[$iterator]['children'] =
|
||||||
}
|
$this->getRecursiveGroup($group['id_grupo']);
|
||||||
else if ($limit >= 1) {
|
}
|
||||||
$groups[$iterator]['children'] =
|
else if ($limit >= 1) {
|
||||||
$this->getRecursiveGroup(
|
$groups[$iterator]['children'] =
|
||||||
$group['id_grupo'],
|
$this->getRecursiveGroup(
|
||||||
($limit - 1));
|
$group['id_grupo'],
|
||||||
}
|
($limit - 1));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
foreach ($groups as $iterator => $group) {
|
|
||||||
if (is_null($limit)) {
|
|
||||||
$groups[$iterator]['children'] =
|
|
||||||
$this->getRecursiveGroup($group['id_grupo']);
|
|
||||||
}
|
|
||||||
else if ($limit >= 1) {
|
|
||||||
$groups[$iterator]['children'] =
|
|
||||||
$this->getRecursiveGroup(
|
|
||||||
$group['id_grupo'],
|
|
||||||
($limit - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $groups;
|
return $groups;
|
||||||
}
|
}
|
||||||
|
@ -177,9 +157,9 @@ class Tree {
|
||||||
$parent = 0;
|
$parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$groups = $this->getRecursiveGroup($parent, 1);
|
||||||
switch ($this->childrenMethod) {
|
switch ($this->childrenMethod) {
|
||||||
case 'on_demand':
|
case 'on_demand':
|
||||||
$groups = $this->getRecursiveGroup($parent, 1);
|
|
||||||
foreach ($groups as $iterator => $group) {
|
foreach ($groups as $iterator => $group) {
|
||||||
if (!empty($group['children'])) {
|
if (!empty($group['children'])) {
|
||||||
$groups[$iterator]['searchChildren'] = 1;
|
$groups[$iterator]['searchChildren'] = 1;
|
||||||
|
@ -198,14 +178,18 @@ class Tree {
|
||||||
|
|
||||||
switch ($this->countAgentStatusMethod) {
|
switch ($this->countAgentStatusMethod) {
|
||||||
case 'on_demand':
|
case 'on_demand':
|
||||||
// I hate myself
|
foreach ($groups as $iterator => $group) {
|
||||||
unset($groups[$iterator]['count_ok']);
|
if (!empty($group['counters'])) {
|
||||||
unset($groups[$iterator]['count_critical']);
|
$groups[$iterator]['searchCounters'] = 1;
|
||||||
unset($groups[$iterator]['count_warning']);
|
// I hate myself
|
||||||
unset($groups[$iterator]['count_unknown']);
|
unset($groups[$iterator]['counters']);
|
||||||
unset($groups[$iterator]['count_not_init']);
|
}
|
||||||
|
else {
|
||||||
$groups[$iterator]['count_agent_status_method'] = 'on_demand';
|
$groups[$iterator]['searchCounters'] = 0;
|
||||||
|
// I hate myself
|
||||||
|
unset($groups[$iterator]['counters']);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +201,7 @@ class Tree {
|
||||||
$data['type'] = 'group';
|
$data['type'] = 'group';
|
||||||
$data['name'] = $group['nombre'];
|
$data['name'] = $group['nombre'];
|
||||||
$data['searchChildren'] = $group['searchChildren'];
|
$data['searchChildren'] = $group['searchChildren'];
|
||||||
|
$data['searchCounters'] = $group['searchCounters'];
|
||||||
|
|
||||||
$this->tree[] = $data;
|
$this->tree[] = $data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue