id = 'agent_details_main'; $table_agent->width = '100%'; $table_agent->cellspacing = 4; $table_agent->cellpadding = 4; $table_agent->class = 'databox_frame'; $table_agent->style[0] = 'width: 16px; text-align:center; padding: 0px;'; $table_agent->style[5] = 'width: 16px; text-align:center; padding: 0px;'; $table_agent->styleTable = 'padding:0px;'; $table_agent->data = array(); $data = array(); $agent_name = ui_print_agent_name ($agent["id_agente"], true, 500, "font-size: medium;", true); if ($agent['disabled']) { $agent_name = "" . $agent_name . "" . ui_print_help_tip(__('Disabled'), true); } else if ($agent['quiet']) { $agent_name = "" . $agent_name . " " . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . ""; } else { $agent_name = $agent_name; } $data[0] = ui_print_group_icon ($agent["id_grupo"], true); $table_agent->cellstyle[count($table_agent->data)][0] = 'width: 16px; text-align:center; padding: 0px;'; $data[2] = $agent_name; $table_agent->colspan[count($table_agent->data)][2] = 3; $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 100px; word-break: break-all;'; $status_img = agents_detail_view_status_img ($agent["critical_count"], $agent["warning_count"], $agent["unknown_count"], $agent["total_count"], $agent["notinit_count"]); $data[5] = $status_img; $table_agent->data[] = $data; $table_agent->rowclass[] = ''; $data = array(); //$data[0] = reporting_tiny_stats ($agent, true, 'agent', '
'); //$table_agent->rowspan[count($table_agent->data)][0] = 6; $data[0] = '
'; $data[0] .= graph_agent_status ($id_agente, 150, 120, true); $data[0] .= '
' . reporting_tiny_stats ($agent, true); $data[0] .= ui_print_help_tip(__('Agent statuses are re-calculated by the server, they are not shown in real time.'), true); $data[0] .= '
'; $table_agent->rowspan[count($table_agent->data)][0] = 6; $table_agent->colspan[count($table_agent->data)][0] = 2; $table_agent->cellstyle[count($table_agent->data)][0] = 'width: 150px; text-align:center; padding: 0px; vertical-align: top;'; $data[2] = ui_print_os_icon ($agent["id_os"], false, true, true, false, false, false, array('title' => __('OS') . ': ' . get_os_name ($agent["id_os"]))); $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px; vertical-align: top;'; $data[3] = empty($agent["os_version"]) ? get_os_name ((int) $agent["id_os"]) : $agent["os_version"]; $table_agent->colspan[count($table_agent->data)][3] = 2; $table_agent->data[] = $data; $table_agent->rowclass[] = ''; $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($address)) { $data = array(); $data[2] = html_print_image('images/world.png', true, array('title' => __('IP address'))); $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px; vertical-align: top;'; $data[3] = ''; $data[3] .= empty($address) ? '' . __('N/A') . '' : $address; $data[3] .= ''; $table_agent->colspan[count($table_agent->data)][3] = 2; $table_agent->data[] = $data; $table_agent->rowclass[] = ''; } $data = array(); $data[2] = html_print_image('images/version.png', true, array('title' => __('Agent Version'))); $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px; vertical-align: top;'; $data[3] = ''; $data[3] .= empty($agent["agent_version"]) ? '' . __('N/A') . '' : $agent["agent_version"]; $data[3] .= ''; $table_agent->colspan[count($table_agent->data)][3] = 2; $table_agent->data[] = $data; $table_agent->rowclass[] = ''; $data = array(); $data[2] = html_print_image('images/default_list.png', true, array('title' => __('Description'))); $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px; vertical-align: top;'; $data[3] = ''; $data[3] .= empty($agent["comentarios"]) ? '' . __('N/A') . '' : $agent["comentarios"]; $data[3] .= ''; $table_agent->colspan[count($table_agent->data)][3] = 2; $table_agent->data[] = $data; $table_agent->rowclass[] = ''; // END: TABLE AGENT BUILD // START: TABLE CONTACT BUILD $table_contact->id = 'agent_contact_main'; $table_contact->width = '100%'; $table_contact->cellspacing = 4; $table_contact->cellpadding = 4; $table_contact->class = 'databox'; $table_contact->style[0] = 'width: 30%;'; $table_contact->style[1] = 'width: 70%;'; $table_contact->head[0] = ' ' . __('Agent contact') . ''; $table_contact->head_colspan[0] = 2; $data = array(); $data[0] = '' . __('Interval') . ''; $data[1] = human_time_description_raw ($agent["intervalo"]); $table_contact->data[] = $data; $data = array(); $data[0] = '' . __('Last contact') . ' / ' . __('Remote') . ''; $data[1] = ui_print_timestamp ($agent["ultimo_contacto"], true); $data[1] .= " / "; if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { $data[1] .= __('Never'); } else { $data[1] .= $agent["ultimo_contacto_remoto"]; } $table_contact->data[] = $data; $data[0] = '' . __('Next contact') . ''; $progress = agents_get_next_contact($id_agente); $data[1] = progress_bar($progress, 200, 20); if ($progress > 100) { $data[1] .= clippy_context_help("agent_out_of_limits"); } $table_contact->data[] = $data; // END: TABLE CONTACT BUILD // START: TABLE DATA BUILD $table_data->id = 'agent_data_main'; $table_data->width = '100%'; $table_data->cellspacing = 4; $table_data->cellpadding = 4; $table_data->class = 'databox'; $table_data->style[0] = 'width: 30%;'; $table_data->style[1] = 'width: 70%;'; $table_data->head[0] = ' ' . __('Agent info') . ''; $table_data->head_colspan[0] = 2; $data = array(); $data[0] = '' . __('Group') . ''; $data[1] = ''.groups_get_name ($agent["id_grupo"]).''; $table_data->data[] = $data; if (!empty($addresses)) { $data = array(); $data[0] = '' . __('Other IP addresses') . ''; $data[1] = implode('
',$addresses); $table_data->data[] = $data; } $data = array(); $data[0] = '' . __('Parent') . ''; if ($agent["id_parent"] == 0) { $data[1] = '' . __('N/A') . ''; } else { $data[1] = ''.agents_get_name ($agent["id_parent"]).''; } $table_data->data[] = $data; $has_remote_conf = enterprise_hook('config_agents_has_remote_configuration',array($agent["id_agente"])); if(enterprise_installed()) { $data = array(); $data[0] = '' . __('Remote configuration') . ''; if (!$has_remote_conf) { $data[1] = __('Disabled'); } else { $data[1] = __('Enabled'); } $table_data->data[] = $data; } if ($config['activate_gis'] || $agent['url_address'] != '') { $data = array(); // Position Information if ($config['activate_gis']) { $dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']); $data[0] = '' . __('Position (Long, Lat)') . ''; if ($dataPositionAgent === false) { $data[1] = __('There is no GIS data.'); } else { $data[1] = ''; if ($dataPositionAgent['description'] != "") $data[1] .= $dataPositionAgent['description']; else $data[1] .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude']; $data[1] .= ""; } $table_data->data[] = $data; } // If the url description is setted if ($agent['url_address'] != '') { $data = array(); $data[0] = '' . __('Url address') . ''; $data[1] = '' . $agent["url_address"] . ''; $table_data->data[] = $data; } } // Timezone Offset if ($agent['timezone_offset'] != 0) { $data = array(); $data[0] = '' . __('Timezone Offset') . ''; $data[1] = $agent["timezone_offset"]; $table->data[] = $data; } // Custom fields $fields = db_get_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1)); if ($fields === false) { $fields = array (); } foreach ($fields as $field) { $data = array(); $data[0] = '' . $field['name'] . ui_print_help_tip (__('Custom field'), true) . ''; $custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente)); if ($custom_value === false || $custom_value == '') { $custom_value = ''.__('N/A').''; } $data[1] = $custom_value; $table_data->data[] = $data; } // END: TABLE DATA BUILD // START: TABLE INCIDENTS $last_incident = db_get_row_sql("SELECT * FROM tincidencia WHERE estado IN (0,1) AND id_agent=$id_agente ORDER BY actualizacion DESC"); if ($last_incident != false) { $table_incident->id = 'agent_incident_main'; $table_incident->width = '100%'; $table_incident->cellspacing = 4; $table_incident->cellpadding = 4; $table_incident->class = 'databox'; $table_incident->style[0] = 'width: 30%;'; $table_incident->style[1] = 'width: 70%;'; $table_incident->head[0] = ' ' . '' .__('Active incident on this agent') .''. ''; $table_incident->head_colspan[0] = 2; $data = array(); $data[0] = '' . __('Author') . ''; $data[1] = $last_incident["id_creator"]; $table_incident->data[] = $data; $data = array(); $data[0] = '' . __('Title') . ''; $data[1] = '' .$last_incident["titulo"].''; $table_incident->data[] = $data; $data = array(); $data[0] = '' . __('Timestamp') . ''; $data[1] = $last_incident["inicio"]; $table_incident->data[] = $data; $data = array(); $data[0] = '' . __('Priority') . ''; $data[1] = incidents_print_priority_img ($last_incident["prioridad"], true); $table_incident->data[] = $data; } // END: TABLE INCIDENTS // START: TABLE INTERFACES $columns = array( "id_agente_modulo", "nombre", "descripcion", "ip_target" ); $filter = array( "id_agente" => $id_agente, "id_tipo_modulo" => (int)db_get_value("id_tipo", "ttipo_modulo", "nombre", "remote_snmp_proc"), "disabled" => 0 ); $modules = agents_get_modules($id_agente, $columns, $filter, true, false); $interfaces = array(); if (!empty($modules)) { foreach ($modules as $key => $module) { // Trying to get the interface name from the module name if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) { if ($matches[1]) { $interface_name = $matches[1]; $interface_name_escaped = str_replace("/", "\/", $interface_name); if (!isset($interfaces[$interface_name]) || (isset($interfaces[$interface_name]) && preg_match ("/^ifOperStatus_$interface_name_escaped$/i", (string)$module['nombre'], $matches))) { $interfaces[$interface_name] = $module; } } } } unset($modules); if (!empty($interfaces)) { $table_interface = new stdClass(); $table_interface->id = 'agent_interface_info'; $table_interface->class = 'databox'; $table_interface->width = '100%'; $table_interface->style = array(); $table_interface->style['interface_status'] = 'width: 30px;'; $table_interface->style['interface_graph'] = 'width: 20px;'; $table_interface->head = array(); $options = array( "class" => "closed", "style" => "vertical-align:middle; cursor:pointer;" ); $table_interface->head[0] = html_print_image("images/go.png", true, $options) . "  "; $table_interface->head[0] .= '' . __('Interface information') .' (SNMP)'; $table_interface->head_colspan = array(); $table_interface->head_colspan[0] = 5; $table_interface->data = array(); foreach ($interfaces as $interface_name => $module) { $interface_name_escaped = str_replace("/", "\/", $interface_name); $module_id = $module['id_agente_modulo']; $db_status = modules_get_agentmodule_status($module_id); $module_value = modules_get_last_value ($module_id); modules_get_status($module_id, $db_status, $module_value, $status, $title); $status = ui_print_status_image($status, $title, true); $ip_target = "--"; // Trying to get something like an IP from the description if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", (string)$module['descripcion'], $matches) || preg_match ("/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]| (2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", (string)$module['descripcion'], $matches)) { if ($matches[0]) { $ip_target = $matches[0]; } } $mac = "--"; // Trying to get something like a mac from the description if (preg_match ("/([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})/i", (string)$module['descripcion'], $matches)) { if ($matches[0]) { $mac = $matches[0]; } } // Get the ifInOctets and ifOutOctets modules of the interface $columns = array( "id_agente_modulo", "nombre" ); $interface_traffic_modules = agents_get_modules($id_agente, $columns, "nombre LIKE 'if%Octets_$interface_name'"); if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) { $interface_traffic_modules_aux = array('in' => '', 'out' => ''); foreach ($interface_traffic_modules as $interface_traffic_module) { $interface_name_escaped = str_replace("/", "\/", $interface_name); if (preg_match ("/^if(.+)Octets_$interface_name_escaped$/i", $interface_traffic_module['nombre'], $matches)) { if (strtolower($matches[1]) == 'in') { $interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo']; } elseif (strtolower($matches[1]) == 'out') { $interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo']; } } } if (!empty($interface_traffic_modules_aux['in']) && !empty($interface_traffic_modules_aux['out'])) { $interface_traffic_modules = $interface_traffic_modules_aux; } else { $interface_traffic_modules = false; } } else { $interface_traffic_modules = false; } if ($interface_traffic_modules != false) { $params = array( 'interface_name' => $interface_name, 'agent_id' => $id_agente, 'traffic_module_in' => $interface_traffic_modules_aux['in'], 'traffic_module_out' => $interface_traffic_modules_aux['out'] ); $params_json = json_encode($params); $params_encoded = base64_encode($params_json); $win_handle = dechex(crc32($module_id.$interface_name)); $graph_link = "" . html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . ""; } else { $graph_link = ""; } $data = array(); $data['interface_name'] = "" . $interface_name . ""; $data['interface_status'] = $status; $data['interface_graph'] = $graph_link; $data['interface_ip'] = $ip_target; $data['interface_mac'] = $mac; $table_interface->data[] = $data; } } // This javascript piece of code is used to make expandible the body of the table ?> id = 'agent_details'; $table->width = '98%'; $table->cellspacing = 4; $table->cellpadding = 4; $table->class = 'databox'; $table->style = array_fill(0, 3, 'vertical-align: top;'); $data = array(); $data[0] = html_print_table($table_agent, true); $data[0] .= '
' . __('Events (24h)') . '' . '
' . graph_graphic_agentevents ($id_agente, 300, 15, 86400, '', true) . '
' . '
'; // ACCESS RATE GRAPH $access_agent = db_get_value_sql("SELECT COUNT(id_agent) FROM tagent_access WHERE id_agent = " . $id_agente); if ($config["agentaccess"] && $access_agent > 0) { $data[0] .= '
' . __('Agent access rate (24h)') . '' . '
' . graphic_agentaccess($id_agente, 300, 100, 86400, true) . '
' . '
'; } $data[1] = html_print_table($table_contact, true); $data[1] .= empty($table_data->data) ? '' : '
' . html_print_table($table_data, true); $data[1] .= !isset($table_incident) ? '' : '
' . html_print_table($table_incident, true); $data[1] .= !isset($table_interface) ? '' : '
' . html_print_table($table_interface, true); $table->rowspan[0][1] = 2; $data[2] = '
'; $data[2] .= '' . html_print_image("images/refresh.png", true, array("border" => '0', "title" => __('Refresh data'), "alt" => "")) . '
'; $data[2] .= '' . html_print_image("images/target.png", true, array("border" => '0', "title" => __('Force'), "alt" => "")) . ''; $data[2] .= '
'; $table->data[] = $data; $table->rowclass[] = ''; $table->cellstyle[1][0] = 'text-align:center;'; html_print_table($table); unset($table); ?>