From 03ed1a9e2bc884d2410e2b44335dfd2fad68de5f Mon Sep 17 00:00:00 2001 From: esanchezm Date: Mon, 12 Jan 2009 14:31:01 +0000 Subject: [PATCH] 2009-01-12 Esteban Sanchez * godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 60 ++ .../lib/libupdate_manager_client.php | 1 - .../extensions/update_manager/main.php | 2 +- .../godmode/agentes/alert_manager.php | 440 +++++++----- .../godmode/agentes/configurar_agente.php | 124 ++-- .../godmode/agentes/manage_config.php | 6 +- .../godmode/agentes/module_manager.php | 191 +++--- .../godmode/alerts/alert_actions.php | 128 ++++ .../godmode/alerts/alert_commands.php | 138 ++++ .../godmode/alerts/alert_templates.php | 201 ++++++ .../godmode/alerts/configure_alert.php | 62 +- .../godmode/alerts/configure_alert_action.php | 121 ++++ .../alerts/configure_alert_command.php | 73 ++ .../alerts/configure_alert_template.php | 590 ++++++++++++++++ .../godmode/alerts/modify_alert.php | 116 ---- pandora_console/godmode/menu.php | 48 +- pandora_console/godmode/setup/setup.php | 6 +- pandora_console/include/functions.php | 7 +- pandora_console/include/functions_alerts.php | 639 ++++++++++++++++++ .../include/functions_custom_graphs.php | 115 ++++ pandora_console/include/functions_db.php | 244 ++++--- pandora_console/include/functions_events.php | 21 +- pandora_console/include/functions_html.php | 145 ++-- .../include/functions_incidents.php | 41 +- pandora_console/include/functions_ui.php | 6 +- pandora_console/include/styles/pandora.css | 139 ++-- pandora_console/index.php | 2 +- .../operation/agentes/networkmap.php | 3 - pandora_console/operation/menu.php | 19 +- .../operation/reporting/graph_viewer.php | 98 +-- .../operation/reporting/reporting_viewer.php | 1 - pandora_console/pandoradb.sql | 97 ++- 32 files changed, 3062 insertions(+), 822 deletions(-) create mode 100644 pandora_console/godmode/alerts/alert_actions.php create mode 100644 pandora_console/godmode/alerts/alert_commands.php create mode 100644 pandora_console/godmode/alerts/alert_templates.php create mode 100644 pandora_console/godmode/alerts/configure_alert_action.php create mode 100644 pandora_console/godmode/alerts/configure_alert_command.php create mode 100644 pandora_console/godmode/alerts/configure_alert_template.php delete mode 100644 pandora_console/godmode/alerts/modify_alert.php create mode 100644 pandora_console/include/functions_alerts.php create mode 100644 pandora_console/include/functions_custom_graphs.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e60199a249..180ec27b49 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,63 @@ +2009-01-12 Esteban Sanchez + + * godmode/agentes/alert_manager.php: Complete rewritten of the alert + system when assigned alerts to an agent. + + * pandoradb.sql: New tables for alert system. These are: + talert_commands, talert_actions, talert_templates, + talert_template_modules, talert_template_module_actions. No migration + tool is available yet. + + * godmode/alerts/configure_alert_template.php, + godmode/alerts/configure_alert_action.php, + godmode/alerts/alert_templates.php, + godmode/alerts/configure_alert_command.php, + godmode/alerts/alert_actions.php: Added to repository. Administration + interface to new alert system. + + * godmode/alerts/modify_alert.php: Deleted from repository. + + * godmode/setup/setup.php: Added an example of the date format. Main + table has now percentage width. + + * godmode/menu.php, operation/menu.php: Added new alert options. + Removed refr value when it's not neccesary. + + * include/styles/pandora.css: Added width to textarea elements. Style + correction and cleanup. Tables doesn't have a odd-even pattern, but + the hovered row now changes its colour. New styles for alert pages. + + * include/functions_custom_graphs.php: Added to repository. custom + graphs functions moved here. + + * include/functions_incidents.php, include/functions_events.php: Moved + to LGPL. Style comment corrections. + + * include/functions_html.php: Documentation style correction. Added + print_input_file() and print_label(). + + * include/functions_ui.php: Doc style correction. + + * operation/reporting/graph_viewer.php: Include new function file with + custom graphs. Use generic functions. + + * index.php: Unset pass from POST and REQUEST arrays. + + * include/functions_db.php: Some documentation updated to new format. + Added format_array_to_update_sql() to generate SQL sentences for + updates. Style correction. + + * godmode/agentes/configurar_agente.php: Variables renamed to have a + meaning. + + * extensions/update_manager/main.php: Mark an string translatable. + + * extensions/update_manager/lib/libupdate_manager_client.php, + godmode/alerts/configure_alert.php, include/functions.php, + godmode/agentes/module_manager.php, operation/agentes/networkmap.php, + operation/reporting/reporting_viewer.php, + godmode/agentes/manage_config.php: Style correction. + 2009-01-12 Sancho Lerena * pandoradb.sql: Removed fields "timestamp" and "id_agente" (and altered diff --git a/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php b/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php index a8675515d3..d6191ad539 100644 --- a/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php +++ b/pandora_console/extensions/update_manager/lib/libupdate_manager_client.php @@ -20,7 +20,6 @@ if ((include_once ('XML/RPC.php')) != 1) error_reporting ($prev_level); unset ($prev_level); - define ('XMLRPC_DEBUG', 0); define ('XMLRPC_TIMEOUT', 15); diff --git a/pandora_console/extensions/update_manager/main.php b/pandora_console/extensions/update_manager/main.php index c02d42a41f..10c53d1532 100644 --- a/pandora_console/extensions/update_manager/main.php +++ b/pandora_console/extensions/update_manager/main.php @@ -51,7 +51,7 @@ $user_key = get_user_key ($settings); $update_package = (bool) get_parameter_post ('update_package'); if ($update_package) { - echo '

Updating...

'; + echo '

'.__('Updating').'...

'; flush (); $force = (bool) get_parameter_post ('force_update'); diff --git a/pandora_console/godmode/agentes/alert_manager.php b/pandora_console/godmode/agentes/alert_manager.php index 84f2a44a08..701228e780 100644 --- a/pandora_console/godmode/agentes/alert_manager.php +++ b/pandora_console/godmode/agentes/alert_manager.php @@ -17,175 +17,311 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Load global vars +require_once ('include/config.php'); +require_once ('include/functions_alerts.php'); + if (!isset ($id_agente)) { die ("Not Authorized"); } echo "

".__('Agent configuration')." > ".__('Alerts')."

"; -// ========================== -// Create module/type combo -// ========================== -echo ''; -echo ''; -echo ""; -echo '
"; -echo ''; -echo ''; -echo ""; -echo "
"; - -// ========================== -// Simple alerts view -// ========================== - -$sql = 'SELECT * FROM tagente_modulo WHERE id_agente = "'.$id_agente.'"'; -$result = mysql_query ($sql); -if ($row = mysql_num_rows( $result)) { - - echo "

".__('Simple alerts')."

"; - - $color=1; - $string=''; - while ($row=mysql_fetch_array($result)){ // All modules of this agent - $id_tipo = $row["id_tipo_modulo"]; - $nombre_modulo = substr($row["nombre"],0,21); - //module type modulo is $row2["nombre"]; +if ($create_alert) { + $id_alert_template = (int) get_parameter ('template'); + $id_agent_module = (int) get_parameter ('id_agent_module'); + + $id = create_alert_agent_module ($id_agent_module, $id_alert_template); + print_error_message ($id, __('Successfully created'), + __('Could not be created')); + if ($id !== false) { + $id_alert_action = (int) get_parameter ('action'); + $fires_min = (int) get_parameter ('fires_min'); + $fires_max = (int) get_parameter ('fires_max'); + $values = array (); + if ($fires_min != -1) + $values['fires_min'] = $fires_min; + if ($fires_max != -1) + $values['fires_max'] = $fires_max; - $sql = 'SELECT * - FROM talerta_agente_modulo - WHERE id_agente_modulo = '.$row["id_agente_modulo"]; - // From all the alerts give me which are from my agent - $result3=mysql_query($sql); - while ($row3=mysql_fetch_array($result3)){ - if ($color == 1){ - $tdcolor="datos"; - $color =0; - } else { - $tdcolor="datos2"; - $color =1; - } - $sql4='SELECT nombre FROM talerta WHERE id_alerta = '.$row3["id_alerta"]; - $result4=mysql_query($sql4); - $row4=mysql_fetch_array($result4); - // Alert name defined by $row4["nombre"]; - $nombre_alerta = $row4["nombre"]; - $string = $string."".$nombre_modulo; - - $string .= show_alert_row_edit ($row3, $tdcolor, $row["id_tipo_modulo"],0); - $string = $string.""; - $id_grupo = dame_id_grupo($id_agente); - if (give_acl ($config['id_user'], $id_grupo, "LW")) { - $string = $string." - ".__(   "; - $string = $string." - ".__("; - } - $string = $string.""; - } + add_alert_agent_module_action ($id, $id_alert_action, $values); } - if (isset($string) & $string!='') { - echo " - - - - - - - - - - "; - echo $string; - echo "
".__('Name')."".__('Type')."".__('Alert')."".__('Threshold')."".__('Min.')."".__('Max.')."".__('Time')."".__('Description')."".__('info')."".__('Action')."
"; - } else { - echo "
".__('This agent doesn\'t have any alert')."
"; - } -} else { - echo "
".__('This agent doesn\'t have any module')."
"; } -// ========================== -// Combined alerts view -// ========================== +if ($add_action) { + $id_action = (int) get_parameter ('action'); + $id_alert_module = (int) get_parameter ('id_alert_module'); + $fires_min = (int) get_parameter ('fires_min'); + $fires_max = (int) get_parameter ('fires_max'); + $values = array (); + if ($fires_min != -1) + $values['fires_min'] = $fires_min; + if ($fires_max != -1) + $values['fires_max'] = $fires_max; + + $result = add_alert_agent_module_action ($id_alert_module, $id_action, $values); + print_error_message ($id, __('Successfully added'), + __('Could not be added')); +} -echo "

".__('Combined alerts')."

"; +$modules = get_agent_modules ($id_agente, + array ('id_tipo_modulo', 'nombre', 'id_agente')); -$sql = 'SELECT * FROM talerta_agente_modulo WHERE id_agent = '.$id_agente; -$result = mysql_query ($sql); -if (mysql_num_rows($result) == 0) { - echo "
".__('This agent doesn\'t have any module')."
"; -} else { - $color = 1; - $string = ""; - while ($row=mysql_fetch_array($result)){ - // Show data for this combined alert - $string .= ""; - $string .= __('Combined')." #".$row["id_aam"]; - $string .= show_alert_row_edit ($row, "datos3", 0, 1); - $string .= ''; // action - if (give_acl($config['id_user'], $id_grupo, "LW")==1){ - $string .= " ".__(   "; - $string .= " - ".__("; - } - $id_aam = $row["id_aam"]; - $sql = "SELECT * FROM tcompound_alert, talerta_agente_modulo WHERE tcompound_alert.id = $id_aam AND talerta_agente_modulo.id_aam = tcompound_alert.id_aam"; - $result2 = mysql_query ($sql); - while ($row2 = mysql_fetch_array($result2)) { - // Show data for each component of this combined alert - if ($color == 1){ - $tdcolor="datos"; - $color =0; - } else { - $tdcolor="datos2"; - $color =1; - } - $module = get_db_row ("tagente_modulo", "id_agente_modulo", $row2["id_agente_modulo"]); - $description = $row2["descripcion"]; - $alert_mode = $row2["operation"]; - $id_agente_name = get_db_value ("nombre", "tagente", "id_agente", $module["id_agente"]); - $string .= "".$id_agente_name." - ".substr($module["nombre"],0,15).""; - - $string .= show_alert_row_edit ($row2, $tdcolor, $module["id_tipo_modulo"],1); +echo "

".__('Modules defined')."

"; - $string .= ""; - $id_grupo = dame_id_grupo($id_agente); - if (give_acl($config['id_user'], $id_grupo, "LW")==1){ - $string .= " ".__(   "; - $string .= " - ".__("; - } - $string .= ""; - } +$table->id = 'modules'; +$table->cellspacing = '0'; +$table->width = '90%'; +$table->head = array (); +$table->head[0] = __('Module'); +$table->data = array (); +$table->style = array (); +$table->style[1] = 'vertical-align: top'; + +$table_alerts->class = 'listing'; +$table_alerts->width = '100%'; +$table_alerts->size = array (); +$table_alerts->size[0] = '50%'; +$table_alerts->size[1] = '50%'; +$table_alerts->style = array (); +$table_alerts->style[0] = 'vertical-align: top'; +$table_alerts->style[1] = 'vertical-align: top'; + +foreach ($modules as $id_agent_module => $module) { + $data = array (); + + $last_data = return_value_agent_module ($id_agent_module); + if ($last_data === false) + $last_data = ''.__('N/A').''; + + $data[0] = ''.$module['nombre'].''; + $data[0] .= ''; + $data[0] .= ''; + + + /* Alerts in module list */ + $table_alerts->id = 'alerts-'.$id_agent_module; + $table_alerts->data = array (); + + $alerts = get_alerts_agent_module ($id_agent_module); + if ($alerts === false) { + $alerts = array (); + } else { + $data[0] .= '

'; + $data[0] .= __('Alerts'); + $data[0] .= '

'; } - if (isset($string) & $string != "") { - echo " - - - - - - - - - - "; - echo $string; - echo "
".__('Name')."".__('Type')."".__('Oper')."".__('Threshold')."".__('Min.')."".__('Max.')."".__('Time')."".__('Description')."".__('info')."".__('Action')."
"; - } else { - echo "
".__('This agent doesn\'t have any alert')."
"; + foreach ($alerts as $alert) { + $alert_data = array (); + + $alert_actions = get_alert_agent_module_actions ($alert['id']); + + $alert_data[0] = get_alert_template_name ($alert['id_alert_template']); + $alert_data[0] .= ''; + + $alert_data[1] = '
    '; + foreach ($alert_actions as $action) { + $alert_data[1] .= '
  • '; + $alert_data[1] .= ''; + $alert_data[1] .= $action['name'].' '; + $alert_data[1] .= '('; + if ($action['fires_min'] == $action['fires_max']) { + if ($action['fires_min'] == 0) + $alert_data[1] .= __('Always'); + else + $alert_data[1] .= __('On').' '.$action['fires_min']; + } else { + if ($action['fires_min'] == 0) + $alert_data[1] .= __('Until').' '.$action['fires_max']; + else + $alert_data[1] .= __('From').' '.$action['fires_min']. + ' '.__('to').' '.$action['fires_max']; + } + + $alert_data[1] .= ')'; + $alert_data[1] .= ''; + $alert_data[1] .= ' '; + $alert_data[1] .= '
  • '; + } + $alert_data[1] .= '
'; + + $alert_data[1] .= ''; + + $table_alerts->data['alert-'.$alert['id']] = $alert_data; } -} + + $data[0] .= print_table ($table_alerts, true); + array_push ($table->data, $data); +} + +print_table ($table); + +/* This hidden value is used in Javascript. It's a workaraound for IE because + it doesn't allow input elements creation. */ +print_input_hidden ('add_action', 1); +print_input_hidden ('id_alert_module', 0); + +echo ''; ?> + + + + diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 1b0cc0508b..75dbcc5d7e 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -567,8 +567,8 @@ if (isset($_GET["id_agente"])) { exit; } - $row = get_db_row ('tagente', 'id_agente', $id_agente); - if (empty ($row)) { + $agent = get_db_row ('tagente', 'id_agente', $id_agente); + if (empty ($agent)) { //Close out the page echo '

'.__('There was a problem loading agent').'

'; echo ''; +} + +function update_template ($step) { + $id = (int) get_parameter ('id'); + + if (empty ($id)) + return false; + + if ($step == 1) { + $type = (string) get_parameter ('type'); + $name = (string) get_parameter ('name'); + $description = (string) get_parameter ('description'); + $type = (string) get_parameter ('type'); + $value = (string) get_parameter ('value'); + $max = (float) get_parameter ('max'); + $min = (float) get_parameter ('min'); + + $result = update_alert_template ($id, + array ('type' => $type, + 'description' => $description, + 'value' => $value, + 'max_value' => $max, + 'min_value' => $min)); + } elseif ($step == 2) { + $monday = (bool) get_parameter ('monday'); + $tuesday = (bool) get_parameter ('tuesday'); + $wednesday = (bool) get_parameter ('wednesday'); + $thursday = (bool) get_parameter ('thursday'); + $friday = (bool) get_parameter ('friday'); + $saturday = (bool) get_parameter ('saturday'); + $sunday = (bool) get_parameter ('sunday'); + $time_from = (string) get_parameter ('time_from'); + $time_from = date ("H:s:00", strtotime ($time_from)); + $time_to = (string) get_parameter ('time_to'); + $time_to = date ("H:s:00", strtotime ($time_to)); + $threshold = (int) get_parameter ('threshold'); + if ($threshold == -1) + $threshold = (int) get_parameter ('other_threshold'); + $field1 = (string) get_parameter ('field1'); + $field2 = (string) get_parameter ('field2'); + $field3 = (string) get_parameter ('field3'); + $default_action = (int) get_parameter ('default_action'); + if (empty ($default_action)) { + $default_action = NULL; + $field1 = ''; + $field2 = ''; + $field3 = ''; + } + + $values = array ('monday' => $monday, + 'tuesday' => $tuesday, + 'wednesday' => $wednesday, + 'thursday' => $thursday, + 'friday' => $friday, + 'saturday' => $saturday, + 'sunday' => $sunday, + 'time_from' => $time_from, + 'time_to' => $time_to, + 'time_threshold' => $threshold, + 'default_action' => $default_action, + 'field1' => $field1, + 'field2' => $field2, + 'field3' => $field3 + ); + + if ($default_action) { + $values['id_alert_action'] = $default_action; + $values['field1'] = $field1; + $values['field2'] = $field2; + $values['field3'] = $field3; + } + + $result = update_alert_template ($id, $values); + } elseif ($step == 3) { + $recovery_notify = (bool) get_parameter ('recovery_notify'); + $field2_recovery = (bool) get_parameter ('field2_recovery'); + $field3_recovery = (bool) get_parameter ('field3_recovery'); + + $result = update_alert_template ($id, + array ('recovery_notify' => $recovery_notify, + 'field2_recovery' => $field2_recovery, + 'field3_recovery' => $field3_recovery)); + } else { + return false; + } + + return $result; +} + +$id = (int) get_parameter ('id'); + +/* We set here the number of steps */ +define ('LAST_STEP', 3); + +$step = (int) get_parameter ('step', 1); + +$create_template = (bool) get_parameter ('create_template'); +$update_template = (bool) get_parameter ('update_template'); + +$name = ''; +$description = ''; +$type = ''; +$value = ''; +$max = ''; +$min = ''; +$time_from = '12:00'; +$time_to = '12:00'; +$monday = true; +$tuesday = true; +$wednesday = true; +$thursday = true; +$friday = true; +$saturday = true; +$sunday = true; +$default_action = 0; +$field1 = ''; +$field2 = ''; +$field3 = ''; +$min_alerts = 0; +$max_alerts = 1; +$threshold = 300; +$recovery_notify = false; +$field2_recovery = ''; +$field3_recovery = ''; + +if ($create_template) { + $name = (string) get_parameter ('name'); + $description = (string) get_parameter ('description'); + $type = (string) get_parameter ('type'); + $value = (string) get_parameter ('value'); + $max = (float) get_parameter ('max'); + $min = (float) get_parameter ('min'); + + $result = create_alert_template ($name, $type, + array ('description' => $description, + 'value' => $value, + 'max' => $max, + 'min' => $min)); + + print_error_message ($result, __('Successfully created'), + __('Could not be created')); + /* Go to previous step in case of error */ + if ($result === false) + $step = $step - 1; +} + +if ($update_template) { + $result = update_template ($step - 1); + + print_error_message ($result, __('Successfully updated'), + __('Could not be updated')); + /* Go to previous step in case of error */ + if ($result === false) { + $step = $step - 1; + } +} + +if ($id) { + $template = get_alert_template ($id); + $name = $template['name']; + $description = $template['description']; + $type = $template['type']; + $value = $template['value']; + $max = $template['max_value']; + $min = $template['min_value']; + $time_from = $template['time_from']; + $time_to = $template['time_to']; + $monday = (bool) $template['monday']; + $tuesday = (bool) $template['tuesday']; + $wednesday = (bool) $template['wednesday']; + $thursday = (bool) $template['thursday']; + $friday = (bool) $template['friday']; + $saturday = (bool) $template['saturday']; + $sunday = (bool) $template['sunday']; + $max_alerts = $template['max_alerts']; + $min_alerts = $template['min_alerts']; + $threshold = $template['time_threshold']; + $recovery_notify = $template['recovery_notify']; + $field2_recovery = $template['field2_recovery']; + $field3_recovery = $template['field3_recovery']; + $default_action = $template['id_alert_action']; + $field1 = $template['field1']; + $field2 = $template['field2']; + $field3 = $template['field3']; +} + +echo '

'.__('Configure alert template').'

'; + +print_alert_template_steps ($step, $id); + +$table->id = 'template'; +$table->width = '90%'; +$table->style = array (); +$table->style[0] = 'font-weight: bold'; +$table->style[2] = 'font-weight: bold'; +$table->size = array (); +$table->size[0] = '20%'; +$table->size[2] = '20%'; + +if ($step == 2) { + /* Firing conditions and events */ + $threshold_values = get_alert_template_threshold_values (); + if (in_array ($threshold, array_keys ($threshold_values))) { + $table->style['other_label'] = 'display:none; font-weight: bold'; + $table->style['other_input'] = 'display:none'; + $threshold_selected = $threshold; + } else { + $table->style['other_label'] = 'font-weight: bold'; + $threshold_selected = -1; + } + + if ($default_action == 0) { + $table->rowstyle = array (); + $table->rowstyle['field1'] = 'display: none'; + $table->rowstyle['field2'] = 'display: none'; + $table->rowstyle['field3'] = 'display: none'; + $table->rowstyle['preview'] = 'display: none'; + } + $table->colspan = array (); + $table->colspan[0][1] = 3; + $table->colspan[4][1] = 3; + $table->colspan['field1'][1] = 3; + $table->colspan['field2'][1] = 3; + $table->colspan['field3'][1] = 3; + $table->colspan['preview'][1] = 3; + + $table->data[0][0] = __('Days of week'); + $table->data[0][1] = __('Mon'); + $table->data[0][1] .= print_checkbox ('monday', 1, $monday, true); + $table->data[0][1] .= __('Tue'); + $table->data[0][1] .= print_checkbox ('tuesday', 1, $tuesday, true); + $table->data[0][1] .= __('Wed'); + $table->data[0][1] .= print_checkbox ('wednesday', 1, $wednesday, true); + $table->data[0][1] .= __('Thu'); + $table->data[0][1] .= print_checkbox ('thursday', 1, $thursday, true); + $table->data[0][1] .= __('Fri'); + $table->data[0][1] .= print_checkbox ('friday', 1, $friday, true); + $table->data[0][1] .= __('Sat'); + $table->data[0][1] .= print_checkbox ('saturday', 1, $saturday, true); + $table->data[0][1] .= __('Sun'); + $table->data[0][1] .= print_checkbox ('sunday', 1, $sunday, true); + + $table->data[1][0] = __('Time from'); + $table->data[1][1] = print_input_text ('time_from', $time_from, '', 7, 7, + true); + $table->data[1][2] = __('Time to'); + $table->data[1][3] = print_input_text ('time_to', $time_to, '', 7, 7, + true); + + $table->data['threshold'][0] = __('Time threshold'); + $table->data['threshold'][1] = print_select ($threshold_values, + 'threshold', $threshold_selected, '', '', '', true, false, false); + $table->data['threshold']['other_label'] = __('Other value'); + $table->data['threshold']['other_input'] = print_input_text ('other_threshold', + $threshold, '', 5, 7, true); + $table->data['threshold']['other_input'] .= ' '.__('seconds'); + + $table->data[3][0] = __('Min. number of alerts'); + $table->data[3][1] = print_input_text ('min_alerts', $min_alerts, '', + 5, 7, true); + $table->data[3][2] = __('Max. number of alerts'); + $table->data[3][3] = print_input_text ('max_alerts', $max_alerts, '', + 5, 7, true); + + $table->data[4][0] = __('Default action'); + $table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name', + 'default_action', $default_action, '', __('None'), 0, + true, false, false); + + $table->data['field1'][0] = __('Field 1'); + $table->data['field1'][1] = print_input_text ('field1', $field1, '', 35, 255, true); + + $table->data['field2'][0] = __('Field 2'); + $table->data['field2'][1] = print_input_text ('field2', $field2, '', 35, 255, true); + + $table->data['field3'][0] = __('Field 3'); + $table->data['field3'][1] = print_textarea ('field3', 30, 30, $field3, '', true); + + $table->data['preview'][0] = __('Command preview'); + $table->data['preview'][1] = print_textarea ('command_preview', 30, 30, + '', 'disabled="disabled"', true); +} else if ($step == 3) { + /* Alert recover */ + if (! $recovery_notify) { + $table->rowstyle = array (); + $table->rowstyle['field2'] = 'display:none;'; + $table->rowstyle['field3'] = 'display:none'; + } + $table->data[0][0] = __('Alert recovery'); + $values = array (false => __('Disabled'), true => __('Enabled')); + $table->data[0][1] = print_select ($values, + 'recovery_notify', $recovery_notify, '', '', '', true, false, + false); + + $table->data['field2'][0] = __('Field 2'); + $table->data['field2'][1] = print_input_text ('field2_recovery', + $field2_recovery, '', 35, 255, true); + + $table->data['field3'][0] = __('Field 3'); + $table->data['field3'][1] = print_textarea ('field3_recovery', 30, 30, + $field3_recovery, '', true); +} else { + /* Step 1 by default */ + $table->size = array (); + $table->size[0] = '20%'; + $table->data = array (); + $table->rowstyle = array (); + $table->rowstyle['value'] = 'display: none'; + $table->rowstyle['max'] = 'display: none'; + $table->rowstyle['min'] = 'display: none'; + + if ($id) { + switch ($type) { + case "equal": + case "not_equal": + case "regex": + $table->rowstyle['value'] = ''; + break; + case "max_min": + case "max": + $table->rowstyle['max'] = ''; + if ($type == 'max') + break; + case "min": + $table->rowstyle['min'] = ''; + break; + } + } + + $table->data[0][0] = __('Name'); + $table->data[0][1] = print_input_text ('name', $name, '', 35, 255, true); + + $table->data[1][0] = __('Description'); + $table->data[1][1] = print_textarea ('description', 30, 30, + $description, '', true); + + $table->data[2][0] = __('Condition type'); + $table->data[2][1] = print_select (get_alert_templates_types (), 'type', + $type, '', __('Select'), 0, true, false, false); + + $table->data['value'][0] = __('Value'); + $table->data['value'][1] = print_input_text ('value', $value, '', + 35, 255, true); + $table->data['value'][1] .= ''; + $table->data['value'][1] .= print_image ('images/suc.png', true, + array ('style' => 'display:none', + 'id' => 'regex_good', + 'title' => __('The regular expression is valid'))); + $table->data['value'][1] .= print_image ('images/err.png', true, + array ('style' => 'display:none', + 'id' => 'regex_bad', + 'title' => __('The regular expression is not valid'))); + $table->data['value'][1] .= ''; + + $table->data['max'][0] = __('Max'); + $table->data['max'][1] = print_input_text ('max', $max, '', 5, 255, true); + + $table->data['min'][0] = __('Min'); + $table->data['min'][1] = print_input_text ('min', $min, '', 5, 255, true); +} + +/* If it's the last step it will redirect to template lists */ +if ($step >= LAST_STEP) { + echo '
'; +} else { + echo ''; +} +print_table ($table); + +echo '
'; +if ($id) { + print_input_hidden ('id', $id); + print_input_hidden ('update_template', 1); +} else { + print_input_hidden ('create_template', 1); +} + +if ($step >= LAST_STEP) { + print_submit_button (__('Finish'), 'finish', false, 'class="sub upd"'); +} else { + print_input_hidden ('step', $step + 1); + print_submit_button (__('Next'), 'next', false, 'class="sub next"'); +} +echo '
'; +echo '
'; +?> + + + + + + + + diff --git a/pandora_console/godmode/alerts/modify_alert.php b/pandora_console/godmode/alerts/modify_alert.php deleted file mode 100644 index 0cf1d24b7b..0000000000 --- a/pandora_console/godmode/alerts/modify_alert.php +++ /dev/null @@ -1,116 +0,0 @@ -".__('There was a problem updating alert').""; - } else { - echo "

".__('Alert successfully updated')."

"; - } -} - -if (isset($_POST["crear_alerta"])){ // if create alert - $nombre = entrada_limpia($_POST["nombre"]); - $comando = entrada_limpia($_POST["comando"]); - $descripcion= entrada_limpia($_POST["descripcion"]); - $sql_update ="INSERT talerta (nombre, comando, descripcion) VALUES ('".$nombre."', '".$comando."', '".$descripcion."')"; - $result=mysql_query($sql_update); - if (! $result) - echo "

".__('There was a problem creating alert')."

"; - else - echo "

".__('Alert successfully created')."

"; -} - -if (isset($_GET["borrar_alerta"])){ // if delete alert - $id_alerta = entrada_limpia($_GET["borrar_alerta"]); - if ($id_alerta < 4) { - audit_db ($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access Alert Management"); - require ("general/noaccess.php"); - exit; - } - $sql_delete= "DELETE FROM talerta WHERE id_alerta = ".$id_alerta; - $result=mysql_query($sql_delete); - if (! $result) - echo "

".__('There was a problem deleting alert')."

"; - else - echo "

".__('Alert successfully deleted')."

"; - - $sql_delete2 ="DELETE FROM talerta_agente_modulo WHERE id_alerta = ".$id_alerta; - $result=mysql_query($sql_delete2); -} - -echo "

".__('Alert configuration')." > "; -echo __('Alerts defined in Pandora')."

"; -echo ""; -echo ""; -echo ""; -echo ""; -$color=1; -$sql1='SELECT * FROM talerta'; -$result=mysql_query($sql1); -while ($row=mysql_fetch_array($result)){ - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - if ($row[0] > 4){ - echo ""; - echo ""; - echo ""; - } else { - echo ""; - echo ""; - } -} - -echo "
".__('Alert name')."".__('Description')."".__('Delete')."
".$row["nombre"]."".$row["descripcion"]."
".$row["nombre"]."".$row["descripcion"]."
"; -echo ""; -echo "
"; -echo "
"; -echo ""; -echo "
"; -echo "
"; -?> diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 0ff3d46f1f..ab498723db 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -25,61 +25,58 @@ if ((! give_acl ($config['id_user'], 0, "LM")) && (! give_acl ($config['id_user' } if (give_acl ($config['id_user'], 0, "AW")) { - $menu["gagente"]["text"] = __('Manage agents'); $menu["gagente"]["sec2"] = "godmode/agentes/modificar_agente"; - $menu["gagente"]["refr"] = 0; $menu["gagente"]["id"] = "god-agents"; $sub = array (); $sub["godmode/agentes/manage_config"]["text"] = __('Manage config'); - $sub["godmode/agentes/manage_config"]["refr"] = 0; $sub["godmode/agentes/manage_config_remote"]["text"] = __('Duplicate config'); - $sub["godmode/agentes/manage_config_remote"]["refr"] = 0; if (give_acl ($config["id_user"], 0, "PM")) { $sub["godmode/groups/group_list"]["text"] = __('Manage groups'); - $sub["godmode/groups/group_list"]["refr"] = 0; } $sub["godmode/agentes/planned_downtime"]["text"] = __('Scheduled downtime'); - $sub["godmode/agentes/planned_downtime"]["refr"] = 0; $menu["gagente"]["sub"] = $sub; } if (give_acl ($config['id_user'], 0, "PM")) { $menu["gmodules"]["text"] = __('Manage modules'); $menu["gmodules"]["sec2"] = "godmode/agentes/modificar_agente"; - $menu["gmodules"]["refr"] = 0; $menu["gmodules"]["id"] = "god-modules"; $sub = array (); $sub["godmode/modules/manage_nc_groups"]["text"] = __('Component groups'); - $sub["godmode/modules/manage_nc_groups"]["refr"] = 0; $sub["godmode/modules/manage_network_components"]["text"] = __('Module components'); - $sub["godmode/modules/manage_network_components"]["refr"] = 0; $sub["godmode/modules/manage_network_templates"]["text"] = __('Module templates'); - $sub["godmode/modules/manage_network_templates"]["refr"] = 0; - + enterprise_hook ('inventory_submenu'); - + $menu["gmodules"]["sub"] = $sub; } if (give_acl ($config['id_user'], 0, "LM")) { $menu["galertas"]["text"] = __('Manage alerts'); $menu["galertas"]["sec2"] = "godmode/alerts/modify_alert"; - $menu["galertas"]["refr"] = 0; $menu["galertas"]["id"] = "god-alerts"; + + $sub = array (); + $sub["godmode/alerts/alert_templates"]["text"] = __('Templates'); + + $sub["godmode/alerts/alert_actions"]["text"] = __('Actions'); + + $sub["godmode/alerts/alert_commands"]["text"] = __('Commands'); + + $menu["galertas"]["sub"] = $sub; } if (give_acl ($config['id_user'], 0, "UM")) { $menu["gusuarios"]["text"] = __('Manage users'); $menu["gusuarios"]["sec2"] = "godmode/users/user_list"; - $menu["gusuarios"]["refr"] = 0; $menu["gusuarios"]["id"] = "god-users"; } @@ -87,13 +84,11 @@ if (give_acl ($config['id_user'], 0, "UM")) { if (give_acl($config['id_user'], 0, "AW")) { $menu["gsnmpconsole"]["text"] = __('Manage SNMP console'); $menu["gsnmpconsole"]["sec2"] = "godmode/snmpconsole/snmp_alert"; - $menu["gsnmpconsole"]["refr"] = 0; $menu["gsnmpconsole"]["id"] = "god-snmpc"; //SNMP Console alert $sub = array (); $sub["godmode/snmpconsole/snmp_alert"]["text"] = __('Component groups'); - $sub["godmode/snmpconsole/snmp_alert"]["refr"] = 0; enterprise_hook ('snmpconsole_submenu'); @@ -104,45 +99,36 @@ if (give_acl($config['id_user'], 0, "AW")) { if (give_acl ($config['id_user'], 0, "PM")) { $menu["greporting"]["text"] = __('Manage reports'); $menu["greporting"]["sec2"] = "godmode/reporting/reporting_builder"; - $menu["greporting"]["refr"] = 0; $menu["greporting"]["id"] = "god-reporting"; // Custom report builder $sub = array (); $sub["godmode/reporting/reporting_builder"]["text"] = __('Report builder'); - $sub["godmode/reporting/reporting_builder"]["refr"] = 0; // Custom graph builder $sub["godmode/reporting/graph_builder"]["text"] = __('Graph builder'); - $sub["godmode/reporting/graph_builder"]["refr"] = 0; // Custom map builder $sub["godmode/reporting/map_builder"]["text"] = __('Map builder'); - $sub["godmode/reporting/map_builder"]["refr"] = 0; $menu["greporting"]["sub"] = $sub; // Manage profiles $menu["gperfiles"]["text"] = __('Manage profiles'); $menu["gperfiles"]["sec2"] = "godmode/profiles/profile_list"; - $menu["gperfiles"]["refr"] = 0; $menu["gperfiles"]["id"] = "god-profiles"; // Servers $menu["gservers"]["text"] = __('Manage servers'); $menu["gservers"]["sec2"] = "godmode/servers/modificar_server"; - $menu["gservers"]["refr"] = 0; $menu["gservers"]["id"] = "god-servers"; $sub = array (); $sub["godmode/servers/manage_recontask"]["text"] = __('Manage recontask'); - $sub["godmode/servers/manage_recontask"]["refr"] = 0; $sub["godmode/servers/plugin"]["text"] = __('Manage plugins'); - $sub["godmode/servers/plugin"]["refr"] = 0; $sub["godmode/servers/manage_export_form"]["text"] = __('Export targets'); - $sub["godmode/servers/manage_export_form"]["refr"] = 0; $menu["gservers"]["sub"] = $sub; @@ -151,21 +137,17 @@ if (give_acl ($config['id_user'], 0, "PM")) { // Audit $menu["glog"]["text"] = __('System audit log'); $menu["glog"]["sec2"] = "godmode/admin_access_logs"; - $menu["glog"]["refr"] = 0; $menu["glog"]["id"] = "god-audit"; // Setup $menu["gsetup"]["text"] = __('Pandora setup'); $menu["gsetup"]["sec2"] = "godmode/setup/setup"; - $menu["gsetup"]["refr"] = 0; $menu["gsetup"]["id"] = "god-setup"; $sub = array (); $sub["godmode/setup/links"]["text"] = __('Links'); - $sub["godmode/setup/links"]["refr"] = 0; $sub["godmode/setup/news"]["text"] = __('Site news'); - $sub["godmode/setup/news"]["refr"] = 0; $menu["gsetup"]["sub"] = $sub; } @@ -173,27 +155,20 @@ if (give_acl ($config['id_user'], 0, "PM")) { if (give_acl ($config['id_user'], 0, "DM")) { $menu["gdbman"]["text"] = __('DB Maintenance'); $menu["gdbman"]["sec2"] = "godmode/db/db_main"; - $menu["gdbman"]["refr"] = 0; $menu["gdbman"]["id"] = "god-dbmaint"; $sub = array (); $sub["godmode/db/db_info"]["text"] = __('DB Information'); - $sub["godmode/db/db_info"]["refr"] = 0; $sub["godmode/db/db_purge"]["text"] = __('Database purge'); - $sub["godmode/db/db_purge"]["refr"] = 0; $sub["godmode/db/db_refine"]["text"] = __('Database debug'); - $sub["godmode/db/db_refine"]["refr"] = 0; $sub["godmode/db/db_audit"]["text"] = __('Database audit'); - $sub["godmode/db/db_audit"]["refr"] = 0; $sub["godmode/db/db_event"]["text"] = __('Database event'); - $sub["godmode/db/db_event"]["refr"] = 0; $sub["godmode/db/db_sanity"]["text"] = __('Database sanity'); - $sub["godmode/db/db_sanity"]["refr"] = 0; $menu["gdbman"]["sub"] = $sub; } @@ -201,7 +176,6 @@ if (give_acl ($config['id_user'], 0, "DM")) { if (is_array ($config['extensions'])) { $menu["gextensions"]["text"] = __('Extensions'); $menu["gextensions"]["sec2"] = "godmode/extensions"; - $menu["gextensions"]["refr"] = 0; $menu["gextensions"]["id"] = "god-extensions"; $sub = array (); diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 98653694ba..e068e25be3 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -80,13 +80,14 @@ echo __('General configuration').""; $file_styles = list_files('include/styles/', "pandora", 1, 0); -$table->width = '500px'; +$table->width = '90%'; $table->data = array (); $table->data[0][0] = __('Language Code for Pandora'); $table->data[0][1] = print_select_from_sql ('SELECT id_language, name FROM tlanguage', 'language_code', $config["language"], '', '', '', true); $table->data[1][0] = __('Date format string') . pandora_help("date_format", true); -$table->data[1][1] = print_input_text ('date_format', $config["date_format"], '', 30, 100, true); +$table->data[1][1] = ''.__('Example').' '.date ($config["date_format"]); +$table->data[1][1] .= print_input_text ('date_format', $config["date_format"], '', 30, 100, true); $table->data[2][0] = __('Remote config directory'); $table->data[2][1] = print_input_text ('remote_config', $config["remote_config"], '', 30, 100, true); @@ -150,7 +151,6 @@ echo ''; ?> - -