";
if (empty($graph)) {
echo "var graph = null;\n";
return;
}
else {
echo "var graph = \n";
}
}
echo "{\n";
echo "'nodes' : \n";
echo "[\n";
$first = true;
foreach ($graph['nodes'] as $id => $node) {
if (!$first) {
echo ",\n";
}
$first = false;
echo "{
'id' : " . $id . ",
'name' : '" . $node['label'] . "',
'url' : '" . $node['url'] . "',
'tooltip' : '" . $node['tooltip'] . "',
'default_tooltip' : 1,
'tooltip_content' : ' " . html_print_image('images/spinner.gif',true) . "',
'color' : '" . $node['color'] . "'}\n";
}
echo "],\n";
echo "'links' : \n";
echo "[\n";
$first = true;
foreach ($graph['lines'] as $line) {
if (!$first) {
echo ",\n";
}
$first = false;
echo "{
'source' : " . $line['source'] . ",
'target' : " . $line['target'] . "}\n";
}
echo "]\n";
echo "}\n";
if ($js_tags) {
echo ";\n";
echo "";
}
}
function networkmap_generate_hash($pandora_name, $group = 0,
$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false, $text_filter = '') {
$graph = networkmap_generate_dot($pandora_name, $group,
$simple, $font_size, $layout, $nooverlap, $zoom, $ranksep,
$center, $regen, $pure, $id_networkmap, $show_snmp_modules,
$cut_names, $relative, $text_filter);
$return = array();
if (!empty($graph)) {
$graph = str_replace("\r", "\n", $graph);
$graph = str_replace("\n", " ", $graph);
//Removed the head
preg_match("/graph networkmap {(.*)}/", $graph, $matches);
$graph = $matches[1];
//Get the lines and nodes
$tokens = preg_split("/; /", $graph);
foreach ($tokens as $token) {
if (empty($token)) {
continue;
}
//Ignore the head rests.
if (preg_match("/(.+)\s*\[(.*)\]/", $token) != 0) {
$items[] = $token;
}
}
$lines = $nodes = array();
foreach ($items as $item) {
$matches = null;
preg_match("/(.+)\s*\[(.*)\]/", $item, $matches);
if (empty($matches))
continue;
$id_item = trim($matches[1]);
$content_item = trim($matches[2]);
//Check if is a edge or node
if (strstr($id_item, "--") !== false) {
//edge
$lines[$id_item] = $content_item;
}
else {
//node
$id_item = (int)$id_item;
$nodes[$id_item] = $content_item;
}
}
foreach($nodes as $key => $node) {
if ($key != 0) {
//Get label
$matches = null;
preg_match("/label=(.*),/", $node, $matches);
$label = $matches[1];
$matches = null;
preg_match("/\
\(.*?)\<\/TD\>\<\/TR\>/",
$label, $matches);
$label = $matches[1];
//Get color
$matches = null;
preg_match("/color=\"([^\"]*)/", $node, $matches);
$color = $matches[1];
//Get tooltip
$matches = null;
preg_match("/tooltip=\"([^\"]*)/", $node, $matches);
$tooltip = $matches[1];
//Get URL
$matches = null;
preg_match("/URL=\"([^\"]*)/", $node, $matches);
$url = $matches[1];
$return['nodes'][$key]['label'] = $label;
$return['nodes'][$key]['color'] = $color;
$return['nodes'][$key]['tooltip'] = $tooltip;
$return['nodes'][$key]['url'] = $url;
}
else {
//Get tooltip
$matches = null;
preg_match("/tooltip=\"([^\"]*)/", $node, $matches);
$tooltip = $matches[1];
//Get URL
$matches = null;
preg_match("/URL=\"([^\"]*)/", $node, $matches);
$url = $matches[1];
$return['nodes'][$key]['label'] = "Pandora FMS";
$return['nodes'][$key]['color'] = "#7EBE3F";
$return['nodes'][$key]['tooltip'] = $tooltip;
$return['nodes'][$key]['url'] = $url;
}
}
ksort($return['nodes']);
foreach($lines as $key => $line) {
$data = array();
$points = explode(' -- ', $key);
$data['source'] = (int) $points[0];
$data['target'] = (int) $points[1];
$return['lines'][] = $data;
}
}
return $return;
}
// Generate a dot graph definition for graphviz
function networkmap_generate_dot ($pandora_name, $group = 0,
$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false, $text_filter = '') {
global $config;
$parents = array();
$orphans = array();
$filter = array ();
$filter['disabled'] = 0;
if (!empty($text_filter)) {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$filter[] =
'(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")';
break;
case "oracle":
$filter[] =
'(upper(nombre) LIKE upper("%' . $text_filter . '%"))';
break;
}
}
if ($group >= 1) {
$filter['id_grupo'] = $group;
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente, normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count'));
}
else if ($group == -666) {
$agents = false;
}
else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count'));
}
if ($agents === false)
//return false;
$agents = array();
// Open Graph
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $font_size);
// Parse agents
$nodes = array ();
$node_count = 1;
// Add node
$node_ref = array();
foreach ($agents as $agent) {
// Add node
$node_ref[$agent['id_agente']] = $node_count;
$node_count++;
}
$node_count = 1;
foreach ($agents as $agent) {
// Save node parent information to define edges later
if ($agent['id_parent'] != "0" && array_key_exists($agent['id_parent'], $node_ref)) {
$parents[$node_count] = $node_ref[$agent['id_parent']];
}
else {
$orphans[$node_count] = 1;
}
$agent['id_node'] = $node_count;
$agent['type'] = 'agent';
// Add node
$nodes[$node_count] = $agent;
if ($show_snmp_modules) {
// Get agent modules data of snmp_proc type
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0, 'id_tipo_modulo' => 18), true, false);
// Parse modules
foreach ($modules as $key => $module) {
$node_count ++;
$agent_module = modules_get_agentmodule($key);
$alerts_module = db_get_sql('SELECT count(*) AS num
FROM talert_template_modules
WHERE id_agent_module = ' . $key);
// Save node parent information to define edges later
$parents[$node_count] = $agent_module['parent'] = $agent['id_node'];
$agent_module['id_node'] = $node_count;
$agent_module['type'] = 'module';
// Add node
$nodes[$node_count] = $agent_module;
}
}
$node_count++;
}
// Create void statistics array
$stats = array();
// Create nodes
foreach ($nodes as $node_id => $node) {
if ($center > 0 && ! networkmap_is_descendant ($node_id, $center, $parents)) {
unset ($parents[$node_id]);
unset ($orphans[$node_id]);
unset ($nodes[$node_id]);
continue;
}
switch ($node['type']) {
case 'agent':
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t";
$stats['agents'][] = $node['id_agente'];
break;
case 'module':
$graph .= networkmap_create_module_node ($node , $simple, $font_size)."\n\t\t";
$stats['modules'][] = $node['id_agente_modulo'];
break;
}
}
// Define edges
foreach ($parents as $node => $parent_id) {
// Verify that the parent is in the graph
if (isset ($nodes[$parent_id])) {
$graph .= networkmap_create_edge ($parent_id, $node , $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
}
else {
$orphans[$node] = 1;
}
}
// Create a central node if orphan nodes exist
if (count ($orphans) || empty ($nodes)) {
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats);
}
// Define edges for orphan nodes
foreach (array_keys($orphans) as $node) {
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
}
// Close graph
$graph .= networkmap_close_graph ();
return $graph;
}
// Generate a dot graph definition for graphviz with groups
function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0, $text_filter = '') {
global $config;
$parents = array();
$orphans = array();
$filter = array ();
$filter['disabled'] = 0;
if (!empty($text_filter)) {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$filter[] =
'(nombre COLLATE utf8_general_ci LIKE "%' . $text_filter . '%")';
break;
case "oracle":
$filter[] =
'(upper(nombre) LIKE upper("%' . $text_filter . '%"))';
break;
}
}
// Get groups data
if ($group > 0) {
$groups = array();
$id_groups = groups_get_id_recursive($group, true);
foreach($id_groups as $id_group) {
$add = false;
if (check_acl($config["id_user"], $id_group, 'AR')) {
$add = true;
}
if ($add) {
$groups[] = db_get_row ('tgrupo', 'id_grupo', $id_group);
}
}
$filter['id_grupo'] = $id_groups;
}
else {
$groups = db_get_all_rows_in_table ('tgrupo');
if ($groups === false) {
$groups = array();
}
}
// Open Graph
$graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $font_size);
$node_count = 0;
// Parse groups
$nodes = array ();
$nodes_groups = array();
foreach ($groups as $group2) {
$node_count ++;
$group2['type'] = 'group';
$group2['id_node'] = $node_count;
// Add node
$nodes_groups[$group2['id_grupo']] = $group2;
}
$node_count = 0;
$groups_hiden = array();
foreach ($nodes_groups as $node_group) {
$node_count++;
// Save node parent information to define edges later
if ($node_group['parent'] != "0" && $node_group['id_grupo'] != $group) {
if ((!$dont_show_subgroups) || ($group == 0)) {
$parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node'];
}
else {
$groups_hiden[$node_group['id_grupo']] = 1;
continue;
}
}
else {
$orphans[$node_count] = 1;
}
$nodes[$node_count] = $node_group;
}
if ($depth != 'group') {
// Get agents data
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_agente,
normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count'));
if ($agents === false)
$agents = array();
// Parse agents
$nodes_agents = array();
foreach ($agents as $agent) {
if ($dont_show_subgroups) {
if (!empty($groups_hiden[$agent['id_grupo']])) {
continue;
}
}
// If only agents with alerts => agents without alerts discarded
$alert_agent = agents_get_alerts($agent['id_agente']);
if ($modwithalerts and empty($alert_agent['simple'])) {
continue;
}
$node_count ++;
// Save node parent information to define edges later
$parents[$node_count] = $agent['parent'] = $nodes_groups[$agent['id_grupo']]['id_node'];
$agent['id_node'] = $node_count;
$agent['type'] = 'agent';
// Add node
$nodes[$node_count] = $nodes_agents[$agent['id_agente']] = $agent;
if ($depth == 'agent') {
continue;
}
// Get agent modules data
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false);
// Parse modules
foreach ($modules as $key => $module) {
$node_count ++;
$agent_module = modules_get_agentmodule($key);
$alerts_module = db_get_sql('SELECT count(*) AS num
FROM talert_template_modules
WHERE id_agent_module = ' . $key);
if ($alerts_module == 0 && $modwithalerts) {
continue;
}
if ($agent_module['id_module_group'] != $module_group &&
$module_group != 0) {
continue;
}
if ($hidepolicymodules && $config['enterprise_installed']) {
enterprise_include_once('include/functions_policies.php');
if (policies_is_module_in_policy($key)) {
continue;
}
}
// Save node parent information to define edges later
$parents[$node_count] = $agent_module['parent'] = $agent['id_node'];
$agent_module['id_node'] = $node_count;
$agent_module['type'] = 'module';
// Add node
$nodes[$node_count] = $agent_module;
}
}
}
if (empty ($nodes)) {
return false;
}
// Create void statistics array
$stats = array();
// Create nodes
foreach ($nodes as $node_id => $node) {
if ($center > 0 && ! networkmap_is_descendant ($node_id, $center, $parents)) {
unset ($parents[$node_id]);
unset ($orphans[$node_id]);
unset ($nodes[$node_id]);
continue;
}
switch ($node['type']) {
case 'group':
$graph .= networkmap_create_group_node ($node , $simple, $font_size) .
"\n\t\t";
$stats['groups'][] = $node['id_grupo'];
break;
case 'agent':
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, true, true) .
"\n\t\t";
$stats['agents'][] = $node['id_agente'];
break;
case 'module':
$graph .= networkmap_create_module_node ($node , $simple, $font_size) .
"\n\t\t";
$stats['modules'][] = $node['id_agente_modulo'];
break;
}
}
// Define edges
foreach ($parents as $node => $parent_id) {
// Verify that the parent is in the graph
if (isset ($nodes[$parent_id])) {
$graph .= networkmap_create_edge ($node, $parent_id, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap);
}
else {
$orphans[$node] = 1;
}
}
// Create a central node if orphan nodes exist
if (count ($orphans)) {
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple, $stats);
}
// Define edges for orphan nodes
foreach (array_keys($orphans) as $node) {
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'groups', $id_networkmap);
}
// Close graph
$graph .= networkmap_close_graph ();
return $graph;
}
// Returns an edge definition
function networkmap_create_edge ($head, $tail, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, $sec2 = 'operation/agentes/networkmap', $tab = 'topology', $id_networkmap = 0) {
if (defined("METACONSOLE")) {
$url = '';
}
else {
$url = 'index.php?sec=estado&sec2='.$sec2.'&tab='.$tab.'&recenter_networkmap=1¢er='.$head.
'&layout='.$layout.'&nooverlap=' .$nooverlap.'&pure='.$pure.
'&zoom='.$zoom.'&ranksep='.$ranksep.'&simple='.$simple.'®en=1'.
'&font_size='.$font_size.'&group='.$group.'&id_networkmap='.$id_networkmap;
}
// edgeURL allows node navigation
$edge = "\n" . $head.' -- '.$tail.'[color="#BDBDBD", headclip=false, tailclip=false,
edgeURL=""];' . "\n";
return $edge;
}
// Returns a group node definition
function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
global $config;
global $hack_networkmap_mobile;
$status = groups_get_status ($group['id_grupo']);
// Set node status
switch ($status) {
case 0:
$status_color = '#8DFF1D'; // Normal monitor
break;
case 1:
$status_color = '#FF1D1D'; // Critical monitor
break;
case 2:
$status_color = '#FFE308'; // Warning monitor
break;
case 4:
$status_color = '#FFA300'; // Alert fired
break;
default:
$status_color = '#BBBBBB'; // Unknown monitor
break;
}
$icon = groups_get_icon($group['id_grupo']);
if ($simple == 0) {
// Set node icon
if ($hack_networkmap_mobile) {
$img_node = $config['homedir'] . "/images/groups_small/" . $icon . ".png";
if (!file_exists($img_node)) {
$img_node = '-';
}
$img_node = '';
}
else if (file_exists (html_print_image("images/groups_small/" . $icon . ".png", true, false, true, true))) {
$img_node = html_print_image("images/groups_small/" . $icon . ".png", true, false, false, true);
}
else {
$img_node = '-';
}
if (strlen(groups_get_name($group['id_grupo'])) > 40) {
$name = substr(groups_get_name($group['id_grupo']), 0, 40) . '...';
}
else {
$name = groups_get_name($group['id_grupo']);
}
if (defined("METACONSOLE")) {
$url = '';
$url_tooltip = '';
}
else {
$url = 'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$group['id_grupo'];
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'];
}
$node = "\n" . $group['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=<'.$img_node.' |
'.io_safe_output($name).' | >,
shape="invtrapezium", URL="' . $url . '",
tooltip="' . $url_tooltip . '"];' . "\n";
}
else {
if (defined("METACONSOLE")) {
$url = '';
$url_tooltip = '';
}
else {
$url = 'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$group['id_grupo'];
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'];
}
$node = "\n" . $group['id_node'] . ' [ color="'.$status_color.'", fontsize='.$font_size.', shape="invtrapezium",
URL="' . $url . '", style="filled", fixedsize=true, width=0.20, height=0.20, label="",
tooltip="' . $url_tooltip . '"];' . "\n";
}
return $node;
}
// Returns a node definition
function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true, $relative = false, $metaconsole = false, $id_server = null) {
global $config;
global $hack_networkmap_mobile;
$status = agents_get_status_from_counts($agent);
if (defined('METACONSOLE')) {
$server_data = db_get_row('tmetaconsole_setup', 'id', $agent['id_server']);
}
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
$console_url = '';
}
else {
$server_name = $server_data['server_name'];
$server_id = $server_data['id'];
$console_url = $server_data['server_url'] . '/';
$url_hash = metaconsole_get_servers_url_hash($server_data);
}
// Set node status
switch ($status) {
case AGENT_STATUS_NORMAL:
$status_color = '#8DFF1D';
break;
case AGENT_STATUS_CRITICAL:
$status_color = '#FF1D1D';
break;
case AGENT_STATUS_WARNING:
$status_color = '#FFE308';
break;
case AGENT_STATUS_ALERT_FIRED:
$status_color = '#FFA300';
break;
default:
//Unknown monitor
$status_color = '#BBBBBB';
break;
}
// Short name
$name = io_safe_output($agent["nombre"]);
if ((strlen ($name) > 16) && ($cut_names)) {
$name = ui_print_truncate_text($name, 16, false, true, false);
}
if ($simple == 0) {
if ($hack_networkmap_mobile) {
$img_node = ui_print_os_icon($agent['id_os'], false, true, true, true, true, true);
$img_node = $config['homedir'] . '/' . $img_node;
$img_node = '';
}
else {
// Set node icon
$img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true, $relative);
$img_node = str_replace($config['homeurl'] . '/', '', $img_node);
$img_node = str_replace($config['homeurl'], '', $img_node);
if (defined('METACONSOLE')) {
$img_node = str_replace('../../', '', $img_node);
}
if ($relative) {
$img_node = html_print_image($img_node, true, false, false, true);
}
else {
$img_node = html_print_image($img_node, true, false, false, false);
}
}
if (defined("METACONSOLE")) {
if (can_user_access_node ()) {
$url = ui_meta_get_url_console_child($id_server,
"estado", "operation/agentes/ver_agente&id_agente=" . $agent['id_agente']);
}
else {
$url = '';
}
$url_tooltip = '../../ajax.php?' .
'page=operation/agentes/ver_agente&' .
'get_agent_status_tooltip=1&' .
'id_agent='.$agent['id_agente'] . '&' .
'metaconsole=1&' .
'id_server=' . $agent['id_server'];
}
else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'];
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'];
}
$node = "\n" . $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<' . $img_node . ' |
'.io_safe_output($name).' | >,
shape="doublecircle", URL="'.$url.'",
tooltip="' . $url_tooltip . '"];' . "\n";
}
else {
$ajax_prefix = '';
$meta_params = '';
if (defined('METACONSOLE')) {
$ajax_prefix = '../../';
$meta_params = '&metaconsole=1&id_server=' . $id_server;
}
if (can_user_access_node ()) {
$url_node_link = ', URL="' . $console_url . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $agent['id_agente'] . $url_hash . '"';
}
else {
$url_node_link = '';
}
$node = $agent['id_node'] . ' [ color="' . $status_color . '", fontsize=' . $font_size . ', shape="doublecircle"' . $url_node_link . ', style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="' . $ajax_prefix . 'ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent=' . $agent['id_agente'] . $meta_params . '"];' . "\n";
}
return $node;
}
function networkmap_create_module_group_node ($module_group, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
global $config;
global $hack_networkmap_mobile;
// Set node status
switch ($module_group['status']) {
case 0:
$status_color = '#8DFF1D'; // Normal monitor
break;
case 1:
$status_color = '#FF1D1D'; // Critical monitor
break;
case 2:
$status_color = '#FFE308'; // Warning monitor
break;
case 4:
$status_color = '#FFA300'; // Alert fired
break;
default:
$status_color = '#BBBBBB'; // Unknown monitor
break;
}
if ($simple == 0) {
if (defined("METACONSOLE")) {
$url = '';
$url_tooltip = '';
}
else {
$url = '';
$url_tooltip = '';
}
$node = $module_group['id_node'].' [ color="' . $status_color .
'", fontsize='.$font_size.', style="filled", ' .
'fixedsize=true, width=0.30, height=0.30, ' .
'label=<' .
io_safe_output($module_group['name']) . ' | >,
shape="square", URL="' . $url . '",
tooltip="' . $url_tooltip . '"];';
}
else {
if ($hack_networkmap_mobile) {
$img_node = ui_print_moduletype_icon($module['id_tipo_modulo'], true, true, false, true);
$img_node = $config['homedir'] . '/' . $img_node;
$img_node = '';
}
else {
$img_node = ui_print_moduletype_icon ($module['id_tipo_modulo'], true, true, false);
}
if (defined("METACONSOLE")) {
$url = '';
$url_tooltip = '';
}
else {
$url = '';
$url_tooltip = '';
}
$node = $module_group['id_node'] . ' [ color="'.$status_color .
'", fontsize='.$font_size.', shape="square", URL="' . $url . '", ' .
'style="filled", fixedsize=true, width=0.20, ' .
'height=0.20, label="", tooltip="' . $url_tooltip . '"];';
}
return $node;
}
// Returns a module node definition
function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
global $config;
global $hack_networkmap_mobile;
if (isset($module['status'])) {
$status = $module['status'];
}
else {
$status = modules_get_agentmodule_status($module['id_agente_modulo'],
false, $metaconsole, $id_server);
}
// Set node status
switch ($status) {
case 0:
$status_color = '#8DFF1D'; // Normal monitor
break;
case 1:
$status_color = '#FF1D1D'; // Critical monitor
break;
case 2:
$status_color = '#FFE308'; // Warning monitor
break;
case 4:
$status_color = '#FFA300'; // Alert fired
break;
default:
$status_color = '#BBBBBB'; // Unknown monitor
break;
}
if ($hack_networkmap_mobile) {
$img_node = ui_print_moduletype_icon($module['id_tipo_modulo'], true, true, false, true);
$img_node = $config['homedir'] . '/' . $img_node;
$img_node = '';
}
else {
$img_node = ui_print_moduletype_icon ($module['id_tipo_modulo'], true, true, false);
}
if ($simple == 0) {
if (defined("METACONSOLE")) {
$url = '';
$url_tooltip = '../../ajax.php?' .
'page=operation/agentes/ver_agente&' .
'get_agentmodule_status_tooltip=1&' .
'id_module='.$module['id_agente_modulo'] .
'&metaconsole=1' .
'&id_server=' . $module['id_server'];
}
else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$module['id_agente'];
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_agentmodule_status_tooltip=1&id_module='.$module['id_agente_modulo'];
}
$node = $module['id_node'].' [ color="' . $status_color .
'", fontsize='.$font_size.', style="filled", ' .
'fixedsize=true, width=0.30, height=0.30, ' .
'label=<' .
$img_node . ' |
' . io_safe_output($module['nombre']) . ' | >,
shape="circle", URL="' . $url . '",
tooltip="' . $url_tooltip . '"];';
}
else {
if (defined("METACONSOLE")) {
$url = 'TODO';
$url_tooltip = '../../ajax.php?page=operation/agentes/ver_agente' .
'&get_agentmodule_status_tooltip=1' .
'&id_module=' . $module['id_agente_modulo'] .
'&metaconsole=1' .
'&id_server=' . $module['id_server'];
}
else {
$url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$module['id_agente'];
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_agentmodule_status_tooltip=1&id_module='.$module['id_agente_modulo'];
}
$node = $module['id_node'] . ' [ color="'.$status_color .
'", fontsize='.$font_size.', shape="circle", URL="' . $url . '", ' .
'style="filled", fixedsize=true, width=0.20, ' .
'height=0.20, label="", tooltip="' . $url_tooltip . '"];';
}
return $node;
}
// Returns the definition of the central module
function networkmap_create_pandora_node ($name, $font_size = 10, $simple = 0, $stats = array()) {
global $hack_networkmap_mobile;
global $config;
$stats_json = base64_encode(json_encode($stats));
$img_src = "images/networkmap/pandora_node.png";
if (defined('METACONSOLE')) {
$url_tooltip = '../../ajax.php?' .
'page=include/ajax/networkmap.ajax&' .
'action=get_networkmap_summary&' .
'stats='.$stats_json . '&' .
'metaconsole=1';
$url = '';
$color = "#052938";
}
else {
$url_tooltip = 'ajax.php?page=include/ajax/networkmap.ajax&action=get_networkmap_summary&stats='.$stats_json.'", URL="index.php?sec=estado&sec2=operation/agentes/group_view';
$url = 'index.php?sec=estado&sec2=operation/agentes/group_view';
$color = "#373737";
}
if ($hack_networkmap_mobile) {
$img = ' |