diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e89c2b6216..39a2e6f811 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2014-03-31 Alejandro Gallardo + + * include/functions_networkmap.php: Updated the function + "networkmap_generate_dot" to fix a regex and delete the + central node if the L2 network interfaces is true. + + * operation/agentes/estado_generalagente.php: Fixed + some regex. + 2014-03-31 Vanessa Gil * pandoradb.oracle.sql diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index f9bec96a9e..2709f249fc 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -328,7 +328,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $node_count ++; // Try to get the interface name - if (preg_match ("/_(\w+)/" , (string)$module['nombre'], $matches)) { + if (preg_match ("/_(.+)$/" , (string)$module['nombre'], $matches)) { if ($matches[1]) { $module['nombre'] = $matches[1]; } @@ -393,16 +393,6 @@ function networkmap_generate_dot ($pandora_name, $group = 0, } } - // 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); - } - // Define edges for the module interfaces relations if ($l2_network) { // Get the remote_snmp_proc relations @@ -418,6 +408,18 @@ function networkmap_generate_dot ($pandora_name, $group = 0, } } } + // Define edges for the orphan nodes + else { + // 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 (); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 89df9de434..cb34400877 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -346,7 +346,7 @@ if (! empty($modules)) { foreach ($modules as $key => $module) { // Trying to get the interface name from the module name - if (preg_match ("/_(\w+)/" , (string)$module['nombre'], $matches)) { + if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) { if ($matches[1]) { $interface_name = $matches[1]; @@ -358,14 +358,16 @@ if (! empty($modules)) { $ip_target = "--"; // Trying to get something like an IP from the description - if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/" , (string)$module['ip_target'], $matches)) { + if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", (string)$module['descripcion'], $matches) || + preg_match ("/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| + (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", (string)$module['descripcion'], $matches)) { if ($matches[0]) { $ip_target = $matches[0]; } } $description = "--"; // Trying to get something like a mac from the description - if (preg_match ("/([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})/i" , (string)$module['descripcion'], $matches)) { + if (preg_match ("/([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})/i", (string)$module['descripcion'], $matches)) { if ($matches[0]) { $description = $matches[0]; }