diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index f6f6ec6a7a..f97fc64855 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -847,30 +847,34 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) $permission = check_acl($config['id_user'], $agent['id_grupo'], 'RR'); if ($permission) { - $params = [ - 'interface_name' => $interface_name, - 'agent_id' => $id_agente, - 'traffic_module_in' => $interface['traffic']['in'], - 'traffic_module_out' => $interface['traffic']['out'], - ]; + if ($interface['traffic']['in'] > 0 && $interface['traffic']['out'] > 0) { + $params = [ + 'interface_name' => $interface_name, + 'agent_id' => $id_agente, + 'traffic_module_in' => $interface['traffic']['in'], + 'traffic_module_out' => $interface['traffic']['out'], + ]; - if (defined('METACONSOLE') && !empty($server_id)) { - $params['server'] = $server_id; + if (defined('METACONSOLE') && !empty($server_id)) { + $params['server'] = $server_id; + } + + $params_json = json_encode($params); + $params_encoded = base64_encode($params_json); + $url = ui_get_full_url('operation/agentes/interface_traffic_graph_win.php', false, false, false); + $graph_url = "$url?params=$params_encoded"; + $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); + + $graph_link = ""; + $graph_link .= html_print_image( + 'images/chart_curve.png', + true, + ['title' => __('Interface traffic')] + ); + $graph_link .= ''; + } else { + $graph_link = __('inOctets and outOctets must be enabled.'); } - - $params_json = json_encode($params); - $params_encoded = base64_encode($params_json); - $url = ui_get_full_url('operation/agentes/interface_traffic_graph_win.php', false, false, false); - $graph_url = "$url?params=$params_encoded"; - $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); - - $graph_link = ""; - $graph_link .= html_print_image( - 'images/chart_curve.png', - true, - ['title' => __('Interface traffic')] - ); - $graph_link .= ''; } else { $graph_link = ''; } diff --git a/pandora_console/operation/agentes/interface_view.functions.php b/pandora_console/operation/agentes/interface_view.functions.php index ca19a26df9..8136f09fb7 100644 --- a/pandora_console/operation/agentes/interface_view.functions.php +++ b/pandora_console/operation/agentes/interface_view.functions.php @@ -539,8 +539,10 @@ function print_table( $select_if_usage_module_data_out_down ); - $table->head[8] = __('Last data'); - $table->head[8] .= ui_get_sorting_arrows( + $table->head[8] = __('Graph'); + + $table->head[9] = __('Last data'); + $table->head[9] .= ui_get_sorting_arrows( $last_data.'up', $last_data.'down', $select_if_last_data_up, @@ -684,26 +686,30 @@ function print_table( $permission = check_acl_one_of_groups($config['id_user'], $all_groups, 'RR'); if ($permission) { - $params = [ - 'interface_name' => $agent_interfaces['if_name'], - 'agent_id' => $agent_interfaces['agent_id'], - 'traffic_module_in' => $agent_interfaces['traffic']['in'], - 'traffic_module_out' => $agent_interfaces['traffic']['out'], - ]; - $params_json = json_encode($params); - $params_encoded = base64_encode($params_json); - $win_handle = dechex(crc32($interface['status_module_id'].$agent_interfaces['if_name'])); - $graph_link = ""; - $graph_link .= html_print_image( - 'images/chart.png', - true, - [ - 'title' => __('Interface traffic'), - 'class' => 'invert_filter', - ] - ).''; + if ($agent_interfaces['traffic']['in'] > 0 && $agent_interfaces['traffic']['out'] > 0) { + $params = [ + 'interface_name' => $agent_interfaces['if_name'], + 'agent_id' => $agent_interfaces['agent_id'], + 'traffic_module_in' => $agent_interfaces['traffic']['in'], + 'traffic_module_out' => $agent_interfaces['traffic']['out'], + ]; + $params_json = json_encode($params); + $params_encoded = base64_encode($params_json); + $win_handle = dechex(crc32($interface['status_module_id'].$agent_interfaces['if_name'])); + $graph_link = ""; + $graph_link .= html_print_image( + 'images/chart.png', + true, + [ + 'title' => __('Interface traffic'), + 'class' => 'invert_filter', + ] + ).''; + } else { + $graph_link = __('inOctets and outOctets must be enabled.'); + } } else { $graph_link = ''; } @@ -715,8 +721,8 @@ function print_table( $table_data[$loop_index]['if_out_octets'] = ($ifOutOctets['datos'] === null) ? __('N/A') : $ifOutOctets['datos']; $table_data[$loop_index]['if_usage_module_data_in'] = ($usage_module_data_in['datos'] === null) ? __('N/A') : $usage_module_data_in['datos']; $table_data[$loop_index]['if_usage_module_data_out'] = ($usage_module_data_out['datos'] === null) ? __('N/A') : $usage_module_data_out['datos']; + $table_data[$loop_index]['if_graph'] = $graph_link; $table_data[$loop_index]['if_last_data'] = human_time_comparation($agent_interfaces['last_contact']); - $table_data[$loop_index]['if_last_data'] .= $graph_link; $loop_index++; } diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index e35ba182a1..fe99d52e50 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -1265,16 +1265,20 @@ if (is_ajax() === true) { $permission = check_acl($config['id_user'], $agent['id_grupo'], 'RR'); if ($permission) { - $params = [ - 'interface_name' => $interface_name, - 'agent_id' => $id_agent, - 'traffic_module_in' => $interface['traffic']['in'], - 'traffic_module_out' => $interface['traffic']['out'], - ]; - $params_json = json_encode($params); - $params_encoded = base64_encode($params_json); - $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); - $graph_link = "".html_print_image('images/chart_curve.png', true, ['title' => __('Interface traffic')]).''; + if ($interface['traffic']['in'] > 0 && $interface['traffic']['out'] > 0) { + $params = [ + 'interface_name' => $interface_name, + 'agent_id' => $id_agent, + 'traffic_module_in' => $interface['traffic']['in'], + 'traffic_module_out' => $interface['traffic']['out'], + ]; + $params_json = json_encode($params); + $params_encoded = base64_encode($params_json); + $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); + $graph_link = "".html_print_image('images/chart_curve.png', true, ['title' => __('Interface traffic')]).''; + } else { + $graph_link = __('inOctets and outOctets must be enabled.'); + } } else { $graph_link = ''; }