' . 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(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 ''; echo ''; echo ''; echo '
'; echo __('Group') . ' '; $groups = users_get_groups (); html_print_select_groups(false, "AR", true, 'group_id', $group_id, 'this.form.submit()', '', '', false, false, true, '', false, 'width:150px'); echo ''; echo __("Recursion") . ' '; html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()'); echo ''; echo __('Search') . ' '; html_print_input_text ("search", $search, '', 12); echo ''; $fields = array (); $fields[AGENT_STATUS_NORMAL] = __('Normal'); $fields[AGENT_STATUS_WARNING] = __('Warning'); $fields[AGENT_STATUS_CRITICAL] = __('Critical'); $fields[AGENT_STATUS_UNKNOW] = __('Unknown'); $fields[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $fields[AGENT_STATUS_NOT_INIT] = __('Not init'); echo __('Status') . ' '; html_print_select ($fields, "status", $status, 'this.form.submit()', __('All'), AGENT_STATUS_ALL, false, false, true, '', false, 'width: 90px;'); echo ''; html_print_submit_button (__('Search'), "srcbutton", '', array ("class" => "sub search")); echo ' 
'; echo '
'; echo '
'; html_print_input_hidden ('new_agent', 1); html_print_submit_button (__('Create agent'), 'crt', false, 'class="sub next"'); echo "
"; 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; switch ($sortField) { case 'name': switch ($sort) { case 'up': $selectNameUp = $selected; $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectNameDown = $selected; $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; case 'os': switch ($sort) { case 'up': $selectOsUp = $selected; $order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectOsDown = $selected; $order = array('field' => 'id_os', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; case 'interval': switch ($sort) { case 'up': $selectIntervalUp = $selected; $order = array('field' => 'intervalo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectIntervalDown = $selected; $order = array('field' => 'intervalo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; case 'group': switch ($sort) { case 'up': $selectGroupUp = $selected; $order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; case 'down': $selectGroupDown = $selected; $order = array('field' => 'id_grupo', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; } break; case 'last_contact': switch ($sort) { case 'up': $selectLastContactUp = $selected; $order = array('field' => 'ultimo_contacto', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC'); break; case 'down': $selectLastContactDown = $selected; $order = array('field' => 'ultimo_contacto', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; } break; default: $selectNameUp = $selected; $selectNameDown = ''; $selectOsUp = ''; $selectOsDown = ''; $selectIntervalUp = ''; $selectIntervalDown = ''; $selectGroupUp = ''; $selectGroupDown = ''; $selectLastContactUp = ''; $selectLastContactDown = ''; $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); break; } $search_sql = ''; if ($search != "") { $search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios 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); } $total_agents = 0; $agents = false; $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 COLLATE utf8_general_ci 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->cellpadding = 4; $table->cellspacing = 4; $table->width = "98%"; $table->class = "databox"; $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->head[1] = __('Description'); $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->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->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->head[5] = __('Modules'); $table->head[6] = __('Status'); $table->head[7] = __('Alerts'); $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->align = array (); //Only for AW flag if (check_acl ($config["id_user"], $group_id, "AW")) { $table->head[9] = __('R'); $table->align[9] = "center"; } $table->align[2] = "center"; $table->align[3] = "center"; $table->align[4] = "center"; $table->align[5] = "center"; $table->align[6] = "center"; $table->align[7] = "center"; $table->align[8] = "right"; $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] = ''; $data[0] .= ''; if ($agent['quiet']) { $data[0] .= html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . " "; } $data[0] .= ui_print_agent_name($agent["id_agente"], true, 60, 'font-size:6.5pt !important;', true); $data[0] .= ''; $data[0] .= ''; $data[1] = ui_print_truncate_text($agent["description"], 'description', false, true, true, '[…]', 'font-size: 6.5pt'); $data[2] = ui_print_os_icon ($agent["id_os"], false, true); $data[3] = human_time_description_raw($agent["intervalo"]); $data[4] = ui_print_group_icon ($agent["id_grupo"], true); $data[5] = reporting_tiny_stats($agent, true); $data[6] = $status_img; $data[7] = $alert_img; $last_time = strtotime ($agent["ultimo_contacto"]); $now = time (); $diferencia = $now - $last_time; $time = ui_print_timestamp ($last_time, true, array('style' => 'font-size:6.5pt')); $style = ''; if ($diferencia > ($agent["intervalo"] * 2)) $data[8] = ''.$time.''; else $data[8] = $time; // This old code was returning "never" on agents without modules, BAD !! // And does not print outdated agents in red. WRONG !!!! // $data[7] = ui_print_timestamp ($agent_info["last_contact"], true); //Only for AW flag if (check_acl ($config["id_user"], $group_id, "AW")) { // Has remote configuration ? $data[9]=""; $agent_name = db_get_value("nombre", "tagente", "id_agente", $agent["id_agente"]); $agent_md5 = md5 ($agent_name, false); if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { $data[9] = "". html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config'))).""; } } array_push ($table->data, $data); } if (!empty ($table->data)) { html_print_table ($table); ui_pagination ($total_agents, ui_get_url_refresh (array ('group_id' => $group_id, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort, 'status' => $status))); unset ($table); } else { echo '
'.__('There are no defined agents').'
'; } ?>