From d2d1bda07b34983d65c7cebc4fd08a67fb6cc7bb Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 9 Mar 2011 14:26:36 +0000 Subject: [PATCH] 2011-03-08 Miguel de Dios * include/functions_html.php, include/functions_messages.php, include/functions_exportserver.php, include/functions_reporting.php, include/functions_gis.php, include/functions_networkmap.php, include/functions_servers.php, include/functions_api.php, include/fgraph.php, include/functions_agents.php, include/functions_db.php, include/functions_alerts.php, extensions/module_groups.php, operation/incidents/incident.php, operation/incidents/incident_detail.php, operation/search_modules.php, operation/agentes/status_monitor.php, operation/agentes/export_csv.php, operation/agentes/estado_ultimopaquete.php, operation/agentes/alerts_status.php, operation/agentes/estado_agente.php, operation/agentes/sla_view.php, operation/agentes/ver_agente.php, operation/servers/view_server_detail.php, operation/menu.php, operation/search_graphs.php, operation/snmpconsole/snmp_view.php, operation/gis_maps/ajax.php, operation/events/events_rss.php, operation/events/events_list.php, operation/search_alerts.php, operation/search_reports.php, operation/reporting/reporting_xml.php, operation/reporting/graph_viewer.php, operation/search_maps.php, operation/search_users.php, mobile/operation/agents/view_agents.php, mobile/operation/events/events.php, godmode/groups/modu_group_list.php, godmode/groups/configure_group.php, godmode/groups/group_list.php, godmode/db/db_main.php, godmode/db/db_purge.php, godmode/agentes/module_manager_editor_prediction.php, godmode/agentes/modificar_agente.php, godmode/agentes/module_manager_editor.php, godmode/agentes/planned_downtime.php, godmode/servers/manage_recontask_form.php, godmode/alerts/alert_list.list.php, godmode/users/configure_user.php, godmode/massive/massive_edit_modules.php, godmode/modules/manage_network_templates_form.php, godmode/modules/manage_network_components_form_wmi.php, godmode/reporting/visual_console_builder.php, godmode/reporting/reporting_builder.item_editor.php: changed or added in some cases the SQL queries for to be PostgreSQL standard, and cleaned source style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 41 ++++- pandora_console/extensions/module_groups.php | 5 +- .../godmode/agentes/modificar_agente.php | 7 +- .../godmode/agentes/module_manager_editor.php | 9 +- .../module_manager_editor_prediction.php | 4 +- .../godmode/agentes/planned_downtime.php | 17 +- .../godmode/alerts/alert_list.list.php | 2 +- pandora_console/godmode/db/db_main.php | 11 +- pandora_console/godmode/db/db_purge.php | 5 +- .../godmode/groups/configure_group.php | 9 +- pandora_console/godmode/groups/group_list.php | 3 - .../godmode/groups/modu_group_list.php | 10 -- .../godmode/massive/massive_edit_modules.php | 7 +- .../manage_network_components_form_wmi.php | 3 +- .../modules/manage_network_templates_form.php | 3 +- .../reporting_builder.item_editor.php | 10 +- .../reporting/visual_console_builder.php | 4 +- .../godmode/servers/manage_recontask_form.php | 4 +- .../godmode/users/configure_user.php | 10 -- pandora_console/include/fgraph.php | 57 +++--- pandora_console/include/functions_agents.php | 24 ++- pandora_console/include/functions_alerts.php | 3 +- pandora_console/include/functions_api.php | 26 ++- pandora_console/include/functions_db.php | 130 +++++++++----- .../include/functions_exportserver.php | 3 +- pandora_console/include/functions_gis.php | 48 +++-- pandora_console/include/functions_html.php | 18 +- .../include/functions_messages.php | 8 +- .../include/functions_networkmap.php | 3 +- .../include/functions_reporting.php | 170 ++++++++++-------- pandora_console/include/functions_servers.php | 135 +++++++------- .../mobile/operation/agents/view_agents.php | 23 ++- .../mobile/operation/events/events.php | 24 --- .../operation/agentes/alerts_status.php | 42 +++-- .../operation/agentes/estado_agente.php | 3 +- .../agentes/estado_ultimopaquete.php | 6 +- .../operation/agentes/export_csv.php | 10 +- .../operation/agentes/sla_view.php | 4 +- .../operation/agentes/status_monitor.php | 6 +- .../operation/agentes/ver_agente.php | 61 +++++-- .../operation/events/events_list.php | 10 +- .../operation/events/events_rss.php | 2 +- pandora_console/operation/gis_maps/ajax.php | 32 +++- .../operation/incidents/incident.php | 10 +- .../operation/incidents/incident_detail.php | 6 +- pandora_console/operation/menu.php | 2 +- .../operation/reporting/graph_viewer.php | 24 +-- .../operation/reporting/reporting_xml.php | 2 +- pandora_console/operation/search_alerts.php | 69 ++++++- pandora_console/operation/search_graphs.php | 10 +- pandora_console/operation/search_maps.php | 6 +- pandora_console/operation/search_modules.php | 71 +++++--- pandora_console/operation/search_reports.php | 11 +- pandora_console/operation/search_users.php | 11 +- .../operation/servers/view_server_detail.php | 43 +++-- .../operation/snmpconsole/snmp_view.php | 85 ++++++--- 56 files changed, 879 insertions(+), 483 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d0bea76c7e..4e34f7ec66 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,10 +1,49 @@ +2011-03-08 Miguel de Dios + + * include/functions_html.php, include/functions_messages.php, + include/functions_exportserver.php, include/functions_reporting.php, + include/functions_gis.php, include/functions_networkmap.php, + include/functions_servers.php, include/functions_api.php, + include/fgraph.php, include/functions_agents.php, include/functions_db.php, + include/functions_alerts.php, extensions/module_groups.php, + operation/incidents/incident.php, operation/incidents/incident_detail.php, + operation/search_modules.php, operation/agentes/status_monitor.php, + operation/agentes/export_csv.php, + operation/agentes/estado_ultimopaquete.php, + operation/agentes/alerts_status.php, operation/agentes/estado_agente.php, + operation/agentes/sla_view.php, operation/agentes/ver_agente.php, + operation/servers/view_server_detail.php, operation/menu.php, + operation/search_graphs.php, operation/snmpconsole/snmp_view.php, + operation/gis_maps/ajax.php, operation/events/events_rss.php, + operation/events/events_list.php, operation/search_alerts.php, + operation/search_reports.php, operation/reporting/reporting_xml.php, + operation/reporting/graph_viewer.php, operation/search_maps.php, + operation/search_users.php, mobile/operation/agents/view_agents.php, + mobile/operation/events/events.php, godmode/groups/modu_group_list.php, + godmode/groups/configure_group.php, godmode/groups/group_list.php, + godmode/db/db_main.php, godmode/db/db_purge.php, + godmode/agentes/module_manager_editor_prediction.php, + godmode/agentes/modificar_agente.php, + godmode/agentes/module_manager_editor.php, + godmode/agentes/planned_downtime.php, + godmode/servers/manage_recontask_form.php, + godmode/alerts/alert_list.list.php, godmode/users/configure_user.php, + godmode/massive/massive_edit_modules.php, + godmode/modules/manage_network_templates_form.php, + godmode/modules/manage_network_components_form_wmi.php, + godmode/reporting/visual_console_builder.php, + godmode/reporting/reporting_builder.item_editor.php: changed or added in + some cases the SQL queries for to be PostgreSQL standard, and cleaned source + style. + 2011-03-08 Miguel de Dios * include/functions_api.php, include/functions_db.php, operation/incidents/incident_detail.php, godmode/agentes/agent_template.php, godmode/servers/manage_recontask.php, godmode/snmpconsole/snmp_alert.php, godmode/users/configure_profile.php: change the source code - for to use process_sql_insert instead of the SQL (SQL write in multiple lines). + for to use process_sql_insert instead of the SQL (SQL write in multiple + lines). 2011-03-08 Miguel de Dios diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 436b321495..ad16853207 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -47,7 +47,8 @@ if (is_ajax ()) { $sql = 'SELECT * FROM talert_template_module_actions AS t1 INNER JOIN talert_actions AS t2 ON t1.id_alert_action = t2.id - WHERE t1.id_alert_template_module = ' . $template['id'] . ' OR t2.id = ' . $template['id_alert_action'] . ';'; + WHERE t1.id_alert_template_module = ' . $template['id'] . ' + OR t2.id = ' . $template['id_alert_action'] . ';'; $actions = get_db_all_rows_sql($sql); if ($actions === false) { @@ -87,7 +88,7 @@ function mainModuleGroups() { require_once ('include/functions_reporting.php'); //The big query - $sql = "select COUNT(id_agente) AS count, estado + $sql = "SELECT COUNT(id_agente) AS count, estado FROM tagente_estado WHERE utimestamp != 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 794c731a8b..76601d358a 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -247,7 +247,7 @@ if ($agents !== false) { $id_grupo = $agent["id_grupo"]; if (! check_acl ($config["id_user"], $id_grupo, "AW")) continue; - if ($color == 1){ + if ($color == 1) { $tdcolor = "datos"; $color = 0; } @@ -265,7 +265,7 @@ if ($agents !== false) { $iterator++; // Agent name echo ""; - if ($agent["disabled"]){ + if ($agent["disabled"]) { echo ""; } echo ''; @@ -330,7 +330,8 @@ if ($agents !== false) { echo ""; pagination ($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&search=$search&sort_field=$sortField&sort=$sort", $offset); echo "
"; -} else { +} +else { echo "
".__('There are no defined agents')."
"; echo " 
"; } diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index fd46e7f489..2784dfc56a 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -67,7 +67,14 @@ if (is_ajax ()) { $typeName = parseLocalModuleExtractValue('module_type',$component['data']); - $component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE "' . $typeName . '"'); + switch ($config["dbtype"]) { + case "mysql": + $component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE "' . $typeName . '"'); + break; + case "postgresql": + $component['type'] = get_db_value_sql('SELECT id_tipo FROM ttipo_modulo WHERE nombre LIKE \'' . $typeName . '\''); + break; + } echo json_encode ($component); return; diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 19e052ffb6..5fb2842c41 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -64,7 +64,9 @@ $data[1] .= print_input_text_extended ('agent_name',$agent_name, 'text_agent_nam $data[1] .= ' ' . __("Type at least two characters to search") . ' 
'; $data[1] .= print_label(__("Module"),'prediction_module',true); if($id_agente) { - $sql = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE history_data = 1 AND id_agente = ".$id_agente; + $sql = "SELECT id_agente_modulo, nombre + FROM tagente_modulo + WHERE history_data = 1 AND id_agente = ".$id_agente; $data[1] .= print_select_from_sql($sql, 'prediction_module', $prediction_module, false, __('Select Module'), 0, true, false, true, $is_service); } else { diff --git a/pandora_console/godmode/agentes/planned_downtime.php b/pandora_console/godmode/agentes/planned_downtime.php index ba7abd1ba1..edad1e4aeb 100644 --- a/pandora_console/godmode/agentes/planned_downtime.php +++ b/pandora_console/godmode/agentes/planned_downtime.php @@ -211,7 +211,15 @@ if ($create_downtime || $update_downtime) { $filter_cond = ''; if($filter_group > 0) $filter_cond = " AND id_grupo = $filter_group "; - $sql = sprintf ("SELECT tagente.id_agente, tagente.nombre, tagente.id_grupo FROM tagente WHERE tagente.id_agente NOT IN (SELECT tagente.id_agente FROM tagente, tplanned_downtime_agents WHERE tplanned_downtime_agents.id_agent = tagente.id_agente AND tplanned_downtime_agents.id_downtime = %d) AND disabled = 0 $filter_cond ORDER by tagente.nombre", $id_downtime); + $sql = sprintf ("SELECT tagente.id_agente, tagente.nombre, tagente.id_grupo + FROM tagente + WHERE tagente.id_agente NOT IN ( + SELECT tagente.id_agente + FROM tagente, tplanned_downtime_agents + WHERE tplanned_downtime_agents.id_agent = tagente.id_agente + AND tplanned_downtime_agents.id_downtime = %d + ) AND disabled = 0 $filter_cond + ORDER by tagente.nombre", $id_downtime); $downtimes = get_db_all_rows_sql ($sql); $data = array (); if ($downtimes) @@ -239,7 +247,12 @@ if ($create_downtime || $update_downtime) { //Start Overview of existing planned downtime echo '

'.__('Agents planned for this downtime').':

'; - $sql = sprintf ("SELECT tagente.nombre, tplanned_downtime_agents.id, tagente.id_os, tagente.id_agente, tagente.id_grupo, tagente.ultimo_contacto FROM tagente, tplanned_downtime_agents WHERE tplanned_downtime_agents.id_agent = tagente.id_agente AND tplanned_downtime_agents.id_downtime = %d ",$id_downtime); + $sql = sprintf ("SELECT tagente.nombre, tplanned_downtime_agents.id, + tagente.id_os, tagente.id_agente, tagente.id_grupo, + tagente.ultimo_contacto + FROM tagente, tplanned_downtime_agents + WHERE tplanned_downtime_agents.id_agent = tagente.id_agente + AND tplanned_downtime_agents.id_downtime = %d ",$id_downtime); $downtimes = get_db_all_rows_sql ($sql); if ($downtimes === false) { diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 0234af40c6..109dcf66d6 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -135,7 +135,7 @@ if ($searchFlag) { if ($enabledisable != -1) $where .= " AND talert_template_modules.disabled =" . $enabledisable; if ($standby != -1) - $where .= " AND talert_template_modules.standby =" . $standby; + $where .= " AND talert_template_modules.standby = " . $standby; } $total = get_agent_alerts_simple (array_keys ($agents), false, diff --git a/pandora_console/godmode/db/db_main.php b/pandora_console/godmode/db/db_main.php index a0fe28b49d..e423bdc57e 100644 --- a/pandora_console/godmode/db/db_main.php +++ b/pandora_console/godmode/db/db_main.php @@ -40,7 +40,16 @@ $stat_data_string = get_db_sql ("SELECT COUNT(*) FROM tagente_datos_string WHERE $stat_modules = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE id_agente_modulo != 0"); $stat_event = get_db_sql (" SELECT COUNT(*) FROM tevento"); $stat_agente = get_db_sql (" SELECT COUNT(*) FROM tagente"); -$stat_uknown = get_db_sql ("SELECT COUNT(*) FROM tagente WHERE ultimo_contacto < NOW() - (intervalo *2)"); +switch ($config["dbtype"]) { + case "mysql": + $stat_uknown = get_db_sql ("SELECT COUNT(*) FROM tagente WHERE ultimo_contacto < NOW() - (intervalo * 2)"); + break; + case "postgresql": + $stat_uknown = get_db_sql ("SELECT COUNT(*) + FROM tagente + WHERE ceil(date_part('epoch', ultimo_contacto)) < ceil(date_part('epoch', NOW())) - (intervalo * 2)"); + break; +} $stat_noninit = get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE utimestamp = 0;"); // Todo: Recalculate this data dinamically using the capacity and total agents diff --git a/pandora_console/godmode/db/db_purge.php b/pandora_console/godmode/db/db_purge.php index 85ad8c1194..4101f5be2f 100644 --- a/pandora_console/godmode/db/db_purge.php +++ b/pandora_console/godmode/db/db_purge.php @@ -179,8 +179,9 @@ flush (); if ($id_agent > 0) { //If the agent is not All or Not selected $modules = get_agent_modules ($id_agent); - $query = sprintf ("AND id_agente_modulo IN(%s)", implode (",", array_keys ($modules))); -} else { + $query = sprintf (" AND id_agente_modulo IN (%s)", implode (",", array_keys ($modules))); +} +else { $query = ""; } diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 32a91b7973..e72a9a67ec 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -46,7 +46,8 @@ if ($id_group) { $custom_id = $group["custom_id"]; $propagate = $group["propagate"]; $skin = $group["id_skin"]; - } else { + } + else { echo "

".__('There was a problem loading group')."

"; echo "
"; include ("general/footer.php"); @@ -57,7 +58,8 @@ if ($id_group) { // Header if ($id_group) { print_page_header (__("Update group"), "images/god1.png", false, "", true, ""); -} else { +} +else { print_page_header (__("Create group"), "images/god1.png", false, "", true, ""); } @@ -113,7 +115,8 @@ if ($id_group) { print_input_hidden ('update_group', 1); print_input_hidden ('id_group', $id_group); print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); -} else { +} +else { print_input_hidden ('create_group', 1); print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); } diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 6a1ba03745..1d8ccf3646 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -155,9 +155,6 @@ if ($update_group) { /* Delete group */ if ($delete_group) { $id_group = (int) get_parameter ('id_group'); - -// $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d', $id_group); -// $agent = process_sql ($sql); $usedGroup = checkUsedGroup($id_group); diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 84e7a47615..25eafaff05 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -113,8 +113,6 @@ $table->align = array (); $table->align[1] = 'center'; $table->data = array (); -//$groups = get_user_groups ($config['id_user']); - $sql = "SELECT * FROM tmodule_group "; $groups = get_db_all_rows_sql ($sql, true); @@ -123,15 +121,7 @@ $groups = get_db_all_rows_sql ($sql, true); foreach ($groups as $id_group ) { $data = array (); -// $group = get_db_row ('tmodule_group', 'id_mg', $id_group); - -// if (!empty ($group["icon"])) -// $data[0] = ''; -// else -// $data[0] = ' '; $data[0] = ''.printTruncateText($id_group["name"], 50).''; -// $data[2] = get_group_name ($group["parent"]); -// $data[3] = $group['disabled'] ? __('Disabled') : __('Enabled'); $data[1] = '' . print_image("images/cross.png", true, array("border" => '0')) . ''; array_push ($table->data, $data); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index ebd1c26e3b..fa46ac75bc 100644 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -119,7 +119,9 @@ if ($update) { if($module_type != 0) $condition = ' AND t2.id_tipo_modulo = '.$module_type; - $agents_ = get_db_all_rows_sql('SELECT DISTINCT(t1.id_agente) FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente'); + $agents_ = get_db_all_rows_sql('SELECT DISTINCT(t1.id_agente) + FROM tagente t1, tagente_modulo t2 + WHERE t1.id_agente = t2.id_agente'); foreach($agents_ as $id_agent) { $module_name = get_db_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent, 'id_tipo_modulo' => $module_type),'nombre'); @@ -316,7 +318,8 @@ $table->data['edit5'][2] = __('Password'); $table->data['edit5'][3] = print_input_password ('plugin_pass', '', '', 15, 60, true); $table->data['edit6'][0] = __('Export target'); -$table->data['edit6'][1] = print_select_from_sql ('SELECT id, name FROM tserver_export ORDER BY name', +$table->data['edit6'][1] = print_select_from_sql ('SELECT id, name + FROM tserver_export ORDER BY name', 'id_export', '', '',__('None'),'0', true, false, false); /* FF stands for Flip-flop */ diff --git a/pandora_console/godmode/modules/manage_network_components_form_wmi.php b/pandora_console/godmode/modules/manage_network_components_form_wmi.php index 524cf823ad..c5bcacc64f 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_wmi.php +++ b/pandora_console/godmode/modules/manage_network_components_form_wmi.php @@ -90,7 +90,8 @@ echo ''; echo '