2010-07-23 Sergio Martin <sergio.martin@artica.es>
* include/functions_networkmap.php include/functions_db.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/ver_agente.php operation/agentes/networkmap.php: Rewritted the get status of modules and agents and writted the same feature for groups and policys. Added the groups view network map. All for pending task: 3019636 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3057 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
74804a0634
commit
24f6eb4c8f
|
@ -1,3 +1,14 @@
|
|||
2010-07-23 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_networkmap.php
|
||||
include/functions_db.php
|
||||
operation/agentes/networkmap.topology.php
|
||||
operation/agentes/networkmap.groups.php
|
||||
operation/agentes/ver_agente.php
|
||||
operation/agentes/networkmap.php: Rewritted the get status of modules
|
||||
and agents and writted the same feature for groups and policys. Added
|
||||
the groups view network map. All for pending task: 3019636
|
||||
|
||||
2010-07-23 Dario Rodriguez <dario.rodriguez@gmail.com>
|
||||
|
||||
* operation/agentes/ver_agente.php: Changed code to use print_page_header
|
||||
|
|
|
@ -782,6 +782,17 @@ function get_module_type_name ($id_type) {
|
|||
return (string) get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', (int) $id_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of a module type
|
||||
*
|
||||
* @param int $id_type Type id
|
||||
*
|
||||
* @return string The name of the given type.
|
||||
*/
|
||||
function get_module_type_icon ($id_type) {
|
||||
return (string) get_db_value ('icon', 'ttipo_modulo', 'id_tipo', (int) $id_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent id of an agent module.
|
||||
*
|
||||
|
@ -1400,6 +1411,17 @@ function get_agent_interval ($id_agent) {
|
|||
return (int) get_db_value ('intervalo', 'tagente', 'id_agente', $id_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the operating system of an agent.
|
||||
*
|
||||
* @param int Agent id.
|
||||
*
|
||||
* @return int The interval value of a given agent
|
||||
*/
|
||||
function get_agent_os ($id_agent) {
|
||||
return (int) get_db_value ('id_os', 'tagente', 'id_agente', $id_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag value of an agent module.
|
||||
*
|
||||
|
@ -2596,19 +2618,24 @@ function get_agentmodule_status ($id_agentmodule = 0) {
|
|||
|
||||
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule);
|
||||
if ($times_fired > 0) {
|
||||
return 4; // Alert
|
||||
return 4; // Alert fired
|
||||
}
|
||||
|
||||
|
||||
|
||||
$status_row = get_db_row ("tagente_estado", "id_agente_modulo", $id_agentmodule);
|
||||
|
||||
// Not init or current_interval == 0: Return current status and avoid problems here !
|
||||
/*// Not init or current_interval == 0: Return current status and avoid problems here !
|
||||
if ($status_row["current_interval"] == 0)
|
||||
return $status_row["estado"];*/
|
||||
|
||||
$module_type = get_agentmodule_type($id_agentmodule);
|
||||
|
||||
// Asynchronous and keepalive modules cant be unknown
|
||||
if(($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
|
||||
return $status_row["estado"];
|
||||
|
||||
}
|
||||
|
||||
// Unknown status
|
||||
if ( ($status_row["current_interval"] * 2) + $status_row["utimestamp"] < $current_timestamp){
|
||||
if ($status_row["current_interval"] == 0 || ($status_row["current_interval"] * 2) + $status_row["utimestamp"] < $current_timestamp){
|
||||
$status = 3;
|
||||
}
|
||||
else {
|
||||
|
@ -2627,21 +2654,122 @@ function get_agentmodule_status ($id_agentmodule = 0) {
|
|||
* The value -1 is returned in case the agent has exceed its interval.
|
||||
*/
|
||||
function get_agent_status ($id_agent = 0) {
|
||||
$modules = get_agent_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0));
|
||||
|
||||
$modules_status = array();
|
||||
$modules_async = 0;
|
||||
foreach($modules as $module) {
|
||||
$modules_status[] = get_agentmodule_status($module);
|
||||
|
||||
$module_type = get_agentmodule_type($module);
|
||||
if(($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
|
||||
$modules_async++;
|
||||
}
|
||||
}
|
||||
|
||||
// If all the modules are asynchronous or keep alive, the gruop cannot be unknown
|
||||
if($modules_async < count($modules)) {
|
||||
$time = get_system_time ();
|
||||
$status = get_db_value_filter ('COUNT(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'UNIX_TIMESTAMP(ultimo_contacto) + intervalo * 2 > '.$time,
|
||||
'UNIX_TIMESTAMP(ultimo_contacto_remoto) + intervalo * 2 > '.$time));
|
||||
if (! $status)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Status is 0 for normal, 1 for critical, 2 for warning and 3 for unknown. 4 for alert fired
|
||||
|
||||
// Checking if any module has alert fired (4)
|
||||
if(is_int(array_search(4,$modules_status))){
|
||||
return 4;
|
||||
}
|
||||
// Checking if any module has unknown status (3)
|
||||
elseif(is_int(array_search(3,$modules_status))){
|
||||
return 3;
|
||||
}
|
||||
// Checking if any module has critical status (1)
|
||||
elseif(is_int(array_search(1,$modules_status))){
|
||||
return 1;
|
||||
}
|
||||
// Checking if any module has warning status (2)
|
||||
elseif(is_int(array_search(2,$modules_status))){
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_group_status ($id_group = 0) {
|
||||
$agents = get_group_agents($id_group);
|
||||
|
||||
$agents_status = array();
|
||||
foreach($agents as $key => $agent){
|
||||
$agents_status[] = get_agent_status($key);
|
||||
}
|
||||
|
||||
$childrens = get_childrens($id_group);
|
||||
|
||||
foreach($childrens as $key => $child){
|
||||
$agents_status[] = get_group_status($key);
|
||||
}
|
||||
|
||||
// Status is 0 for normal, 1 for critical, 2 for warning and 3/-1 for unknown. 4 for fired alerts
|
||||
|
||||
// Checking if any agent has fired alert (4)
|
||||
if(is_int(array_search(4,$agents_status))){
|
||||
return 4;
|
||||
}
|
||||
// Checking if any agent has unknown status (-1)
|
||||
elseif(is_int(array_search(-1,$agents_status))){
|
||||
return -1;
|
||||
}
|
||||
// Checking if any agents module has unknown status (3)
|
||||
elseif(is_int(array_search(3,$agents_status))){
|
||||
return 3;
|
||||
}
|
||||
// Checking if any agent has critical status (1)
|
||||
elseif(is_int(array_search(1,$agents_status))){
|
||||
return 1;
|
||||
}
|
||||
// Checking if any agent has warning status (2)
|
||||
elseif(is_int(array_search(2,$agents_status))){
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the worst status of all modules of the agents of a group.
|
||||
*
|
||||
* @param int Id module to check.
|
||||
*
|
||||
* @return int Worst status of a module for all of its agents.
|
||||
* The value -1 is returned in case the agent has exceed its interval. <-- DISABLED
|
||||
*/
|
||||
function get_module_status ($id_module = 0) {
|
||||
$time = get_system_time ();
|
||||
$status = get_db_value_filter ('COUNT(*)',
|
||||
/*$status = get_db_value_filter ('COUNT(*)',
|
||||
'tagente',
|
||||
array ('id_agente' => (int) $id_agent,
|
||||
'UNIX_TIMESTAMP(ultimo_contacto) + intervalo * 2 > '.$time,
|
||||
'UNIX_TIMESTAMP(ultimo_contacto_remoto) + intervalo * 2 > '.$time));
|
||||
if (! $status)
|
||||
return -1;
|
||||
return -1;*/
|
||||
|
||||
$status = get_db_sql ("SELECT MAX(estado)
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.delete_pending = 0
|
||||
AND tagente_modulo.id_agente = $id_agent");
|
||||
$status = get_db_sql ("SELECT estado
|
||||
FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.delete_pending = 0
|
||||
AND tagente_modulo.id_agente_modulo = ".$id_module);
|
||||
|
||||
// TODO: Check any alert for that agent who has recept alerts fired
|
||||
|
||||
|
@ -3124,6 +3252,17 @@ function get_agent_group ($id_agent) {
|
|||
return (int) get_db_value ('id_grupo', 'tagente', 'id_agente', (int) $id_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the modulegroup for a given group
|
||||
*
|
||||
* @param int The group id
|
||||
*
|
||||
* @return int The modulegroup id
|
||||
*/
|
||||
function get_agentmodule_modulegroup ($id_module) {
|
||||
return (int) get_db_value ('id_module_group', 'tagente_modulo', 'id_agente_modulo', (int) $id_module);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets the group name for a given group id
|
||||
*
|
||||
|
@ -3169,7 +3308,10 @@ function get_modulegroups () {
|
|||
* @return string The modulegroup name
|
||||
*/
|
||||
function get_modulegroup_name ($modulegroup_id) {
|
||||
return (string) get_db_value ('name', 'tmodule_group', 'id_mg', (int) $modulegroup_id);
|
||||
if($modulegroup_id == 0)
|
||||
return false;
|
||||
else
|
||||
return (string) get_db_value ('name', 'tmodule_group', 'id_mg', (int) $modulegroup_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -113,12 +113,175 @@ function generate_dot ($pandora_name, $group = 0, $simple = 0, $font_size = 12,
|
|||
return $graph;
|
||||
}
|
||||
|
||||
// Generate a dot graph definition for graphviz with groups
|
||||
function 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') {
|
||||
|
||||
global $config;
|
||||
|
||||
$parents = array();
|
||||
$orphans = array();
|
||||
|
||||
$filter = array ();
|
||||
$filter['disabled'] = 0;
|
||||
|
||||
// Get groups data
|
||||
if ($group > 0) {
|
||||
$filter['id_grupo'] = $group;
|
||||
$groups[0] = get_db_row ('tgrupo', 'id_grupo', $group);
|
||||
}
|
||||
else {
|
||||
$groups = get_db_all_rows_in_table ('tgrupo');
|
||||
}
|
||||
|
||||
|
||||
// Open Graph
|
||||
$graph = open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $font_size);
|
||||
|
||||
$node_count = 0;
|
||||
|
||||
// Parse groups
|
||||
$nodes = array ();
|
||||
$nodes_groups = array();
|
||||
foreach ($groups as $group) {
|
||||
$node_count ++;
|
||||
$group['type'] = 'group';
|
||||
$group['id_node'] = $node_count;
|
||||
|
||||
// Add node
|
||||
$nodes_groups[$group['id_grupo']] = $group;
|
||||
}
|
||||
|
||||
$node_count = 0;
|
||||
|
||||
foreach ($nodes_groups as $node_group) {
|
||||
|
||||
$node_count++;
|
||||
|
||||
// Save node parent information to define edges later
|
||||
if ($node_group['parent'] != "0") {
|
||||
$parents[$node_count] = $nodes_groups[$node_group['parent']]['id_node'];
|
||||
} else {
|
||||
$orphans[$node_count] = 1;
|
||||
}
|
||||
|
||||
$nodes[$node_count] = $node_group;
|
||||
}
|
||||
|
||||
if($depth != 'group') {
|
||||
// Get agents data
|
||||
$agents = get_agents ($filter,
|
||||
array ('id_grupo, nombre, id_os, id_agente'));
|
||||
if ($agents === false)
|
||||
return false;
|
||||
|
||||
// Parse agents
|
||||
$nodes_agents = array();
|
||||
foreach ($agents as $agent) {
|
||||
$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 = get_agent_modules ($agent['id_agente'], false, array('disabled' => 0));
|
||||
// Parse modules
|
||||
foreach ($modules as $key => $module) {
|
||||
$node_count ++;
|
||||
$agent_module = get_agentmodule($key);
|
||||
$alerts_module = get_db_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(isModuleInPolicy($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 nodes
|
||||
foreach ($nodes as $node_id => $node) {
|
||||
if ($center > 0 && ! 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 .= create_group_node ($node , $simple, $font_size)."\n\t\t";
|
||||
break;
|
||||
case 'agent':
|
||||
$graph .= create_agent_node ($node , $simple, $font_size)."\n\t\t";
|
||||
break;
|
||||
case 'module':
|
||||
$graph .= create_module_node ($node , $simple, $font_size)."\n\t\t";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Define edges
|
||||
foreach ($parents as $node => $parent_id) {
|
||||
// Verify that the parent is in the graph
|
||||
if (isset ($nodes[$parent_id])) {
|
||||
$graph .= create_edge ($node, $parent_id, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap2');
|
||||
} else {
|
||||
$orphans[$node] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a central node if orphan nodes exist
|
||||
if (count ($orphans)) {
|
||||
$graph .= create_pandora_node ($pandora_name, $font_size, $simple);
|
||||
}
|
||||
|
||||
// Define edges for orphan nodes
|
||||
foreach (array_keys($orphans) as $node) {
|
||||
$graph .= create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap2');
|
||||
}
|
||||
|
||||
// Close graph
|
||||
$graph .= close_graph ();
|
||||
|
||||
return $graph;
|
||||
}
|
||||
|
||||
// Returns an edge definition
|
||||
function create_edge ($head, $tail, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group) {
|
||||
function create_edge ($head, $tail, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, $sec2 = 'operation/agentes/networkmap') {
|
||||
|
||||
// edgeURL allows node navigation
|
||||
$edge = $head.' -- '.$tail.'[color="#BDBDBD", headclip=false, tailclip=false,
|
||||
edgeURL="index.php?sec=estado&sec2=operation/agentes/networkmap¢er='.$head.
|
||||
edgeURL="index.php?sec=estado&sec2='.$sec2.'¢er='.$head.
|
||||
'&layout='.$layout.'&nooverlap=' .$nooverlap.'&pure='.$pure.
|
||||
'&zoom='.$zoom.'&ranksep='.$ranksep.'&simple='.$simple.'®en=1'.
|
||||
'&font_size='.$font_size.'&group='.$group.'"];';
|
||||
|
@ -182,6 +345,146 @@ function create_node ($agent, $simple = 0, $font_size = 10) {
|
|||
return $node;
|
||||
}
|
||||
|
||||
// Returns a group node definition
|
||||
function create_group_node ($group, $simple = 0, $font_size = 10) {
|
||||
$status = get_group_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 = '#FFE308'; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
$icon = get_group_icon($group['id_grupo']);
|
||||
|
||||
if ($simple == 0){
|
||||
// Set node icon
|
||||
if (file_exists ('images/groups_small/'.$icon.'.png')) {
|
||||
$img_node = '<IMG SRC="images/groups_small/'.$icon.'.png"/>';
|
||||
} else {
|
||||
$img_node = '-';
|
||||
}
|
||||
|
||||
$name = get_group_name($group['id_grupo']);
|
||||
|
||||
$node = $group['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>'.$img_node.'</TD></TR>
|
||||
<TR><TD>'.$name.'</TD></TR></TABLE>>,
|
||||
shape="ellipse", URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$group['id_grupo'].'",
|
||||
tooltip="ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'].'"];';
|
||||
} else {
|
||||
$node = $group['id_node'] . ' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_group_status_tooltip=1&id_group='.$group['id_grupo'].'"];';
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
// Returns a node definition
|
||||
function create_agent_node ($agent, $simple = 0, $font_size = 10) {
|
||||
$status = get_agent_status($agent['id_agente']);
|
||||
|
||||
// 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 = '#FFE308'; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
// Check for alert
|
||||
/*$sql = sprintf ('SELECT COUNT(talert_template_modules.id)
|
||||
FROM talert_template_modules, tagente_modulo, tagente
|
||||
WHERE tagente.id_agente = %d
|
||||
AND tagente.disabled = 0
|
||||
AND tagente.id_agente = tagente_modulo.id_agente
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
|
||||
AND talert_template_modules.times_fired > 0 ',
|
||||
$agent['id_agente']);
|
||||
$alert_modules = get_db_sql ($sql);
|
||||
if ($alert_modules)
|
||||
$status_color = '#FFE308';*/
|
||||
|
||||
// Short name
|
||||
$name = strtolower ($agent["nombre"]);
|
||||
if (strlen ($name) > 16)
|
||||
$name = substr ($name, 0, 16);
|
||||
|
||||
if ($simple == 0){
|
||||
// Set node icon
|
||||
if (file_exists ('images/networkmap/'.$agent['id_os'].'.png')) {
|
||||
$img_node = 'images/networkmap/'.$agent['id_os'].'.png';
|
||||
} else {
|
||||
$img_node = 'images/networkmap/0.png';
|
||||
}
|
||||
|
||||
$node = $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD><IMG SRC="'.$img_node.'"/></TD></TR>
|
||||
<TR><TD>'.$name.'</TD></TR></TABLE>>,
|
||||
shape="ellipse", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'",
|
||||
tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];';
|
||||
} else {
|
||||
$node = $agent['id_node'] . ' [ color="' . $status_color . '", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];';
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
// Returns a module node definition
|
||||
function create_module_node ($module, $simple = 0, $font_size = 10) {
|
||||
$status = get_agentmodule_status($module['id_agente_modulo']);
|
||||
|
||||
// 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 = '#FFE308'; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($simple == 0){
|
||||
$node = $module['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>'.print_moduletype_icon ($module['id_tipo_modulo'], true).'</TD></TR>
|
||||
<TR><TD>'.$module['nombre'].'</TD></TR></TABLE>>,
|
||||
shape="ellipse", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$module['id_agente'].'",
|
||||
tooltip="ajax.php?page=operation/agentes/ver_agente&get_agentmodule_status_tooltip=1&id_module='.$module['id_agente_modulo'].'"];';
|
||||
} else {
|
||||
$node = $module['id_node'] . ' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.20, height=0.20, label="", tooltip="ajax.php?page=operation/agentes/ver_agente&get_agentmodule_status_tooltip=1&id_module='.$module['id_agente_modulo'].'"];';
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
// Returns the definition of the central module
|
||||
function create_pandora_node ($name, $font_size = 10, $simple = 0) {
|
||||
$img = '<TR><TD><IMG SRC="images/networkmap/pandora_node.png"/></TD></TR>';
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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 General Public License
|
||||
// as published by the Free Software Foundation for 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.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "AR")) {
|
||||
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_networkmap.php');
|
||||
|
||||
// Load variables
|
||||
$layout = (string) get_parameter ('layout', 'radial');
|
||||
$depth = (string) get_parameter ('depth', 'all'); // 0 to all
|
||||
$nooverlap = (int) get_parameter ('nooverlap', 0);
|
||||
$modwithalerts = (int) get_parameter ('modwithalerts', 0);
|
||||
$showmodules = (int) get_parameter ('showmodules', 0);
|
||||
$hidepolicymodules = (int) get_parameter ('hidepolicymodules', 0);
|
||||
$pure = (int) get_parameter ('pure');
|
||||
$zoom = (float) get_parameter ('zoom');
|
||||
$ranksep = (float) get_parameter ('ranksep', 2.5);
|
||||
$simple = (int) get_parameter ('simple', 0);
|
||||
$regen = (int) get_parameter ('regen',1); // Always regen by default
|
||||
$font_size = (int) get_parameter ('font_size', 12);
|
||||
$group = (int) get_parameter ('group', 0);
|
||||
$module_group = (int) get_parameter ('module_group', 0);
|
||||
$center = (int) get_parameter ('center', 0);
|
||||
|
||||
// Layout selection
|
||||
$layout_array = array (
|
||||
'circular' => 'circular',
|
||||
'radial' => 'radial',
|
||||
'spring1' => 'spring 1',
|
||||
'spring2' => 'spring 2',
|
||||
'flat' => 'flat');
|
||||
|
||||
echo '<form action="index.php?sec=estado&sec2=operation/agentes/networkmap&tab=groups&pure='.$pure.'&center='.$center.'" method="post">';
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox" width="99%">';
|
||||
echo '<tr><td>';
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<td valign="top">' . __('Group') . '<br />';
|
||||
print_select_from_sql ('SELECT id_grupo, nombre FROM tgrupo WHERE id_grupo > 0 ORDER BY nombre', 'group', $group, '', 'All', 0, false);
|
||||
echo '</td>';
|
||||
echo '<td valign="top">' . __('Module group') . '<br />';
|
||||
print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, false);
|
||||
echo '</td>';
|
||||
echo '<td valign="top">' . __('Layout') . '<br />';
|
||||
print_select ($layout_array, 'layout', $layout, '', '', '');
|
||||
echo '</td>';
|
||||
echo '<td valign="top">' . __('Depth') . '<br />';
|
||||
$depth_levels = array('all' => __('All'), 'agent' => __('Agents'), 'group' => __('Groups'));
|
||||
print_select ($depth_levels, 'depth', $depth, '', '', '', 0, false, false);
|
||||
echo '</td>';
|
||||
echo '</tr></table>';
|
||||
|
||||
echo '</td></tr><tr><td>';
|
||||
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<td valign="top">' . __('No Overlap') . '<br />';
|
||||
print_checkbox ('nooverlap', '1', $nooverlap);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('Only modules with alerts') . '<br />';
|
||||
print_checkbox ('modwithalerts', '1', $modwithalerts);
|
||||
echo '</td>';
|
||||
|
||||
if(($depth == 'all') && $config['enterprise_installed']) {
|
||||
echo '<td valign="top">' . __('Hide policy modules') . '<br />';
|
||||
print_checkbox ('hidepolicymodules', '1', $hidepolicymodules);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
echo '<td valign="top">' . __('Simple') . '<br />';
|
||||
print_checkbox ('simple', '1', $simple);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('Regenerate') . '<br />';
|
||||
print_checkbox ('regen', '1', $regen);
|
||||
echo '</td>';
|
||||
|
||||
if ($pure == "1") {
|
||||
// Zoom
|
||||
$zoom_array = array (
|
||||
'1' => 'x1',
|
||||
'1.2' => 'x2',
|
||||
'1.6' => 'x3',
|
||||
'2' => 'x4',
|
||||
'2.5' => 'x5',
|
||||
'5' => 'x10',
|
||||
);
|
||||
|
||||
echo '<td valign="top">' . __('Zoom') . '<br />';
|
||||
print_select ($zoom_array, 'zoom', $zoom, '', '', '', 0, false, false, false);
|
||||
echo '</td>';
|
||||
|
||||
}
|
||||
|
||||
if ($nooverlap == 1){
|
||||
echo "<td>";
|
||||
echo __('Distance between nodes') . '<br />';
|
||||
print_input_text ('ranksep', $ranksep, $alt = 'Separation between elements in the map (in Non-overlap mode)', 3, 4, 0);
|
||||
echo "</td>";
|
||||
}
|
||||
|
||||
echo "<td>";
|
||||
echo __('Font') . '<br />';
|
||||
print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, 0);
|
||||
echo "</td>";
|
||||
|
||||
//echo ' Display groups <input type="checkbox" name="group" value="group" class="chk"/>';
|
||||
echo '<td>';
|
||||
print_submit_button (__('Update'), "updbutton", false, 'class="sub upd"');
|
||||
echo '</td></tr>';
|
||||
echo '</table>';
|
||||
echo '</table></form>';
|
||||
|
||||
// Set filter
|
||||
$filter = get_filter ($layout);
|
||||
|
||||
// Generate dot file
|
||||
$graph = generate_dot_groups (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $modwithalerts, $module_group, $hidepolicymodules, $depth);
|
||||
|
||||
if ($graph === false) {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo '<div class="nf">' . __('No agents found') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
|
||||
$filename_map = $config["attachment_store"]."/networkmap_".$layout;
|
||||
$filename_img = "attachment/networkmap_".$layout."_".$font_size;
|
||||
$filename_dot = $config["attachment_store"]."/networkmap_".$layout;
|
||||
if ($simple) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($nooverlap) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= ".map";
|
||||
$filename_img .= ".png";
|
||||
$filename_dot .= ".dot";
|
||||
|
||||
if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) {
|
||||
$result = true;
|
||||
} else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
} else {
|
||||
fwrite ($fh, $graph);
|
||||
$cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot;
|
||||
$result = system ($cmd);
|
||||
fclose ($fh);
|
||||
unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong reading the output.</div>";
|
||||
echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?";
|
||||
echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
return;
|
||||
}
|
||||
print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
|
||||
require ($filename_map);
|
||||
} else {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong executing the command or writing the output.</div>";
|
||||
echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)";
|
||||
echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"];
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
|
@ -39,151 +39,61 @@ $regen = (int) get_parameter ('regen',1); // Always regen by default
|
|||
$font_size = (int) get_parameter ('font_size', 12);
|
||||
$group = (int) get_parameter ('group', 0);
|
||||
$center = (int) get_parameter ('center', 0);
|
||||
$activeTab = get_parameter ('tab', 'topology');
|
||||
/* Main code */
|
||||
|
||||
|
||||
if ($pure == 1) {
|
||||
$onheader = '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&pure=0&layout='.$layout.'&nooverlap='.$nooverlap.'&simple='.$simple.'&ranksep='.$ranksep.'®en='.$regen.'&font_size='.$font_size.'&group='.$group.'">';
|
||||
$onheader .= print_image ("images/normalscreen.png", true, array ('title' => __('Normal screen'), 'alt' => __('Normal screen')));
|
||||
$onheader .= '</a>';
|
||||
$buttons['screen'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&tab='.$activeTab.'">' .
|
||||
print_image("images/normalscreen.png", true, array ('title' => __('Normal screen'))) .'</a>');
|
||||
|
||||
} else {
|
||||
$onheader = '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&pure=1&layout='.$layout.'&nooverlap='.$nooverlap.'&simple='.$simple.'&ranksep='.$ranksep.'®en='.$regen.'&font_size='.$font_size.'&group='.$group.'">';
|
||||
$onheader .= print_image ("images/fullscreen.png", true, array ('title' => __('Full screen'), 'alt' => __('Normal screen')));
|
||||
$onheader .= '</a>';
|
||||
$buttons['screen'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&pure=1&tab='.$activeTab.'">' .
|
||||
print_image("images/fullscreen.png", true, array ('title' => __('Full screen'))) .'</a>');
|
||||
}
|
||||
if($config['enterprise_installed']) {
|
||||
$buttons['policies'] = array('active' => $activeTab == 'policies',
|
||||
'text' => '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&tab=policies&pure='.$pure.'">' .
|
||||
print_image("images/policies.png", true, array ("title" => __('Policies view'))) .'</a>');
|
||||
}
|
||||
|
||||
$buttons['groups'] = array('active' => $activeTab == 'groups',
|
||||
'text' => '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&tab=groups&pure='.$pure.'">' .
|
||||
print_image("images/group.png", true, array ("title" => __('Groups view'))) .'</a>');
|
||||
|
||||
$buttons['topology'] = array('active' => $activeTab == 'topology',
|
||||
'text' => '<a href="index.php?sec=estado&sec2=operation/agentes/networkmap&tab=topology&pure='.$pure.'">' .
|
||||
print_image("images/recon.png", true, array ("title" => __('Topology view'))) .'</a>');
|
||||
|
||||
switch($activeTab){
|
||||
case 'topology':
|
||||
$title = __('Topology view');
|
||||
break;
|
||||
case 'groups':
|
||||
$title = __('Groups view');
|
||||
break;
|
||||
case 'policies':
|
||||
$title = __('Policies view');
|
||||
break;
|
||||
}
|
||||
|
||||
print_page_header (__('Network map'), "images/bricks.png", false, "", false, $onheader);
|
||||
print_page_header (__('Network map')." - ".$title, "images/bricks.png", false, "", false, $buttons);
|
||||
|
||||
// Layout selection
|
||||
$layout_array = array (
|
||||
'circular' => 'circular',
|
||||
'radial' => 'radial',
|
||||
'spring1' => 'spring 1',
|
||||
'spring2' => 'spring 2',
|
||||
'flat' => 'flat');
|
||||
|
||||
echo '<form action="index.php?sec=estado&sec2=operation/agentes/networkmap&pure='.$pure.'&center='.$center.'" method="post">';
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<td valign="top">' . __('Group') . '<br />';
|
||||
print_select_groups(false, false, false, 'group', $group, '', 'All', 0, false);
|
||||
echo '</td>';
|
||||
echo '<td valign="top">' . __('Layout') . '<br />';
|
||||
print_select ($layout_array, 'layout', $layout, '', '', '');
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('No Overlap') . '<br />';
|
||||
print_checkbox ('nooverlap', '1', $nooverlap);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('Simple') . '<br />';
|
||||
print_checkbox ('simple', '1', $simple);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('Regenerate') . '<br />';
|
||||
print_checkbox ('regen', '1', $regen);
|
||||
echo '</td>';
|
||||
|
||||
if ($pure == "1") {
|
||||
// Zoom
|
||||
$zoom_array = array (
|
||||
'1' => 'x1',
|
||||
'1.2' => 'x2',
|
||||
'1.6' => 'x3',
|
||||
'2' => 'x4',
|
||||
'2.5' => 'x5',
|
||||
'5' => 'x10',
|
||||
);
|
||||
|
||||
echo '<td valign="top">' . __('Zoom') . '<br />';
|
||||
print_select ($zoom_array, 'zoom', $zoom, '', '', '', 0, false, false, false);
|
||||
echo '</td>';
|
||||
|
||||
}
|
||||
|
||||
if ($nooverlap == 1){
|
||||
echo "<td>";
|
||||
echo __('Distance between nodes') . '<br />';
|
||||
print_input_text ('ranksep', $ranksep, $alt = 'Separation between elements in the map (in Non-overlap mode)', 3, 4, 0);
|
||||
echo "</td>";
|
||||
}
|
||||
|
||||
echo "<td>";
|
||||
echo __('Font') . '<br />';
|
||||
print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, 0);
|
||||
echo "</td>";
|
||||
|
||||
//echo ' Display groups <input type="checkbox" name="group" value="group" class="chk"/>';
|
||||
echo '<td>';
|
||||
print_submit_button (__('Update'), "updbutton", false, 'class="sub upd"');
|
||||
echo '</td></tr>';
|
||||
echo '</table></form>';
|
||||
|
||||
// Set filter
|
||||
$filter = get_filter ($layout);
|
||||
|
||||
// Generate dot file
|
||||
$graph = generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure);
|
||||
|
||||
if ($graph === false) {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo '<div class="nf">' . __('No agents found') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
|
||||
$filename_map = $config["attachment_store"]."/networkmap_".$layout;
|
||||
$filename_img = "attachment/networkmap_".$layout."_".$font_size;
|
||||
$filename_dot = $config["attachment_store"]."/networkmap_".$layout;
|
||||
if ($simple) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($nooverlap) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= ".map";
|
||||
$filename_img .= ".png";
|
||||
$filename_dot .= ".dot";
|
||||
|
||||
if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) {
|
||||
$result = true;
|
||||
} else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
} else {
|
||||
fwrite ($fh, $graph);
|
||||
$cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot;
|
||||
$result = system ($cmd);
|
||||
fclose ($fh);
|
||||
unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong reading the output.</div>";
|
||||
echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?";
|
||||
echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
return;
|
||||
}
|
||||
print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
|
||||
require ($filename_map);
|
||||
} else {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong executing the command or writing the output.</div>";
|
||||
echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)";
|
||||
echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"];
|
||||
return;
|
||||
switch ($activeTab) {
|
||||
case 'topology':
|
||||
require_once('operation/agentes/networkmap.topology.php');
|
||||
break;
|
||||
case 'groups':
|
||||
require_once('operation/agentes/networkmap.groups.php');
|
||||
break;
|
||||
case 'policies':
|
||||
require_once(''.ENTERPRISE_DIR.'/operation/policies/networkmap.policies.php');
|
||||
break;
|
||||
default:
|
||||
enterprise_selectTab($activeTab);
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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 General Public License
|
||||
// as published by the Free Software Foundation for 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.
|
||||
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "AR")) {
|
||||
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access node graph builder");
|
||||
include ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('include/functions_networkmap.php');
|
||||
|
||||
// Load variables
|
||||
$layout = (string) get_parameter ('layout', 'radial');
|
||||
$nooverlap = (int) get_parameter ('nooverlap', 0);
|
||||
$pure = (int) get_parameter ('pure');
|
||||
$zoom = (float) get_parameter ('zoom');
|
||||
$ranksep = (float) get_parameter ('ranksep', 2.5);
|
||||
$simple = (int) get_parameter ('simple', 0);
|
||||
$regen = (int) get_parameter ('regen',1); // Always regen by default
|
||||
$font_size = (int) get_parameter ('font_size', 12);
|
||||
$group = (int) get_parameter ('group', 0);
|
||||
$center = (int) get_parameter ('center', 0);
|
||||
|
||||
// Layout selection
|
||||
$layout_array = array (
|
||||
'circular' => 'circular',
|
||||
'radial' => 'radial',
|
||||
'spring1' => 'spring 1',
|
||||
'spring2' => 'spring 2',
|
||||
'flat' => 'flat');
|
||||
|
||||
echo '<form action="index.php?sec=estado&sec2=operation/agentes/networkmap&tab=topology&pure='.$pure.'&center='.$center.'" method="post">';
|
||||
echo '<table cellpadding="4" cellspacing="4" class="databox" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<td valign="top">' . __('Group') . '<br />';
|
||||
print_select_groups(false, false, false, 'group', $group, '', 'All', 0, false);
|
||||
echo '</td>';
|
||||
echo '<td valign="top">' . __('Layout') . '<br />';
|
||||
print_select ($layout_array, 'layout', $layout, '', '', '');
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('No Overlap') . '<br />';
|
||||
print_checkbox ('nooverlap', '1', $nooverlap);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('Simple') . '<br />';
|
||||
print_checkbox ('simple', '1', $simple);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td valign="top">' . __('Regenerate') . '<br />';
|
||||
print_checkbox ('regen', '1', $regen);
|
||||
echo '</td>';
|
||||
|
||||
if ($pure == "1") {
|
||||
// Zoom
|
||||
$zoom_array = array (
|
||||
'1' => 'x1',
|
||||
'1.2' => 'x2',
|
||||
'1.6' => 'x3',
|
||||
'2' => 'x4',
|
||||
'2.5' => 'x5',
|
||||
'5' => 'x10',
|
||||
);
|
||||
|
||||
echo '<td valign="top">' . __('Zoom') . '<br />';
|
||||
print_select ($zoom_array, 'zoom', $zoom, '', '', '', 0, false, false, false);
|
||||
echo '</td>';
|
||||
|
||||
}
|
||||
|
||||
if ($nooverlap == 1){
|
||||
echo "<td>";
|
||||
echo __('Distance between nodes') . '<br />';
|
||||
print_input_text ('ranksep', $ranksep, $alt = 'Separation between elements in the map (in Non-overlap mode)', 3, 4, 0);
|
||||
echo "</td>";
|
||||
}
|
||||
|
||||
echo "<td>";
|
||||
echo __('Font') . '<br />';
|
||||
print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 2, 4, 0);
|
||||
echo "</td>";
|
||||
|
||||
//echo ' Display groups <input type="checkbox" name="group" value="group" class="chk"/>';
|
||||
echo '<td>';
|
||||
print_submit_button (__('Update'), "updbutton", false, 'class="sub upd"');
|
||||
echo '</td></tr>';
|
||||
echo '</table></form>';
|
||||
|
||||
// Set filter
|
||||
$filter = get_filter ($layout);
|
||||
|
||||
// Generate dot file
|
||||
$graph = generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure);
|
||||
|
||||
if ($graph === false) {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo '<div class="nf">' . __('No agents found') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
|
||||
$filename_map = $config["attachment_store"]."/networkmap_".$layout;
|
||||
$filename_img = "attachment/networkmap_".$layout."_".$font_size;
|
||||
$filename_dot = $config["attachment_store"]."/networkmap_".$layout;
|
||||
if ($simple) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($nooverlap) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= ".map";
|
||||
$filename_img .= ".png";
|
||||
$filename_dot .= ".dot";
|
||||
|
||||
if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) {
|
||||
$result = true;
|
||||
} else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
} else {
|
||||
fwrite ($fh, $graph);
|
||||
$cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot;
|
||||
$result = system ($cmd);
|
||||
fclose ($fh);
|
||||
unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong reading the output.</div>";
|
||||
echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?";
|
||||
echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
return;
|
||||
}
|
||||
print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
|
||||
require ($filename_map);
|
||||
} else {
|
||||
print_error_message (__('Map could not be generated'));
|
||||
echo $result;
|
||||
echo "<div class='warn'>Apparently something went wrong executing the command or writing the output.</div>";
|
||||
echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
|
||||
echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)";
|
||||
echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"];
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
|
@ -30,6 +30,8 @@ if (is_ajax ()) {
|
|||
$get_agent_json = (bool) get_parameter ('get_agent_json');
|
||||
$get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json');
|
||||
$get_agent_status_tooltip = (bool) get_parameter ("get_agent_status_tooltip");
|
||||
$get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip");
|
||||
$get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip");
|
||||
$get_agents_group_json = (bool) get_parameter ("get_agents_group_json");
|
||||
$get_agent_modules_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_json_for_multiple_agents");
|
||||
$get_agent_modules_json_for_multiple_agents_id = (bool) get_parameter("get_agent_modules_json_for_multiple_agents_id");
|
||||
|
@ -118,7 +120,9 @@ if (is_ajax ()) {
|
|||
if ($get_agent_status_tooltip) {
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
$agent = get_db_row ('tagente', 'id_agente', $id_agent);
|
||||
echo '<h3>'.$agent['nombre'].'</h3>';
|
||||
echo '<h3>';
|
||||
echo '<img src="images/bricks.png" /> ';
|
||||
echo printTruncateText($agent['nombre'],25,false,true,false).'</h3>';
|
||||
echo '<strong>'.__('Main IP').':</strong> '.$agent['direccion'].'<br />';
|
||||
echo '<strong>'.__('Group').':</strong> ';
|
||||
echo '<img src="images/groups_small/'.get_group_icon ($agent['id_grupo']).'.png" /> ';
|
||||
|
@ -202,6 +206,60 @@ if (is_ajax ()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($get_agentmodule_status_tooltip) {
|
||||
$id_module = (int) get_parameter ('id_module');
|
||||
$module = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_module);
|
||||
echo '<h3>';
|
||||
echo '<img src="images/brick.png" /> ';
|
||||
echo printTruncateText($module['nombre'],25,false,true,false).'</h3>';
|
||||
echo '<strong>'.__('Type').':</strong> ';
|
||||
$agentmoduletype = get_agentmodule_type ($module['id_agente_modulo']);
|
||||
echo get_moduletype_name ($agentmoduletype).' ';
|
||||
echo '<img src="images/'.get_module_type_icon ($agentmoduletype).'" /> <br />';
|
||||
echo '<strong>'.__('Module group').':</strong> ';
|
||||
$modulegroup = get_modulegroup_name (get_agentmodule_modulegroup ($module['id_agente_modulo']));
|
||||
if($modulegroup === false){
|
||||
echo __('None').'<br />';
|
||||
}
|
||||
else{
|
||||
echo $modulegroup.'<br />';
|
||||
}
|
||||
echo '<strong>'.__('Agent').':</strong> ';
|
||||
echo printTruncateText(get_agentmodule_agent_name ($module['id_agente_modulo']),25,false,true,false).'<br />';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_group_status_tooltip) {
|
||||
$id_group = (int) get_parameter ('id_group');
|
||||
$group = get_db_row ('tgrupo', 'id_grupo', $id_group);
|
||||
echo '<h3><img src="images/groups_small/'.get_group_icon ($group['id_grupo']).'.png" /> ';
|
||||
echo printTruncateText($group['nombre'],25,false,true,false).'</h3>';
|
||||
echo '<strong>'.__('Parent').':</strong> ';
|
||||
if($group['parent'] == 0) {
|
||||
echo __('None').'<br />';
|
||||
}
|
||||
else {
|
||||
$group_parent = get_db_row ('tgrupo', 'id_grupo', $group['parent']);
|
||||
echo '<img src="images/groups_small/'.get_group_icon ($group['parent']).'.png" /> ';
|
||||
echo $group_parent['nombre'].'<br />';
|
||||
}
|
||||
echo '<strong>'.__('Sons').':</strong> ';
|
||||
$groups_sons = get_db_all_fields_in_table ('tgrupo', 'parent', $group['id_grupo']);
|
||||
if($groups_sons === false){
|
||||
echo __('None').'<br />';
|
||||
}
|
||||
else{
|
||||
echo '<br /><br />';
|
||||
foreach($groups_sons as $group_son) {
|
||||
echo '<img src="images/groups_small/'.get_group_icon ($group_son['id_grupo']).'.png" /> ';
|
||||
echo $group_son['nombre'].'<br />';
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue