2013-01-28 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_networkmap.php,
	operation/agentes/networkmap.topology.php,
	operation/agentes/networkmap.groups.php: fixed the lost parameter
	in the generation of networkmap with a text filter.
	
	Fixes: #3602233




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7532 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-01-28 11:50:30 +00:00
parent 3d20a1b8b3
commit 123a93ac5e
4 changed files with 51 additions and 15 deletions

View File

@ -1,3 +1,12 @@
2013-01-28 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_networkmap.php,
operation/agentes/networkmap.topology.php,
operation/agentes/networkmap.groups.php: fixed the lost parameter
in the generation of networkmap with a text filter.
Fixes: #3602233
2013-01-28 Miguel de Dios <miguel.dedios@artica.es> 2013-01-28 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager.php: fixed the PHP notices in the * godmode/agentes/module_manager.php: fixed the PHP notices in the

View File

@ -202,7 +202,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0,
} }
// Generate a dot graph definition for graphviz with groups // 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) { 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; global $config;
$parents = array(); $parents = array();
@ -211,6 +211,20 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
$filter = array (); $filter = array ();
$filter['disabled'] = 0; $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 // Get groups data
if ($group > 0) { if ($group > 0) {
$groups = array(); $groups = array();

View File

@ -32,7 +32,10 @@ require_once ('include/functions_networkmap.php');
$filter = networkmap_get_filter ($layout); $filter = networkmap_get_filter ($layout);
// Generate dot file // Generate dot file
$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $modwithalerts, $module_group, $hidepolicymodules, $depth, $id_networkmap, $dont_show_subgroups); $graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group,
$simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center,
$regen, $pure, $modwithalerts, $module_group, $hidepolicymodules,
$depth, $id_networkmap, $dont_show_subgroups, $text_filter);
if ($graph === false) { if ($graph === false) {
ui_print_error_message (__('Map could not be generated')); ui_print_error_message (__('Map could not be generated'));
@ -41,10 +44,13 @@ if ($graph === false) {
} }
// Generate image and map // 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 // If image was generated just a few minutes ago, then don't regenerate
$filename_map = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; // (it takes long) unless regen checkbox is set
$filename_img = "attachment/networkmap_".$filter."_".$font_size; $filename_map = safe_url_extraclean($config["attachment_store"]) .
$filename_dot = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; "/networkmap_" . $filter;
$filename_img = "attachment/networkmap_" . $filter . "_" . $font_size;
$filename_dot = safe_url_extraclean($config["attachment_store"]) .
"/networkmap_" . $filter;
if ($simple) { if ($simple) {
$filename_map .= "_simple"; $filename_map .= "_simple";
$filename_img .= "_simple"; $filename_img .= "_simple";
@ -55,9 +61,9 @@ if ($nooverlap) {
$filename_img .= "_nooverlap"; $filename_img .= "_nooverlap";
$filename_dot .= "_nooverlap"; $filename_dot .= "_nooverlap";
} }
$filename_map .= "_".$id_networkmap.".map"; $filename_map .= "_" . $id_networkmap . ".map";
$filename_img .= "_".$id_networkmap.".png"; $filename_img .= "_" . $id_networkmap . ".png";
$filename_dot .= "_".$id_networkmap.".dot"; $filename_dot .= "_" . $id_networkmap . ".dot";
if ($regen != 1 && file_exists ($filename_img) && if ($regen != 1 && file_exists ($filename_img) &&
filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) { filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) {
@ -70,7 +76,8 @@ else {
} }
else { else {
fwrite ($fh, $graph); fwrite ($fh, $graph);
$cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; $cmd = "$filter -Tcmapx -o" . $filename_map . " -Tpng " .
"-o" . $filename_img . " " . $filename_dot;
$result = system ($cmd); $result = system ($cmd);
fclose ($fh); fclose ($fh);
unlink ($filename_dot); unlink ($filename_dot);
@ -87,7 +94,8 @@ if ($result !== false) {
return; return;
} }
html_print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); html_print_image ($filename_img, false,
array ("alt" => __('Network map'), "usemap" => "#networkmap"));
require ($filename_map); require ($filename_map);
} }
else { else {

View File

@ -32,7 +32,10 @@ require_once ('include/functions_networkmap.php');
$filter = networkmap_get_filter ($layout); $filter = networkmap_get_filter ($layout);
// Generate dot file // Generate dot file
$graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen, $pure, $id_networkmap, $show_snmp_modules, true, true, $text_filter); $graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple,
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
$pure, $id_networkmap, $show_snmp_modules, true, true,
$text_filter);
if ($graph === false) { if ($graph === false) {
ui_print_error_message (__('Map could not be generated')); ui_print_error_message (__('Map could not be generated'));
@ -43,9 +46,11 @@ if ($graph === false) {
// Generate image and map // 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 // If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
$filename_map = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; $filename_map = safe_url_extraclean($config["attachment_store"]) .
$filename_img = "attachment/networkmap_".$filter."_".$font_size; "/networkmap_" . $filter;
$filename_dot = safe_url_extraclean ($config["attachment_store"])."/networkmap_".$filter; $filename_img = "attachment/networkmap_" . $filter . "_" . $font_size;
$filename_dot = safe_url_extraclean($config["attachment_store"]) .
"/networkmap_" . $filter;
if ($simple) { if ($simple) {
$filename_map .= "_simple"; $filename_map .= "_simple";
$filename_img .= "_simple"; $filename_img .= "_simple";