'; echo ''; echo ''; echo '"; echo "'; echo ''; echo ''; echo ''; echo '"; echo "
'.__('Group').''; html_print_select_groups(false, "AR", true, "ag_group", $ag_group, 'this.form.submit();', '', '0', false, false, false, 'w130', false, 'width:150px;'); echo "".__('Monitor status').""; $fields = array (); $fields[0] = __('Normal'); $fields[1] = __('Warning'); $fields[2] = __('Critical'); $fields[3] = __('Unknown'); $fields[4] = __('Not normal'); //default $fields[5] = __('Not init'); html_print_select ($fields, "status", $status, 'this.form.submit();', __('All'), -1, false, false, true, '', false, 'width: 125px;'); echo ''.__('Module group').''; html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name", 'modulegroup', $modulegroup, 'this.form.submit();',__('All'), 0, false, false, true, false, 'width: 100px;'); echo '
'.__('Module name').''; $user_groups = implode (",", array_keys (users_get_groups ())); //$user_agents = array_keys (agents_get_group_agents($user_groups)); //$modules = db_get_all_rows_filter ('tagente_modulo', array('id_agente' => $user_agents, 'nombre' => '<>delete_pending'), 'DISTINCT(nombre)'); switch ($config["dbtype"]) { case "mysql": $sql = ' SELECT distinct(nombre) FROM tagente_modulo WHERE nombre <> "delete_pending" and id_agente in ( select id_agente from tagente where id_grupo 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 ) ) OR (1 = ( SELECT is_admin FROM tusuario WHERE id_user = "' . $config['id_user'] . '" ) ) 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 ) ) )'; break; case "postgresql": $sql = ' select distinct(nombre) from tagente_modulo where nombre <> \'delete_pending\' and id_agente in ( select id_agente from tagente where id_grupo 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 ) ) OR (1 = ( SELECT is_admin FROM tusuario WHERE id_user = \'' . $config['id_user'] . '\' ) ) 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 ) ) )'; break; case "oracle": $names = oracle_db_get_all_rows_filter ('user_tab_columns',array ('table_name' => 'TAGENTE_MODULO', 'column_name' => '<>NOMBRE'), 'column_name'); $column_names = ''; foreach ($names as $column_name => $value) { $column_names .= $value['column_name'] . ','; } $column_names = substr($column_names,0,-1); $sql = ' select nombre from (select distinct dbms_lob.substr(nombre,4000,1) as nombre, ' . $column_names .' from tagente_modulo) where nombre <> \'delete_pending\' and id_agente in ( select id_agente from tagente where id_grupo 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 ) ) OR (1 = ( SELECT is_admin FROM tusuario WHERE id_user = \'' . $config['id_user'] . '\' ) ) 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 ) ) )'; break; } $modules = db_get_all_rows_sql($sql); html_print_select (index_array ($modules, 'nombre', 'nombre'), "ag_modulename", $ag_modulename, 'this.form.submit();', __('All'), '', false, false, true, '', false, 'width: 150px;'); echo ''.__('Search').''; html_print_input_text ("ag_freestring", $ag_freestring, '', 20,30, false); echo ''; html_print_submit_button (__('Show'), "uptbutton", false, 'class="sub search"'); echo "
"; echo ""; // Begin Build SQL sentences $sql = " FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; // Agent group selector if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) { $sql .= sprintf (" AND tagente.id_grupo = %d", $ag_group); } else { // User has explicit permission on group 1 ? $sql .= " AND tagente.id_grupo IN (".$user_groups.")"; } // Module group if ($modulegroup > 0) { $sql .= sprintf (" AND tagente_modulo.id_module_group = '%d'", $modulegroup); } // Module name selector if ($ag_modulename != "") { $sql .= sprintf (" AND tagente_modulo.nombre = '%s'", $ag_modulename); } // Freestring selector if ($ag_freestring != "") { $sql .= sprintf (" AND (tagente.nombre LIKE '%%%s%%' OR tagente_modulo.nombre LIKE '%%%s%%' OR tagente_modulo.descripcion LIKE '%%%s%%')", $ag_freestring, $ag_freestring, $ag_freestring); } // Status selector if ($status == 0) { //Normal $sql .= " AND tagente_estado.estado = 0 AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) "; } elseif ($status == 2) { //Critical $sql .= " AND tagente_estado.estado = 1 AND utimestamp > 0"; } elseif ($status == 1) { //Warning $sql .= " AND tagente_estado.estado = 2 AND utimestamp > 0"; } elseif ($status == 4) { //Not normal $sql .= " AND tagente_estado.estado <> 0"; } elseif ($status == 3) { //Unknown $sql .= " AND tagente_estado.estado = 3"; } elseif ($status == 5) { //Not init $sql .= " AND tagente_estado.utimestamp = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)"; } $sql .= " ORDER BY tagente.id_grupo, tagente.nombre"; // Build final SQL sentences $count = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo)".$sql); switch ($config["dbtype"]) { case "mysql": $sql = "SELECT tagente_modulo.id_agente_modulo, tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, tagente_modulo.id_agente_modulo, tagente_modulo.history_data, tagente_modulo.flag AS flag, tagente.id_grupo AS id_group, tagente.id_agente AS id_agent, tagente_modulo.id_tipo_modulo AS module_type, tagente_modulo.module_interval, tagente_estado.datos, tagente_estado.estado, tagente_estado.utimestamp AS utimestamp".$sql." LIMIT ".$offset.",".$config["block_size"]; break; case "postgresql": $sql = "SELECT tagente_modulo.id_agente_modulo, tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, tagente_modulo.id_agente_modulo, tagente_modulo.history_data, tagente_modulo.flag AS flag, tagente.id_grupo AS id_group, tagente.id_agente AS id_agent, tagente_modulo.id_tipo_modulo AS module_type, tagente_modulo.module_interval, tagente_estado.datos, tagente_estado.estado, tagente_estado.utimestamp AS utimestamp".$sql." LIMIT " . $config["block_size"] . " OFFSET " . $offset; break; case "oracle": $set = array(); $set['limit'] = $config["block_size"]; $set['offset'] = $offset; $sql = "SELECT tagente_modulo.id_agente_modulo, tagente.intervalo AS agent_interval, tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, tagente_modulo.history_data, tagente_modulo.flag AS flag, tagente.id_grupo AS id_group, tagente.id_agente AS id_agent, tagente_modulo.id_tipo_modulo AS module_type, tagente_modulo.module_interval, tagente_estado.datos, tagente_estado.estado, tagente_estado.utimestamp AS utimestamp".$sql; $sql = oracle_recode_query ($sql, $set); break; } $result = db_get_all_rows_sql ($sql); if ($count > $config["block_size"]) { ui_pagination ($count, false, $offset); } if ($result === false) { $result = array (); } if (($config['dbtype'] == 'oracle') && ($result !== false)) { for ($i=0; $i < count($result); $i++) { unset($result[$i]['rnum']); } } $table->cellpadding = 4; $table->cellspacing = 4; $table->width = 750; $table->class = "databox"; $table->head = array (); $table->data = array (); $table->size = array (); $table->align = array (); if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) $table->head[0] = "" . __('P.') . ""; $table->head[1] = __('Agent'); $table->head[2] = __('Type'); $table->align[2] = "left"; $table->head[3] = __('Module name'); $table->head[4] = __('Interval'); $table->align[4] = "center"; $table->head[5] = __('Status'); $table->align[5] = "center"; $table->head[6] = __('Graph'); $table->align[6] = "center"; $table->head[7] = __('Data'); $table->align[7] = "left"; $table->head[8] = __('Timestamp'); $table->align[8] = "right"; $rowPair = true; $iterator = 0; foreach ($result as $row) { if ($rowPair) $table->rowclass[$iterator] = 'rowPair'; else $table->rowclass[$iterator] = 'rowOdd'; $rowPair = !$rowPair; $iterator++; $data = array (); if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $policyInfo = policies_info_module_policy($row['id_agente_modulo']); if ($policyInfo === false) $data[0] = ''; else { $linked = policies_is_module_linked($row['id_agente_modulo']); $adopt = false; if (policies_is_module_adopt($row['id_agente_modulo'])) { $adopt = true; } if ($linked) { if ($adopt) { $img = 'images/policies_brick.png'; $title = __('(Adopt) ') . $policyInfo['name_policy']; } else { $img = 'images/policies.png'; $title = $policyInfo['name_policy']; } } else { if ($adopt) { $img = 'images/policies_not_brick.png'; $title = __('(Unlinked) (Adopt) ') . $policyInfo['name_policy']; } else { $img = 'images/unlinkpolicy.png'; $title = __('(Unlinked) ') . $policyInfo['name_policy']; } } $data[0] = '' . html_print_image($img,true, array('title' => $title)) . ''; } } $data[1] = ''; $data[1] .= substr ($row["agent_name"], 0, 25); $data[1] .= ''; $data[2] = html_print_image("images/" . modules_show_icon_type ($row["module_type"]), true); $data[3] = mb_strimwidth (io_safe_output($row["module_name"]), 0, 30); $data[4] = ($row['module_interval'] == 0) ? $row['agent_interval'] : $row['module_interval']; if($row['utimestamp'] == 0 && (($row['module_type'] < 21 || $row['module_type'] > 23) && $row['module_type'] != 100)){ $data[5] = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); } elseif ($row["estado"] == 0) { $data[5] = ui_print_status_image(STATUS_MODULE_OK, __('NORMAL').": ".$row["datos"], true); } elseif ($row["estado"] == 1) { $data[5] = ui_print_status_image(STATUS_MODULE_CRITICAL, __('CRITICAL').": ".$row["datos"], true); } elseif ($row["estado"] == 2) { $data[5] = ui_print_status_image(STATUS_MODULE_WARNING, __('WARNING').": ".$row["datos"], true); } else { $last_status = modules_get_agentmodule_last_status($row['id_agente_modulo']); switch($last_status) { case 0: $data[5] = ui_print_status_image(STATUS_MODULE_OK, __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL').": ".$row["datos"], true); break; case 1: $data[5] = ui_print_status_image(STATUS_MODULE_CRITICAL, __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL').": ".$row["datos"], true); break; case 2: $data[5] = ui_print_status_image(STATUS_MODULE_WARNING, __('UNKNOWN')." - ".__('Last status')." ".__('WARNING').": ".$row["datos"], true); break; } } $data[6] = ""; if ($row['history_data'] == 1){ $graph_type = return_graphtype ($row["module_type"]); $nombre_tipo_modulo = modules_get_moduletype_name ($row["module_type"]); $handle = "stat".$nombre_tipo_modulo."_".$row["id_agente_modulo"]; $url = 'include/procesos.php?agente='.$row["id_agente_modulo"]; $win_handle=dechex(crc32($row["id_agente_modulo"].$row["module_name"])); $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$row["id_agente_modulo"]."&label=".base64_encode($row["module_name"])."&refresh=600','day_".$win_handle."')"; $data[6] = '' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . ''; $data[6] .= " " . html_print_image('images/binary.png', true, array("style" => '0', "alt" => '')) . ""; } if (is_numeric($row["datos"])) $data[7] = format_numeric($row["datos"]); else $data[7] = "".substr(io_safe_output($row["datos"]),0,12).""; if ($row["module_interval"] > 0) $interval = $row["module_interval"]; else $interval = $row["agent_interval"]; if ($row['estado'] == 3){ $option = array ("html_attr" => 'class="redb"'); } else { $option = array (); } $data[8] = ui_print_timestamp ($row["utimestamp"], true, $option); array_push ($table->data, $data); } if (!empty ($table->data)) { html_print_table ($table); } else { echo '
'.__('This group doesn\'t have any monitor').'
'; } ?>