' . 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"; break; case "postgresql": case "oracle": $order_collation = ""; break; } switch ($sortField) { case 'name': switch ($sort) { case 'up': $selectNameUp = $selected; $order = array('field' => 'nombre' . $order_collation, 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; $order = array('field' => 'nombre' . $order_collation, 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; case 'os': switch ($sort) { case 'up': $selectOsUp = $selected; $order = array('field' => 'id_os', 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; $order = array('field' => 'id_os', 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; case 'interval': switch ($sort) { case 'up': $selectIntervalUp = $selected; $order = array('field' => 'intervalo', 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectIntervalDown = $selected; $order = array('field' => 'intervalo', 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; case 'group': switch ($sort) { case 'up': $selectGroupUp = $selected; $order = array('field' => 'id_grupo', 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; $order = array('field' => 'id_grupo', 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; } break; case 'last_contact': switch ($sort) { case 'up': $selectLastContactUp = $selected; $order = array('field' => 'ultimo_contacto', 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; case 'down': $selectLastContactDown = $selected; $order = array('field' => 'ultimo_contacto', 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; } break; case 'description': switch ($sort) { case 'up': $selectLastContactUp = $selected; $order = array('field' => 'comentarios', 'field2' => 'nombre' . $order_collation, 'order' => 'DESC'); break; case 'down': $selectLastContactDown = $selected; $order = array('field' => 'comentarios', 'field2' => 'nombre' . $order_collation, 'order' => 'ASC'); break; } break; default: $selectNameUp = $selected; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectIntervalUp = ''; $selectIntervalDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; $selectLastContactUp = ''; $selectLastContactDown = ''; $order = array('field' => 'nombre' . $order_collation, 'field2' => 'nombre' . $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 . " 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 . " 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"], "AR"); $groups = array_keys($user_groups); } if ($strict_user) { $count_filter = array ( 'order' => 'tagente.nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, 'status' => $status, 'search' => $search); $filter = array ( 'order' => 'tagente.nombre COLLATE utf8_general_ci 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'); $acltags = tags_get_user_module_and_tags ($config['id_user'], 'AR', $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'), 'AR', 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', 'id_os', 'ultimo_contacto', 'intervalo', 'comentarios description', 'quiet', 'normal_count', 'warning_count', 'critical_count', 'unknown_count', 'notinit_count', 'total_count', 'fired_count'), 'AR', $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] = "25%"; $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] = "15%"; $table->head[5] = __('Modules'); $table->size[5] = "10%"; $table->head[6] = __('Status'); $table->size[6] = "4%"; $table->head[7] = __('Alerts'); $table->size[7] = "4%"; $table->head[8] = __('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[8] = "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->style = array(); //$table->style[0] = 'width: 15%'; $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] = '