diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8157128633..7667ee805f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,50 @@ +2009-01-15 Esteban Sanchez + + * include/styles/menu.css: Changed the z-index property of the menu + which was overlapped in some cases. + + * include/functions.php: format_alert_row() moved to functions_ui.php + + * include/functions_ui.php: Added format_alert_row() from function.php + + * include/functions_agents.php: Added to repository. + + * include/functions_alerts.php: Added new functions + get_alerts_agent_module_disabled(), + set_alerts_agent_module_force_execution(), + get_alerts_agent_module_last_fired(). + + * include/functions_db.php, operation/agentes/estado_agente.php, + operation/agentes/networkmap.php: Style correction. + + * include/functions_reporting.php: Use new functions_agent.php. Added + a bit of documentation and style correction. + + * godmode/alerts/alert_templates.php: Improved a bit the template + tooltip. + + * operation/agentes/alerts_status.php: Added to repository. New + interface to list agent alerts. + + * operation/agentes/estado_alertas.php: Removed from repository. + Replaced by alert_status.php. + + * operation/agentes/ver_agente.php: Removed flag_alert code snippet. + Use new files added. Style correction. + + * operation/menu.php: Old files references replaced by new ones. + + * index.php: Removed build and pandora version references. + + * pandoradb.sql: Removed useless module_type field in + talert_templates. + + * pandoradb_migrate_20_to_21.sql: Removed duplicate fields addition. + Fixed some warnings. Added custom_id field to tagente. Style + correction. + + * include/config_process.php: Updated build version. + 2009-01-14 Sancho Lerena * operation/servers/view_server_detail.php: Fixed missing parameter. diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index d6d8a47888..9f47824d3d 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -40,35 +40,33 @@ if (defined ('AJAX')) { return; echo '

'.$template['name'].'

'; - echo ''.__('Type').': '.get_alert_templates_type_name ($template['type']).'
'; + echo ''.get_alert_templates_type_name ($template['type']).': '; switch ($template['type']) { case 'regex': case 'equal': case 'not_equal': - echo ''.__('Value').': '; if (empty ($template['value'])) echo ''.__('Empty').''; else echo ''.$template['value'].''; - echo '
'; break; - case 'max': case 'max_min': - echo ''.__('Max. Value').': '; + echo __('Between').' '; + case 'max': echo format_numeric ($template['max_value']); - echo '
'; /* Break on max to not show min */ if ($template['type'] == 'max') break; + echo ''.__('and').' '; case 'min': - echo ''.__('Min. Value').': '; echo format_numeric ($template['min_value']); - echo '
'; } + echo '
'; + if ($template['description'] != '') { echo ''.__('Description').':
'; echo $template['description']; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 6de1dd463f..537d2eedc6 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -17,10 +17,8 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //Pandora Version -if (!isset ($build_version)) - $build_version="PC081016"; -if (!isset ($pandora_version)) - $pandora_version="v2.1-dev"; +$build_version = "PC090115"; +$pandora_version = "v2.1-dev"; // This is directory where placed "/attachment" directory, to upload files stores. // This MUST be writtable by http server user, and should be in pandora root. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index c121b9dbb8..9eb0eca697 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -800,95 +800,6 @@ function show_alert_row_edit ($row2, $tdcolor = "datos", $id_tipo_modulo = 1, $c return $string; } -/** - * Formats a row from the alert table and returns an array usable in the table function - * - * @param array $alert A valid (non empty) row from the alert table - * @param bool $combined Whether or not this is a combined alert - * @param bool $agent Whether to print the agent information with the module information - * @param string $section Tab where the function was called from (used for urls) - * - * @return array A formatted array with proper html for use in $table->data (7 columns) - */ -function format_alert_row ($alert, $combined = 0, $agent = 1, $tab = 'main') { - if (empty ($alert)) { - return array ("", "", "", "", "", "", ""); - } - - // Get agent id - $id_agente = get_agentmodule_agent($alert["id_agente_modulo"]); - - $data = array (); - - // Force alert execution - if ($combined == 0) { - if ($alert["flag"] == 0) { - $data[0] = ""; - } else { - $data[0] = ""; - } - } else { - $data[0] = ''; - } - - $data[1] = get_alert_type ($alert["id_alerta"]); - - if ($combined == 1) { - $data[2] = print_agent_name ($id_agente, true, 20); - } elseif ($agent == 0) { - $data[2] = mb_substr (get_agentmodule_name ($alert["id_agente_modulo"]), 0, 20); - } else { - $data[2] = print_agent_name (get_agentmodule_agent ($alert["id_agente_modulo"]), true, 20); - } - - $data[3] = mb_substr (safe_input ($alert["descripcion"]), 0, 35); - - //Eye tooltip - $data[4] = 'detail tooltip'; - $data[4] .= ' - - - - - - - - - -
'.__('Recovery').'
'.($alert["recovery_notify"] == 1 ? __('Yes') : __('No')).'
'.__('Priority').'
'.get_alert_priority ($alert["priority"]).'
'.__('Fires every').'
'; - if ($alert["min_alerts"] > 0) { - $data[4] .= human_time_description_raw ($alert["time_threshold"] / $alert["min_alerts"]); - } else { - $data[4] .= human_time_description_raw ($alert["time_threshold"]); - } - $data[4] .= '
'.__('Firing days').'
'.get_alert_days ($alert).'
'.__('Firing times').'
'.($alert["time_from"] == $alert["time_to"] ? __('Always') : $alert["time_from"].' - '.$alert["time_to"]).'
'; - - //Min. and Max. - maybe move this to the span - $data[5] = format_numeric ($alert["dis_min"], 2).' / '.format_numeric ($alert["dis_max"], 2); - - $data[6] = print_timestamp ($alert["last_fired"], true); - - $options = array (); - $options["height"] = 9; - $options["width"] = 20; - - if ($alert["times_fired"] > 0) { - $options["src"] = "images/pixel_red.png"; - $options["title"] = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); - } elseif ($alert["disable"] > 0) { - $options["src"] = "images/pixel_gray.png"; - $options["title"] = __('Alert disabled'); - } else { - $options["src"] = "images/pixel_green.png"; - $options["title"] = __('Alert not fired'); - } - $data[7] = print_image ($options["src"], true, $options); - - $data[8] = print_checkbox ("validate[]", $alert["id_aam"], false, true); - - return $data; -} - /** * Get report types in an array. * diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php new file mode 100644 index 0000000000..68baed8ecb --- /dev/null +++ b/pandora_console/include/functions_agents.php @@ -0,0 +1,104 @@ + 0 AND disable = 0'; + break; + case "disabled": + $filter = ' AND disable = 1'; + break; + default: + $filter = ''; + } + + $id_modules = array_keys (get_agent_modules ($id_agent)); + + //$modules = (); + + $sql = sprintf ("SELECT talert_template_modules.* + FROM talert_template_modules + WHERE id_agent_module in (%s)", + $id_agent, implode (",", $id_modules)); + + $alerts = get_db_all_rows_sql ($sql); + + if ($alerts === false) + return array (); + return $alerts; +} + +/** + * Get all the combined alerts of an agent. + * + * @param int $id_agent Agent id + * + * @return array An array with all combined alerts defined for an agent. + */ +function get_agent_alerts_combined ($id_agent, $filter = false) { + switch ($filter) { + case "notfired": + $filter = ' AND times_fired = 0 AND disable = 0'; + break; + case "fired": + $filter = ' AND times_fired > 0 AND disable = 0'; + break; + case "disabled": + $filter = ' AND disable = 1'; + break; + default: + $filter = ''; + } + $sql = sprintf ("SELECT * FROM talerta_agente_modulo WHERE id_agent = %d%s", $id_agent, $filter); + $alerts = get_db_all_rows_sql ($sql); + + if ($alerts === false) + return array (); + return $alerts; +} + +/** + * Get all the alerts of an agent, simple and combined. + * + * @param int $id_agent Agent id + * + * @return array An array with all alerts defined for an agent. + */ +function get_agent_alerts ($id_agent, $filter = false) { + $simple_alerts = get_agent_alerts_simple ($id_agent, $filter); + $combined_alerts = get_agent_alerts_combined ($id_agent, $filter); + + return array_merge ($simple_alerts, $combined_alerts); +} + +?> diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index a7747d99d6..d99a2b91aa 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -589,12 +589,35 @@ function get_alert_agent_module ($id_alert_agent_module) { } function get_alerts_agent_module ($id_agent_module) { + $id_alert_agent_module = safe_int ($id_agent_module, 1); $sql = sprintf ('SELECT * FROM talert_template_modules WHERE id_agent_module = %d AND disabled = 0', $id_agent_module); return get_db_all_rows_sql ($sql); } +function get_alerts_agent_module_disabled ($id_alert_agent_module) { + $id_alert_agent_module = safe_int ($id_alert_agent_module, 1); + return get_db_value ('disabled', 'talert_template_modules', 'id', + $id_alert_agent_module); +} + +function set_alerts_agent_module_force_execution ($id_alert_agent_module) { + $id_alert_agent_module = safe_int ($id_alert_agent_module, 1); + $sql = sprintf ('UPDATE talert_template_modules + SET force_execution = 1 + WHERE id = %d', + $id_alert_agent_module); + + return process_sql ($sql) !== false; +} + +function get_alerts_agent_module_last_fired ($id_alert_agent_module) { + $id_alert_agent_module = safe_int ($id_alert_agent_module, 1); + return get_db_value ('last_fired', 'talert_template_modules', 'id', + $id_alert_agent_module); +} + function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action, $options = false) { if (empty ($id_alert_agent_module)) return false; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 92f3947d1b..8802c497ef 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -291,87 +291,6 @@ function get_agent_modules ($id_agent, $details = false) { } return $modules; } - -/** - * Get all the simple alerts of an agent. - * - * @param int Agent id - * @param string Filter on "fired", "notfired" or "disabled". Any other value - * will not do any filter. - * - * @return array All simple alerts defined for an agent. Empty array if no - * alerts found. - */ -function get_agent_alerts_simple ($id_agent, $filter = false) { - switch ($filter) { - case "notfired": - $filter = ' AND times_fired = 0 AND disable = 0'; - break; - case "fired": - $filter = ' AND times_fired > 0 AND disable = 0'; - break; - case "disabled": - $filter = ' AND disable = 1'; - break; - default: - $filter = ''; - } - - $sql = sprintf ("SELECT talerta_agente_modulo.* - FROM talerta_agente_modulo, tagente_modulo - WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.id_agente = %d %s", - $id_agent, $filter); - $alerts = get_db_all_rows_sql ($sql); - - if ($alerts === false) - return array (); - return $alerts; -} - -/** - * Get all the combined alerts of an agent. - * - * @param int $id_agent Agent id - * - * @return array An array with all combined alerts defined for an agent. - */ -function get_agent_alerts_combined ($id_agent, $filter = false) { - switch ($filter) { - case "notfired": - $filter = ' AND times_fired = 0 AND disable = 0'; - break; - case "fired": - $filter = ' AND times_fired > 0 AND disable = 0'; - break; - case "disabled": - $filter = ' AND disable = 1'; - break; - default: - $filter = ''; - } - $sql = sprintf ("SELECT * FROM talerta_agente_modulo WHERE id_agent = %d%s", $id_agent, $filter); - $alerts = get_db_all_rows_sql ($sql); - - if ($alerts === false) - return array (); - return $alerts; -} - -/** - * Get all the alerts of an agent, simple and combined. - * - * @param int $id_agent Agent id - * - * @return array An array with all alerts defined for an agent. - */ -function get_agent_alerts ($id_agent, $filter = false) { - $simple_alerts = get_agent_alerts_simple ($id_agent, $filter); - $combined_alerts = get_agent_alerts_combined ($id_agent, $filter); - - return array_merge ($simple_alerts, $combined_alerts); -} - /** * Get a list of the reports the user can view. * @@ -2273,7 +2192,7 @@ function get_server_info ($id_server = -1) { } //Push the raw data on the return stack - $return[$server["id_server"]] = $server; + $return[$server["id_server"]] = $server; } return $return; } @@ -2520,4 +2439,4 @@ function process_sql_update ($table, $values) { return process_sql ($query); } -?> \ No newline at end of file +?> diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 58d5a53648..1cf5eb84fd 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -17,6 +17,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +require_once ("include/functions_agents.php"); + /** * Get SLA of a module. * @@ -111,7 +113,7 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value /** * Get general stats info on a group * - * @param int $id_group + * @param int Group Id to get info. * * @return array */ @@ -125,10 +127,13 @@ function get_group_stats ($id_group) { //Select all modules in group $sql = sprintf ("SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos, tagente_estado.current_interval, tagente_estado.utimestamp, - tagente_estado.id_agente_modulo, tagente_modulo.id_tipo_modulo FROM tagente, tagente_estado, tagente_modulo + tagente_estado.id_agente_modulo, tagente_modulo.id_tipo_modulo + FROM tagente, tagente_estado, tagente_modulo WHERE tagente.disabled = 0 AND tagente.id_grupo IN (%s) - AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0", implode (",",$groups)); + AND tagente.id_agente = tagente_estado.id_agente + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0", + implode (",",$groups)); $result = get_db_all_rows_sql ($sql); if ($result === false) @@ -152,7 +157,6 @@ function get_group_stats ($id_group) { $data["data_alerts_fired"] = 0; $data["data_alerts_fire_count"] = 0; - $cur_time = get_system_time (); foreach ($result as $row) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 5f40dd350b..7326db12fa 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -220,4 +220,75 @@ function print_agent_name ($id_agent, $return = false, $cutoff = 0) { echo $output; } + +/** + * Formats a row from the alert table and returns an array usable in the table function + * + * @param array A valid (non empty) row from the alert table + * @param bool Whether or not this is a combined alert + * @param bool Whether to print the agent information with the module information + * @param string Tab where the function was called from (used for urls) + * + * @return array A formatted array with proper html for use in $table->data (6 columns) + */ +function format_alert_row ($alert, $combined = false, $agent = true, $url = '') { + require_once ("include/functions_alerts.php"); + + if (empty ($alert)) + return array ("", "", "", "", "", "", ""); + + // Get agent id + $id_agente = get_agentmodule_agent ($alert["id_agent_module"]); + $template = get_alert_template ($alert['id_alert_template']); + + $data = array (); + + // Force alert execution + $data[0] = ''; + if (! $combined) { + if ($alert["force_execution"] == 0) { + $data[0] = ''; + } else { + $data[0] = ''; + } + } + + if ($combined == 1) { + $data[1] = print_agent_name ($id_agente, true, 20); + } elseif ($agent == 0) { + $data[1] = mb_substr (get_agentmodule_name ($alert["id_agent_module"]), 0, 20); + } else { + $data[1] = print_agent_name (get_agentmodule_agent ($alert["id_agent_module"]), true, 20); + } + + $data[2] = ''; + $data[2] .= mb_substr (safe_input ($template["description"]), 0, 35); + $data[2] .= ' '; + $data[2] .= ''; + $data[2] .= ''; + $data[2] .= ''; + + $data[3] = print_timestamp ($alert["last_fired"], true); + + $options = array (); + $options["height"] = 9; + $options["width"] = 20; + + if ($alert["times_fired"] > 0) { + $options["src"] = "images/pixel_red.png"; + $options["title"] = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); + } elseif ($alert["disabled"] > 0) { + $options["src"] = "images/pixel_gray.png"; + $options["title"] = __('Alert disabled'); + } else { + $options["src"] = "images/pixel_green.png"; + $options["title"] = __('Alert not fired'); + } + + $data[4] = print_image ($options["src"], true, $options); + + $data[5] = print_checkbox ("validate[]", $alert["id"], false, true); + + return $data; +} ?> diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index e30ec2cc4e..fb181f314f 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -78,7 +78,7 @@ top:-25px; left:155px; width:130px; - z-index:1; + z-index:5; background: #E9F3D2 url(../../images/arrow.png) no-repeat scroll 6px 4px; padding-left: 8px; } @@ -171,4 +171,4 @@ #god-agents.selected, #god-modules.selected, #god-alerts.selected, #god-dbmaint.selected, #god-users.selected, #god-reporting.selected, #god-profiles.selected, #god-servers.selected, #god-audit.selected, #god-setup.selected, #god-snmpc.selected, #god-extensions.selected { background-color: #efefbd; -} \ No newline at end of file +} diff --git a/pandora_console/index.php b/pandora_console/index.php index fbb2d6440d..53bdf57b17 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -20,11 +20,6 @@ // Silk icon set 1.3 (cc) Mark James, http://www.famfamfam.com/lab/icons/silk/ // Pandora FMS uses Pear Image::Graph code -$build_version="PC090106"; -$pandora_version="v2.1-dev"; -global $build_version; -global $pandora_version; - //Set character encoding to UTF-8 - fixes a lot of multibyte character headaches if (function_exists (mb_internal_encoding)) { mb_internal_encoding ("UTF-8"); diff --git a/pandora_console/operation/agentes/estado_alertas.php b/pandora_console/operation/agentes/alerts_status.php similarity index 55% rename from pandora_console/operation/agentes/estado_alertas.php rename to pandora_console/operation/agentes/alerts_status.php index 31fee98a82..6637623f2d 100644 --- a/pandora_console/operation/agentes/estado_alertas.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -16,11 +16,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// Load global vars -require_once ("include/config.php"); - check_login (); +require_once ("include/functions_agents.php"); + $filter = get_parameter_get ("filter", "all"); $offset = (int) get_parameter_get ("offset", 0); $id_group = (int) get_parameter ("ag_group", 1); //1 is the All group (selects all groups) @@ -33,6 +32,13 @@ $sec = safe_url_extraclean ($sec); $url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&refr='.$config["refr"].'&filter='.$filter.'&ag_group='.$id_group; +// Force alert execution +$flag_alert = (bool) get_parameter ('force_execution'); +if ($flag_alert == 1 && give_acl ($config['id_user'], $id_grupo, "AW")) { + require_once ("include/functions_alerts.php"); + $id_alert = (int) get_parameter ('id_alert'); + set_alerts_agent_module_force_execution ($id_alert); +} // Show alerts for specific agent if (isset ($_GET["id_agente"])) { @@ -49,7 +55,7 @@ if (isset ($_GET["id_agente"])) { $alerts_simple = get_agent_alerts_simple ($id_agent, $filter); $alerts_combined = get_agent_alerts_combined ($id_agent, $filter); - $print_agent = 0; + $print_agent = false; } else { if (give_acl ($config["id_user"], $id_group, "AR") == 0) { audit_db ($config["id_user"], $config["remote_addr"], "ACL Violation","Trying to access alert view"); @@ -70,122 +76,134 @@ if (isset ($_GET["id_agente"])) { $alerts_combined = array_merge ($alerts_combined, $combined); } - $print_agent = 1; + $print_agent = true; } $tab = get_parameter_get ("tab"); if ($tab != '') { - echo "

".__('Pandora Agents')." > ".__('Full list of Alerts')."

"; $url = $url.'&tab='.$tab; -} else { - echo "

".__('Full list of alerts').'

'; } - -echo '
'; -if (isset ($_POST["alert_validate"])) { +echo "

".__('Alerts').'

'; + +if (get_parameter ('alert_validate')) { $validate = get_parameter_post ("validate", array ()); $result = process_alerts_validate ($validate); print_error_message ($result, __('Alert(s) validated'), __('Error processing alert(s)')); } +echo ''; -if ($print_agent == 1) { - echo ''; - echo ''; + $table->data[0][2] = ''.__('Alert fired').''; + $table->data[0][3] = ''.__('Alert not fired').''; + $table->data[0][4] = ''.__('Alert disabled').''; - //And finish the table here - echo ''; - echo ''; - echo '
'.__('Group').''; +if ($print_agent) { + $table->width = '90%'; + $table->data = array (); + $table->style = array (); - //Select box - $fields = get_user_groups ($config["id_user"]); - print_select ($fields, "ag_group", $id_group, 'javascript:this.form.submit();" class="w150',''); + $table->data[0][0] = __('Group'); + $table->data[0][1] = print_select (get_user_groups (), "ag_group", $id_group, + 'javascript:this.form.submit();', '', '', true); - //And submit button - echo ' '.__('Alert fired').' '.__('Alert not fired').' '.__('Alert disabled').'
'; + switch ($filter) { + case 'fired': + $table->style[2] = 'font-weight: bold'; + + break; + case 'notfired': + $table->style[3] = 'font-weight: bold'; + + break; + case 'disabled': + $table->style[4] = 'font-weight: bold'; + + break; + } + + print_table ($table); } -$table->cellpadding = 4; -$table->cellspacing = 4; -$table->width = 750; -$table->border = 0; +$table->width = '90%'; $table->class = "databox"; - $table->head = array (); - $table->head[0] = ''; -$table->head[1] = __('Type'); -$table->head[2] = ''; //Placeholder for name -$table->head[3] = __('Description'); -$table->head[4] = __('Info'); -$table->head[5] = __('Min.').'/'.__('Max.'); -$table->head[6] = __('Last fired'); -$table->head[7] = __('Status'); -$table->head[8] = __('Validate') . pandora_help('alert_validation', true); -$table->align = array (); -$table->align[0] = "center"; -$table->align[1] = "center"; -$table->align[4] = "center"; -$table->align[5] = "center"; -$table->align[6] = "center"; -$table->align[7] = "center"; -$table->align[8] = "center"; - +$table->head[1] = ''; //Placeholder for name +$table->head[2] = __('Template'); +$table->head[3] = __('Last fired'); +$table->head[4] = __('Status'); +$table->head[5] = __('Validate').pandora_help ('alert_validation', true); $table->title = __('Single alerts'); -if ($print_agent == 0) { - $table->head[2] = __('Module name'); -} else { - $table->head[2] = __('Agent name'); -} +if ($print_agent == 0) { + $table->head[1] = __('Module'); +} else { + $table->head[1] = __('Agent'); +} +$table->align = array (); +$table->align[4] = 'center'; +$table->align[5] = 'center'; $table->data = array (); -$counter[0] = 0; //Dual counter. This one counts the total number of alerts -$counter[1] = 0; //Dual counter. This one counts only the printed alerts +$total = 0; +$printed = 0; foreach ($alerts_simple as $alert) { - $counter[0]++; - if (empty ($alert) || $counter[1] >= $config["block_size"] || $counter[0] <= $offset) { + $total++; + if (empty ($alert) || $printed >= $config["block_size"] || $total <= $offset) { continue; } - $counter[1]++; - array_push ($table->data, format_alert_row ($alert, 0, $print_agent, 'alert')); + $printed++; + array_push ($table->data, format_alert_row ($alert, 0, $print_agent, $url)); } if (!empty ($table->data)) { - pagination ($counter[0], $url, $offset); + pagination ($total, $url, $offset); print_table ($table); } else { echo '
'.__('No simple alerts found').'
'; } $table->title = __('Combined alerts'); -$table->head[1] = __('Agent name'); +$table->head[1] = __('Agent'); $table->data = array (); -$counter[2] = 0; -$counter[3] = 0; +$combined_total = 0; +$combined_printed = 0; foreach ($alerts_combined as $alert) { - $counter[2]++; - if (empty ($alert) || $counter[3] >= $config["block_size"] || $counter[2] <= $offset) { + $combined_total++; + if (empty ($alert) || $combined_printed >= $config["block_size"] || $combined_total <= $offset) { continue; } - $counter[3]++; + $combined_printed++; array_push ($table->data, format_alert_row ($alert, 1, $print_agent)); } if (!empty ($table->data)) { - pagination ($counter[0], $url, $offset); + pagination ($total, $url, $offset); print_table ($table); -} else { - echo '
'.__('No combined alerts found').'
'; } -if ($counter[1] > 0 || $counter[2] > 0) { - echo '
'; +if ($printed > 0 || $combined_total > 0) { + echo '
'; print_submit_button (__('Validate'), 'alert_validate', false, 'class="sub upd"', false); echo '
'; } + echo ''; ?> + + + + diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 11c71f8c1e..47e8ac6c74 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -33,7 +33,7 @@ $group_id = get_parameter ("group_id", 0); $ag_group = get_parameter ("ag_group", $group_id); $ag_group = get_parameter_get ("ag_group_refresh", $ag_group); //if it isn't set, defaults to prev. value -$search = get_parameter ("search", ""); +$search = get_parameter ("search"); echo "

".__('Pandora Agents')." > ".__('Summary')."

"; @@ -242,11 +242,11 @@ if ($agents !== false) { echo " - "; +  "; } - echo "  - ".$nombre_agente.""; + echo ''; + echo $nombre_agente; + echo ""; // Show SO icon :) echo ""; @@ -267,7 +267,7 @@ if ($agents !== false) { //echo ' ('; //echo get_group_name ($id_grupo); //echo ")"; - echo ""; + echo ""; echo "".$numero_modulos." : "; diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 42b6acda0c..48ce79d196 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Load global vars -require("include/config.php"); +require ("include/config.php"); check_login (); @@ -43,22 +43,26 @@ function generate_dot ($simple = 0, $font_size) { $graph = open_graph (); // Get agent data - $agents = get_db_all_rows_sql ('SELECT id_grupo, nombre, id_os, id_parent, id_agente FROM tagente WHERE disabled = 0 ORDER BY id_grupo'); - if ($agents) - foreach ($agents as $agent) { - if (give_acl ($config["id_user"], $agent["id_grupo"], "AR") == 0) - continue; - // Save node parent information to define edges later - if ($agent['id_parent'] != "0") { - $parents[$agent['id_agente']] = $agent['id_parent']; - } else { - $orphans[$agent['id_agente']] = 1; - } + $agents = get_db_all_rows_sql ('SELECT id_grupo, nombre, id_os, id_parent, id_agente + FROM tagente + WHERE disabled = 0 + ORDER BY id_grupo'); + if ($agents){ + foreach ($agents as $agent) { + if (give_acl ($config["id_user"], $agent["id_grupo"], "AR") == 0) + continue; + // Save node parent information to define edges later + if ($agent['id_parent'] != "0") { + $parents[$agent['id_agente']] = $agent['id_parent']; + } else { + $orphans[$agent['id_agente']] = 1; + } - // Add node - $graph .= create_node ($agent , $simple, $font_size)."\n\t\t"; + // Add node + $graph .= create_node ($agent , $simple, $font_size)."\n\t\t"; + } } - + // Create a central node if orphan nodes exist if (count ($orphans)) { $graph .= create_pandora_node ($pandora_name, $font_size); @@ -94,7 +98,8 @@ function create_node ($agent, $simple = 0, $font_size = 10) { AND tagente_modulo.id_tipo_modulo in (2, 6, 9, 18, 21, 100) AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 - AND tagente_estado.estado = 1', $agent['id_agente']); + AND tagente_estado.estado = 1', + $agent['id_agente']); $bad_modules = get_db_sql ($sql); // Set node status @@ -105,7 +110,15 @@ function create_node ($agent, $simple = 0, $font_size = 10) { } // Check for alert - $sql = sprintf ('SELECT COUNT(talerta_agente_modulo.id_aam) from talerta_agente_modulo, tagente_modulo, tagente WHERE tagente.id_agente = %d AND tagente.disabled = 0 AND tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo AND talerta_agente_modulo.times_fired > 0 ', $agent['id_agente']); + $sql = sprintf ('SELECT COUNT(talerta_agente_modulo.id_aam) + FROM talerta_agente_modulo, tagente_modulo, tagente + WHERE tagente.id_agente = %d + AND tagente.disabled = 0 + AND tagente.id_agente = tagente_modulo.id_agente + AND tagente_modulo.disabled = 0 + AND tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo + AND talerta_agente_modulo.times_fired > 0 ', + $agent['id_agente']); $alert_modules = get_db_sql ($sql); if ($alert_modules) $status_color = '#FFE308'; @@ -151,7 +164,7 @@ function create_pandora_node ($name, $font_size = 10) { // Opens a group definition function open_group ($id) { - $img = 'images/' . dame_grupo_icono($id) . '.png'; + $img = 'images/'.dame_grupo_icono ($id).'.png'; $name = get_group_name ($id); $group = 'subgraph cluster_' . $id . @@ -160,7 +173,7 @@ function open_group ($id) { >; tooltip="'.$name.'"; URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' . $id . '";'; - + return $group; } @@ -180,27 +193,19 @@ function open_graph () { if ($layout == 'radial') $overlap = 'true'; - if (($layout == 'flat') OR ($layout == 'radial') OR ($layout == 'spring1') OR ($layout == "spring2")) + if ($layout == 'flat' || $layout == 'radial' || $layout == 'spring1' || $layout == "spring2") if ($nooverlap != '') $overlap = 'scalexy'; - if ($pure == 1 && $zoom > 1 ) { $size_x *= $zoom; $size_y *= $zoom; } $size = $size_x . ',' . $size_y; -// -/* -echo "SIZE $size
"; -echo "NO OVERLAP $nooverlap
"; -echo "LAYOUT $layout
"; -echo "FONTSIZE $font_size
"; -echo "RANKSEP $ranksep
"; -*/ + // BEWARE: graphwiz DONT use single ('), you need double (") $head = "graph networkmap { labeljust=l; margin=0; "; - if ($nooverlap != ''){ + if ($nooverlap != '') { $head .= "overlap=\"$overlap\";"; $head .= "ranksep=\"$ranksep\";"; $head .= "outputorder=edgesfirst;"; @@ -208,6 +213,7 @@ echo "RANKSEP $ranksep
"; $head .= "ratio=fill;"; $head .= "root=0;"; $head .= "size=\"$size\";"; + return $head; } @@ -217,7 +223,7 @@ function close_graph () { } // Returns the filter used to achieve the desired layout -function set_filter () { +function set_filter () { global $layout; switch($layout) { @@ -263,7 +269,7 @@ $layout_array = array ( 'spring2' => 'spring 2', 'flat' => 'flat'); -echo '
'; +echo ''; echo ''; echo ''; echo ''; echo '
' . __('Layout') . '  '; @@ -318,7 +324,7 @@ echo '
'; // Set filter -$filter = set_filter(); +$filter = set_filter (); // Generate dot file $graph = generate_dot ($simple, $font_size); @@ -328,12 +334,12 @@ $graph = generate_dot ($simple, $font_size); $filename_map = $config["attachment_store"]."/networkmap_".$layout; $filename_img = "attachment/networkmap_".$layout."_".$font_size; $filename_dot = $config["attachment_store"]."/networkmap_".$layout; -if($simple) { +if ($simple) { $filename_map .= "_simple"; $filename_img .= "_simple"; $filename_dot .= "_simple"; } -if($nooverlap) { +if ($nooverlap) { $filename_map .= "_nooverlap"; $filename_img .= "_nooverlap"; $filename_dot .= "_nooverlap"; @@ -345,7 +351,7 @@ $filename_dot .= ".dot"; if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) { $result = true; } else { - $fh = fopen($filename_dot, 'w'); + $fh = fopen ($filename_dot, 'w'); if ($fh === false) { $result = false; break; @@ -367,13 +373,14 @@ if ($result !== false) { return; } echo ''; - include $filename_map; + include ($filename_map); } else { echo '

'.__('Map could not be generated').'

'; echo $result; echo "
Apparently something went wrong executing the command."; echo "
Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver?"; - echo "
Is your webserver restricted from executing command line tools through the system() call (PHP Safe Mode or SELinux)"; + echo "
Is your webserver restricted from executing command line tools through the system() call (PHP Safe Mode or SELinux)"; + return; } ?> diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 9ab8ffe9e7..d35a136303 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -161,13 +161,6 @@ if (isset($_GET["flag_agent"])){ process_sql ($sql); } } -// Force alert execution -$flag_alert = (int) get_parameter ('flag_alert', 0); -$id_agente_modulo = (int) get_parameter ('id_agente_modulo', 0); -if ($flag_alert == 1 && give_acl ($config['id_user'], $id_grupo, "AW")) { - $sql = "UPDATE talerta_agente_modulo SET flag = 1 WHERE id_agente_modulo = " . $id_agente_modulo; - process_sql ($sql); -} echo "