From 428e4e0baf2da37cd277ef1df690438787286a86 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 17 Sep 2010 12:34:11 +0000 Subject: [PATCH] 2010-09-17 Sergio Martin * include/functions_events.php pandoradb.sql extras/pandoradb_migrate_v3.1_to_v3.2.sql operation/events/events_validate.php operation/events/events_list.php operation/events/events.php: Deleted several columns from the events view and adding a show/hide advanced fields feature. Added a new state 'in process' to validation and an input comment when a status is changed. * include/fgraph.php: Fixed quotes in constant definition * include/functions_ui.php include/functions_agents.php include/functions_alerts.php operation/agentes/alerts_status.php operation/agentes/alerts_status.functions.php images/bell_pause.png godmode/alerts/alert_list.list.php godmode/alerts/alert_list.php godmode/massive/massive_operations.php godmode/massive/massive_standby_alerts.php: Added the feature of set and set off on standby an alert in the alets management and view if an alert is in standby in the rest of views. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3251 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 30 + .../extras/pandoradb_migrate_v3.1_to_v3.2.sql | 5 + .../godmode/alerts/alert_list.list.php | 183 ++++-- pandora_console/godmode/alerts/alert_list.php | 23 +- .../godmode/massive/massive_operations.php | 5 +- .../massive/massive_standby_alerts.php | 206 ++++++ pandora_console/images/bell_pause.png | Bin 0 -> 863 bytes pandora_console/include/fgraph.php | 5 +- pandora_console/include/functions_agents.php | 51 +- pandora_console/include/functions_alerts.php | 7 + pandora_console/include/functions_events.php | 107 +++- pandora_console/include/functions_ui.php | 30 +- .../agentes/alerts_status.functions.php | 25 +- .../operation/agentes/alerts_status.php | 155 +++-- pandora_console/operation/events/events.php | 596 ++++-------------- .../operation/events/events_list.php | 579 +++++++++++++++++ .../operation/events/events_validate.php | 84 +++ pandora_console/pandoradb.sql | 2 +- 18 files changed, 1450 insertions(+), 643 deletions(-) create mode 100644 pandora_console/godmode/massive/massive_standby_alerts.php create mode 100644 pandora_console/images/bell_pause.png create mode 100644 pandora_console/operation/events/events_list.php create mode 100644 pandora_console/operation/events/events_validate.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 66450bed8c..0380202be9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,33 @@ +2010-09-17 Sergio Martin + + * include/functions_events.php + pandoradb.sql + extras/pandoradb_migrate_v3.1_to_v3.2.sql + operation/events/events_validate.php + operation/events/events_list.php + operation/events/events.php: Deleted several + columns from the events view and adding a + show/hide advanced fields feature. + Added a new state 'in process' to validation + and an input comment when a status is changed. + + * include/fgraph.php: Fixed quotes + in constant definition + + * include/functions_ui.php + include/functions_agents.php + include/functions_alerts.php + operation/agentes/alerts_status.php + operation/agentes/alerts_status.functions.php + images/bell_pause.png + godmode/alerts/alert_list.list.php + godmode/alerts/alert_list.php + godmode/massive/massive_operations.php + godmode/massive/massive_standby_alerts.php: Added + the feature of set and set off on standby an alert + in the alets management and view if an alert is in + standby in the rest of views. + 2010-09-17 Miguel de Dios * include/fgraph.php: added function "grafico_modulo_sparse_mobile" for diff --git a/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql b/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql index 34a3705417..035aaa2d12 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql @@ -122,3 +122,8 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_data` ( PRIMARY KEY (`id_field`, `id_agent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ----------------------------------------------------- +-- Table `tagent_custom_data` +-- ----------------------------------------------------- + +ALTER TABLE `tevento` MODIFY COLUMN `user_comment` TEXT NOT NULL; diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 3c565f02a8..1778e4c892 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -34,10 +34,6 @@ if (! give_acl ($config['id_user'], 0, "LW")) { exit; } -if (isset($_GET["tab"])) { - echo "

".__('Alerts')."

"; -} - // Table for filter controls $form_filter = '
'; $form_filter .= "\n"; @@ -88,6 +84,11 @@ $ed_list = array (); $ed_list[0] = __('Enable'); $ed_list[1] = __('Disable'); $form_filter .= print_select ($ed_list, 'enabledisable', $enabledisable, '', __('All'), -1, true); +$form_filter .= "".__('Standby').""; +$sb_list = array (); +$sb_list[1] = __('Standby on'); +$sb_list[0] = __('Standby off'); +$form_filter .= print_select ($sb_list, 'standby', $standby, '', __('All'), -1, true); $form_filter .= "\n"; $form_filter .= "\n"; @@ -128,6 +129,8 @@ if ($searchFlag) { $where .= " AND id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = " . $actionID . ")"; if ($enabledisable != -1) $where .= " AND talert_template_modules.disabled =" . $enabledisable; + if ($standby != -1) + $where .= " AND talert_template_modules.standby =" . $standby; } $total = get_agent_alerts_simple (array_keys ($agents), false, @@ -142,6 +145,8 @@ $sort = get_parameter('sort', 'none'); $selected = 'border: 1px solid black;'; $selectDisabledUp = ''; $selectDisabledDown = ''; +$selectStandbyUp = ''; +$selectStandbyDown = ''; $selectAgentUp = ''; $selectAgentDown = ''; $selectModuleUp = ''; @@ -162,6 +167,18 @@ switch ($sortField) { break; } break; + case 'standby': + switch ($sort) { + case 'up': + $selectStandbyUp = $selected; + $order = array('field' => 'standby', 'order' => 'ASC'); + break; + case 'down': + $selectStandbyDown = $selected; + $order = array('field' => 'standby', 'order' => 'DESC'); + break; + } + break; case 'agent': switch ($sort) { case 'up': @@ -202,6 +219,8 @@ switch ($sortField) { if (!$id_agente) { $selectDisabledUp = ''; $selectDisabledDown = ''; + $selectStandbyUp = ''; + $selectStandbyDown = ''; $selectAgentUp = $selected; $selectAgentDown = ''; $selectModuleUp = ''; @@ -213,6 +232,8 @@ switch ($sortField) { else { $selectDisabledUp = ''; $selectDisabledDown = ''; + $selectStandbyUp = ''; + $selectStandbyDown = ''; $selectAgentUp = ''; $selectAgentDown = ''; $selectModuleUp = $selected; @@ -247,19 +268,23 @@ $table->width = '90%'; $table->size = array (); $table->align[0] = 'center'; +$table->align[1] = 'center'; $table->head = array (); -$table->head[0] = "" . __('E/D') . "" . ' ' . +$table->head[0] = "" . __('E/D') . "
" . '' . ''; +$table->head[1] = "" . __('Standby') . "
" . + '' . + ''; if (! $id_agente) { $table->style = array (); - $table->style[1] = 'font-weight: bold'; - $table->head[1] = __('Agent') . ' ' . + $table->style[2] = 'font-weight: bold'; + $table->head[2] = __('Agent') . '
' . '' . ''; - $table->size[0] = '12%'; - $table->size[1] = '15%'; + $table->size[0] = '8%'; + $table->size[1] = '8%'; $table->size[2] = '20%'; $table->size[3] = '15%'; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { @@ -269,7 +294,8 @@ if (! $id_agente) { } else { /* Different sizes or the layout screws up */ - $table->size[0] = '12%'; + $table->size[0] = '8%'; + $table->size[1] = '8%'; $table->size[2] = '30%'; $table->size[3] = '20%'; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { @@ -278,18 +304,18 @@ else { $table->size[5] = '50%'; } -$table->head[2] = __('Module') . ' ' . +$table->head[3] = __('Module') . '
' . '' . ''; -$table->head[3] = __('Template') . ' ' . +$table->head[4] = __('Template') . '
' . '' . ''; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->head[4] = "" . __('P.') . ""; + $table->head[5] = "" . __('P.') . ""; } -$table->head[5] = __('Actions'); -$table->head[6] = __('Status'); -$table->head[7] = __('Delete'); +$table->head[6] = __('Actions'); +$table->head[7] = __('Status'); +$table->head[8] = __('Delete'); $table->valign[6] = 'middle'; $table->align[6] = 'center'; @@ -325,33 +351,46 @@ foreach ($simple_alerts as $alert) { } $data[0] .= print_input_hidden ('id_alert', $alert['id'], true); $data[0] .= '
'; + + $data[1] = '
'; + if (!$alert['standby']) { + $data[1] .= print_input_image ('standby_off', 'images/bell.png', 1, '', true); + $data[1] .= print_input_hidden ('standbyon_alert', 1, true); + } + else { + $data[1] .= print_input_image ('standby_on', 'images/bell_pause.png', 1, '', true); + $data[1] .= print_input_hidden ('standbyoff_alert', 1, true); + } + $data[1] .= print_input_hidden ('id_alert', $alert['id'], true); + $data[1] .= '
'; + if (! $id_agente) { $id_agent = get_agentmodule_agent ($alert['id_agent_module']); - $data[1] = ''; + $data[2] = ''; if ($alert['disabled']) - $data[1] .= ''; - $data[1] .= get_agent_name ($id_agent); + $data[2] .= ''; + $data[2] .= get_agent_name ($id_agent); if ($alert['disabled']) - $data[1] .= ''; - $data[1] .= ''; + $data[2] .= ''; + $data[2] .= ''; } - $data[2] = get_agentmodule_name ($alert['id_agent_module']); - $data[3] = ' '; - $data[3] .= ""; - $data[3] .= get_alert_template_name ($alert['id_alert_template']); - $data[3] .= ""; + $data[4] .= ""; + $data[4] .= get_alert_template_name ($alert['id_alert_template']); + $data[4] .= ""; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $policyInfo = isAlertInPolicy($alert['id_agent_module'], $alert['id_alert_template'], false); if ($policyInfo === false) - $data[4] = ''; + $data[5] = ''; else { $img = 'images/policies.png'; - $data[4] = '' . + $data[5] = '' . print_image($img,true, array('title' => $policyInfo['name_policy'])) . ''; } @@ -359,60 +398,60 @@ foreach ($simple_alerts as $alert) { $actions = get_alert_agent_module_actions ($alert['id']); - $data[5] = ''; + $data[6] = ''; if (empty($actions)){ // Get and show default actions for this alert $default_action = get_db_sql ("SELECT id_alert_action FROM talert_templates WHERE id = ".$alert["id_alert_template"]); if ($default_action != ""){ - $data[5] = __("Default"). " : ".get_db_sql ("SELECT name FROM talert_actions WHERE id = $default_action"); + $data[6] = __("Default"). " : ".get_db_sql ("SELECT name FROM talert_actions WHERE id = $default_action"); } } else { - $data[5] = '
    '; + $data[6] = '
      '; foreach ($actions as $action_id => $action) { - $data[5] .= '
    • '; + $data[6] .= '
    • '; if ($alert['disabled']) - $data[5] .= ''; + $data[6] .= ''; else - $data[5] .= ''; - $data[5] .= $action['name']; - $data[5] .= ' ('; + $data[6] .= ''; + $data[6] .= $action['name']; + $data[6] .= ' ('; if ($action['fires_min'] == $action['fires_max']) { if ($action['fires_min'] == 0) - $data[5] .= __('Always'); + $data[6] .= __('Always'); else - $data[5] .= __('On').' '.$action['fires_min']; + $data[6] .= __('On').' '.$action['fires_min']; } else { if ($action['fires_min'] == 0) - $data[5] .= __('Until').' '.$action['fires_max']; + $data[6] .= __('Until').' '.$action['fires_max']; else - $data[5] .= __('From').' '.$action['fires_min']. + $data[6] .= __('From').' '.$action['fires_min']. ' '.__('to').' '.$action['fires_max']; } - $data[5] .= ')'; - $data[5] .= ''; -// $data[5] .= ' '; - $data[5] .= ''; -// $data[5] .= ''; - $data[5] .= '
    • '; + $data[6] .= ')'; + $data[6] .= ''; +// $data[6] .= ' '; + $data[6] .= ''; +// $data[6] .= ''; + $data[6] .= ''; } - $data[5] .= '
    '; + $data[6] .= '
'; } - $data[5] .= ''; - $data[5] .= print_image ('images/add.png', true); + $data[6] .= ''; + $data[6] .= print_image ('images/add.png', true); if ($alert['disabled']) - $data[5] .= ' '. '' .__('Add action') . ''; + $data[6] .= ' '. '' .__('Add action') . ''; else - $data[5] .= ' ' . __('Add action'); - $data[5] .= ''; + $data[6] .= ' ' . __('Add action'); + $data[6] .= ''; $status = STATUS_ALERT_NOT_FIRED; $title = ""; @@ -428,14 +467,14 @@ foreach ($simple_alerts as $alert) { $title = __('Alert not fired'); } - $data[6] = print_status_image($status, $title, true); + $data[7] = print_status_image($status, $title, true); - $data[7] = '
'; + $data[8] = ''; - $data[7] .= print_input_image ('delete', 'images/cross.png', 1, '', true); - $data[7] .= print_input_hidden ('delete_alert', 1, true); - $data[7] .= print_input_hidden ('id_alert', $alert['id'], true); - $data[7] .= '
'; + $data[8] .= print_input_image ('delete', 'images/cross.png', 1, '', true); + $data[8] .= print_input_hidden ('delete_alert', 1, true); + $data[8] .= print_input_hidden ('id_alert', $alert['id'], true); + $data[8] .= ''; array_push ($table->data, $data); } @@ -547,6 +586,24 @@ $(document).ready (function () { $(this).attr ("src", "images/lightbulb_off.png"); } ); + + $("input[name=standby_on]").attr ("title", "") + .hover (function () { + $(this).attr ("src", "images/bell.png"); + }, + function () { + $(this).attr ("src", "images/bell_pause.png"); + } + ); + + $("input[name=standby_off]").attr ("title", "") + .hover (function () { + $(this).attr ("src", "images/bell_pause.png"); + }, + function () { + $(this).attr ("src", "images/bell.png"); + } + ); $("form.disable_alert_form").submit (function () { return true; }); diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 5cd4be672c..5165f42ca1 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -44,6 +44,8 @@ $delete_action = (bool) get_parameter ('delete_action'); $delete_alert = (bool) get_parameter ('delete_alert'); $disable_alert = (bool) get_parameter ('disable_alert'); $enable_alert = (bool) get_parameter ('enable_alert'); +$standbyon_alert = (bool) get_parameter ('standbyon_alert'); +$standbyoff_alert = (bool) get_parameter ('standbyoff_alert'); $tab = get_parameter('tab', 'list'); $group = get_parameter('group', 0); //0 is All group $templateName = get_parameter('template_name',''); @@ -56,6 +58,7 @@ $searchType = get_parameter('search_type',''); $priority = get_parameter('priority',''); $searchFlag = get_parameter('search',0); $enabledisable = get_parameter('enabledisable',''); +$standby = get_parameter('standby',''); $messageAction = ''; @@ -151,6 +154,20 @@ if ($disable_alert) { $messageAction = print_result_message ($result, __('Successfully disabled'), __('Could not be disabled'), '', true); } +if ($standbyon_alert) { + $id_alert = (int) get_parameter ('id_alert'); + + $result = set_alerts_agent_module_standby ($id_alert, true); + $messageAction = print_result_message ($result, __('Successfully set standby'), __('Could not be set standby'), '', true); +} + +if ($standbyoff_alert) { + $id_alert = (int) get_parameter ('id_alert'); + + $result = set_alerts_agent_module_standby ($id_alert, false); + $messageAction = print_result_message ($result, __('Successfully set off standby'), __('Could not be set off standby'), '', true); +} + if ($id_agente) { $agents = array ($id_agente => get_agent_name ($id_agente)); @@ -180,10 +197,10 @@ else { $buttons[$tab]['active'] = true; - if (isset($_GET["tab"])) { - print_page_header(__('Alerts') . ' » ' . __('Manage alerts') . ' » ' . __('Create'), "images/god2.png", false, "manage_alert_list", true, $buttons); - } else { + if ($tab == 'list') { print_page_header(__('Alerts') . ' » ' . __('Manage alerts') . ' » ' . __('List'), "images/god2.png", false, "manage_alert_list", true, $buttons); + } else { + print_page_header(__('Alerts') . ' » ' . __('Manage alerts') . ' » ' . __('Create'), "images/god2.png", false, "manage_alert_list", true, $buttons); } echo $messageAction; diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 51f45c0424..0d5ac6dfaa 100644 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -34,7 +34,7 @@ $option = (string) get_parameter ('option', ''); $options_alerts = array('add_alerts' => __('Massive alerts addition'), 'delete_alerts' => __('Massive alerts deletion'), 'add_action_alerts' => __('Massive alert actions addition'), 'delete_action_alerts' => __('Massive alert actions deletion'), - 'enable_disable_alerts' => __('Massive alert enable/disable')); + 'enable_disable_alerts' => __('Massive alert enable/disable'), 'standby_alerts' => __('Massive alert setting standby')); $options_agents = array('delete_agents' => __('Massive agents deletion')); @@ -149,6 +149,9 @@ switch ($option) { case 'enable_disable_alerts': require_once ('godmode/massive/massive_enable_disable_alerts.php'); break; + case 'standby_alerts': + require_once ('godmode/massive/massive_standby_alerts.php'); + break; case 'add_profiles': require_once ('godmode/massive/massive_add_profiles.php'); break; diff --git a/pandora_console/godmode/massive/massive_standby_alerts.php b/pandora_console/godmode/massive/massive_standby_alerts.php new file mode 100644 index 0000000000..eb2c844ffd --- /dev/null +++ b/pandora_console/godmode/massive/massive_standby_alerts.php @@ -0,0 +1,206 @@ + 'tagente.nombre, talert_template_modules.standby', '`talert_template_modules`.standby' => $standby), + array ('LEFT(CONCAT(LEFT(tagente.nombre,40), " - ", tagente_modulo.nombre), 85) as agent_agentmodule_name', + 'talert_template_modules.id as template_module_id')); + + echo json_encode (index_array ($agents_alerts, 'template_module_id', 'agent_agentmodule_name')); + return; + } + return; +} + +$id_group = (int) get_parameter ('id_group'); +$action = (string) get_parameter ('action', ''); + +$result = false; + +switch($action) { + case 'set_off_standby_alerts': + $id_alert_template = (int) get_parameter ('id_alert_template_standby', 0); + $id_standby_alerts = get_parameter_post ('id_standby_alerts', array()); + foreach($id_standby_alerts as $id_alert) { + $result = set_alerts_agent_module_standby ($id_alert, false); + } + print_result_message ($result, __('Successfully set off standby'), __('Could not be set off standby')); + break; + case 'set_standby_alerts': + $id_alert_template = (int) get_parameter ('id_alert_template_standby', 0); + $id_not_standby_alerts = get_parameter_post ('id_not_standby_alerts', array()); + + foreach($id_not_standby_alerts as $id_alert) { + $result = set_alerts_agent_module_standby ($id_alert, true); + } + print_result_message ($result, __('Successfully set standby'), __('Could not be set standby')); + break; + default: + $id_alert_template = (int) get_parameter ('id_alert_template', 0); + break; +} + +$groups = get_user_groups (); + +$table->id = 'delete_table'; +$table->width = '95%'; +$table->data = array (); +$table->style = array (); +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold'; +$table->size = array (); +$table->size[0] = '15%'; +$table->size[1] = '85%'; + +$table->data = array (); + +$templates = get_alert_templates (false, array ('id', 'name')); +$table->data[0][0] = '
'; +$table->data[0][0] .= print_input_hidden('id_alert_template_not_standby', $id_alert_template, true); +$table->data[0][0] .= __('Alert template'); +$table->data[0][1] = print_select (index_array ($templates, 'id', 'name'), + 'id_alert_template', $id_alert_template, false, __('All'), 0, true); + +$table->data[1][0] = __('Group'); +$table->data[1][1] = print_select_groups(false, "AR", true, 'id_group', $id_group, + '', '', '', true, false, true, ''); + +$table->data[2][0] = __('Not standby alerts').print_help_tip(__('Format').":
".__('Agent')." - ".__('Module'), true); +$table->data[2][0] .= ''; +$agents_alerts = get_agents_with_alert_template ($id_alert_template, $id_group, + false, array ('tagente.nombre', 'tagente.id_agente')); +$table->data[2][1] = print_select (index_array ($agents_alerts, 'id_agente', 'nombre'), + 'id_not_standby_alerts[]', '', '', '', '', true, true, true, '', $id_alert_template == 0); + +$table->data[3][0] = __('Action'); + +$table->data[3][1] = "
".print_input_image ('standby_alerts', 'images/darrowdown.png', 1, 'margin-left: 150px;', true, array ('title' => __('Set standby selected alerts'))).""; +$table->data[3][1] .= ''; +$table->data[3][1] .= '
'; +$table->data[3][1] .= print_input_hidden('id_alert_template_standby', $id_alert_template, true); +$table->data[3][1] .= print_input_image ('set_off_standby_alerts', 'images/darrowup.png', 1, 'margin-left: 200px;', true, array ('title' => __('Set standby selected alerts')))."
"; + +$table->data[4][0] = __('Standby alerts').print_help_tip(__('Format').":
".__('Agent')." - ".__('Module'), true); +$table->data[4][0] .= ''; +$table->data[4][1] = print_select (index_array ($agents_alerts, 'id_agente2', 'nombre'), + 'id_standby_alerts[]', '', '', '', '', true, true, true, '', $id_alert_template == 0); +$table->data[4][1] .= ''; + +print_table ($table); + +echo ''; + +require_jquery_file ('form'); +require_jquery_file ('pandora.controls'); +?> + + diff --git a/pandora_console/images/bell_pause.png b/pandora_console/images/bell_pause.png new file mode 100644 index 0000000000000000000000000000000000000000..a1859deda11a8c8a416bbfa68f232f9ed00b7750 GIT binary patch literal 863 zcmV-l1EBngP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ige@ z5e7O9xtKNp00Q4hL_t(I%axN)Xj=sw$3HK5>Ds&|S-SjL)~>HzX@jss@Q}@mA`CMB zwNx)V486F+9CbqNK|~mv;&HbQWd{|-39`#Fd{aD46lyV`V3WngHA!p2V$$uUYw}*+ z`*|2G)8WM5>HCB4_j~w#zduDp_&-z3CbPCB8MEeO550DCR{c-Gm1NX~s7GPl6`Ak% z1fC1`4^eL3d>-JD1|=i;0SeDZkC5%kU|?Xkr&?$TuBF`Tit(=oB_lcM3O@%Enf}o5 z47d*M>UBDQt}z(BtE}C=bN=wjkLLlDf8L;EBwzCO@A*=T&k~9pWUKlSO?evs@HD~D z5CE-aLn_tv3+Z(F)Q&;PNG5tnw%^d$#tj4T5#mpk?7<+9;b*|`HXvQAO7KKG)?35={G2s%iOq8-wu|uPYZKlc_{7b`+;u#I7ykvF{+Z#a%Oi9vY(4>7c4AuInNqsH#f4Z7T72+^5>6 zJhn@V(A``k|3j9(J{O-1vJ3FFtkZ1N@%elNgF$TD#_RRsI1ZYoNwHY86%pb3`2*hv65%H%(ntCB!z`JTFSE7L z;K#4C42(`Q_0$~kc$|%m4J^wd7K=%tP*4oRSlmhBoA(bCg8Oz);Z70LN7y?aqWbF! zUwx5f|Ka0|re8rHo4~eh^7*{Ayu5sIVPWCa-+FN6%=l$36qZaXn7%yCuw) z!;_gY)X*ropIY@lhMrBQQmM+!%#1u#q|0xQXAm(GdYJvGVN|EbYQD@!LTIe^v9#P; zI&ralXq*2~m0x`C_iKQ1>CLgTtA*w}v3&tX_G)a_g-W@NZOOF<`O2f-`P0{Ruho^e pY@0c&Ctk71DR5%$^UAGl&R_nhW@$`yuW|qY002ovPDHLkV1hK!qk{kd literal 0 HcmV?d00001 diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index 6cdafd343d..fd0ca4d939 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -42,7 +42,8 @@ else { set_time_limit (0); -error_reporting (0); +//error_reporting (0); +error_reporting (E_ALL); if (! isset ($config["id_user"])) { session_start (); @@ -973,7 +974,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") { $url = html_entity_decode (rawurldecode ($url), ENT_QUOTES); //It was urlencoded, so we urldecode it $data = array (); $loop = 0; - define (NUM_PIECES_PIE, 6); + define ('NUM_PIECES_PIE', 6); $badstrings = array (";", "SELECT ", "DELETE ", "UPDATE ", "INSERT ", "EXEC"); //remove bad strings from the query so queries like ; DELETE FROM don't pass diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index d23fcbf3a4..73f9994a72 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -110,22 +110,29 @@ function create_agent ($name, $id_group, $interval, $ip_address, $values = false * alerts found. */ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false, $idGroup = false, $count = false) { + if (is_array($filter)) { + $disabled = $filter['disabled']; + $filter = ' AND talert_template_modules.standby = "'.$filter['standby'].'"'; + }else { + $filter = ''; + $disabled = $filter; + } - switch ($filter) { + switch ($disabled) { case "notfired": - $filter = ' AND times_fired = 0 AND talert_template_modules.disabled = 0'; + $filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0'; break; case "fired": - $filter = ' AND times_fired > 0 AND talert_template_modules.disabled = 0'; + $filter .= ' AND times_fired > 0 AND talert_template_modules.disabled = 0'; break; case "disabled": - $filter = ' AND talert_template_modules.disabled = 1'; + $filter .= ' AND talert_template_modules.disabled = 1'; break; - case 'all_enabled': - $filter = ' AND talert_template_modules.disabled = 0'; + case "all_enabled": + $filter .= ' AND talert_template_modules.disabled = 0'; break; default: - $filter = ''; + $filter .= ''; } if (is_array ($options)) { @@ -180,7 +187,7 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa ON talert_template_modules.id_alert_template = t4.id WHERE id_agent_module in (%s) %s %s %s", $selectText, $subQuery, $where, $filter, $orderbyText); - + $alerts = get_db_all_rows_sql ($sql); if ($alerts === false) @@ -206,20 +213,20 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa */ function get_agent_alerts_compound ($id_agent = false, $filter = '', $options = false, $idGroup = false, $count = false, $where = '') { switch ($filter) { - case "notfired": - $filter = ' AND times_fired = 0 AND disabled = 0'; - break; - case "fired": - $filter = ' AND times_fired > 0 AND disabled = 0'; - break; - case "disabled": - $filter = ' AND disabled = 1'; - break; - case 'all_enabled': - $filter = ' AND disabled = 0'; - break; - default: - $filter = ''; + case "notfired": + $filter = ' AND times_fired = 0 AND disabled = 0'; + break; + case "fired": + $filter = ' AND times_fired > 0 AND disabled = 0'; + break; + case "disabled": + $filter = ' AND disabled = 1'; + break; + case 'all_enabled': + $filter = ' AND disabled = 0'; + break; + default: + $filter = ''; } if (is_array ($options)) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 04bdb8a857..b6b6cbe0f7 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -526,6 +526,13 @@ function set_alerts_agent_module_disable ($id_alert_agent_module, $disabled) { array ('id' => $id_alert_agent_module))) !== false; } +function set_alerts_agent_module_standby ($id_alert_agent_module, $standby) { + $id_alert_agent_module = safe_int ($id_alert_agent_module, 0); + return (@process_sql_update ('talert_template_modules', + array ('standby' => (bool) $standby), + array ('id' => $id_alert_agent_module))) !== 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', diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index bb6eb14f4c..ce48eef559 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -150,7 +150,7 @@ function delete_event ($id_event, $similar = true) { * * @return bool Whether or not it was successful */ -function validate_event ($id_event, $similars = true) { +function validate_event ($id_event, $similars = true, $comment = '', $new_status = 1) { global $config; //Cleans up the selection for all unwanted values also casts any single values as an array @@ -166,8 +166,34 @@ function validate_event ($id_event, $similars = true) { process_sql_begin (); $errors = 0; + switch($new_status) { + case 1: + $new_status_string = __('Validated'); + break; + case 2: + $new_status_string = __('Setted in process'); + break; + } + + $comment = str_replace(array("\r\n", "\r", "\n"), '
', $comment); + + if($comment != '') { + $commentbox = '
'.$comment.'
'; + }else { + $commentbox = ''; + } + + $comment = '-- '.$new_status_string.' '.__('by').' '.$config['id_user'].' '.'['.date ($config["date_format"]).'] --
'.$commentbox; + foreach ($id_event as $event) { - $sql = sprintf ("UPDATE tevento SET estado = 1, id_usuario = '%s' WHERE id_evento = %d", $config['id_user'], $event); + $fullevent = get_event($event); + + if($fullevent['user_comment'] != ''){ + $commentbox = '
'.$fullevent['user_comment'].'
'; + $comment .= '
'.$fullevent['user_comment']; + } + + $sql = sprintf ("UPDATE tevento SET estado = %d, id_usuario = '%s', user_comment = '%s' WHERE id_evento = %d", $new_status, $config['id_user'], $comment, $event); $ret = process_sql ($sql); if (give_acl ($config["id_user"], get_event_group ($event), "IW") == 0) { @@ -403,50 +429,105 @@ function print_event_type_img ($type, $return = false) { switch ($type) { case "alert_recovered": $output .= print_image ("images/error.png", true, - array ("title" => __('Alert recovered'))); + array ("title" => print_event_type_description($type, true))); break; case "alert_manual_validation": $output .= print_image ("images/eye.png", true, - array ("title" => __('Alert manually validated'))); + array ("title" => print_event_type_description($type, true))); break; case "going_up_warning": $output .= print_image ("images/b_yellow.png", true, - array ("title" => __('Going from critical to warning'))); + array ("title" => print_event_type_description($type, true))); break; case "going_down_critical": case "going_up_critical": //This is to be backwards compatible $output .= print_image ("images/b_red.png", true, - array ("title" => __('Going down to critical state'))); + array ("title" => print_event_type_description($type, true))); break; case "going_up_normal": case "going_down_normal": //This is to be backwards compatible $output .= print_image ("images/b_green.png", true, - array ("title" => __('Going up to normal state'))); + array ("title" => print_event_type_description($type, true))); break; case "going_down_warning": $output .= print_image ("images/b_yellow.png", true, - array ("title" => __('Going down from normal to warning'))); + array ("title" => print_event_type_description($type, true))); break; case "alert_fired": $output .= print_image ("images/bell.png", true, - array ("title" => __('Alert fired'))); + array ("title" => print_event_type_description($type, true))); break; case "system"; $output .= print_image ("images/cog.png", true, - array ("title" => __('SYSTEM'))); + array ("title" => print_event_type_description($type, true))); break; case "recon_host_detected"; $output .= print_image ("images/network.png", true, - array ("title" => __('Recon server detected a new host'))); + array ("title" => print_event_type_description($type, true))); break; case "new_agent"; $output .= print_image ("images/wand.png", true, - array ("title" => __('New agent created'))); + array ("title" => print_event_type_description($type, true))); break; case "unknown": default: $output .= print_image ("images/err.png", true, - array ("title" => __('Unknown type:').': '.$type)); + array ("title" => print_event_type_description($type, true))); + break; + } + + if ($return) + return $output; + echo $output; +} + +/** + * Prints the event type description + * + * @param string $type Event type from SQL + * @param bool $return Whether to return or print + * + * @return string HTML with img + */ +function print_event_type_description ($type, $return = false) { + $output = ''; + + switch ($type) { + case "alert_recovered": + $output .= __('Alert recovered'); + break; + case "alert_manual_validation": + $output .= __('Alert manually validated'); + break; + case "going_up_warning": + $output .= __('Going from critical to warning'); + break; + case "going_down_critical": + case "going_up_critical": //This is to be backwards compatible + $output .= __('Going down to critical state'); + break; + case "going_up_normal": + case "going_down_normal": //This is to be backwards compatible + $output .= __('Going up to normal state'); + break; + case "going_down_warning": + $output .= __('Going down from normal to warning'); + break; + case "alert_fired": + $output .= __('Alert fired'); + break; + case "system"; + $output .= __('SYSTEM'); + break; + case "recon_host_detected"; + $output .= __('Recon server detected a new host'); + break; + case "new_agent"; + $output .= __('New agent created'); + break; + case "unknown": + default: + $output .= __('Unknown type:').': '.$type; break; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 2f4c358cc0..94add822d7 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -375,26 +375,26 @@ function format_alert_row ($alert, $compound = false, $agent = true, $url = '') if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if ($agent) { - $index = array('policy' => 0, 'force_execution' => 1, 'agent_name' => 2, 'module_name' => 3, - 'description' => 4, 'template' => 4, 'action' => 5, 'last_fired' => 6, 'status' => 7, - 'validate' => 8); + $index = array('policy' => 0, 'standby' => 1, 'force_execution' => 2, 'agent_name' => 3, 'module_name' => 4, + 'description' => 5, 'template' => 5, 'action' => 6, 'last_fired' => 7, 'status' => 8, + 'validate' => 9); } else { - $index = array('policy' => 0, 'force_execution' => 1, 'agent_name' => 2, 'module_name' => 2, - 'description' => 3, 'template' => 3, 'action' => 4, 'last_fired' => 5, 'status' => 6, - 'validate' => 7); + $index = array('policy' => 0, 'standby' => 1, 'force_execution' => 2, 'agent_name' => 3, 'module_name' => 3, + 'description' => 4, 'template' => 4, 'action' => 5, 'last_fired' => 6, 'status' => 7, + 'validate' => 8); } } else { if ($agent) { - $index = array('force_execution' => 0, 'agent_name' => 1, 'module_name' => 2, - 'description' => 3, 'template' => 3, 'action' => 4, 'last_fired' => 5, 'status' => 6, - 'validate' => 6); + $index = array('standby' => 0, 'force_execution' => 1, 'agent_name' => 2, 'module_name' => 3, + 'description' => 4, 'template' => 4, 'action' => 5, 'last_fired' => 6, 'status' => 7, + 'validate' => 7); } else { - $index = array('force_execution' => 0, 'agent_name' => 1, 'module_name' => 1, - 'description' => 2, 'template' => 2, 'action' => 3, 'last_fired' => 4, 'status' => 5, - 'validate' => 6); + $index = array('standby' => 0, 'force_execution' => 1, 'agent_name' => 2, 'module_name' => 2, + 'description' => 3, 'template' => 3, 'action' => 4, 'last_fired' => 5, 'status' => 6, + 'validate' => 7); } } @@ -444,6 +444,12 @@ function format_alert_row ($alert, $compound = false, $agent = true, $url = '') else if (($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) && ($compound)) $data[$index['policy']] = ''; + // Standby + $data[$index['standby']] = ''; + if ($alert["standby"] == 1) { + $data[$index['standby']] = print_image ('images/bell_pause.png', true, array('title' => __('Standby on'))); + } + // Force alert execution $data[$index['force_execution']] = ''; if (! $compound) { diff --git a/pandora_console/operation/agentes/alerts_status.functions.php b/pandora_console/operation/agentes/alerts_status.functions.php index 130b665d7a..2d3378c1de 100755 --- a/pandora_console/operation/agentes/alerts_status.functions.php +++ b/pandora_console/operation/agentes/alerts_status.functions.php @@ -37,7 +37,7 @@ function validateAlert() { } } -function printFormFilterAlert($id_group, $filter, $free_search, $url) { +function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby = false, $return = false) { $table->width = '90%'; $table->data = array (); $table->style = array (); @@ -52,17 +52,30 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url) { $alert_status_filter['fired'] = __('Fired'); $alert_status_filter['notfired'] = __('Not fired'); $alert_status_filter['disabled'] = __('Disabled'); + + $alert_standby = array(); + $alert_standby['all'] = __('All'); + $alert_standby['standby_on'] = __('Standby on'); + $alert_standby['standby_off'] = __('Standby off'); $table->data[0][2] = __('Status'); $table->data[0][3] = print_select ($alert_status_filter, "filter", $filter, 'javascript:this.form.submit();', '', '', true); + $table->data[0][4] = ''; $table->data[1][0] = __('Free text for search') . ' ' . __("Filter by agent name, module name, template name or action name") . ''; $table->data[1][1] = print_input_text('free_search', $free_search, '', 20, 40, true); - $table->colspan[1][2] = 2; - $table->data[1][2] = print_submit_button(__('Filter'), 'filter_button', false, 'class="sub search"', true); + $table->data[1][2] = __('Standby'); + $table->data[1][3] = print_select ($alert_standby, "filter_standby", $filter_standby, 'javascript:this.form.submit();', '', '', true); + $table->data[1][4] = print_submit_button(__('Filter'), 'filter_button', false, 'class="sub search"', true); - echo '
'; - print_table ($table); - echo '
'; + $data = '
'; + $data .= print_table ($table, true); + $data .= '
'; + + if($return) { + return $data; + }else{ + echo $data; + } } ?> diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index a854c37fc4..d7d8e0b07c 100644 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -24,6 +24,7 @@ require_once('operation/agentes/alerts_status.functions.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); $filter = get_parameter ("filter", "all_enabled"); +$filter_standby = get_parameter ("filter_standby", "all"); $offset_simple = (int) get_parameter_get ("offset_simple", 0); $offset_combined = (int) get_parameter_get("offset_combined", 0); $id_group = (int) get_parameter ("ag_group", 0); //0 is the All group (selects all groups) @@ -39,7 +40,7 @@ $flag_alert = (bool) get_parameter ('force_execution', 0); $alert_validate = (bool) get_parameter ('alert_validate', 0); $tab = get_parameter_get ("tab", null); -$url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&refr='.$config["refr"].'&filter='.$filter.'&ag_group='.$id_group; +$url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&refr='.$config["refr"].'&filter='.$filter.'&filter_standby='.$filter_standby.'&ag_group='.$id_group; if ($flag_alert == 1 && give_acl($config['id_user'], $id_group, "AW")) { forceExecution($id_group); @@ -178,16 +179,32 @@ switch ($sortField) { } $alerts = array(); -$alerts['alerts_simple'] = get_agent_alerts_simple ($agents, $filter, array('offset' => $offset_simple, 'limit' => $config['block_size'], 'order' => $order), $whereAlertSimple, false, false, $idGroup); +$options_simple = array('offset' => $offset_simple, 'limit' => $config['block_size'], 'order' => $order); +$options_combined = array('limit' => $config["block_size"], 'offset' => $offset_combined); + +$filter_alert = array(); +if($filter_standby == 'standby_on') { + $filter_alert['disabled'] = $filter; + $filter_alert['standby'] = '1'; +}else if($filter_standby == 'standby_off') { + $filter_alert['disabled'] = $filter; + $filter_alert['standby'] = '0'; +}else { + $filter_alert = $filter; +} + +$alerts['alerts_simple'] = get_agent_alerts_simple ($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup); $countAlertsSimple = get_agent_alerts_simple ($agents, $filter, false, $whereAlertSimple, false, false, $idGroup, true); -$alerts['alerts_combined'] = get_agent_alerts_compound($agents, $filter, array('limit' => $config["block_size"], 'offset' => $offset_combined), $idGroup, false, $whereAlertCombined); + +$alerts['alerts_combined'] = get_agent_alerts_compound($agents, $filter, $options_combined, $idGroup, false, $whereAlertCombined); $countAlertsCombined = get_agent_alerts_compound($agents, $filter, false, $idGroup, true, $whereAlertCombined); if ($tab != null) { $url = $url.'&tab='.$tab; } + // Filter form if ($print_agent) { - printFormFilterAlert($id_group, $filter, $free_search, $url); + toggle(printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby, true),__('Alert control filter'), __('Toggle filter(s)')); } $table->width = '95%'; @@ -201,14 +218,75 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if ($print_agent) { $table->size[0] = '20px'; $table->size[1] = '20px'; - $table->size[2] = '25%'; + $table->size[2] = '20px'; $table->size[3] = '25%'; - $table->size[4] = '30%'; + $table->size[4] = '25%'; $table->size[5] = '30%'; + $table->size[6] = '30%'; + $table->size[7] = '20px'; + $table->size[8] = '60px'; + + $table->head[0] = "" . __('P.') . ""; + $table->head[1] = "" . __('S.') . ""; + $table->head[2] = "" . __('F.') . ""; + $table->head[3] = __('Agent') . ' ' . + '' . + ''; + $table->head[4] = __('Module') . ' ' . + '' . + ''; + $table->head[5] = __('Template') . ' ' . + '' . + ''; + $table->head[6] = __('Action'); + $table->head[7] = __('Last fired'); + $table->head[8] = __('Status'); + $table->head[9] = __('Validate'); + + $table->align[8] = 'center'; + $table->align[9] = 'center'; + } + else { + $table->size[0] = '20px'; + $table->size[1] = '20px'; + $table->size[2] = '20px'; + $table->size[3] = '25%'; + $table->size[4] = '50%'; + $table->size[5] = '25%'; $table->size[6] = '20px'; $table->size[7] = '60px'; $table->head[0] = "" . __('P.') . ""; + $table->head[1] = "" . __('S.') . ""; + $table->head[2] = "" . __('F.') . ""; + $table->head[3] = __('Module') . ' ' . + '' . + ''; + $table->head[4] = __('Template') . ' ' . + '' . + ''; + $table->head[5] = __('Action'); + $table->head[6] = __('Last fired'); + $table->head[7] = __('Status'); + $table->head[8] = __('Validate'); + + $table->align[7] = 'center'; + $table->align[8] = 'center'; + } +} +else +{ + if ($print_agent) { + $table->size[0] = '20px'; + $table->size[1] = '20px'; + $table->size[2] = '25%'; + $table->size[3] = '25%'; + $table->size[4] = '50%'; + $table->size[5] = '25%'; + $table->size[6] = '20px'; + $table->size[7] = '60px'; + + $table->head[0] = "" . __('S.') . ""; $table->head[1] = "" . __('F.') . ""; $table->head[2] = __('Agent') . ' ' . '' . @@ -236,7 +314,7 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $table->size[5] = '20px'; $table->size[6] = '60px'; - $table->head[0] = "" . __('P.') . ""; + $table->head[0] = "" . __('S.') . ""; $table->head[1] = "" . __('F.') . ""; $table->head[2] = __('Module') . ' ' . '' . @@ -253,59 +331,6 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $table->align[7] = 'center'; } } -else -{ - if ($print_agent) { - $table->size[0] = '20px'; - $table->size[1] = '25%'; - $table->size[2] = '25%'; - $table->size[3] = '50%'; - $table->size[4] = '25%'; - $table->size[5] = '20px'; - $table->size[6] = '60px'; - - $table->head[0] = "" . __('F.') . ""; - $table->head[1] = __('Agent') . ' ' . - '' . - ''; - $table->head[2] = __('Module') . ' ' . - '' . - ''; - $table->head[3] = __('Template') . ' ' . - '' . - ''; - $table->head[4] = __('Action'); - $table->head[5] = __('Last fired'); - $table->head[6] = __('Status'); - $table->head[7] = __('Validate'); - - $table->align[6] = 'center'; - $table->align[7] = 'center'; - } - else { - $table->size[0] = '20px'; - $table->size[1] = '25%'; - $table->size[2] = '50%'; - $table->size[3] = '25%'; - $table->size[4] = '20px'; - $table->size[5] = '60px'; - - $table->head[0] = "" . __('F.') . ""; - $table->head[1] = __('Module') . ' ' . - '' . - ''; - $table->head[2] = __('Template') . ' ' . - '' . - ''; - $table->head[3] = __('Action'); - $table->head[4] = __('Last fired'); - $table->head[5] = __('Status'); - $table->head[6] = __('Validate'); - - $table->align[5] = 'center'; - $table->align[6] = 'center'; - } -} $table->title = __('Single alerts'); $table->titlestyle = "background-color:#799E48;"; @@ -339,14 +364,16 @@ $table->titlestyle = "background-color:#799E48;"; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $table->head[0] = ''; $table->head[1] = ''; - $table->head[2] = __('Agent'); - $table->head[3] = __('Description'); + $table->head[2] = ''; + $table->head[3] = __('Agent'); + $table->head[4] = __('Description'); } else { $table->head[0] = ''; - $table->head[1] = __('Agent'); - $table->head[2] = __('Description'); + $table->head[1] = ''; + $table->head[2] = __('Agent'); + $table->head[3] = __('Description'); } $table->data = array (); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 3345fb65f6..0a7124eaa9 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -18,6 +18,7 @@ global $config; require_once ("include/functions_events.php"); //Event processing functions +require_once ("include/functions_alerts.php"); //Alerts processing functions check_login (); @@ -33,6 +34,7 @@ if (is_ajax ()) { $validate_event = (bool) get_parameter ('validate_event'); $delete_event = (bool) get_parameter ('delete_event'); $get_events_fired = (bool) get_parameter('get_events_fired'); + $standby_alert = (bool) get_parameter('standby_alert'); if ($get_event_tooltip) { $id = (int) get_parameter ('id'); @@ -64,11 +66,29 @@ if (is_ajax ()) { return; } + if ($standby_alert) { + $id = (int) get_parameter ('id'); + $event = get_event ($id); + if ($event === false) + return; + + set_alerts_agent_module_standby ($event['id_alert_am'], 1); + return; + } + if ($validate_event) { $id = (int) get_parameter ("id"); $similars = (bool) get_parameter ('similars'); - - $return = validate_event ($id, $similars); + $comment = (string) get_parameter ('comment'); + $new_status = get_parameter ('new_status'); + + // Set off the standby mode when close an event + if($new_status == 1) { + $event = get_event ($id); + set_alerts_agent_module_standby ($event['id_alert_am'], 0); + } + + $return = validate_event ($id, $similars, $comment, $new_status); if ($return) echo 'ok'; else @@ -135,119 +155,23 @@ if ($config['flash_charts']) { $offset = (int) get_parameter ("offset", 0); $ev_group = (int) get_parameter ("ev_group", 0); //0 = all -$search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurldecode (get_parameter ("search"))); $event_type = get_parameter ("event_type", ''); // 0 all $severity = (int) get_parameter ("severity", -1); // -1 all -$status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green +$status = (int) get_parameter ("status", 3); // -1 all, 0 only new, 1 only validated, 2 only in process, 3 only not validated, $id_agent = (int) get_parameter ("id_agent", -2); //-1 all, 0 system - -if($id_agent == -2) { - $text_agent = (string) get_parameter("text_agent", __("All")); - - switch ($text_agent) - { - case __('All'): - $id_agent = -1; - break; - case __('Server'): - $id_agent = 0; - break; - default: - $id_agent = get_agent_id($text_agent); - break; - } -} -else{ - switch ($id_agent) - { - case -1: - $text_agent = __('All'); - break; - case 0: - $text_agent = __('Server'); - break; - default: - $text_agent = get_agent_name($id_agent); - break; - } -} - $id_event = (int) get_parameter ("id_event", -1); $pagination = (int) get_parameter ("pagination", $config["block_size"]); $event_view_hr = (int) get_parameter ("event_view_hr", $config["event_view_hr"]); $id_user_ack = get_parameter ("id_user_ack", 0); $group_rep = (int) get_parameter ("group_rep", 0); $delete = (bool) get_parameter ("delete"); -$validate = (bool) get_parameter ("validate"); +$validate = (bool) get_parameter ("validate", 0); +$section = (string) get_parameter ("section", "list"); + +$search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurldecode (get_parameter ("search"))); $groups = get_user_groups ($config["id_user"], "IR"); -//Group selection -if ($ev_group > 0 && in_array ($ev_group, array_keys ($groups))) { - //If a group is selected and it's in the groups allowed - $sql_post = " AND id_grupo = $ev_group"; -} else { - if (is_user_admin ($config["id_user"])) { - //Do nothing if you're admin, you get full access - $sql_post = ""; - } else { - //Otherwise select all groups the user has rights to. - $sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; - } -} - -// Skip system messages if user is not PM -if (!give_acl ($config["id_user"], 0, "PM")) { - $sql_post .= " AND id_grupo != 0"; -} - -if ($status == 1) { - $sql_post .= " AND estado = 1"; -} -elseif ($status == 0) { - $sql_post .= " AND estado = 0"; -} - -if ($search != "") { - $sql_post .= " AND evento LIKE '%".$search."%'"; -} - -if ($event_type != "") { - // If normal, warning, could be several (going_up_warning, going_down_warning... too complex - // for the user so for him is presented only "warning, critical and normal" - if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { - $sql_post .= " AND event_type LIKE '%$event_type%' "; - } - elseif ($event_type == "not_normal") { - $sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' "; - } - else { - $sql_post .= " AND event_type = '".$event_type."'"; - } - -} -if ($severity != -1) - $sql_post .= " AND criticity >= ".$severity; -if ($id_agent != -1) - $sql_post .= " AND id_agente = ".$id_agent; -if ($id_event != -1) - $sql_post .= " AND id_evento = ".$id_event; - -if ($id_user_ack != "0") - $sql_post .= " AND id_usuario = '".$id_user_ack."'"; - - -if ($event_view_hr > 0) { - $unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds - $sql_post .= " AND utimestamp > ".$unixtime; -} - -$url = "index.php?sec=eventos&sec2=operation/events/events&search=" . - rawurlencode($search) . "&event_type=" . $event_type . - "&severity=" . $severity . "&status=" . $status . "&ev_group=" . - $ev_group . "&refr=" . $config["refr"] . "&id_agent=" . - $id_agent . "&id_event=" . $id_event . "&pagination=" . - $pagination . "&group_rep=" . $group_rep . "&event_view_hr=" . - $event_view_hr . "&id_user_ack=" . $id_user_ack; +$ids = (array) get_parameter ("eventid", -1); // Header if ($config["pure"] == 0) { @@ -269,7 +193,7 @@ if ($config["pure"] == 0) { ); print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $buttons); - + ?> diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php new file mode 100644 index 0000000000..fd120d3fee --- /dev/null +++ b/pandora_console/operation/events/events_list.php @@ -0,0 +1,579 @@ + 0 && in_array ($ev_group, array_keys ($groups))) { + //If a group is selected and it's in the groups allowed + $sql_post = " AND id_grupo = $ev_group"; +} else { + if (is_user_admin ($config["id_user"])) { + //Do nothing if you're admin, you get full access + $sql_post = ""; + } else { + //Otherwise select all groups the user has rights to. + $sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; + } +} + +// Skip system messages if user is not PM +if (!give_acl ($config["id_user"], 0, "PM")) { + $sql_post .= " AND id_grupo != 0"; +} + +switch($status) { + case 0: + case 1: + case 2: + $sql_post .= " AND estado = ".$status; + break; + case 3: + $sql_post .= " AND (estado = 0 OR estado = 2)"; + break; +} + +if ($search != "") { + $sql_post .= " AND evento LIKE '%".$search."%'"; +} + +if ($event_type != "") { + // If normal, warning, could be several (going_up_warning, going_down_warning... too complex + // for the user so for him is presented only "warning, critical and normal" + if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { + $sql_post .= " AND event_type LIKE '%$event_type%' "; + } + elseif ($event_type == "not_normal") { + $sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' "; + } + else { + $sql_post .= " AND event_type = '".$event_type."'"; + } + +} +if ($severity != -1) + $sql_post .= " AND criticity >= ".$severity; +if ($id_agent != -1) + $sql_post .= " AND id_agente = ".$id_agent; +if ($id_event != -1) + $sql_post .= " AND id_evento = ".$id_event; + +if ($id_user_ack != "0") + $sql_post .= " AND id_usuario = '".$id_user_ack."'"; + + +if ($event_view_hr > 0) { + $unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds + $sql_post .= " AND utimestamp > ".$unixtime; +} + +$url = "index.php?sec=eventos&sec2=operation/events/events&search=" . + rawurlencode($search) . "&event_type=" . $event_type . + "&severity=" . $severity . "&status=" . $status . "&ev_group=" . + $ev_group . "&refr=" . $config["refr"] . "&id_agent=" . + $id_agent . "&id_event=" . $id_event . "&pagination=" . + $pagination . "&group_rep=" . $group_rep . "&event_view_hr=" . + $event_view_hr . "&id_user_ack=" . $id_user_ack . "&offset=" . $offset; + +//Link to toggle filter +echo ''.__('Event control filter').' '.print_image ("images/down.png", true, array ("title" => __('Toggle filter(s)'))).'

'; + +//Start div +echo ''; + +if ($group_rep == 0) { + $sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; +} else { + $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; +} + +//Extract the events by filter (or not) from db +$result = get_db_all_rows_sql ($sql); + +if ($group_rep == 0) { + $sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post; +} else { + $sql = "SELECT COUNT(DISTINCT(evento)) FROM tevento WHERE 1=1 ".$sql_post; +} + + + +//Count the events with this filter (TODO but not utimestamp). +$total_events = (int) get_db_sql ($sql); + +if (empty ($result)) { + $result = array (); +} + +$table->width = '100%'; +$table->id = "eventtable"; +$table->cellpadding = 4; +$table->cellspacing = 4; +$table->class = "databox"; +$table->head = array (); +$table->data = array (); + +$table->head[0] = __('Status'); +$table->align[0] = 'center'; + +$table->head[1] = __('Event name'); + +$table->head[2] = __('Agent name'); +$table->align[2] = 'center'; + +$table->head[3] = __('Timestamp'); +$table->align[3] = 'center'; + +$table->head[4] = __('Action'); +$table->align[4] = 'center'; +$table->size[4] = '80px'; + +$table->head[5] = print_checkbox ("allbox", "1", false, true); +$table->align[5] = 'center'; + +$idx = 0; +//Arrange data. We already did ACL's in the query +foreach ($result as $event) { + $data = array (); + + //First pass along the class of this row + $table->rowclass[] = get_priority_class ($event["criticity"]); + + // Colored box + switch($event["estado"]) { + case 0: + $img_st = "images/star.png"; + $title_st = __('New event'); + break; + case 1: + $img_st = "images/tick.png"; + $title_st = __('Event validated'); + break; + case 2: + $img_st = "images/hourglass.png"; + $title_st = __('Event in process'); + break; + } + + $data[0] = print_image ($img_st, true, + array ("class" => "image_status", + "width" => 16, + "height" => 16, + "title" => $title_st, + "id" => 'status_img_'.$event["id_evento"])); + + switch ($event["criticity"]) { + default: + case 0: + $img_sev = "images/status_sets/default/severity_maintenance.png"; + break; + case 1: + $img_sev = "images/status_sets/default/severity_informational.png"; + break; + case 2: + $img_sev = "images/status_sets/default/severity_normal.png"; + break; + case 3: + $img_sev = "images/status_sets/default/severity_warning.png"; + break; + case 4: + $img_sev = "images/status_sets/default/severity_critical.png"; + break; + } + + // Event description + $data[1] = ''; + $data[1] .= ''; + if (strlen ($event["evento"]) > 50) { + $data[1] .= mb_substr ($event["evento"], 0, 50)."..."; + } + else { + $data[1] .= $event["evento"]; + } + $data[1] .= ''; + + if ($event["event_type"] == "system") { + $data[2] = __('System'); + } + elseif ($event["id_agente"] > 0) { + // Agent name + $data[2] = print_agent_name ($event["id_agente"], true); + } + else { + $data[2] = __('Alert').__('SNMP'); + } + + //Time + if ($group_rep == 1) { + $data[3] = print_timestamp ($event['timestamp_rep'], true); + } + else { + $data[3] = print_timestamp ($event["timestamp"], true); + } + + //Actions + $data[4] = ''; + // Validate event + if (($event["estado"] != 1) and (give_acl ($config["id_user"], $event["id_grupo"], "IW") == 1)) { + $data[4] .= ''; + $data[4] .= print_image ("images/ok.png", true, + array ("title" => __('Validate event'))); + $data[4] .= ' '; + }else { + $data[4] .= print_image ("images/tick.png", true, + array ("title" => __('Event validated'))).' '; + } + // Delete event + if (give_acl ($config["id_user"], $event["id_grupo"], "IM") == 1) { + if($event['estado'] != 2) { + $data[4] .= ''; + $data[4] .= print_image ("images/cross.png", true, + array ("title" => __('Delete event'))); + $data[4] .= ' '; + }else { + $data[4] .= print_image ("images/cross.disabled.png", true, + array ("title" => __('Is not allowed delete events in process'))).' '; + } + } + + $data[4] .= ''; + $data[4] .= print_image ("images/eye.png", true, + array ("title" => __('Show more'))); + $data[4] .= ' '; + + // Create incident from this event + if (give_acl ($config["id_user"], $event["id_grupo"], "IW") == 1) { + $data[4] .= ''; + $data[4] .= print_image ("images/page_lightning.png", true, + array ("title" => __('Create incident from event'))); + $data[4] .= ''; + } + + //Checkbox + if($event["estado"] != 1) { + $data[5] = print_checkbox_extended ("eventid[]", $event["id_evento"], false, false, false, 'class="chk"', true); + } + else { + $data[5] = ''; + } + array_push ($table->data, $data); + + //Hiden row with description form + $string = '
'; + $string .= ''; + $string .= ''; + $string .= '
'; + $string .= '' . __('Comment:') . '' . print_textarea("comment_".$event["id_evento"], 2, 10, '', 'style="min-height: 10px; width: 250px;"', true) . ''; + $string .= '
'; + if($event["estado"] == 0) { + $string .= print_select(array('1' => __('Validate'), '2' => __('Set in process')), 'select_validate_'.$event["id_evento"], '', '', '', 0, true, false, false, 'select_validate').'

'; + } + $string .= ''; + if($event["estado"] == 2) { + $string .= print_button (__('Validate'), 'validate', false, '', 'class="sub ok validate_event" id="validate-'.$event["id_evento"].'"', true).'
'; + }else { + $string .= print_button (__('Change status'), 'validate', false, '', 'class="sub ok validate_event" id="validate-'.$event["id_evento"].'"', true).''; + } + $string .= ''; + $string .= '
'; + if($event["id_alert_am"] != 0) { + $string .= ''; + } + $string .= '
'; + + $data = array($string); + + $idx++; + + $table->rowclass[$idx] = 'event_form_' . $event["id_evento"].' event_form'; + $table->colspan[$idx][0] = 10; + $table->rowstyle[$idx] = 'display: none;'; + array_push ($table->data, $data); + + //Hiden row with extended description + $string = ''; + $string .= ''; + $string .= ''; + $string .= ''; + $string .= ''; + + + if ($event["id_agentmodule"] != 0) { + $string .= ''; + } + + if ($event["id_alert_am"] != 0) { + $string .= ''; + } + + $string .= ''; + $string .= ''; + $string .= ''; + $string .= '
'; + $string .= '' . __('Event name') . ':'; + $string .= $event["evento"]; + $string .= '
'; + $string .= '' . __('Severity') . ':'; + $string .= print_image ($img_sev, true, + array ("class" => "image_status", + "width" => 12, + "height" => 12, + "title" => get_priority_name ($event["criticity"]))); + $string .= ' '.get_priority_name ($event["criticity"]); + $string .= '
'; + $string .= '' . __('Type') . ':'; + $string .= print_event_type_img ($event["event_type"], true).' '.print_event_type_description($event["event_type"], true); + $string .= '
'; + $string .= '' . __('Agent name') . ':'; + $string .= print_agent_name ($event["id_agente"], true); + $string .= '
'; + $string .= ''; + $string .= '' . __('Agent module source') . ':'; + $string .= print_image ("images/bricks.png", true, + array ("title" => __('Go to data overview'))); + $string .= '
'; + $string .= ''; + $string .= '' . __('Alert source') . ':'; + $standby = get_db_value('standby', 'talert_template_modules', 'id', $event["id_alert_am"]); + if(!$standby) { + $string .= print_image ("images/bell.png", true, + array ("title" => __('Go to data overview'))); + }else { + $string .= print_image ("images/bell_pause.png", true, + array ("title" => __('Go to data overview'))); + } + + $string .= '
'; + $string .= '' . __('Group') . ':'; + $string .= print_group_icon ($event["id_grupo"], true); + $string .= ' '. get_group_name ($event["id_grupo"], true); + $string .= '
'; + if ($group_rep == 0) { + $string .= '' . __('User ID') . ':'; + } else { + $string .= '' . __('Count') . ':'; + } + + if ($group_rep == 1) { + $string .= $event["event_rep"]; + } + else { + if (!empty ($event["estado"])) { + if ($event["id_usuario"] != '0' && $event["id_usuario"] != '' && $event["id_usuario"] != 'system' && $event["id_usuario"] != "System"){ + $string .= ''.mb_substr ($event["id_usuario"],0,8).''; + } + else { + $string .= __('System'); + } + } + else { + $string .= '- ' . __('Empty') . ' -'; + } + } + $string .= '
' . '' . __('Comments') . ':'; + if($event["user_comment"] != '') { + $string .= $event["user_comment"]; + } else { + $string .= '- ' . __('Empty') . ' -'; + } + + $string .= '
'; + + $data = array($string); + + $idx++; + + $table->rowclass[$idx] = 'event_info_' . $event["id_evento"].' event_info'; + $table->colspan[$idx][0] = 10; + $table->rowstyle[$idx] = 'display: none;'; + array_push ($table->data, $data); + + $idx++; +} + +echo '
'; +if (!empty ($table->data)) { + pagination ($total_events, $url."&pure=".$config["pure"], $offset, $pagination); + + echo '
'; + + print_table ($table); + + echo '
'; + if (give_acl ($config["id_user"], 0, "IW") == 1) { + print_submit_button (__('Change status'), 'validate_btn', false, 'class="sub ok"'); + } + if (give_acl ($config["id_user"], 0,"IM") == 1) { + print_submit_button (__('Delete'), 'delete', false, 'class="sub delete"'); + } + echo '
'; + +} +else { + echo '
'.__('No events').'
'; +} +echo '
'; + +unset ($table); + +?> diff --git a/pandora_console/operation/events/events_validate.php b/pandora_console/operation/events/events_validate.php new file mode 100644 index 0000000000..916735a961 --- /dev/null +++ b/pandora_console/operation/events/events_validate.php @@ -0,0 +1,84 @@ +".__('Events to validate').":"; + +$event_list .= ''; +$event_list .= "
    "; +$any_alert = false; +$any_inprocess = false; +foreach($ids as $key => $id) { + $event = get_event($id); + $event_list .= "".$event['evento']."
    "; + if($event['id_alert_am'] != 0) { + $any_alert = true; + } + if($event['estado'] == 2) { + $any_inprocess = true; + } +} +$event_list .= "
"; + +//Hiden row with description form +$string = '
'; +$string .= ''; +$string .= print_input_hidden('eventid', implode(',',$ids), true); +$string .= ''; +$string .= '
'; +$string .= '' . __('Comment:') . '' . print_textarea("comment", 2, 10, '', 'style="min-height: 10px; width: 250px;"', true) . ''; +$string .= '
'; +if(!$any_inprocess) { + $string .= print_select(array('1' => __('Validate'), '2' => __('Set in process')), 'select_validate', '', '', '', 0, true, false, false, 'select_validate').'

'; + $string .= print_submit_button (__('Change status'), 'validate', false, 'class="sub ok validate_event" id="validate"', true).'
'; +}else { + $string .= print_submit_button (__('Validate'), 'validate', false, 'class="sub ok validate_event" id="validate"', true).''; +} +$string .= '
'; +if($any_alert) { + $string .= ''; +} +$string .= '
'; + +echo $string; + +echo "

".$event_list; + +?> diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8f421c4674..2b0b071ecc 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -414,7 +414,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `id_agentmodule` int(10) NOT NULL default '0', `id_alert_am` int(10) NOT NULL default '0', `criticity` int(4) unsigned NOT NULL default '0', - `user_comment` varchar(255) NOT NULL default '', + `user_comment` text NOT NULL, PRIMARY KEY (`id_evento`), KEY `indice_1` (`id_agente`,`id_evento`), KEY `indice_2` (`utimestamp`,`id_evento`),