Fixed the colors status.

This commit is contained in:
mdtrooper 2016-04-19 13:43:48 +02:00
parent 2da53b7b9e
commit dc3da8babe
1 changed files with 42 additions and 42 deletions

View File

@ -106,18 +106,18 @@ class Networkmap extends Map {
} }
} }
$chunks = explode("ajax.php?", $chunks[1]); $other_chunks = explode("ajax.php?", $chunks[1]);
$is_node_group = false; $is_node_group = false;
if ($this->subtype == MAP_SUBTYPE_GROUPS) { if ($this->subtype == MAP_SUBTYPE_GROUPS) {
if (strstr($chunks[1], "&id_group=") !== false) { if (strstr($other_chunks[1], "&id_group=") !== false) {
$is_node_group = true; $is_node_group = true;
} }
} }
$is_node_policy = false; $is_node_policy = false;
if ($this->subtype == MAP_SUBTYPE_POLICIES) { if ($this->subtype == MAP_SUBTYPE_POLICIES) {
if (strstr($chunks[1], "&id_policy=") !== false) { if (strstr($other_chunks[1], "&id_policy=") !== false) {
$is_node_policy = true; $is_node_policy = true;
} }
} }
@ -133,33 +133,33 @@ class Networkmap extends Map {
$image = DEFAULT_NODE_IMAGE; $image = DEFAULT_NODE_IMAGE;
if ($is_node_policy) { if ($is_node_policy) {
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches); preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $other_chunks[0], $matches);
$title = io_safe_output($matches[1]); $title = io_safe_output($matches[1]);
preg_match("/id_policy=([0-9]*)/", $chunks[1], $matches); preg_match("/id_policy=([0-9]*)/", $other_chunks[1], $matches);
$id = $matches[1]; $id = $matches[1];
$type = ITEM_TYPE_POLICY_NETWORKMAP; $type = ITEM_TYPE_POLICY_NETWORKMAP;
preg_match("/data-status=\"([0-9]*)\"/", $chunks[1], $matches); preg_match("/data-status=\"([0-9]*)\"/", $other_chunks[1], $matches);
$status = $matches[1]; $status = $matches[1];
$shape = "rhombus"; $shape = "rhombus";
preg_match("/<img src=\"(.*)\" \/>/", $chunks[0], $matches); preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
$image = $matches[1]; $image = $matches[1];
} }
elseif ($is_node_group) { elseif ($is_node_group) {
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches); preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $other_chunks[0], $matches);
$title = $matches[1]; $title = $matches[1];
preg_match("/id_group=([0-9]*)/", $chunks[1], $matches); preg_match("/id_group=([0-9]*)/", $other_chunks[1], $matches);
$id = $matches[1]; $id = $matches[1];
$type = ITEM_TYPE_GROUP_NETWORKMAP; $type = ITEM_TYPE_GROUP_NETWORKMAP;
preg_match("/data-status=\"([0-9]*)\"/", $chunks[1], $matches); preg_match("/data-status=\"([0-9]*)\"/", $other_chunks[1], $matches);
$status = $matches[1]; $status = $matches[1];
$shape = "rhombus"; $shape = "rhombus";
preg_match("/<img src=\"(.*)\" \/>/", $chunks[0], $matches); preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
$image = $matches[1]; $image = $matches[1];
} }
elseif ($is_node_module_group) { elseif ($is_node_module_group) {
preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches); preg_match("/<TR><TD>(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[1], $matches);
$title = $matches[1]; $title = $matches[1];
$id = db_get_value('id_mg', 'tmodule_group', $id = db_get_value('id_mg', 'tmodule_group',
'name', $title); 'name', $title);
@ -169,10 +169,11 @@ class Networkmap extends Map {
$shape = "rhombus"; $shape = "rhombus";
//The module group has not icon. //The module group has not icon.
$image = "";
} }
elseif (strstr($chunks[1], "&id_module=") !== false) { elseif (strstr($other_chunks[1], "&id_module=") !== false) {
// MODULE // MODULE
preg_match("/id_module=([0-9]*)/", $chunks[1], $matches); preg_match("/id_module=([0-9]*)/", $other_chunks[1], $matches);
$id = $matches[1]; $id = $matches[1];
$id_agent = agents_get_module_id($id); $id_agent = agents_get_module_id($id);
$status = modules_get_agentmodule_status($id); $status = modules_get_agentmodule_status($id);
@ -180,44 +181,43 @@ class Networkmap extends Map {
$type = ITEM_TYPE_MODULE_NETWORKMAP; $type = ITEM_TYPE_MODULE_NETWORKMAP;
$shape = "square"; $shape = "square";
preg_match("/<img src=\"(.*)\" \/>/", $chunks[0], $matches); preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
$image = $matches[1]; $image = $matches[1];
} }
else { else {
// AGENT // AGENT
preg_match("/id_agent=([0-9]*)/", $chunks[1], $matches); preg_match("/id_agent=([0-9]*)/", $other_chunks[1], $matches);
$id_agent = $id = $matches[1]; $id_agent = $id = $matches[1];
$status = agents_get_status($id); $status = agents_get_status($id);
$title = agents_get_name($id); $title = agents_get_name($id);
$type = ITEM_TYPE_AGENT_NETWORKMAP; $type = ITEM_TYPE_AGENT_NETWORKMAP;
preg_match("/<img src=\"(.*)\" \/>/", $chunks[0], $matches); preg_match("/<img src=\"(.*)\" \/>/", $other_chunks[0], $matches);
$image = $matches[1]; $image = $matches[1];
}
// Set node status // Set node status
switch ($status) { switch ($status) {
case AGENT_STATUS_NORMAL: case AGENT_STATUS_NORMAL:
$color = COL_NORMAL; $color = COL_NORMAL;
break; break;
case AGENT_STATUS_CRITICAL: case AGENT_STATUS_CRITICAL:
$color = COL_CRITICAL; $color = COL_CRITICAL;
break; break;
case AGENT_STATUS_WARNING: case AGENT_STATUS_WARNING:
$color = COL_WARNING; $color = COL_WARNING;
break; break;
case AGENT_STATUS_ALERT_FIRED: case AGENT_STATUS_ALERT_FIRED:
$color = COL_ALERTFIRED; $color = COL_ALERTFIRED;
break; break;
# Juanma (05/05/2014) Fix: Correct color for not init agents! # Juanma (05/05/2014) Fix: Correct color for not init agents!
case AGENT_STATUS_NOT_INIT: case AGENT_STATUS_NOT_INIT:
$color = COL_NOTINIT; $color = COL_NOTINIT;
break; break;
default: default:
//Unknown monitor //Unknown monitor
$color = COL_UNKNOWN; $color = COL_UNKNOWN;
break; break;
}
} }