2014-04-16 Alejandro Gallardo <alejandro.gallardo@artica.es>

* 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.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9771 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-04-16 12:06:19 +00:00
parent 6014e2a7f4
commit 52f1c97842
8 changed files with 304 additions and 31 deletions

View File

@ -1,3 +1,23 @@
2014-04-16 Alejandro Gallardo <alejandro.gallardo@artica.es>
* 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 <alejandro.gallardo@artica.es>
* include/functions_ui.php: Improved the function

View File

@ -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').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('ne
$table->data[6][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('netflow_disable_custom_lvfilters', 0, '', $config["netflow_disable_custom_lvfilters"], true).'&nbsp;&nbsp;';
$table->data[7][0] = '<b>' . __('Netflow max lifetime') . '</b>'.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] = '<b>' . __('Name resolution for IP address') . '</b>' .
ui_print_help_tip (__("Resolve the IP addresses to get their hostnames."), true);
$table->data[8][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('netflow_get_ip_hostname', 1, '', $config["netflow_get_ip_hostname"], true).'&nbsp;&nbsp;';
$table->data[8][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('netflow_get_ip_hostname', 0, '', $config["netflow_get_ip_hostname"], true).'&nbsp;&nbsp;';
echo '<form id="netflow_setup" method="post">';
@ -71,10 +73,4 @@ echo '<div class="action-buttons" style="width:98%;">';
html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"');
echo '</div></form>';
?>
<script type="text/javascript">
$(document).ready (function () {
$("textarea").TextAreaResizer ();
});
</script>
?>

View File

@ -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')))

View File

@ -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);
}

View File

@ -218,8 +218,8 @@ function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){
$table->head = array ();
$table->head[0] = '<b>' . netflow_format_aggregate ($aggregate) . '</b>';
$table->head[1] = '<b>' . netflow_format_unit ($unit) . '</b>';
$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] = '<b>'.__('Total flows').'</b>';
$table->data[0][1] = format_numeric ($data['totalflows']);
$table->data[1][0] = '<b>'.__('Total bytes').'</b>';
$table->data[1][1] = format_numeric ($data['totalbytes']);
$table->data[2][0] = '<b>'.__('Total packets').'</b>';
$table->data[2][1] = format_numeric ($data['totalpackets']);
$table->data[3][0] = '<b>'.__('Average bits per second'). '</b>';
$table->data[3][1] = format_numeric ($data['avgbps']);
$table->data[4][0] = '<b>'.__('Average packets per second').'</b>';
$table->data[4][1] = format_numeric ($data['avgpps']);
$table->data[5][0] = '<b>'.__('Average bytes per packet').'</b>';
$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;
}

View File

@ -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':

View File

@ -0,0 +1,53 @@
<?php
// 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.
function include_javascript_d3 ($return = false) {
global $config;
static $is_include_javascript = false;
$output = '';
if (!$is_include_javascript) {
$is_include_javascript = true;
$output .= '<script type="text/javascript" src="' . $config['homeurl'] . 'include/javascript/d3.v3.js" charset="utf-8"></script>';
$output .= '<script type="text/javascript" src="' . $config['homeurl'] . 'include/graphs/pandora.d3.js" charset="utf-8"></script>';
}
if (!$return)
echo $output;
return $output;
}
function d3_relationship_graph ($elements, $matrix, $unit, $width = 700, $return = false) {
global $config;
$output = "<div id=\"chord_diagram\"></div>";
$output .= include_javascript_d3(true);
$output .= "<script language=\"javascript\" type=\"text/javascript\">
chordDiagram('#chord_diagram', $elements, $matrix, '$unit', $width);
</script>";
if (!$return)
echo $output;
return $output;
}
?>

View File

@ -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);
}