'module_name', 'order' => 'ASC'); break; case 'down': $selectModuleNameDown = $selected; $order = array('field' => 'module_name', 'order' => 'DESC'); break; } break; case 'agent_name': switch ($sort) { case 'up': $selectAgentNameUp = $selected; $order = array('field' => 'agent_name', 'order' => 'ASC'); break; case 'down': $selectAgentNameDown = $selected; $order = array('field' => 'agent_name', 'order' => 'DESC'); break; } break; default: $selectModuleNameUp = $selected; $order = array('field' => 'module_name', 'order' => 'ASC'); break; } $modules = false; if ($searchModules) { $userGroups = users_get_groups($config['id_user'], 'AR', false); $id_userGroups = array_keys($userGroups); switch ($config["dbtype"]) { case "mysql": $chunk_sql = ' FROM tagente_modulo AS t1 INNER JOIN tagente AS t2 ON t2.id_agente = t1.id_agente INNER JOIN tgrupo AS t3 ON t3.id_grupo = t2.id_grupo INNER JOIN tagente_estado AS t4 ON t4.id_agente_modulo = t1.id_agente_modulo WHERE ('.$extra_sql.'t2.id_grupo IN (' . implode(',', $id_userGroups) . ') OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = "' . $config['id_user'] . '" AND id_perfil IN ( SELECT id_perfil FROM tperfil WHERE agent_view = 1 ) ) ) AND t1.nombre COLLATE utf8_general_ci LIKE "%' . $stringSearchSQL . '%" OR t3.nombre LIKE "%' . $stringSearchSQL . '%"'; break; case "postgresql": $chunk_sql = ' FROM tagente_modulo AS t1 INNER JOIN tagente AS t2 ON t2.id_agente = t1.id_agente INNER JOIN tgrupo AS t3 ON t3.id_grupo = t2.id_grupo INNER JOIN tagente_estado AS t4 ON t4.id_agente_modulo = t1.id_agente_modulo WHERE ('.$extra_sql.'t2.id_grupo IN (' . implode(',', $id_userGroups) . ') OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = \'' . $config['id_user'] . '\' AND id_perfil IN ( SELECT id_perfil FROM tperfil WHERE agent_view = 1 ) ) ) AND t1.nombre COLLATE utf8_general_ci LIKE \'%' . $stringSearchSQL . '%\' OR t3.nombre LIKE \'%' . $stringSearchSQL . '%\''; break; case "oracle": $chunk_sql = ' FROM tagente_modulo AS t1 INNER JOIN tagente AS t2 ON t2.id_agente = t1.id_agente INNER JOIN tgrupo AS t3 ON t3.id_grupo = t2.id_grupo INNER JOIN tagente_estado AS t4 ON t4.id_agente_modulo = t1.id_agente_modulo WHERE ' . $subquery_enterprise . ' (t2.id_grupo IN (' . implode(',', $id_userGroups) . ') OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = \'' . $config['id_user'] . '\' AND id_perfil IN ( SELECT id_perfil FROM tperfil WHERE agent_view = 1 ) ) ) AND UPPER(t1.nombre) LIKE UPPER(\'%' . $stringSearchSQL . '%\') OR t3.nombre LIKE \'%' . $stringSearchSQL . '%\''; break; } $select = "SELECT *, t1.nombre AS module_name, t2.nombre AS agent_name "; $limit = " ORDER BY " . $order['field'] . " " . $order['order'] . " LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0); $modules = db_get_all_rows_sql($select . $chunk_sql . $limit); } if (!$modules) { echo "
" . __("Zero results found") . "
\n"; } else { $totalModules = db_get_all_rows_sql("SELECT COUNT(t1.id_agente_modulo) AS count_modules " . $chunk_sql); $totalModules = $totalModules[0]['count_modules']; $table->cellpadding = 4; $table->cellspacing = 4; $table->width = "98%"; $table->class = "databox"; $table->head = array (); $table->head[0] = __('Module') . ' ' . ''. html_print_image("images/sort_up.png", true, array("style" => $selectModuleNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectModuleNameDown)) . ''; $table->head[1] = __('Agent') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectAgentNameUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectAgentNameDown)) .''; $table->head[2] = __('Type'); $table->head[3] = __('Interval'); $table->head[4] = __('Status'); $table->head[5] = __('Graph'); $table->head[6] = __('Data'); $table->head[7] = __('Timestamp'); $table->head[8] = ""; $table->align = array (); $table->align[0] = "left"; $table->align[1] = "left"; $table->align[2] = "center"; $table->align[3] = "center"; $table->align[4] = "center"; $table->align[5] = "center"; $table->align[6] = "right"; $table->align[7] = "right"; $table->align[8] = "center"; $table->data = array (); $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'web_content_string'); foreach ($modules as $module) { //Fixed the goliat sends the strings from web //without HTML entities if ($module['id_tipo_modulo'] == $id_type_web_content_string) { $module['datos'] = io_safe_input($module['datos']); } //Fixed the data from Selenium Plugin if ($module['datos'] != strip_tags($module['datos'])) { $module['datos'] = io_safe_input($module['datos']); } $agentCell = '' . $module['agent_name'] . ''; $typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true); $intervalCell = modules_get_interval ($module['id_agente_modulo']); if ($module['utimestamp'] == 0 && ( ($module['id_tipo_modulo'] < 21 || $module['id_tipo_modulo'] > 23) && $module['id_tipo_modulo'] != 100) ) { $statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); } elseif ($module["estado"] == 0) { $statusCell = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL') . ": " . $module["datos"], true); } elseif ($module["estado"] == 1) { $statusCell = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL') . ": " . $module["datos"], true); } elseif ($module["estado"] == 2) { $statusCell = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING') . ": " . $module["datos"], true); } else { $last_status = modules_get_agentmodule_last_status($module['id_agente_modulo']); switch($last_status) { case 0: $statusCell = ui_print_status_image( STATUS_MODULE_OK, __('UNKNOWN') . " - " . __('Last status') . " " . __('NORMAL') .": " . $module["datos"], true); break; case 1: $statusCell = ui_print_status_image( STATUS_MODULE_CRITICAL, __('UNKNOWN') . " - " . __('Last status') . " " . __('CRITICAL') . ": " . $module["datos"], true); break; case 2: $statusCell = ui_print_status_image( STATUS_MODULE_WARNING, __('UNKNOWN') . " - " . __('Last status') . " " . __('WARNING') . ": " . $module["datos"], true); break; } } $graphCell = ""; if ($module['history_data'] == 1) { $graph_type = return_graphtype ($module["id_tipo_modulo"]); $name_module_type = modules_get_moduletype_name ($module["id_tipo_modulo"]); $handle = "stat" . $name_module_type . "_" . $module["id_agente_modulo"]; $url = 'include/procesos.php?agente=' . $module["id_agente_modulo"]; $win_handle = dechex(crc32($module["id_agente_modulo"] . $module["module_name"])); $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".base64_encode($module["module_name"])."&refresh=600','day_".$win_handle."')"; $graphCell = '' . html_print_image("images/chart_curve.png", true, array("border" => 0, "alt" => "")) . ''; $graphCell .= " " . html_print_image('images/binary.png', true, array("border" => "0", "alt" => "")) . ""; } if (is_numeric($module["datos"])) { $dataCell = format_numeric($module["datos"]); } else { //Fixed the goliat sends the strings from web //without HTML entities if ($module['id_tipo_modulo'] == $id_type_web_content_string) { $module_value = $module["datos"]; } else { $module_value = io_safe_output($module["datos"]); } // There are carriage returns here ? // If carriage returns present... then is a "Snapshot" data (full command output) if (($config['command_snapshot']) && (preg_match ("/[\n]+/i", io_safe_output($module["datos"])))) { $handle = "snapshot"."_".$module["id_agente_modulo"]; $url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; $win_handle=dechex(crc32($handle)); $link ="winopeng_var('operation/agentes/snapshot_view.php?id=".$module["id_agente_modulo"]."&refr=".$module["current_interval"]."&label=".$module["nombre"]."','".$win_handle."', 700,480)"; $dataCell = '' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '   '; } else { //Fixed the goliat sends the strings from web //without HTML entities if ($module['id_tipo_modulo'] == $id_type_web_content_string) { $sub_string = substr($module_value, 0, 12); } else { //Fixed the data from Selenium Plugin if ($module_value != strip_tags($module_value)) { $module_value = io_safe_input($module_value); $sub_string = substr($module_value, 0, 12); } else { $sub_string = substr(io_safe_output($module_value),0, 12); } } if ($module_value == $sub_string) { $dataCell = $module_value; } else { $dataCell = "" . $module_value . "" . "" . '' . $sub_string . ' ' . "" . html_print_image("images/rosette.png", true) . "" . ""; } } } if ($module['estado'] == 3) { $option = array ("html_attr" => 'class="redb"'); } else { $option = array (); } $timestampCell = ui_print_timestamp ($module["utimestamp"], true, $option); $group_agent = agents_get_agent_group($module['id_agente']); if (check_acl ($config['id_user'], $group_agent, "AW")) { $edit_module = 'aaa'; $url_edit = "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $module['id_agente'] . "&tab=module&id_agent_module=" . $module["id_agente_modulo"] . "&edit_module=1"; $edit_module = '' . html_print_image("images/config.png", true) . ''; } else { $edit_module = ''; } array_push($table->data, array( $module['module_name'], $agentCell, $typeCell, $intervalCell, $statusCell, $graphCell, $dataCell, $timestampCell, $edit_module)); } echo "
"; ui_pagination ($totalModules); html_print_table ($table); unset($table); ui_pagination ($totalModules); } ?>