From 573a0f5534f759c7e5006e036407e6e6adb86dd2 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 30 Aug 2017 16:26:06 +0200 Subject: [PATCH] Added condition to query --- .../operation/search_modules.getdata.php | 3 +- pandora_console/operation/search_modules.php | 296 +++++++++--------- 2 files changed, 149 insertions(+), 150 deletions(-) diff --git a/pandora_console/operation/search_modules.getdata.php b/pandora_console/operation/search_modules.getdata.php index 0582b294a4..4a04e0bb9d 100644 --- a/pandora_console/operation/search_modules.getdata.php +++ b/pandora_console/operation/search_modules.getdata.php @@ -120,7 +120,8 @@ if ($searchModules) { ) AND (t1.nombre COLLATE utf8_general_ci LIKE "%' . $stringSearchSQL . '%" OR - t3.nombre LIKE "%' . $stringSearchSQL . '%")'; + t3.nombre LIKE "%' . $stringSearchSQL . '%") + AND t1.disabled = 0'; break; case "postgresql": $chunk_sql = ' diff --git a/pandora_console/operation/search_modules.php b/pandora_console/operation/search_modules.php index 0c1962b6d2..dd3785f8dd 100644 --- a/pandora_console/operation/search_modules.php +++ b/pandora_console/operation/search_modules.php @@ -73,156 +73,154 @@ else { 'nombre', 'web_content_string'); foreach ($modules as $module) { - if(!$module['disabled']){ - $module["datos"] = - modules_get_last_value($module['id_agente_modulo']); - $module["module_name"] = $module['nombre']; - - //To search the monitor status - $status_sql = sprintf('SELECT estado from tagente_estado where id_agente_modulo =' . $module['id_agente_modulo']); - $status_sql = db_process_sql($status_sql); - $status_sql = $status_sql[0]; - //To search the monitor utimestamp - $utimestamp_sql = sprintf('SELECT utimestamp from tagente_estado where id_agente_modulo =' . $module['id_agente_modulo']); - $utimestamp_sql = db_process_sql($utimestamp_sql); - $utimestamp_sql = $utimestamp_sql[0]; - - - $agent = db_get_row ('tagente', 'id_agente', $module['id_agente']); - $agentCell = '' . - $agent['alias'] . ''; - - $typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true); - - $intervalCell = modules_get_interval ($module['id_agente_modulo']); - - if ($utimestamp_sql['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 ($status_sql['estado'] == 0) { - $statusCell = ui_print_status_image(STATUS_MODULE_OK, - __('NORMAL') . ": " . modules_get_last_value($module["id_agente_modulo"]), true); - } - elseif ($status_sql['estado'] == 1) { - $statusCell = ui_print_status_image(STATUS_MODULE_CRITICAL, - __('CRITICAL') . ": " . modules_get_last_value($module["id_agente_modulo"]), true); - } - elseif ($status_sql['estado'] == 2) { - $statusCell = ui_print_status_image(STATUS_MODULE_WARNING, - __('WARNING') . ": " . modules_get_last_value($module["id_agente_modulo"]), 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') .": " . modules_get_last_value($module["id_agente_modulo"]), - true); - break; - case 1: - $statusCell = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('UNKNOWN') . " - " . __('Last status') . - " " . __('CRITICAL') . ": " . modules_get_last_value($module["id_agente_modulo"]), - true); - break; - case 2: - $statusCell = ui_print_status_image( - STATUS_MODULE_WARNING, - __('UNKNOWN') . " - " . __('Last status') . - " " . __('WARNING') . ": " . modules_get_last_value($module["id_agente_modulo"]), - 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=" . SECONDS_1DAY . "&" . - "id=" . $module["id_agente_modulo"] . "&" . - "label=" . rawurlencode( - urlencode( - base64_encode($module["module_name"]))) . "&" . - "refresh=" . SECONDS_10MINUTES . "', " . - "'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(modules_get_last_value($module["id_agente_modulo"]))) { - $dataCell = format_numeric(modules_get_last_value($module["id_agente_modulo"])); - } - else { - $dataCell = ui_print_module_string_value( - $module["datos"], $module["id_agente_modulo"], - $module["current_interval"]); - } - - if ($module['estado'] == 3) { - $option = array ("html_attr" => 'class="redb"'); - } - else { - $option = array (); - } - $timestampCell = ui_print_timestamp ($utimestamp_sql["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)); + $module["datos"] = + modules_get_last_value($module['id_agente_modulo']); + $module["module_name"] = $module['nombre']; + + //To search the monitor status + $status_sql = sprintf('SELECT estado from tagente_estado where id_agente_modulo =' . $module['id_agente_modulo']); + $status_sql = db_process_sql($status_sql); + $status_sql = $status_sql[0]; + //To search the monitor utimestamp + $utimestamp_sql = sprintf('SELECT utimestamp from tagente_estado where id_agente_modulo =' . $module['id_agente_modulo']); + $utimestamp_sql = db_process_sql($utimestamp_sql); + $utimestamp_sql = $utimestamp_sql[0]; + + + $agent = db_get_row ('tagente', 'id_agente', $module['id_agente']); + $agentCell = '' . + $agent['alias'] . ''; + + $typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true); + + $intervalCell = modules_get_interval ($module['id_agente_modulo']); + + if ($utimestamp_sql['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 ($status_sql['estado'] == 0) { + $statusCell = ui_print_status_image(STATUS_MODULE_OK, + __('NORMAL') . ": " . modules_get_last_value($module["id_agente_modulo"]), true); + } + elseif ($status_sql['estado'] == 1) { + $statusCell = ui_print_status_image(STATUS_MODULE_CRITICAL, + __('CRITICAL') . ": " . modules_get_last_value($module["id_agente_modulo"]), true); + } + elseif ($status_sql['estado'] == 2) { + $statusCell = ui_print_status_image(STATUS_MODULE_WARNING, + __('WARNING') . ": " . modules_get_last_value($module["id_agente_modulo"]), 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') .": " . modules_get_last_value($module["id_agente_modulo"]), + true); + break; + case 1: + $statusCell = ui_print_status_image( + STATUS_MODULE_CRITICAL, + __('UNKNOWN') . " - " . __('Last status') . + " " . __('CRITICAL') . ": " . modules_get_last_value($module["id_agente_modulo"]), + true); + break; + case 2: + $statusCell = ui_print_status_image( + STATUS_MODULE_WARNING, + __('UNKNOWN') . " - " . __('Last status') . + " " . __('WARNING') . ": " . modules_get_last_value($module["id_agente_modulo"]), + 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=" . SECONDS_1DAY . "&" . + "id=" . $module["id_agente_modulo"] . "&" . + "label=" . rawurlencode( + urlencode( + base64_encode($module["module_name"]))) . "&" . + "refresh=" . SECONDS_10MINUTES . "', " . + "'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(modules_get_last_value($module["id_agente_modulo"]))) { + $dataCell = format_numeric(modules_get_last_value($module["id_agente_modulo"])); + } + else { + $dataCell = ui_print_module_string_value( + $module["datos"], $module["id_agente_modulo"], + $module["current_interval"]); + } + + if ($module['estado'] == 3) { + $option = array ("html_attr" => 'class="redb"'); + } + else { + $option = array (); + } + $timestampCell = ui_print_timestamp ($utimestamp_sql["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 "
";