diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ca3a12d3d1..9f2d50f428 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2008-06-17 Ramon Novoa + + * pandora_console/operation/agentes/networkmap.php: Added to + repository. Network Map. + * pandora_console/operation/menu.php: Added an entry for Network Map. + * pandora_console/images/networkmap + pandora_console/images/networkmap/0.png + pandora_console/images/networkmap/router.png + pandora_console/images/networkmap/10.png + pandora_console/images/networkmap/1.png + pandora_console/images/networkmap/2.png + pandora_console/images/networkmap/11.png + pandora_console/images/networkmap/printer.png + pandora_console/images/networkmap/firewall.png + pandora_console/images/networkmap/server.png + pandora_console/images/networkmap/9.png + pandora_console/images/networkmap/pandora_node.png + pandora_console/images/networkmap/server_hpux.png: Added to + repository. Network Map icons. + 2008-06-17 Esteban Sanchez * godmode/reporting/reporting_builder.php: Changing the group of a diff --git a/pandora_console/images/networkmap/0.png b/pandora_console/images/networkmap/0.png new file mode 100644 index 0000000000..fd9e1a4b3c Binary files /dev/null and b/pandora_console/images/networkmap/0.png differ diff --git a/pandora_console/images/networkmap/1.png b/pandora_console/images/networkmap/1.png new file mode 100644 index 0000000000..c2300168fd Binary files /dev/null and b/pandora_console/images/networkmap/1.png differ diff --git a/pandora_console/images/networkmap/10.png b/pandora_console/images/networkmap/10.png new file mode 100644 index 0000000000..b7aea11172 Binary files /dev/null and b/pandora_console/images/networkmap/10.png differ diff --git a/pandora_console/images/networkmap/11.png b/pandora_console/images/networkmap/11.png new file mode 100644 index 0000000000..4bf0a9e061 Binary files /dev/null and b/pandora_console/images/networkmap/11.png differ diff --git a/pandora_console/images/networkmap/2.png b/pandora_console/images/networkmap/2.png new file mode 100644 index 0000000000..865ccef469 Binary files /dev/null and b/pandora_console/images/networkmap/2.png differ diff --git a/pandora_console/images/networkmap/9.png b/pandora_console/images/networkmap/9.png new file mode 100644 index 0000000000..bb21b7a2bf Binary files /dev/null and b/pandora_console/images/networkmap/9.png differ diff --git a/pandora_console/images/networkmap/firewall.png b/pandora_console/images/networkmap/firewall.png new file mode 100644 index 0000000000..bc8402d732 Binary files /dev/null and b/pandora_console/images/networkmap/firewall.png differ diff --git a/pandora_console/images/networkmap/pandora_node.png b/pandora_console/images/networkmap/pandora_node.png new file mode 100644 index 0000000000..7429a27d15 Binary files /dev/null and b/pandora_console/images/networkmap/pandora_node.png differ diff --git a/pandora_console/images/networkmap/printer.png b/pandora_console/images/networkmap/printer.png new file mode 100644 index 0000000000..a9388ba469 Binary files /dev/null and b/pandora_console/images/networkmap/printer.png differ diff --git a/pandora_console/images/networkmap/router.png b/pandora_console/images/networkmap/router.png new file mode 100644 index 0000000000..a06f06687c Binary files /dev/null and b/pandora_console/images/networkmap/router.png differ diff --git a/pandora_console/images/networkmap/server.png b/pandora_console/images/networkmap/server.png new file mode 100644 index 0000000000..b7aea11172 Binary files /dev/null and b/pandora_console/images/networkmap/server.png differ diff --git a/pandora_console/images/networkmap/server_hpux.png b/pandora_console/images/networkmap/server_hpux.png new file mode 100644 index 0000000000..a96ace9e02 Binary files /dev/null and b/pandora_console/images/networkmap/server_hpux.png differ diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php new file mode 100644 index 0000000000..9141514a2e --- /dev/null +++ b/pandora_console/operation/agentes/networkmap.php @@ -0,0 +1,305 @@ + 0) { + $graph .= create_pandora_node ('Pandora_FMS'); + } + + // Define edges + foreach ($parents as $node => $parent_id) { + $graph .= create_edge($node, $nodes[$parent_id]); + + } + + // Define edges for orphan nodes + foreach(array_keys($orphans) as $node) { + $graph .= create_edge('Pandora_FMS', $node); + } + + // Close graph + $graph .= close_graph(); + + return $graph; +} + +// Returns an edge definition +function create_edge($head, $tail) { + + $edge = str_replace("-", "_", $head) . ' -- ' . str_replace("-", "_", $tail) . '[color="grey35", headclip=false, tailclip=false];'; + return $edge; +} + +// Returns a node definition +function create_node($agent) { + $bad_modules = mysql_query('SELECT estado FROM tagente_estado AS e, + tagente_modulo AS m + WHERE m.id_agente=' . $agent['id_agente'] . + ' AND m.id_tipo_modulo in (2, 6, 9, 18, 21, 100) + AND e.id_agente_modulo = m.id_agente_modulo + AND e.datos = 0'); + + // Set node status + if (mysql_num_rows($bad_modules) > 0) { + $status_color = "orangered1"; + } + else { + $status_color = "chartreuse1"; + } + + // 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 = str_replace("-", "_", $agent['nombre']) . ' [ color="' . $status_color . '", fontsize=10, style="filled", fixedsize=true, width=0.6, height=0.6, label=< + +
\N
>, + shape="ellipse", tooltip="' . $agent['nombre'] . ' (' . $agent['direccion'] . ')", URL="' + . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' + . $agent['id_agente'] . '"];'; + + return $node; +} + +// Returns the definition of the central module +function create_pandora_node($name) { + + $node = $name . ' [ color="black", fontsize=10, style="filled", fixedsize=true, width=1.4, height=0.6, label=< + +
\N
>, + shape="ellipse", tooltip="' . $name . '", URL="index.php?sec=estado&sec2=operation/agentes/estado_grupo" ];'; + + return $node; +} + +// Opens a group definition +function open_group($id) { + $img = 'images/' . dame_grupo_icono($id) . '.png'; + $name = dame_nombre_grupo($id); + + $group = 'subgraph cluster_' . $id . + ' { style=filled; color=darkolivegreen3; label=< + +
' . $name . '
>; tooltip="' . $name . '"; + URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' + . $id . '";'; + + return $group; +} + +// Closes a group definition +function close_group() { + return '}'; +} + +// Opens a graph definition +function open_graph($root) { + global $config, $layout, $nooverlap, $pure, $zoom; + $overlap = 'compress'; + $size_x = 8; + $size_y = 6; + $size = ''; + + if ($layout == '' || $layout == 'radial') { + $overlap = 'true'; + } + + if ($nooverlap != '') { + $overlap = 'scalexy'; + } + + if ($pure == 1 && $zoom > 1 && $zoom <= 3) { + $size_x *= $zoom; + $size_y *= $zoom; + } + + $size = $size_x . ',' . $size_y; + + $head = 'graph networkmap { labeljust=l; outputorder="edgesfirst"; overlap=' . + $overlap . '; ratio="fill"; root="' . $root . + '"; size="' . $size . '"; '; + + return $head; +} + +// Closes a graph definition +function close_graph() { + return '}'; +} + +/////////////////////////////////////////////////////////////////////////////// +// General purpose functions +/////////////////////////////////////////////////////////////////////////////// + +// Returns the filter used to achieve the desired layout +function set_filter() { + global $layout; + + switch($layout) { + case 'flat': return 'dot'; + case 'radial': return 'twopi'; + case 'circular': return 'circo'; + case 'spring1': return 'neato'; + case 'spring2': return 'fdp'; + default: return 'twopi'; + } +} + +/////////////////////////////////////////////////////////////////////////////// +// Main code +/////////////////////////////////////////////////////////////////////////////// + +// Load variables +$layout = (string) get_parameter ('layout'); +$nooverlap = (boolean) get_parameter ('nooverlap'); +$pure = (int) get_parameter ('pure'); +$zoom = (float) get_parameter ('zoom'); + +// Login check +$id_user = $_SESSION["id_usuario"]; +global $REMOTE_ADDR; + +if (comprueba_login() != 0) { + audit_db($id_user, $REMOTE_ADDR, "ACL Violation", "Trying to access node graph builder"); + include("general/noaccess.php"); + exit; +} + +if ((give_acl($id_user, 0, "AR") != 1 ) AND (dame_admin($id_user) !=1 )) { + audit_db($id_user, $REMOTE_ADDR, "ACL Violation", "Trying to access node graph builder"); + include("general/noaccess.php"); + exit; +} + +echo '

' . $lang_label['ag_title'] . ' > ' . lang_string("Network Map") . ' '; +if ($pure == 1) { + echo ''; +} +else { + echo ''; +} +echo '

'; + +// Layout selection +$layout_array = array ( + 'radial' => 'radial', + 'circular' => 'circular', + 'spring1' => 'spring 1', + 'spring2' => 'spring 2', + 'flat' => 'flat', +); + +echo '
'; +echo ''; +echo ''; +echo ''; +if ($pure == "1") { + // Zoom + $zoom_array = array ( + '1' => 'x1', + '1.5' => 'x1.5', + '2' => 'x2', + '2.5' => 'x2.5', + '3' => 'x3', + ); + + echo ''; + echo ''; +} +//echo ' Display groups '; +echo ''; +echo '
' . lang_string('Layout') . '  '; +print_select ($layout_array, 'layout', $layout, '', '', ''); +echo '' . lang_string('Layout') . '  '; + print_select ($zoom_array, 'zoom', $zoom, '', '', ''); + echo '' . lang_string('No Overlap') . '  '; + print_checkbox ('nooverlap', 'nooverlap', $nooverlap); + echo ''; +echo ''; +echo '
'; +echo '
'; + +// Set filter +$filter = set_filter(); + +// Generate dot file +$graph = generate_dot(); + +//DEBUG +//$fh = fopen("networkmap.dot", 'w') or die("can't open file"); +//fwrite($fh, $graph); +//fclose($fh); + +// Generate image and map +$cmd = "echo " . escapeshellarg($graph) . + " | $filter -Tcmapx -onetworkmap.map -Tpng -onetworkmap.png"; + +if (system($cmd) !== false) { + echo ''; + include "networkmap.map"; +} + +?> diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 7f844d78e5..6051ca92d2 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -56,6 +56,13 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) { echo ""; + + if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/agentes/networkmap"){ + echo "
"; + } else { + echo ""; if (isset($_GET["sec2"]) && ($_GET["sec2"] == "operation/agentes/estado_agente" || $_GET["sec2"] == "operation/agentes/ver_agente" || $_GET["sec2"] == "operation/agentes/datos_agente")) { echo "
";