diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 86f65fcba4..d33eee22e5 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2014-04-16 Alejandro Gallardo + + * godmode/setup/setup_netflow.php: Added a radio buttons + to activate or deactivate the name resolution for ip addresses. + + * include/functions_config.php: Added the name resolution by + if to the funcion "config_update_config". + + * include/functions_graph.php: Added 50px to the width of the + pie of the function "graph_netflow_aggregate_pie". + + * include/functions_netflow.php: Improved the styles of the + netflow report tables. + + * include/graphs/flot/pandora.flot.js: Now the legend items + show the percentage when the pie labels are hidden. + + * pandora_console/include/graphs/functions_d3.php, + pandora_console/include/graphs/pandora.d3.js: Added files. + 2014-04-14 Alejandro Gallardo * include/functions_ui.php: Improved the function diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index 81f91598a8..abbaa3990b 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -17,9 +17,7 @@ global $config; -//include_once("include/functions_graph.php"); include_once("include/functions_ui.php"); -//ui_require_javascript_file ('calendar'); check_login (); @@ -60,6 +58,10 @@ $table->data[6][1] = __('Yes').'   '.html_print_radio_button ('ne $table->data[6][1] .= __('No').'   '.html_print_radio_button ('netflow_disable_custom_lvfilters', 0, '', $config["netflow_disable_custom_lvfilters"], true).'  '; $table->data[7][0] = '' . __('Netflow max lifetime') . ''.ui_print_help_tip (__("Sets the maximum lifetime for netflow data in days."), true); $table->data[7][1] = html_print_input_text ('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true); +$table->data[8][0] = '' . __('Name resolution for IP address') . '' . + ui_print_help_tip (__("Resolve the IP addresses to get their hostnames."), true); +$table->data[8][1] = __('Yes').'   '.html_print_radio_button ('netflow_get_ip_hostname', 1, '', $config["netflow_get_ip_hostname"], true).'  '; +$table->data[8][1] .= __('No').'   '.html_print_radio_button ('netflow_get_ip_hostname', 0, '', $config["netflow_get_ip_hostname"], true).'  '; echo '
'; @@ -71,10 +73,4 @@ echo '
'; html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); echo '
'; -?> - - +?> \ No newline at end of file diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 49038fda86..68f25da9e6 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -479,6 +479,8 @@ function config_update_config () { $error_update[] = __('Disable custom live view filters'); if (!config_update_value ('netflow_max_lifetime', (int) get_parameter ('netflow_max_lifetime'))) $error_update[] = __('Netflow max lifetime'); + if (!config_update_value ('netflow_get_ip_hostname', (int) get_parameter ('netflow_get_ip_hostname'))) + $error_update[] = __('Name resolution for IP address'); break; case 'log': if (!config_update_value ('log_dir', get_parameter('log_dir'))) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index b2a5411b71..138a440df7 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3189,7 +3189,7 @@ function graph_netflow_aggregate_pie ($data, $aggregate, $ttl = 1, $only_image = $flash_chart = false; } - return pie3d_graph($flash_chart, $values, 320, 200, + return pie3d_graph($flash_chart, $values, 370, 200, __('Other'), $config['homeurl'], $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], $ttl); } diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 21a284dc17..693d952dc1 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -218,8 +218,8 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){ $table->head = array (); $table->head[0] = '' . netflow_format_aggregate ($aggregate) . ''; $table->head[1] = '' . netflow_format_unit ($unit) . ''; - $table->style[0] = 'border: 1px solid black; padding: 4px'; - $table->style[1] = 'border: 1px solid black; padding: 4px'; + $table->style[0] = 'padding: 6px'; + $table->style[1] = 'padding: 6px'; while (isset ($data[$j])) { $agg = $data[$j]['agg']; @@ -276,7 +276,7 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) { $values = array(); $table->size = array ('60%'); - $table->class = 'databox_grid'; + $table->class = 'databox'; $table->cellspacing = 0; $table->data = array(); @@ -346,25 +346,43 @@ function netflow_summary_table ($data) { global $nfdump_date_format; $values = array(); - $table->size = array ('50%'); + $table->size = array('50%'); $table->cellspacing = 0; $table->class = 'databox'; $table->data = array(); - $table->style[0] = 'border: 1px solid black;padding: 4px'; - $table->style[1] = 'border: 1px solid black;padding: 4px'; - $table->data[0][0] = ''.__('Total flows').''; - $table->data[0][1] = format_numeric ($data['totalflows']); - $table->data[1][0] = ''.__('Total bytes').''; - $table->data[1][1] = format_numeric ($data['totalbytes']); - $table->data[2][0] = ''.__('Total packets').''; - $table->data[2][1] = format_numeric ($data['totalpackets']); - $table->data[3][0] = ''.__('Average bits per second'). ''; - $table->data[3][1] = format_numeric ($data['avgbps']); - $table->data[4][0] = ''.__('Average packets per second').''; - $table->data[4][1] = format_numeric ($data['avgpps']); - $table->data[5][0] = ''.__('Average bytes per packet').''; - $table->data[5][1] = format_numeric ($data['avgbpp']); + $table->style[0] = 'font-weight: bold; padding: 6px'; + $table->style[1] = 'padding: 6px'; + + $data = array(); + $data[] = __('Total flows'); + $data[] = format_numeric ($data['totalflows']); + $table->data[] = $data; + + $data = array(); + $data[] = __('Total bytes'); + $data[] = format_numeric ($data['totalbytes']); + $table->data[] = $data; + + $data = array(); + $data[] = __('Total packets'); + $data[] = format_numeric ($data['totalpackets']); + $table->data[] = $data; + + $data = array(); + $data[] = __('Average bits per second'); + $data[] = format_numeric ($data['avgbps']); + $table->data[] = $data; + + $data = array(); + $data[] = __('Average packets per second'); + $data[] = format_numeric ($data['avgpps']); + $table->data[] = $data; + + $data = array(); + $data[] = __('Average bytes per packet'); + $data[] = format_numeric ($data['avgbpp']); + $table->data[] = $data; $html = html_print_table ($table, true); @@ -539,7 +557,7 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a if (($aggregate != 'none') && (empty($values['data']))) { return array(); } - + return $values; } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 119e92974d..33beb0e08b 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -65,6 +65,12 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat clickable: true } }; + + if (width < 400) { + conf_pie.legend.labelFormatter = function(label, series) { + return label + " (" + series.percent.toFixed(1) + "%)"; + } + } switch (legend_position) { case 'bottom': @@ -73,9 +79,8 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat else offset = - (width / 5); conf_pie.series.pie.radius = 1 / 2.5; - conf_pie.series.pie.offset = conf_pie.series.pie.offset = {top: offset}; - conf_pie.legend.position = "s"; + conf_pie.legend.position = "se"; break; case 'right': case 'inner': diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php new file mode 100644 index 0000000000..819d1dc808 --- /dev/null +++ b/pandora_console/include/graphs/functions_d3.php @@ -0,0 +1,53 @@ +'; + $output .= ''; + + } + if (!$return) + echo $output; + + return $output; +} + +function d3_relationship_graph ($elements, $matrix, $unit, $width = 700, $return = false) { + global $config; + + $output = "
"; + $output .= include_javascript_d3(true); + $output .= ""; + + if (!$return) + echo $output; + + return $output; +} + + +?> \ No newline at end of file diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js new file mode 100644 index 0000000000..51cbd24c67 --- /dev/null +++ b/pandora_console/include/graphs/pandora.d3.js @@ -0,0 +1,179 @@ +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2 + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + + +// https://github.com/fzaninotto/DependencyWheel +function chordDiagram (recipient, elements, matrix, unit, width) { + + d3.chart = d3.chart || {}; + d3.chart.chordWheel = function(options) { + + // Default values + var width = 700; + var margin = 150; + var padding = 0.02; + + function chart(selection) { + selection.each(function(data) { + + var matrix = data.matrix; + var elements = data.elements; + var radius = width / 2 - margin; + + // create the layout + var chord = d3.layout.chord() + .padding(padding) + .sortSubgroups(d3.descending); + + // Select the svg element, if it exists. + var svg = d3.select(this).selectAll("svg").data([data]); + + // Otherwise, create the skeletal chart. + var gEnter = svg.enter().append("svg:svg") + .attr("width", width) + .attr("height", width) + .attr("class", "dependencyWheel") + .append("g") + .attr("transform", "translate(" + (width / 2) + "," + (width / 2) + ")"); + + var arc = d3.svg.arc() + .innerRadius(radius) + .outerRadius(radius + 20); + + var fill = function(d) { + if (d.index === 0) return '#ccc'; + return "hsl(" + parseInt(((elements[d.index][0].charCodeAt() - 97) / 26) * 360, 10) + ",90%,70%)"; + }; + + // Returns an event handler for fading a given chord group. + var fade = function(opacity) { + return function(g, i) { + svg.selectAll(".chord") + .filter(function(d) { + return d.source.index != i && d.target.index != i; + }) + .transition() + .style("opacity", opacity); + var groups = []; + svg.selectAll(".chord") + .filter(function(d) { + if (d.source.index == i) { + groups.push(d.target.index); + } + if (d.target.index == i) { + groups.push(d.source.index); + } + }); + groups.push(i); + var length = groups.length; + svg.selectAll('.group') + .filter(function(d) { + for (var i = 0; i < length; i++) { + if(groups[i] == d.index) return false; + } + return true; + }) + .transition() + .style("opacity", opacity); + }; + }; + + chord.matrix(matrix); + + var rootGroup = chord.groups()[0]; + var rotation = - (rootGroup.endAngle - rootGroup.startAngle) / 2 * (180 / Math.PI); + + var g = gEnter.selectAll("g.group") + .data(chord.groups) + .enter().append("svg:g") + .attr("class", "group") + .attr("transform", function(d) { + return "rotate(" + rotation + ")"; + }); + + g.append("svg:path") + .style("fill", fill) + .style("stroke", fill) + .attr("d", arc) + .on("mouseover", fade(0.1)) + .on("mouseout", fade(1)); + + g.append("svg:text") + .each(function(d) { d.angle = (d.startAngle + d.endAngle) / 2; }) + .attr("dy", ".35em") + .attr("text-anchor", function(d) { return d.angle > Math.PI ? "end" : null; }) + .attr("transform", function(d) { + return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")" + + "translate(" + (radius + 26) + ")" + + (d.angle > Math.PI ? "rotate(180)" : ""); + }) + .text(function(d) { return elements[d.index]; }); + + gEnter.selectAll("path.chord") + .data(chord.chords) + .enter().append("svg:path") + .attr("class", "chord") + .style("stroke", function(d) { return d3.rgb(fill(d.source)).darker(); }) + .style("fill", function(d) { return fill(d.source); }) + .attr("d", d3.svg.chord().radius(radius)) + .attr("transform", function(d) { + return "rotate(" + rotation + ")"; + }) + .style("opacity", 1); + + // Add an elaborate mouseover title for each chord. + gEnter.selectAll("path.chord").append("title").text(function(d) { + return elements[d.source.index] + + " → " + elements[d.target.index] + + ": " + d.source.value + " " + unit + + "\n" + elements[d.target.index] + + " → " + elements[d.source.index] + + ": " + d.target.value + " " + unit; + }); + }); + } + + chart.width = function(value) { + if (!arguments.length) return width; + width = value; + return chart; + }; + + chart.margin = function(value) { + if (!arguments.length) return margin; + margin = value; + return chart; + }; + + chart.padding = function(value) { + if (!arguments.length) return padding; + padding = value; + return chart; + }; + + return chart; + }; + + var chart = d3.chart.chordWheel() + .width(width) + .margin(150) + .padding(.02); + + d3.select(recipient) + .datum({ + elements: elements, + matrix: matrix + }) + .call(chart); +} \ No newline at end of file