diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a9da1ef261..838b852e56 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2014-06-26 Alejandro Gallardo <alejandro.gallardo@artica.es> + + * operation/netflow/nf_live_view.php, + godmode/netflow/nf_edit.php, + godmode/servers/manage_recontask_form.php, + godmode/servers/plugin.php, + godmode/setup/setup_general.php: Added messages to + warn about incompatibilities for Windows users. + + * include/functions_graph.php: Added the function + "graph_monitor_wheel". + + * include/graphs/functions_d3.php: Added the function + "d3_sunburst_graph". + + * include/graphs/pandora.d3.js: Added the function "sunburst". + 2014-06-25 Miguel de Dios <miguel.dedios@artica.es> * include/functions_config.php: set the default size of networkmap diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index e8fc076b83..3d055ebf57 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -35,6 +35,11 @@ $pure = get_parameter('pure', 0); //Header if (! defined ('METACONSOLE')) { ui_print_page_header (__('Manage Netflow Filter'), "images/gm_netflow.png", false, "", true); + + $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; + if ($is_windows) { + ui_print_error_message(__('Not supported in Windows systems')); + } } else { $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 142d2d4ca4..6e1bc7a041 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -143,6 +143,12 @@ elseif (isset ($_GET["create"]) or isset($_GET["crt"])) { // Headers ui_print_page_header (__('Manage recontask'), "", false, "recontask", true); +$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; +if ($is_windows) { + echo '<div class="notify">'; + echo __('Warning') . ": " . __("By default, in Windows, Pandora FMS only support Standard network sweep, not custom scripts"); + echo '</div>'; +} $table->id='table_recon'; $table->width='98%'; @@ -182,7 +188,8 @@ $table->data[1][1] = html_print_select_from_sql ('SELECT id_server, name $fields['network_sweep'] = __("Network sweep"); -$fields['recon_script'] = __("Custom script"); +if (!$is_windows) + $fields['recon_script'] = __("Custom script"); $table->data[2][0] = "<b>".__('Mode')."</b>"; diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 307c4c24c8..9b19a42d9c 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -390,6 +390,13 @@ else { } else { ui_print_page_header (__('Plugins registered in Pandora FMS'), "images/gm_servers.png", false, "", true); + + $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; + if ($is_windows) { + echo '<div class="notify">'; + echo __("You need to create your own plugins with Windows compatibility"); + echo '</div>'; + } } enterprise_hook('open_meta_frame'); diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 0883f2d448..d83d176635 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -164,7 +164,7 @@ $table->data[19][0] = __('Enable Netflow'); $rbt_disabled = false; if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $rbt_disabled = true; - $table->data[19][0] .= ui_print_help_tip (__('Not supported in Windows systems.'), true); + $table->data[19][0] .= ui_print_help_tip (__('Not supported in Windows systems'), true); } $table->data[19][1] = __('Yes').' '.html_print_radio_button_extended ('activate_netflow', 1, '', $config["activate_netflow"], $rbt_disabled, '', '', true).' '; $table->data[19][1] .= __('No').' '.html_print_radio_button_extended ('activate_netflow', 0, '', $config["activate_netflow"], $rbt_disabled, '', '', true); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 4169f541c8..f216ba1f0d 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4103,4 +4103,50 @@ function graph_snmp_traps_treemap ($data, $width = 700, $height = 700) { return d3_tree_map_graph ($data, $width, $height, true); } +/** + * Print a solarburst graph with a representation of all the groups, agents, module groups and modules grouped + */ +function graph_monitor_wheel ($data, $unit, $width = 700, $height = 700) { + global $config; + + $data = array(); + + include_once ($config['homedir'] . "/include/functions_users.php"); + //include_once ($config['homedir'] . "/include/functions_groups.php"); + include_once ($config['homedir'] . "/include/functions_agents.php"); + //include_once ($config['homedir'] . "/include/functions_modules.php"); + + $groups = users_get_groups(false, "AR", false, true); + + if (!empty($groups)) { + $filter = array('id_grupo' => array_keys($groups)); + $fields = array('id_agente', 'id_parent', 'id_grupo', 'nombre'); + $agents = agents_get_agents($filter, $fields); + + if (!empty($agents)) { + $agents_id = array(); + foreach ($agents as $key => $agent) { + $agents_id[] = $agent['id_agente']; + } + $fields = array('id_agente_modulo', 'id_agente', 'id_module_group', 'nombre'); + + $module_groups = modules_get_modulegroups(); + $modules = agents_get_modules($agents_id, $fields); + + if (!empty($modules)) { + + } + } + } + + + if (empty ($data)) { + return fs_error_image (); + } + + include_once($config['homedir'] . "/include/graphs/functions_d3.php"); + + return d3_tree_map_graph ($data, $width, $height, true); +} + ?> diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 135c88ff1e..b2e7c2078b 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -117,4 +117,28 @@ function d3_tree_map_graph ($data, $width = 700, $height = 700, $return = false) return $output; } +function d3_sunburst_graph ($data, $width = 700, $height = 700, $return = false) { + global $config; + + if (is_array($data)) + $data = json_encode($data); + + $output = "<div id=\"sunburst\" style='overflow: hidden;'></div>"; + $output .= include_javascript_d3(true); + $output .= "<style type=\"text/css\"> + path { + stroke: #fff; + fill-rule: evenodd; + } + </style>"; + $output .= "<script language=\"javascript\" type=\"text/javascript\"> + sunburst('#sunburst', $data, '$width', '$height'); + </script>"; + + if (!$return) + echo $output; + + return $output; +} + ?> diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index ec6feffd62..89e746e5e0 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -18,9 +18,9 @@ // The matrix must be a 2 dimensional array with a row and a column for each element // Ex: // elements = ["a", "b", "c"]; -// matrix = [[0, 0, 2], // a[a => a, a => b, a => c] -// [5, 0, 1], // b[b => a, b => b, b => c] -// [2, 3, 0]]; // c[c => a, c => b, c => c] +// matrix = [[0, 0, 2], // a[a => a, a => b, a => c] +// [5, 0, 1], // b[b => a, b => b, b => c] +// [2, 3, 0]]; // c[c => a, c => b, c => c] function chordDiagram (recipient, elements, matrix, unit, width) { d3.chart = d3.chart || {}; @@ -266,37 +266,37 @@ function chordDiagram (recipient, elements, matrix, unit, width) { // The recipient is the selector of the html element // The data must be a bunch of associative arrays like this // data = { -// "name": "IP Traffic", -// "id": 0, -// "children": [ -// { -// "name": "192.168.1.1", -// "id": 1, -// "children": [ -// { -// "name": "HTTP", -// "id": 2, -// "value": 33938 -// } -// ] -// }, -// { -// "name": "192.168.1.2", -// "id": 3, -// "children": [ -// { -// "name": "HTTP", -// "id": 4, -// "value": 3938 -// }, -// { -// "name": "FTP", -// "id": 5, -// "value": 1312 -// } -// ] -// } -// ] +// "name": "IP Traffic", +// "id": 0, +// "children": [ +// { +// "name": "192.168.1.1", +// "id": 1, +// "children": [ +// { +// "name": "HTTP", +// "id": 2, +// "value": 33938 +// } +// ] +// }, +// { +// "name": "192.168.1.2", +// "id": 3, +// "children": [ +// { +// "name": "HTTP", +// "id": 4, +// "value": 3938 +// }, +// { +// "name": "FTP", +// "id": 5, +// "value": 1312 +// } +// ] +// } +// ] // }; function treeMap(recipient, data, width, height) { @@ -668,4 +668,73 @@ function treeMap(recipient, data, width, height) { function hide_tooltip() { $("#tooltip").hide(); } +} + + +// A sunburst is similar to a treemap, except it uses a radial layout. +// The root node of the tree is at the center, with leaves on the circumference. +// The area (or angle, depending on implementation) of each arc corresponds to its value. +// Sunburst design by John Stasko. Data courtesy Jeff Heer. +// http://bl.ocks.org/mbostock/4348373 +function sunburst (recipient, data, width, height) { + + if (width === 'auto') { + width = $(recipient).innerWidth(); + } + if (height === 'auto') { + height = width; + } + // var width = 960, + // height = 700; + var radius = Math.min(width, height) / 2; + + var x = d3.scale.linear() + .range([0, 2 * Math.PI]); + + var y = d3.scale.sqrt() + .range([0, radius]); + + var color = d3.scale.category20c(); + + var svg = d3.select(recipient).append("svg") + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")"); + + var partition = d3.layout.partition() + .value(function(d) { return d.size; }); + + var arc = d3.svg.arc() + .startAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x))); }) + .endAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx))); }) + .innerRadius(function(d) { return Math.max(0, y(d.y)); }) + .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); }); + + var path = svg.selectAll("path") + .data(partition.nodes(data)) + .enter().append("path") + .attr("d", arc) + .style("fill", function(d) { return color((d.children ? d : d.parent).name); }) + .on("click", click); + + function click(d) { + path.transition() + .duration(750) + .attrTween("d", arcTween(d)); + } + + d3.select(self.frameElement).style("height", height + "px"); + + // Interpolate the scales! + function arcTween(d) { + var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]), + yd = d3.interpolate(y.domain(), [d.y, 1]), + yr = d3.interpolate(y.range(), [d.y ? 20 : 0, radius]); + return function(d, i) { + return i + ? function(t) { return arc(d); } + : function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); }; + }; + } } \ No newline at end of file diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 6ee0f66d2e..21c1e762d1 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -104,20 +104,27 @@ $start_date = $end_date - $period; if (! defined ('METACONSOLE')) { //Header ui_print_page_header (__('Netflow live view'), "images/op_netflow.png", false, "", false, array ()); - - // Check the nfdump binary - $check_result = netflow_check_nfdump_binary ($config['netflow_nfdump']); - - // Not found or not executable - if ($check_result == 1) { - ui_print_error_message( - sprintf(__('nfdump binary (%s) not found!'), - $config['netflow_nfdump'])); + + $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; + if ($is_windows) { + ui_print_error_message(__('Not supported in Windows systems')); } - // Wrong version - else if ($check_result == 2) { - ui_print_error_message(sprintf(__('Make sure nfdump version 1.6.8 or newer is installed!'))); + else { + // Check the nfdump binary + $check_result = netflow_check_nfdump_binary ($config['netflow_nfdump']); + + // Not found or not executable + if ($check_result == 1) { + ui_print_error_message( + sprintf(__('nfdump binary (%s) not found!'), + $config['netflow_nfdump'])); + } + // Wrong version + else if ($check_result == 2) { + ui_print_error_message(sprintf(__('Make sure nfdump version 1.6.8 or newer is installed!'))); + } } + } else { $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),