Improvements on the combined graphs
* pandora_console/operation/agentes/interface_traffic_graph_win.php: Modified the graph function call. Modified the refresh time. * pandora_console/include/functions_graph.php: Modified the function "graphic_combined_module". Now is possible to set the items name and choose which values will appear on the items list. * pandora_console/include/functions_custom_graphs.php: Added new parameters to the function "custom_graphs_print" to call the function "graphic_combined_module".
This commit is contained in:
parent
016a353e8e
commit
eb590aae72
|
@ -145,14 +145,25 @@ function custom_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGr
|
|||
* @param $height Height of the returning image.
|
||||
* @param $width Width of the returning image.
|
||||
* @param $period Period of time to get data in seconds.
|
||||
* @param $stacked Wheter the graph is stacked or not.
|
||||
* @param $stacked Whether the graph is stacked or not.
|
||||
* @param $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param $date Date to start printing the graph
|
||||
* @param bool Wether to show an image instead a interactive chart or not
|
||||
* @param string Background color
|
||||
* @param array List of names for the items. Should have the same size as the module list.
|
||||
* @param bool Show the last value of the item on the list.
|
||||
* @param bool Show the max value of the item on the list.
|
||||
* @param bool Show the min value of the item on the list.
|
||||
* @param bool Show the average value of the item on the list.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
|
||||
function custom_graphs_print($id_graph, $height, $width, $period,
|
||||
$stacked = null, $return = false, $date = 0, $only_image = false,
|
||||
$background_color = 'white', $modules_param = array(), $homeurl = '') {
|
||||
$background_color = 'white', $modules_param = array(), $homeurl = '',
|
||||
$name_list = array(), $show_last = true, $show_max = true,
|
||||
$show_min = true, $show_avg = true) {
|
||||
|
||||
global $config;
|
||||
|
||||
|
@ -214,7 +225,12 @@ function custom_graphs_print($id_graph, $height, $width, $period,
|
|||
1,
|
||||
false,
|
||||
false,
|
||||
$background_color);
|
||||
$background_color,
|
||||
$name_list,
|
||||
$show_last,
|
||||
$show_max,
|
||||
$show_min,
|
||||
$show_avg);
|
||||
|
||||
if ($return)
|
||||
return $output;
|
||||
|
|
|
@ -854,6 +854,11 @@ function graph_get_formatted_date($timestamp, $format1, $format2) {
|
|||
* @param int Date to start of getting info.
|
||||
* @param mixed If is a projection graph this parameter will be module data with prediction data (the projection)
|
||||
* or false in other case.
|
||||
* @param array List of names for the items. Should have the same size as the module list.
|
||||
* @param bool Show the last value of the item on the list.
|
||||
* @param bool Show the max value of the item on the list.
|
||||
* @param bool Show the min value of the item on the list.
|
||||
* @param bool Show the average value of the item on the list.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
|
@ -861,7 +866,9 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
$width, $height, $title, $unit_name, $show_events = 0,
|
||||
$show_alerts = 0, $pure = 0, $stacked = 0, $date = 0,
|
||||
$only_image = false, $homeurl = '', $ttl = 1, $projection = false,
|
||||
$prediction_period = false, $background_color = 'white') {
|
||||
$prediction_period = false, $background_color = 'white',
|
||||
$name_list = array(), $show_last = true, $show_max = true,
|
||||
$show_min = true, $show_avg = true) {
|
||||
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
@ -971,23 +978,28 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
if ($projection != false && $i != 0) {
|
||||
$agent_module_id = $module_list[0];
|
||||
|
||||
//Get and process agent name
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_name ($agent_module_id));
|
||||
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
|
||||
if (!empty($name_list) && isset($name_list[$i])) {
|
||||
$module_name_list[$i] = $name_list[$i];
|
||||
}
|
||||
else {
|
||||
//Get and process agent name
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_name ($agent_module_id));
|
||||
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
|
||||
|
||||
|
||||
$agent_id = agents_get_agent_id ($agent_name);
|
||||
|
||||
|
||||
//Get and process module name
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name ($agent_module_id));
|
||||
$module_name = sprintf(__("projection for %s"), $module_name);
|
||||
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
|
||||
|
||||
$module_name_list[$i] = $agent_name ." / ". $module_name;
|
||||
}
|
||||
|
||||
|
||||
$agent_id = agents_get_agent_id ($agent_name);
|
||||
|
||||
|
||||
//Get and process module name
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name ($agent_module_id));
|
||||
$module_name = sprintf(__("projection for %s"), $module_name);
|
||||
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
|
||||
|
||||
|
||||
$module_name_list[$i] = $agent_name ." / ". $module_name;
|
||||
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
|
@ -995,20 +1007,26 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
else {
|
||||
$agent_module_id = $module_list[$i];
|
||||
|
||||
//Get and process agent name
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_name ($agent_module_id));
|
||||
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
|
||||
|
||||
|
||||
$agent_id = agents_get_agent_id ($agent_name);
|
||||
|
||||
//Get and process module name
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name ($agent_module_id));
|
||||
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
|
||||
|
||||
$module_name_list[$i] = $agent_name . " / " . $module_name;
|
||||
if (!empty($name_list) && isset($name_list[$i])) {
|
||||
$module_name_list[$i] = $name_list[$i];
|
||||
}
|
||||
else {
|
||||
//Get and process agent name
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_name ($agent_module_id));
|
||||
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
|
||||
|
||||
|
||||
$agent_id = agents_get_agent_id ($agent_name);
|
||||
|
||||
//Get and process module name
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name ($agent_module_id));
|
||||
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
|
||||
|
||||
$module_name_list[$i] = $agent_name . " / " . $module_name;
|
||||
}
|
||||
|
||||
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
|
||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
|
@ -1199,18 +1217,22 @@ function graphic_combined_module ($module_list, $weight_list, $period,
|
|||
|
||||
$graph_stats = get_graph_statistics($graph_values[$i]);
|
||||
|
||||
$min = $graph_stats['min'];
|
||||
$max = $graph_stats['max'];
|
||||
$avg = $graph_stats['avg'];
|
||||
$last = $graph_stats['last'];
|
||||
$min = number_format($graph_stats['min'], 2);
|
||||
$max = number_format($graph_stats['max'], 2);
|
||||
$avg = number_format($graph_stats['avg'], 2);
|
||||
$last = number_format($graph_stats['last'], 2);
|
||||
$units = modules_get_unit($agent_module_id);
|
||||
|
||||
if ($projection == false or ($projection != false and $i == 0)) {
|
||||
$module_name_list[$i] .= ": " .
|
||||
__('Last') . ": $last $units; " .
|
||||
__("Max") . ": $max $units; " .
|
||||
__("Min") . ": $min $units; " .
|
||||
__("Avg") . ": $avg";
|
||||
$module_name_list[$i] .= ": ";
|
||||
if ($show_last)
|
||||
$module_name_list[$i] .= __('Last') . ": $last $units; ";
|
||||
if ($show_max)
|
||||
$module_name_list[$i] .= __("Max") . ": $max $units; ";
|
||||
if ($show_min)
|
||||
$module_name_list[$i] .= __("Min") . ": $min $units; ";
|
||||
if ($show_avg)
|
||||
$module_name_list[$i] .= __("Avg") . ": $avg $units";
|
||||
}
|
||||
|
||||
if ($weight_list[$i] != 1) {
|
||||
|
|
|
@ -60,8 +60,8 @@ $params = json_decode($params_json, true);
|
|||
$interface_name = (string) $params['interface_name'];
|
||||
$agent_id = (int) $params['agent_id'];
|
||||
$interface_traffic_modules = array(
|
||||
'in' => (int) $params['traffic_module_in'],
|
||||
'out' => (int) $params['traffic_module_out']
|
||||
__('In') => (int) $params['traffic_module_in'],
|
||||
__('Out') => (int) $params['traffic_module_out']
|
||||
);
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
@ -69,7 +69,7 @@ $interface_traffic_modules = array(
|
|||
<head>
|
||||
<?php
|
||||
// Parsing the refresh before sending any header
|
||||
$refresh = (int) get_parameter('refresh', SECONDS_10MINUTES);
|
||||
$refresh = (int) get_parameter('refresh', SECONDS_5MINUTES);
|
||||
if ($refresh > 0) {
|
||||
$query = ui_get_url_refresh(false);
|
||||
|
||||
|
@ -135,8 +135,19 @@ $interface_traffic_modules = array(
|
|||
else
|
||||
echo '<div style="margin-left: 50px; padding-top: 10px;">';
|
||||
|
||||
$modules = array($interface_traffic_modules['in'], $interface_traffic_modules['out']);
|
||||
custom_graphs_print(0, $height, $width, $period, null, false, $date, false, 'white', $modules, $config['homeurl']);
|
||||
custom_graphs_print(0,
|
||||
$height,
|
||||
$width,
|
||||
$period,
|
||||
null,
|
||||
false,
|
||||
$date,
|
||||
false,
|
||||
'white',
|
||||
array_values($interface_traffic_modules),
|
||||
$config['homeurl'],
|
||||
array_keys($interface_traffic_modules),
|
||||
false);
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
|
Loading…
Reference in New Issue