Skip to content

Commit

Permalink
Uploaded lost changes from the last day
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtrooper committed Dec 19, 2014
1 parent 149a510 commit 432d966
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pandora_console/include/ajax/tree.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$id = (int)get_parameter('id', 0);
$childrenMethod = get_parameter('childrenMethod', 'on_demand');
$countModuleStatusMethod = get_parameter('countModuleStatusMethod', 'on_demand');
$countAgentStatusMethod = get_parameter('countAgentStatusMethod', 'on_demand');
$countAgentStatusMethod = get_parameter('countAgentStatusMethod', 'live');

$tree = new Tree($type,
$id,
Expand Down
81 changes: 52 additions & 29 deletions pandora_console/include/class/Tree.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,52 +92,52 @@ private function getRecursiveGroup($parent, $limit = null) {


foreach ($groups as $iterator => $group) {
$data = reporting_get_group_stats($group['id_grupo']);

$groups[$iterator]['counters'] = array();
$groups[$iterator]['counters']['ok'] =
groups_monitor_ok(array($group['id_grupo']));
$groups[$iterator]['counters']['critical'] =
groups_monitor_critical(array($group['id_grupo']));
$groups[$iterator]['counters']['warning'] =
groups_monitor_warning(array($group['id_grupo']));
$groups[$iterator]['counters']['unknown'] =
groups_monitor_unknown(array($group['id_grupo']));
$groups[$iterator]['counters']['not_init'] =
groups_monitor_not_init(array($group['id_grupo']));

$groups[$iterator]['counters']['unknown'] = $data['agents_unknown'];
$groups[$iterator]['counters']['critical'] = $data['agent_critical'];
$groups[$iterator]['counters']['warning'] = $data['agent_warning'];
$groups[$iterator]['counters']['not_init'] = $data['agent_not_init'];
$groups[$iterator]['counters']['ok'] = $data['agent_ok'];
$groups[$iterator]['counters']['total'] = $data['total_agents'];
$groups[$iterator]['status'] = $data['status'];




if ($filter_status != AGENT_STATUS_ALL) {
$remove_group = true;
switch ($filter_status) {
case AGENT_STATUS_NORMAL:
if (($count_critical == 0) &&
($count_warning == 0) &&
($count_unknown == 0) &&
($count_not_init == 0)) {

if ($groups[$iterator]['status'] === "ok")
$remove_group = false;
}
break;
case AGENT_STATUS_WARNING:
if ($count_warning > 0)
if ($groups[$iterator]['status'] === "warning")
$remove_group = false;
break;
case AGENT_STATUS_CRITICAL:
if ($count_critical > 0)
if ($groups[$iterator]['status'] === "critical")
$remove_group = false;
break;
case AGENT_STATUS_UNKNOWN:
if ($count_unknown > 0)
if ($groups[$iterator]['status'] === "unknown")
$remove_group = false;
break;
case AGENT_STATUS_NOT_INIT:
if ($count_not_init > 0)
if ($groups[$iterator]['status'] === "not_init")
$remove_group = false;
break;
}

if ($remove_group)
if ($remove_group) {
unset($groups[$iterator]);
continue;
}
}

if (is_null($limit)) {
$groups[$iterator]['children'] =
$this->getRecursiveGroup($group['id_grupo']);
Expand All @@ -148,6 +148,10 @@ private function getRecursiveGroup($parent, $limit = null) {
$group['id_grupo'],
($limit - 1));
}

$groups[$iterator]['type'] = 'group';
$groups[$iterator]['name'] = $groups[$iterator]['nombre'];
$groups[$iterator]['id'] = $groups[$iterator]['id_grupo'];
}

if ($parent == 0) {
Expand All @@ -172,18 +176,35 @@ public function getDataGroup() {
}

$data = $this->getRecursiveGroup($parent, 1);
switch ($this->childrenMethod) {
case 'on_demand':
foreach ($data as $iterator => $item) {

// Make the data
$this->tree = array();
foreach ($data as $item) {
$temp = array();
$temp['id'] = $item['id'];
$temp['type'] = $item['type'];
$temp['name'] = $item['name'];
$temp['status'] = $item['status'];
switch ($this->countAgentStatusMethod) {
case 'on_demand':
$temp['searchCounters'] = 1;
break;
case 'live':
$temp['searchCounters'] = 0;
$temp['counters'] = $item['counters'];
break;
}
switch ($this->childrenMethod) {
case 'on_demand':
if (!empty($item['children'])) {
$data[$iterator]['searchChildren'] = 1;
$temp['searchChildren'] = 1;
// I hate myself
unset($data[$iterator]['children']);
// No add children
}
else {
$data[$iterator]['searchChildren'] = 0;
$temp['searchChildren'] = 0;
// I hate myself
unset($data[$iterator]['children']);
// No add children
}
break;
case 'live':
Expand Down Expand Up @@ -213,6 +234,8 @@ public function getDataAgents($type, $id) {

foreach ($agents as $iterator => $agent) {
$agents[$iterator]['type'] = 'agent';
$agents[$iterator]['id'] = $agents[$iterator]['id_agente'];
$agents[$iterator]['name'] = $agents[$iterator]['nombre'];
}

return $agents;
Expand Down

0 comments on commit 432d966

Please sign in to comment.