From 31ae5afe84cfec984f1122ac69e358d9991df5c6 Mon Sep 17 00:00:00 2001 From: slerena Date: Fri, 1 May 2009 23:41:09 +0000 Subject: [PATCH] 2009-05-02 Sancho Lerena * extensions/dbmanager.php: Fixed problems with quotes. * operation/agentes/status_monitor.php: Used module_interval insted deprecated tagente_estado.current_interval. * operation/agentes/estado_grupo.php: Same as above. * operation/agentes/estado_monitores.php: same as above. * godmode/agentes/module_manager.php: Uses new server_type field instead old server fields. * godmode/agentes/configurar_agente.php: Added tab in godmode/edit agent to go to a filtered list view per groups from the agent edit view. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1671 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 17 +++++ pandora_console/extensions/dbmanager.php | 65 +++++++++++++++++-- .../godmode/agentes/configurar_agente.php | 5 ++ .../godmode/agentes/module_manager.php | 9 +-- .../operation/agentes/estado_grupo.php | 4 +- .../operation/agentes/estado_monitores.php | 2 +- .../operation/agentes/status_monitor.php | 2 +- 7 files changed, 90 insertions(+), 14 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 26068d2463..dc88d1f3e1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2009-05-02 Sancho Lerena + + * extensions/dbmanager.php: Fixed problems with quotes. + + * operation/agentes/status_monitor.php: Used module_interval insted deprecated + tagente_estado.current_interval. + + * operation/agentes/estado_grupo.php: Same as above. + + * operation/agentes/estado_monitores.php: same as above. + + * godmode/agentes/module_manager.php: Uses new server_type field instead old + server fields. + + * godmode/agentes/configurar_agente.php: Added tab in godmode/edit agent + to go to a filtered list view per groups from the agent edit view. + 2009-05-01 Sancho Lerena * extensions/dbmanager*: New extensions to interface with Pandora database diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index 744fca532f..44b64d3b2c 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -16,7 +16,61 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/* You can safely delete this file */ + +function string_decompose ($mystring){ + + $output = ""; + for ($a=0; $a < strlen($mystring); $a++){ + $output .= substr($mystring, $a, 1)."|"; +// $output .= ord(substr($mystring, $a, 1)).":".substr($mystring, $a, 1)."|"; +// $output .= ord(substr($mystring, $a, 1))."|"; + } + return $output; +} + +function dbmanager_query ($sql, $rettype = "affected_rows") { + global $config; + + $retval = array(); + + if ($sql == '') + return false; + + // This following two lines are for real clean the string coming from the PHP + // because add ' for single quote and " for the double, you cannot + // see with a simple echo and mysql reject it, so dont forget to do this. + + $sql = unsafe_string ($sql); + $sql = htmlspecialchars_decode ($sql, ENT_QUOTES ); + + $result = mysql_query ($sql); + if ($result === false) { + $backtrace = debug_backtrace (); + $error = sprintf ('%s (\'%s\') in %s on line %d', + mysql_error (), $sql, $backtrace[0]['file'], $backtrace[0]['line']); + set_error_handler ('sql_error_handler'); + trigger_error ($error); + restore_error_handler (); + return false; + } elseif ($result === true) { + if ($rettype == "insert_id") { + return mysql_insert_id (); + } elseif ($rettype == "info") { + return mysql_info (); + } + return mysql_affected_rows (); //This happens in case the statement was executed but didn't need a resource + } else { + while ($row = mysql_fetch_array ($result)) { + array_push ($retval, $row); + } + mysql_free_result ($result); + } + if (! empty ($retval)) + return $retval; + //Return false, check with === or !== + return false; +} + function dbmgr_extension_main () { @@ -34,19 +88,18 @@ function dbmgr_extension_main () { echo "

"; echo "
"; echo ""; echo "

"; - print_submit_button ('SQL Exec'); - //echo ""; + print_submit_button (__('Execute SQL'), '', false, 'class="sub next"',false); echo "
"; // Processing SQL Code if ($sqlcode != ""){ echo "
"; echo "
"; - echo ""; + $result = dbmanager_query ($sqlcode); if (!is_array($result)){ echo "Result: ".$result; } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 6bbee5bba7..4327dc8963 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -216,6 +216,11 @@ if ($id_agente) { enterprise_hook ('inventory_tab'); + echo '
  • '; + echo ''; + print_image ("images/god4.png", false, $img_style); + echo '  '.__('Group').'
  • '; + echo ""; // Make some space between tabs and title diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 6d6aef9f5d..5e694d967d 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -31,10 +31,11 @@ echo ""; // Check if there is at least one server of each type available to assign that // kind of modules. If not, do not show server type in combo -$network_available = get_db_value ("network_server", "tserver", "network_server", "1"); -$wmi_available = get_db_value ("wmi_server", "tserver", "wmi_server", "1"); -$plugin_available = get_db_value ("plugin_server", "tserver", "plugin_server", "1"); -$prediction_available = get_db_value ("prediction_server", "tserver", "prediction_server", "1"); + +$network_available = get_db_sql ("SELECT count(*) from tserver where server_type = 2"); +$wmi_available = get_db_sql ("SELECT count(*) from tserver where server_type = 6"); +$plugin_available = get_db_sql ("SELECT count(*) from tserver where server_type = 4"); +$prediction_available = get_db_sql ("SELECT count(*) from tserver where server_type = 5"); // Development mode to use all servers if ($develop_bypass) { diff --git a/pandora_console/operation/agentes/estado_grupo.php b/pandora_console/operation/agentes/estado_grupo.php index 212451b0c8..54ff1e3832 100644 --- a/pandora_console/operation/agentes/estado_grupo.php +++ b/pandora_console/operation/agentes/estado_grupo.php @@ -75,7 +75,7 @@ foreach ($groups as $id_group => $group_name) { 'name' => $group_name); // SQL Join to get monitor status for agents belong this group - $sql = sprintf ("SELECT tagente_estado.estado, tagente_estado.current_interval, + $sql = sprintf ("SELECT tagente_estado.estado, tagente_modulo.module_interval, tagente_estado.utimestamp, tagente_modulo.id_tipo_modulo FROM tagente, tagente_estado, tagente_modulo WHERE tagente.disabled = 0 @@ -90,7 +90,7 @@ foreach ($groups as $id_group => $group_name) { $modules = array (); foreach ($modules as $module) { $seconds = $now - $module['utimestamp']; - if ($seconds >= ($module['current_interval'] * 2)) { + if ($seconds >= ($module['module_interval'] * 2)) { if ($module['id_tipo_modulo'] < 21) // Avoiding ASYNC and Keepalive $group_info['down']++; } elseif ($module['estado'] == 2) { diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index ae618e47a3..97b50b194e 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -107,7 +107,7 @@ foreach ($modules as $module) { } $seconds = get_system_time () - $module["utimestamp"]; - if ($module['id_tipo_modulo'] < 21 && $module["current_interval"] > 0 && $module["utimestamp"] > 0 && $seconds >= ($module["current_interval"] * 2)) { + if ($module['id_tipo_modulo'] < 21 && $module["module_interval"] > 0 && $module["utimestamp"] > 0 && $seconds >= ($module["module_interval"] * 2)) { $data[6] = ''; } else { $data[6] = ''; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 1b4b93e3cf..f395f0a33f 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -243,7 +243,7 @@ foreach ($result as $row) { $seconds = get_system_time () - $row["utimestamp"]; - if ($seconds >= ($row["agent_interval"] * 2)) { + if ($seconds >= ($row["module_interval"] * 2)) { $option = array ("html_attr" => 'class="redb"'); } else { $option = array ();