' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . ' '; } else { $value = ui_print_module_string_value( $module_value, $module["id_agente_modulo"], $module["current_interval"], $module["module_name"]); } } echo json_encode ($value); return; } return; } ob_end_clean(); // Take some parameters (GET) $group_id = (int) get_parameter ("group_id", 0); $search = trim(get_parameter ("search", "")); $offset = (int)get_parameter('offset', 0); $refr = get_parameter('refr', 0); $recursion = get_parameter('recursion', 0); $status = (int) get_parameter ('status', -1); $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); $agent_a = (bool) check_acl ($config['id_user'], 0, "AR"); $agent_w = (bool) check_acl ($config['id_user'], 0, "AW"); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $onheader = array(); if (check_acl ($config['id_user'], 0, "AW")) { // Prepare the tab system to the future $tab = 'setup'; /* Setup tab */ $setuptab['text'] = '' . html_print_image ("images/setup.png", true, array ("title" =>__('Setup'))) . ''; $setuptab['godmode'] = true; $setuptab['active'] = false; $onheader = array('setup' => $setuptab); } ui_print_page_header ( __("Agent detail"), "images/agent_mc.png", false, "agent_status", false, $onheader); if (!$strict_user) { if (tags_has_user_acl_tags()) { ui_print_tags_warning(); } } // User is deleting agent if (isset($result_delete)) { if ($result_delete) ui_print_success_message(__("Sucessfully deleted agent")); else ui_print_error_message(__("There was an error message deleting the agent")); } echo '
'; if ($search != "") { $filter = array ("string" => '%' . $search . '%'); } else { $filter = array (); } $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $selected = 'border: 1px solid black;'; $selectNameUp = ''; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectIntervalUp = ''; $selectIntervalDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; $selectLastContactUp = ''; $selectLastContactDown = ''; $order = null; $order_collation = ""; switch ($config["dbtype"]) { case "mysql": //$order_collation = " COLLATE utf8_general_ci"; $order_collation = ""; break; case "postgresql": case "oracle": $order_collation = ""; break; } switch ($sortField) { case 'remote': switch ($sort) { case 'up': $selectRemoteUp = $selected; $order = array('field' => 'remote' . $order_collation, 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectRemoteDown = $selected; $order = array('field' => 'remote' . $order_collation, 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; case 'name': switch ($sort) { case 'up': $selectNameUp = $selected; $order = array('field' => 'alias' . $order_collation, 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; $order = array('field' => 'alias' . $order_collation, 'field2' => 'alias' . $order_collation, 'order' => 'DESC'); break; } break; case 'os': switch ($sort) { case 'up': $selectOsUp = $selected; $order = array('field' => 'id_os', 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; $order = array('field' => 'id_os', 'field2' => 'alias' . $order_collation, 'order' => 'DESC'); break; } break; case 'interval': switch ($sort) { case 'up': $selectIntervalUp = $selected; $order = array('field' => 'intervalo', 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectIntervalDown = $selected; $order = array('field' => 'intervalo', 'field2' => 'alias' . $order_collation, 'order' => 'DESC'); break; } break; case 'group': switch ($sort) { case 'up': $selectGroupUp = $selected; $order = array('field' => 'id_grupo', 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; $order = array('field' => 'id_grupo', 'field2' => 'alias' . $order_collation, 'order' => 'DESC'); break; } break; case 'last_contact': switch ($sort) { case 'up': $selectLastContactUp = $selected; $order = array('field' => 'ultimo_contacto', 'field2' => 'alias' . $order_collation, 'order' => 'DESC'); break; case 'down': $selectLastContactDown = $selected; $order = array('field' => 'ultimo_contacto', 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; } break; case 'description': switch ($sort) { case 'up': $selectLastContactUp = $selected; $order = array('field' => 'comentarios', 'field2' => 'alias' . $order_collation, 'order' => 'DESC'); break; case 'down': $selectLastContactDown = $selected; $order = array('field' => 'comentarios', 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; } break; default: $selectNameUp = $selected; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectIntervalUp = ''; $selectIntervalDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; $selectLastContactUp = ''; $selectLastContactDown = ''; $order = array('field' => 'alias' . $order_collation, 'field2' => 'alias' . $order_collation, 'order' => 'ASC'); break; } $search_sql = ''; if ($search != "") { //$search_sql = " AND ( nombre " . $order_collation . " LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') "; $sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress INNER JOIN taddress_agent ON taddress.id_a = taddress_agent.id_a WHERE taddress.ip LIKE '%$search%'"; $id = db_get_all_rows_sql($sql); if($id != ''){ $aux = $id[0]['id_agent']; $search_sql = " AND ( nombre " . $order_collation . " COLLATE utf8_general_ci LIKE '%$search%' OR alias ".$order_collation." COLLATE utf8_general_ci LIKE '%$search%' OR tagente.id_agente = $aux"; if(count($id)>=2){ for ($i = 1; $i < count($id); $i++){ $aux = $id[$i]['id_agent']; $search_sql .= " OR tagente.id_agente = $aux"; } } $search_sql .= ")"; }else{ $search_sql = " AND ( nombre " . $order_collation . " COLLATE utf8_general_ci LIKE '%$search%' OR alias ".$order_collation." COLLATE utf8_general_ci LIKE '%$search%') "; } } // Show only selected groups if ($group_id > 0) { $groups = array($group_id); if ($recursion) { $groups = groups_get_id_recursive($group_id, true); } } else { $groups = array(); $user_groups = users_get_groups($config["id_user"], $access); $groups = array_keys($user_groups); } if ($strict_user) { $count_filter = array ( //'order' => 'tagente.nombre COLLATE utf8_general_ci ASC', 'order' => 'tagente.nombre ASC', 'disabled' => 0, 'status' => $status, 'search' => $search); $filter = array ( //'order' => 'tagente.nombre COLLATE utf8_general_ci ASC', 'order' => 'tagente.nombre ASC', 'disabled' => 0, 'status' => $status, 'search' => $search, 'offset' => (int) get_parameter ('offset'), 'limit' => (int) $config['block_size']); if ($group_id > 0) { $groups = array($group_id); if ($recursion) { $groups = groups_get_id_recursive($group_id, true); } $filter['id_group'] = implode(',', $groups); $count_filter['id_group'] = $filter['id_group']; } $fields = array ('tagente.id_agente','tagente.id_grupo','tagente.id_os','tagente.ultimo_contacto','tagente.intervalo','tagente.comentarios description','tagente.quiet', 'tagente.normal_count','tagente.warning_count','tagente.critical_count','tagente.unknown_count','tagente.notinit_count','tagente.total_count','tagente.fired_count', 'tagente.nombre', 'tagente.alias'); $acltags = tags_get_user_module_and_tags ($config['id_user'], $access, $strict_user); $total_agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $count_filter, $fields, false, $strict_user, true); $total_agents = count($total_agents); $agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true); } else { $total_agents = agents_get_agents(array ( 'disabled' => 0, 'id_grupo' => $groups, 'search' => $search_sql, 'status' => $status), array ('COUNT(*) as total'), $access, false); $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0; $agents = agents_get_agents(array ( 'order' => 'nombre ' . $order_collation . ' ASC', 'id_grupo' => $groups, 'disabled' => 0, 'status' => $status, 'search' => $search_sql, 'offset' => (int) get_parameter ('offset'), 'limit' => (int) $config['block_size']), array ('id_agente', 'id_grupo', 'nombre', 'alias', 'id_os', 'ultimo_contacto', 'intervalo', 'comentarios description', 'quiet', 'normal_count', 'warning_count', 'critical_count', 'unknown_count', 'notinit_count', 'total_count', 'fired_count', 'ultimo_contacto_remoto', 'remote', 'agent_version'), $access, $order); } if (empty ($agents)) { $agents = array (); } // Prepare pagination ui_pagination ($total_agents, ui_get_url_refresh (array ('group_id' => $group_id, 'recursion' => $recursion, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort, 'status' => $status))); // Show data. $table = new stdClass(); $table->cellpadding = 0; $table->cellspacing = 0; $table->width = "100%"; $table->class = "databox data"; $table->head = array (); $table->head[0] = __('Agent'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; $table->size[0] = "10%"; $table->head[1] = __('Description'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; $table->size[1] = "16%"; $table->head[10] = __('Remote'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectRemoteUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectRemoteDown, "alt" => "down")) . ''; $table->size[10] = "9%"; $table->head[2] = __('OS'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectOsUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectOsDown, "alt" => "down")) . ''; $table->size[2] = "8%"; $table->head[3] = __('Interval'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . ''; $table->size[3] = "10%"; $table->head[4] = __('Group'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown, "alt" => "down")) . ''; $table->size[4] = "8%"; $table->head[5] = __('Type'); $table->size[5] = "8%"; $table->head[6] = __('Modules'); $table->size[6] = "10%"; $table->head[7] = __('Status'); $table->size[7] = "4%"; $table->head[8] = __('Alerts'); $table->size[8] = "4%"; $table->head[9] = __('Last contact'). ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectLastContactUp, "alt" => "up")) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectLastContactDown, "alt" => "down")) . ''; $table->size[9] = "15%"; $table->align = array (); $table->align[2] = "left"; $table->align[3] = "left"; $table->align[4] = "left"; $table->align[5] = "left"; $table->align[6] = "left"; $table->align[7] = "left"; $table->align[8] = "left"; $table->align[9] = "left"; $table->style = array(); $table->data = array (); $rowPair = true; $iterator = 0; foreach ($agents as $agent) { if ($rowPair) $table->rowclass[$iterator] = 'rowPair'; else $table->rowclass[$iterator] = 'rowOdd'; $rowPair = !$rowPair; $iterator++; $alert_img = agents_tree_view_alert_img ($agent["fired_count"]); $status_img = agents_tree_view_status_img ($agent["critical_count"], $agent["warning_count"], $agent["unknown_count"], $agent["total_count"], $agent["notinit_count"]); $data = array (); $data[0] = '