diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 662c4a2828..9da8a33702 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -16,7 +16,7 @@ function treeview_printModuleTable($id_module, $server_data = false) { global $config; - + if (empty($server_data)) { $server_name = ''; $server_id = ''; @@ -29,7 +29,7 @@ function treeview_printModuleTable($id_module, $server_data = false) { $console_url = $server_data['server_url'] . '/'; $url_hash = metaconsole_get_servers_url_hash($server_data); } - + require_once ($config["homedir"] . "/include/functions_agents.php"); require_once ($config["homedir"] . "/include/functions_graph.php"); include_graphs_dependencies($config['homedir'].'/'); @@ -38,23 +38,23 @@ function treeview_printModuleTable($id_module, $server_data = false) { enterprise_include_once ('meta/include/functions_modules_meta.php'); enterprise_include_once ('meta/include/functions_ui_meta.php'); enterprise_include_once ('meta/include/functions_metaconsole.php'); - + $filter["id_agente_modulo"] = $id_module; - + $module = db_get_row_filter ("tagente_modulo", $filter); - + if ($module === false) { ui_print_error_message(__('There was a problem loading module')); return; } - + if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) { - db_pandora_audit("ACL Violation", + db_pandora_audit("ACL Violation", "Trying to access Module Information"); require_once ("general/noaccess.php"); return; } - + $table = new StdClass(); $table->width = "100%"; $table->class = "databox data"; @@ -64,49 +64,49 @@ function treeview_printModuleTable($id_module, $server_data = false) { $table->head[] = __('Module'); $table->head_colspan[] = 2; $table->data = array(); - + //Module name if ($module["disabled"]) $cellName = "" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . ""; else $cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;"); - + $row = array(); $row['title'] = __('Name'); $row['data'] = "".$cellName.""; $table->data['name'] = $row; - + // Interval $row = array(); $row['title'] = __('Interval'); $row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true); $table->data['interval'] = $row; - + // Warning Min/Max if (modules_is_string_type($module['id_tipo_modulo'])) { $warning_status_str = __('Str.') . ': ' . $module['str_warning']; } else { - $warning_status_str = __('Min.') . ': ' . $module['min_warning'] . '
' . __('Max.') . ': ' . $module['max_warning']; + $warning_status_str = __('Min.') . ': ' . (float)$module['min_warning'] . '
' . __('Max.') . ': ' . (float)$module['max_warning']; } $row = array(); $row['title'] = __('Warning status'); $row['data'] = $warning_status_str; $table->data['watning_status'] = $row; - + // Critical Min/Max if (modules_is_string_type($module['id_tipo_modulo'])) { $critical_status_str = __('Str.') . ': ' . $module['str_warning']; } else { - $critical_status_str = __('Min.') . ': ' . $module['min_critical'] . '
' . __('Max.') . ': ' . $module['max_critical']; + $critical_status_str = __('Min.') . ': ' . (float)$module['min_critical'] . '
' . __('Max.') . ': ' . (float)$module['max_critical']; } $row = array(); $row['title'] = __('Critical status'); $row['data'] = $critical_status_str; $table->data['critical_status'] = $row; - + // Module group $module_group = modules_get_modulegroup_name($module['id_module_group']); @@ -114,27 +114,27 @@ function treeview_printModuleTable($id_module, $server_data = false) { $module_group = __('Not assigned'); else $module_group = __("$module_group"); - + $row = array(); $row['title'] = __('Module group'); $row['data'] = $module_group; $table->data['module_group'] = $row; - + // Description $row = array(); $row['title'] = __('Description'); $row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]'); $table->data['description'] = $row; - + // Tags $tags = tags_get_module_tags($module['id_agente_modulo']); - + if (empty($tags)) { $tags = array(); } - + $user_tags = tags_get_user_tags($config["id_user"]); - + foreach ($tags as $k => $v) { if (!array_key_exists($v, $user_tags)) { //only show user's tags. unset($tags[$k]); @@ -148,53 +148,53 @@ function treeview_printModuleTable($id_module, $server_data = false) { } } } - + if (empty($tags)) { $tags = '' . __('N/A') . ''; } else { $tags = implode(', ' , $tags); } - + $row = array(); $row['title'] = __('Tags'); $row['data'] = $tags; $table->data['tags'] = $row; - + // Data $last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC'))); if (is_numeric($last_data["datos"])) $data = "" . format_numeric($last_data["datos"]) . ""; else $data = "" . substr(io_safe_output($last_data['datos']),0,12) . ""; - + if (!empty($last_data['utimestamp'])) { $last_data_str = $data; - + if ($module['unit'] != '') { $last_data_str .= " "; $last_data_str .= '('.$module['unit'].')'; } - + $last_data_str .= " "; $last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px')); } else { $last_data_str = '' . __('No data') . ''; } - + $row = array(); $row['title'] = __('Last data'); $row['data'] = $last_data_str; $table->data['last_data'] = $row; - + //End of table html_print_table($table); - + $id_group = agents_get_agent_group($module['id_agente']); - $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); - $agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']); - + $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); + $agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']); + if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) { // Actions table echo '
'; @@ -211,13 +211,13 @@ function treeview_printModuleTable($id_module, $server_data = false) { html_print_input_text('id_agent', $module['id_agente']); html_print_input_text('server_name', $server_name); echo '
'; - + return; } function treeview_printAlertsTable($id_module, $server_data = array()) { global $config; - + if (empty($server_data)) { $server_name = ''; $server_id = ''; @@ -230,7 +230,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { $console_url = $server_data['server_url'] . '/'; $url_hash = metaconsole_get_servers_url_hash($server_data); } - + $module_alerts = alerts_get_alerts_agent_module($id_module); $module_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_module); $agent_id = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_module); @@ -240,7 +240,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { ui_print_error_message(__('There was a problem loading alerts')); return; } - + $table = new StdClass(); $table->width = "100%"; $table->style = array(); @@ -254,13 +254,13 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { $row['template'] = __('Template'); $row['actions'] = __('Actions'); $table->data['titles'] = $row; - + foreach($module_alerts as $module_alert) { //Template name $template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']); - + $actions = alerts_get_alert_agent_module_actions($module_alert['id']); - + if (empty($actions)) { $actions_list = ''.__('N/A').''; } @@ -281,7 +281,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { } html_print_table($table); - + if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) { // Actions table echo '
'; @@ -294,7 +294,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { function treeview_printTable($id_agente, $server_data = array()) { global $config; - + if (empty($server_data)) { $server_name = ''; $server_id = ''; @@ -307,31 +307,31 @@ function treeview_printTable($id_agente, $server_data = array()) { $console_url = $server_data['server_url'] . '/'; $url_hash = metaconsole_get_servers_url_hash($server_data); } - + require_once ($config["homedir"] . "/include/functions_agents.php"); require_once ($config["homedir"] . '/include/functions_graph.php'); require_once ($config['homedir'] . '/include/functions_groups.php'); require_once ($config['homedir'] . '/include/functions_gis.php'); enterprise_include_once ('meta/include/functions_ui_meta.php'); include_graphs_dependencies(); - + $strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']); - + $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); - + if ($is_extra === ENTERPRISE_NOT_HOOK) { $is_extra = false; } - + if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR") && !$is_extra) { - db_pandora_audit("ACL Violation", + db_pandora_audit("ACL Violation", "Trying to access Agent General Information"); require_once ("general/noaccess.php"); return; } - + $agent = db_get_row ("tagente", "id_agente", $id_agente); - + if ($agent === false) { ui_print_error_message(__('There was a problem loading agent')); return; @@ -352,9 +352,9 @@ function treeview_printTable($id_agente, $server_data = array()) { else { $cellName = ''; } - + $cellName .= ui_print_agent_name ($agent["id_agente"], true, 500, "text-transform: uppercase;", true, $console_url, $url_hash, false, can_user_access_node ()); - + if ($agent['disabled']) { $cellName .= ui_print_help_tip(__('Disabled'), true) . ""; } @@ -368,38 +368,38 @@ function treeview_printTable($id_agente, $server_data = array()) { $ips = array(); $addresses = agents_get_addresses ($id_agente); $address = agents_get_address($id_agente); - + foreach ($addresses as $k => $add) { if ($add == $address) { unset($addresses[$k]); } } - + if (!empty($addresses)) { $address .= ui_print_help_tip(__('Other IP addresses').':
'.implode('
',$addresses), true); } - + $row = array(); $row['title'] = __('IP Address'); $row['data'] = $address; $table->data['address'] = $row; - + // Agent Interval $row = array(); $row['title'] = __('Interval'); $row['data'] = human_time_description_raw ($agent["intervalo"]); $table->data['interval'] = $row; - + // Comments $row = array(); $row['title'] = __('Description'); $row['data'] = $agent["comentarios"]; $table->data['description'] = $row; - + // Last contact $last_contact = ui_print_timestamp($agent["ultimo_contacto"], true); - if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { + if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { $last_remote_contact = __('Never'); } else { @@ -410,15 +410,15 @@ function treeview_printTable($id_agente, $server_data = array()) { $row['title'] = __('Last contact') . " / " . __('Remote'); $row['data'] = "$last_contact / $last_remote_contact"; $table->data['contact'] = $row; - + // Next contact (agent) $progress = agents_get_next_contact($id_agente); - + $row = array(); $row['title'] = __('Next agent contact'); $row['data'] = progress_bar($progress, 150, 20); $table->data['next_contact'] = $row; - + //End of table $agent_table = html_print_table($table, true); @@ -432,11 +432,11 @@ function treeview_printTable($id_agente, $server_data = array()) { $agent_table .= $go_to_agent; } $agent_table .= "
"; - + // print agent data toggle ui_toggle($agent_table, __('Agent data'), '', false); - + // Advanced data $table = new StdClass(); $table->width = "100%"; @@ -450,11 +450,11 @@ function treeview_printTable($id_agente, $server_data = array()) { $row['title'] = __('Agent Version'); $row['data'] = $agent["agent_version"]; $table->data['agent_version'] = $row; - + // Position Information if ($config['activate_gis']) { $dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']); - + if ($dataPositionAgent !== false) { $position = ''; if ($dataPositionAgent['description'] != "") @@ -469,7 +469,7 @@ function treeview_printTable($id_agente, $server_data = array()) { $table->data['agent_position'] = $row; } } - + // If the url description is setted if ($agent['url_address'] != '') { $row = array(); @@ -477,7 +477,7 @@ function treeview_printTable($id_agente, $server_data = array()) { $row['data'] = ''.$agent["url_address"].''; $table->data['agent_address'] = $row; } - + // Timezone Offset if ($agent['timezone_offset'] != 0) { $row = array(); @@ -485,7 +485,7 @@ function treeview_printTable($id_agente, $server_data = array()) { $row['data'] = $agent["timezone_offset"]; $table->data['agent_timezone_offset'] = $row; } - + // Custom fields $fields = db_get_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1)); if ($fields === false) { @@ -502,36 +502,36 @@ function treeview_printTable($id_agente, $server_data = array()) { } } } - + //End of table advanced $table_advanced = html_print_table($table, true); $table_advanced .= "
"; - + ui_toggle($table_advanced, __('Advanced information')); - + // Blank space below title, DONT remove this, this // Breaks the layout when Flash charts are enabled :-o //echo '
 
'; - + if ($config["agentaccess"]) { $access_graph = '
'; $access_graph .= graphic_agentaccess($id_agente, 290, 110, SECONDS_1DAY, true); $access_graph .= '

'; - + ui_toggle($access_graph, __('Agent access rate (24h)')); } - + $events_graph = '
'; $events_graph .= graph_graphic_agentevents ($id_agente, 290, 15, SECONDS_1DAY, '', true); $events_graph .= '

'; - + ui_toggle($events_graph, __('Events (24h)')); - + // Table network interfaces $network_interfaces_by_agents = agents_get_network_interfaces(array($agent)); - + $network_interfaces = array(); if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agents[$id_agente])) { $network_interfaces = $network_interfaces_by_agents[$id_agente]['interfaces']; @@ -547,11 +547,11 @@ function treeview_printTable($id_agente, $server_data = array()) { $table->style['interface_graph'] = 'width: 20px;'; $table->head = array(); $table->data = array(); - + foreach ($network_interfaces as $interface_name => $interface) { if (!empty($interface['traffic'])) { $permission = false; - + if ($strict_user) { if (tags_check_acl_by_module($interface['traffic']['in'], $config['id_user'], 'RR') === true && tags_check_acl_by_module($interface['traffic']['out'], $config['id_user'], 'RR') === true) @@ -560,7 +560,7 @@ function treeview_printTable($id_agente, $server_data = array()) { else { $permission = check_acl($config['id_user'], $agent["id_grupo"], "RR"); } - + if ($permission) { $params = array( 'interface_name' => $interface_name, @@ -568,16 +568,16 @@ function treeview_printTable($id_agente, $server_data = array()) { 'traffic_module_in' => $interface['traffic']['in'], 'traffic_module_out' => $interface['traffic']['out'] ); - + 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 = "" . html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . ""; } @@ -588,7 +588,7 @@ function treeview_printTable($id_agente, $server_data = array()) { else { $graph_link = ""; } - + $data = array(); $data['interface_name'] = "" . $interface_name . ""; $data['interface_status'] = $interface['status_image']; @@ -603,7 +603,7 @@ function treeview_printTable($id_agente, $server_data = array()) { ui_toggle($table_interfaces, __('Interface information') . ' (SNMP)'); } - + return; }