WIP: NetworkMap class
Former-commit-id: 888621c19262397298ac934e26e55a0b0ab218ec
This commit is contained in:
parent
c91c79a735
commit
1bc326c00c
|
@ -38,13 +38,6 @@ define('SOURCE_GROUP', 0);
|
|||
define('SOURCE_TASK', 1);
|
||||
define('SOURCE_NETWORK', 2);
|
||||
|
||||
define('LAYOUT_CIRCULAR', 0);
|
||||
define('LAYOUT_FLAT', 1);
|
||||
define('LAYOUT_RADIAL', 2);
|
||||
define('LAYOUT_SPRING1', 3);
|
||||
define('LAYOUT_SPRING2', 4);
|
||||
|
||||
|
||||
/**
|
||||
* Manage networkmaps in Pandora FMS
|
||||
*/
|
||||
|
@ -625,15 +618,16 @@ class NetworkMap
|
|||
$filename_dot .= '_nooverlap';
|
||||
}
|
||||
|
||||
$filename_dot .= '_'.$this->idMap.'.dot';
|
||||
$filename_dot .= uniqid().'_'.$this->idMap.'.dot';
|
||||
|
||||
file_put_contents($filename_dot, $this->dotGraph);
|
||||
|
||||
$plain_file = 'plain'.uniqid().'.txt';
|
||||
switch (PHP_OS) {
|
||||
case 'WIN32':
|
||||
case 'WINNT':
|
||||
case 'Windows':
|
||||
$filename_plain = sys_get_temp_dir().'\\plain.txt';
|
||||
$filename_plain = sys_get_temp_dir().'\\'.$plain_file;
|
||||
|
||||
$cmd = io_safe_output(
|
||||
$config['graphviz_bin_dir'].'\\'.$filter.'.exe -Tplain -o '.$filename_plain.' '.$filename_dot
|
||||
|
@ -641,13 +635,22 @@ class NetworkMap
|
|||
break;
|
||||
|
||||
default:
|
||||
$filename_plain = sys_get_temp_dir().'/plain.txt';
|
||||
$filename_plain = sys_get_temp_dir().'/'.$plain_file;
|
||||
|
||||
$cmd = $filter.' -Tplain -o '.$filename_plain.' '.$filename_dot;
|
||||
break;
|
||||
}
|
||||
|
||||
$r = system($cmd);
|
||||
$retval = 0;
|
||||
$r = system($cmd, $retval);
|
||||
|
||||
if ($retval != 0) {
|
||||
ui_print_error_message(
|
||||
__('Failed to generate dotmap, please select different layout schema')
|
||||
);
|
||||
$this->graph = networkmap_process_networkmap($this->idMap);
|
||||
return;
|
||||
}
|
||||
|
||||
unlink($filename_dot);
|
||||
|
||||
|
|
|
@ -535,6 +535,20 @@ define('MAP_GENERATION_RADIAL', 2);
|
|||
define('MAP_GENERATION_SPRING1', 3);
|
||||
define('MAP_GENERATION_SPRING2', 4);
|
||||
|
||||
// Algorithm: Circo.
|
||||
define('LAYOUT_CIRCULAR', 0);
|
||||
// Algorithm: Dot.
|
||||
define('LAYOUT_FLAT', 1);
|
||||
// Algorithm: Twopi.
|
||||
define('LAYOUT_RADIAL', 2);
|
||||
// Algorithm: Neato.
|
||||
define('LAYOUT_SPRING1', 3);
|
||||
// Algorithm: Fdp.
|
||||
define('LAYOUT_SPRING2', 4);
|
||||
// Extra: radial dynamic.
|
||||
define('LAYOUT_RADIAL_DYNAMIC', 6);
|
||||
|
||||
|
||||
define('MAP_SOURCE_GROUP', 0);
|
||||
define('MAP_SOURCE_IP_MASK', 1);
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ function networkmap_generate_dot(
|
|||
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$text_filter.'%")';
|
||||
}
|
||||
|
||||
if ($group >= 1) {
|
||||
if ($group >= 0 && empty($ip_mask)) {
|
||||
if ($dont_show_subgroups) {
|
||||
$filter['id_grupo'] = $group;
|
||||
} else {
|
||||
|
|
|
@ -57,27 +57,27 @@ function networkmap_process_networkmap($id=0)
|
|||
$pure = (int) get_parameter('pure', 0);
|
||||
|
||||
switch ($networkmap['generation_method']) {
|
||||
case 0:
|
||||
case LAYOUT_CIRCULAR:
|
||||
$filter = 'circo';
|
||||
$layout = 'circular';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case LAYOUT_FLAT:
|
||||
$filter = 'dot';
|
||||
$layout = 'flat';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case LAYOUT_RADIAL:
|
||||
$filter = 'twopi';
|
||||
$layout = 'radial';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case LAYOUT_SPRING1:
|
||||
$filter = 'neato';
|
||||
$layout = 'spring1';
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case LAYOUT_SPRING2:
|
||||
$filter = 'fdp';
|
||||
$layout = 'spring2';
|
||||
break;
|
||||
|
|
|
@ -272,31 +272,31 @@ if ($new_networkmap || $save_networkmap) {
|
|||
|
||||
switch ($method) {
|
||||
case 'twopi':
|
||||
$values['generation_method'] = 2;
|
||||
$values['generation_method'] = LAYOUT_RADIAL;
|
||||
break;
|
||||
|
||||
case 'dot':
|
||||
$values['generation_method'] = 1;
|
||||
$values['generation_method'] = LAYOUT_FLAT;
|
||||
break;
|
||||
|
||||
case 'circo':
|
||||
$values['generation_method'] = 0;
|
||||
$values['generation_method'] = LAYOUT_CIRCULAR;
|
||||
break;
|
||||
|
||||
case 'neato':
|
||||
$values['generation_method'] = 3;
|
||||
$values['generation_method'] = LAYOUT_SPRING1;
|
||||
break;
|
||||
|
||||
case 'fdp':
|
||||
$values['generation_method'] = 4;
|
||||
$values['generation_method'] = LAYOUT_SPRING2;
|
||||
break;
|
||||
|
||||
case 'radial_dinamic':
|
||||
$values['generation_method'] = 6;
|
||||
$values['generation_method'] = LAYOUT_RADIAL_DYNAMIC;
|
||||
break;
|
||||
|
||||
default:
|
||||
$values['generation_method'] = 2;
|
||||
$values['generation_method'] = LAYOUT_RADIAL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -353,12 +353,12 @@ if ($new_networkmap || $save_networkmap) {
|
|||
define('_id_', $id);
|
||||
|
||||
if ($result !== false) {
|
||||
$tab = 'view';
|
||||
if ($values['generation_method'] == 6) {
|
||||
$tab = 'r_dinamic';
|
||||
define('_activeTab_', 'radial_dynamic');
|
||||
}
|
||||
|
||||
$tab = 'view';
|
||||
header('Location: '.$_SERVER['HTTP_REFERER'].'&tab='.$tab.'&id_networkmap='.$id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -890,7 +890,7 @@ if ($networkmap === false) {
|
|||
|
||||
|
||||
include_once $config['homedir'].'/include/class/NetworkMap.class.php';
|
||||
echo 'generado por clase';
|
||||
|
||||
$map_manager = new NetworkMap(
|
||||
[ 'id_map' => $networkmap['id']]
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue