From b6e53c707fd6d68b85d1ee690aa77dbcf5972a72 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 21 Jan 2014 16:42:44 +0000 Subject: [PATCH] 2014-01-21 Sergio Martin * images/long_arrow.png godmode/alerts/alert_view.php godmode/alerts/alert_list.list.php include/styles/pandora.css: Added an advanced alert view with details, triggering conditions, actions escalation and actions fields including triggering, recovering and command preview git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9349 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 + .../godmode/alerts/alert_list.list.php | 9 +- pandora_console/godmode/alerts/alert_view.php | 579 ++++++++++++++++++ pandora_console/images/long_arrow.png | Bin 0 -> 565 bytes pandora_console/include/styles/pandora.css | 25 + 5 files changed, 621 insertions(+), 1 deletion(-) create mode 100644 pandora_console/godmode/alerts/alert_view.php create mode 100644 pandora_console/images/long_arrow.png diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5bcf006349..e48c7c83db 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2014-01-21 Sergio Martin + + * images/long_arrow.png + godmode/alerts/alert_view.php + godmode/alerts/alert_list.list.php + include/styles/pandora.css: Added an advanced alert view + with details, triggering conditions, actions escalation and + actions fields including triggering, recovering and command preview + 2014-01-20 Ramon Novoa * pandoradb.sql: Changed the type of tnetwork_component.description to diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 50fc4fcb80..d308fdcfcf 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -334,7 +334,7 @@ if (! $id_agente) { $table->size[1] = '25%'; $table->size[2] = '25%'; $table->size[3] = '1%'; - $table->size[4] = '10%'; + $table->size[4] = '12%'; /* if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $table->size[4] = '8%'; @@ -647,6 +647,13 @@ foreach ($simple_alerts as $alert) { $data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true); $data[4] .= ''; } + + if(check_acl ($config['id_user'], $agent_group, "LM")) { + $data[4] .= '
'; + $data[4] .= html_print_input_image ('view_alert', 'images/eye.png', 1, '', true, array('title' => __('View alert advanced details'))); + $data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true); + $data[4] .= '
'; + } array_push ($table->data, $data); } diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php new file mode 100644 index 0000000000..6930280413 --- /dev/null +++ b/pandora_console/godmode/alerts/alert_view.php @@ -0,0 +1,579 @@ +class = 'alternate'; +$table_details->width = '100%'; +$table_details->size = array (); +$table_details->data = array(); +$table_details->style = array(); +$table_details->style[0] = 'font-weight: bold;'; +$data = array(); + +$data[0] = __('Agent'); +$data[1] = $agent_name; +$table_details->data[] = $data; + +$data[0] = __('Module'); +$data[1] = $module_name; +$table_details->data[] = $data; + +$data[0] = __('Template'); +$data[1] = $template['name'] . ui_print_help_tip($template['description'], true); +$table_details->data[] = $data; + +$data[0] = __('Last fired'); +$data[1] = ui_print_timestamp ($alert["last_fired"], true); +$table_details->data[] = $data; + +if ($alert["times_fired"] > 0) { + $status = STATUS_ALERT_FIRED; + $title = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); +} +elseif ($alert["disabled"] > 0) { + $status = STATUS_ALERT_DISABLED; + $title = __('Alert disabled'); +} +else { + $status = STATUS_ALERT_NOT_FIRED; + $title = __('Alert not fired'); +} + +$data[0] = __('Status'); +$data[1] = '' . ui_print_status_image($status, $title, true) . '' . $title; +$table_details->data[] = $data; + +$priorities = get_priorities (); + +$data[0] = __('Priority'); +$data[1] = ' ' . $priorities[$template['priority']]; +$table_details->data[] = $data; + +$data[0] = __('Stand by'); +$data[1] = $alert['standby'] == 1 ? __('Yes') : __('No'); +$table_details->data[] = $data; + +if (enterprise_installed() && $alert['id_policy_alerts'] != 0) { + $policyInfo = policies_is_alert_in_policy2($alert['id'], false); + if ($policyInfo === false) { + $policy = __('N/A'); + } + else { + $img = 'images/policies.png'; + + $policy = '' . + html_print_image($img, true, array('title' => $policyInfo['name'])) . + ''; + } + + $data[0] = __('Policy'); + $data[1] = $policy; + $table_details->data[] = $data; +} + +// TABLE DETAILS END + +// TABLE CONDITIONS + +$table_conditions->class = 'alternate'; +$table_conditions->width = '100%'; +$table_conditions->size = array (); +$table_conditions->data = array(); +$table_conditions->style = array(); +$table_conditions->style[0] = 'font-weight: bold; width: 50%;'; +$data = array(); +$table_conditions->colspan[0][0] = 2; + +switch ($template['type']) { + case 'regex': + if ($template['matches_value']) { + $condition = __('The alert would fire when the value matches '); + } + else { + $condition = __('The alert would fire when the value doesn\'t match '); + } + $condition = str_replace('', $template['value'], $condition); + break; + case 'equal': + $condition = __('The alert would fire when the value is '); + $condition = str_replace('', $template['value'], $condition); + break; + case 'not_equal': + $condition = __('The alert would fire when the value is not '); + $condition = str_replace('', $template['value'], $condition); + break; + case 'max_min': + if ($template['matches_value']) { + $condition = __('The alert would fire when the value is between and '); + } + else { + $condition = __('The alert would fire when the value is not between and '); + } + $condition = str_replace('', $template['min_value'], $condition); + $condition = str_replace('', $template['max_value'], $condition); + break; + case 'max': + $condition = __('The alert would fire when the value is below '); + $condition = str_replace('', $template['min_value'], $condition); + break; + case 'min': + $condition = __('The alert would fire when the value is above '); + $condition = str_replace('', $template['max_value'], $condition); + break; + case 'onchange': + if ($template['matches_value']) { + $condition = __('The alert would fire when the module value changes'); + } + else { + $condition = __('The alert would fire when the module value does not change'); + } + break; + case 'warning': + $condition = __('The alert would fire when the module is in warning status'); + break; + case 'critical': + $condition = __('The alert would fire when the module is in critical status'); + break; + case 'unknown': + $condition = __('The alert would fire when the module is in unknown status'); + break; + case 'always': + $condition = __('Always'); +} +$data[0] = $condition; + +$table_conditions->data[] = $data; + +//DAYS +$table_days->class = 'databox alert_days'; +$table_days->width = '100%'; +$table_days->size = array (); +$table_days->data = array(); +$table_days->style = array(); +$table_days->styleTable = 'padding: 1px; margin: 0px; text-align: center; height: 80px;'; +$table_days->head[0] = __('Mon'); +$table_days->head[1] = __('Tue'); +$table_days->head[2] = __('Wed'); +$table_days->head[3] = __('Thu'); +$table_days->head[4] = __('Fri'); +$table_days->head[5] = __('Sat'); +$table_days->head[6] = __('Sun'); +$table_days->data[0][0] = $table_days->data[0][1] = $table_days->data[0][2] = + $table_days->data[0][3] = $table_days->data[0][4] = $table_days->data[0][5] = + $table_days->data[0][6] = html_print_image('images/blade.png', true); + +$days = array(); +if ($template['monday']) { + $table_days->data[0][0] = html_print_image('images/tick.png', true); +} +if ($template['tuesday']) { + $table_days->data[0][1] = html_print_image('images/tick.png', true); +} +if ($template['wednesday']) { + $table_days->data[0][2] = html_print_image('images/tick.png', true); +} +if ($template['thursday']) { + $table_days->data[0][3] = html_print_image('images/tick.png', true); +} +if ($template['friday']) { + $table_days->data[0][4] = html_print_image('images/tick.png', true); +} +if ($template['saturday']) { + $table_days->data[0][5] = html_print_image('images/tick.png', true); +} +if ($template['sunday']) { + $table_days->data[0][6] = html_print_image('images/tick.png', true); +} + +$data[0] = html_print_table($table_days, true); +unset($table_days); + +// TIME +$table_time->class = 'databox alert_time'; +$table_time->width = '100%'; +$table_time->size = array (); +$table_time->data = array(); +$table_time->style = array(); +$table_time->styleTable = 'padding: 1px; margin: 0px; text-align: center; height: 80px; width: 100%;'; + +//$data[0] = __('Time from') . ' / ' . __('Time to'); +if ($template['time_from'] == $template['time_to']) { + $table_time->head[0] = '00:00:00
-
23:59:59'; + $table_time->data[0][0] = html_print_image('images/tick.png', true); +} +else { + $from_array = explode(':', $template['time_from']); + $from = $from_array[0] * 3600 + $from_array[1] * 60 + $from_array[2]; + $to_array = explode(':', $template['time_to']); + $to = $to_array[0] * 3600 + $to_array[1] * 60 + $to_array[2]; + if ($to > $from) { + if ($template['time_from'] != '00:00:00') { + $table_time->head[0] = '00:00:00
-
' . $template['time_from']; + $table_time->data[0][0] = html_print_image('images/blade.png', true); + } + + $table_time->head[1] = $template['time_from'] . '
-
' . $template['time_to']; + $table_time->data[0][1] = html_print_image('images/tick.png', true); + + if ($template['time_to'] != '23:59:59') { + $table_time->head[2] = $template['time_to'] . '
-
23:59:59'; + $table_time->data[0][2] = html_print_image('images/blade.png', true); + } + } + else { + if ($template['time_to'] != '00:00:00') { + $table_time->head[0] = '00:00:00
-
' . $template['time_to']; + $table_time->data[0][0] = html_print_image('images/tick.png', true); + } + + $table_time->head[1] = $template['time_to'] . '
-
' . $template['time_from']; + $table_time->data[0][1] = html_print_image('images/blade.png', true); + + if ($template['time_from'] != '23:59:59') { + $table_time->head[2] = $template['time_from'] . '
-
23:59:59'; + $table_time->data[0][2] = html_print_image('images/tick.png', true); + } + + } + $data[1] = $template['time_from'] . ' / ' . $template['time_to']; +} + +$data[1] = html_print_table($table_time, true); +unset($table_time); + +$table_conditions->data[] = $data; + +$data[0] = __('Use special days list'); +$data[1] = $alert['special_day'] == 1 ? __('Yes') : __('No'); +$table_conditions->data[] = $data; + +$data[0] = __('Time threshold'); +$data[1] = human_time_description_raw ($template['time_threshold'], true); +$table_conditions->data[] = $data; + +$data[0] = __('Number of alerts') . ' ('. __('Min') . '/' . __('Max') . ')'; +$data[1] = $template['min_alerts'] . '/' . $template['max_alerts']; +$table_conditions->data[] = $data; + +// TABLE CONDITIONS END + +$table->class = 'alert_list databox'; +$table->width = '98%'; +$table->size = array(); +$table->head = array(); +$table->data = array(); +$table->style = array(); +$table->style[0] = 'width: 50%;'; + +$table->head[0] = __('Alert details'); +$table->head[1] = __('Firing conditions'); + +$table->data[0][0] = html_print_table($table_details, true); +$table->data[0][1] = html_print_table($table_conditions, true); + +html_print_table($table); +unset($table); + + +$table->class = 'alert_list databox'; +$table->width = '98%'; +$table->size = array (); +$table->head = array(); +$table->data = array(); +$table->rowstyle[1] = 'font-weight: bold;'; + +foreach($actions as $kaction => $action) { + $actions_select[$kaction] = $action['name']; +} + +$table->data[0][0] = __('Select the desired action and mode to see the Escalation and Firing/Recovery fields for this action'); +$table->colspan[0][0] = 2; + +$table->data[1][0] = __('Action') . '
' . html_print_select($actions_select, 'firing_action_select', -1, '', 'Select', -1, true, false, false); + +$modes = array(); +$modes['firing'] = __('Firing'); +$modes['recovering'] = __('Recovering'); + +$table->data[1][1] = ''; + +html_print_table($table); +unset($table); + +// ESCALATION +foreach($actions as $kaction => $action) { + $style = 'width: 100%; display:none;'; + + echo '
'; + $table->class = 'alert_list databox alternate'; + $table->width = '98%'; + $table->size = array (); + $table->head = array(); + $table->data = array(); + $table->styleTable = 'text-align: center;'; + + $table->title = __('Escalation') . ui_print_help_tip(__('Escalation is the alert firing times when the action is executed. I.E.: The 2 first alert firing times.'), true); + + if ($action['fires_min'] == 0 && $action['fires_max'] == 0) { + if (isset($action['default'])) { + $table->head[0] = __('Every time that the alert is fired and no other action is executed'); + } + else { + $table->head[0] = __('Every time that the alert is fired'); + } + $table->data[0][0] = html_print_image('images/tick.png', true); + } + else if ($action['fires_min'] == $action['fires_max']) { + $table->head[0] = '< #' . ($action['fires_min']); + $table->data[0][0] = html_print_image('images/blade.png', true); + $table->head[1] = '#' . ($action['fires_min']); + $table->data[0][1] = html_print_image('images/tick.png', true); + } + else if ($action['fires_min'] > 0){ + $table->head[0] = '< #' . ($action['fires_min'] + 1); + $table->data[0][0] = html_print_image('images/blade.png', true); + } + + for ($i=$action['fires_min'];$i<$action['fires_max'];$i++) { + $table->head[$i] = '#' . ($i+1); + $table->data[0][$i] = html_print_image('images/tick.png', true); + } + + if (!isset($action['default']) && ($action['fires_min'] != 0 || $action['fires_max'] != 0)) { + $table->head[$i+1] = '> #' . ($i); + $table->data[0][$i+1] = html_print_image('images/blade.png', true); + } + + + html_print_table($table); + unset($table); + echo '
'; // Escalation table +} + + +$table->class = 'alert_list databox alternate'; +$table->width = '98%'; +$table->size = array (); +$table->head = array(); +$table->data = array(); +$table->style[0] = 'width: 100px;'; +$table->style[1] = 'width: 30%;'; +$table->style[2] = 'width: 30%;'; +$table->style[3] = 'font-weight: bold; width: 30%;'; + +$table->title = __('Firing fields') . ui_print_help_tip(__('Fields passed to the command executed by this action when the alert is fired'), true); + +$table->head[0] = __('Field') . ui_print_help_tip(__('Fields configured on the command associated to the action'), true); +$table->head[1] = __('Template fields') . ui_print_help_tip(__('Triggering fields configured in template'), true); +$table->head[2] = __('Action fields') . ui_print_help_tip(__('Triggering fields configured in action'), true); + +$table->head[3] = __('Executed on firing') . ui_print_help_tip(__('Fields used on execution when the alert is fired'), true); + +$firing_fields = array(); +foreach ($actions as $kaction => $action) { + $command = alerts_get_alert_command($action['id_alert_command']); + $command_preview = $command['command']; + $firing_fields[$kaction]['command'] = $command['command']; + + $descriptions = json_decode($command['fields_descriptions'], true); + + foreach ($descriptions as $kdesc => $desc) { + if (empty($desc)) { + //continue; + } + $field = "field" . ($kdesc + 1); + $data = array(); + $data[0] = $firing_fields[$kaction]['description'][$field] = $desc; + if (!empty($data[0])) { + $data[0] = '' . $data[0] . '
'; + } + $data[0] .= '
(' . sprintf(__("Field %s"), ($kdesc + 1)) . ')'; + $data[1] = $template[$field]; + $data[2] = $action[$field]; + $data[3] = $firing_fields[$kaction]['value'][$field] = empty($action[$field]) ? $template[$field] : $action[$field]; + + $first_level = $template[$field]; + $second_level = $action[$field]; + if (!empty($second_level) || !empty($first_level)) { + if (empty($second_level)) { + $table->cellclass[count($table->data)][1] = 'used_field'; + $table->cellclass[count($table->data)][2] = 'empty_field'; + } + else { + $table->cellclass[count($table->data)][1] = 'overrided_field'; + $table->cellclass[count($table->data)][2] = 'used_field'; + } + } + $table->data[] = $data; + + if ($kaction == $action_selected) { + $table->rowstyle[] = ''; + } + else { + $table->rowstyle[] = 'display: none;'; + } + + $table->rowclass[] = 'firing_action firing_action_' . $kaction; + + if ($command_preview != 'Internal type') { + $command_preview = str_replace('_'.$field.'_', $data[3], $command_preview); + } + } + $firing_fields[$kaction]['command_preview'] = $command_preview; +} + +echo ''; // Firing table + +echo ''; // Recovering table + +?> + + diff --git a/pandora_console/images/long_arrow.png b/pandora_console/images/long_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..687015b873406a5334260e50a97126fd03e2b5b6 GIT binary patch literal 565 zcmV-50?Pe~P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i^e{ z4mk|7>$Q0R00Fg0L_t(|+U?uFY7}7@h4JTIRsw=bihy_>HZ~c^c3Nwf#zwFa(n<#0 z#ZE=UP2o*=4MHS>ki#sZ4T%A7?33C3~krcdEa}k zNRo6$cq{>{28bl-!q&&jOTcH~L)$fv{x(;xN|JP}eTl?5}_|ymP zB$>J`Nz%MwOey+By#;On38|vCfi~pzXs|W4e@K!}X}jiQl6w>j^B)R-5Y{O+Mk`xW zfWB*zBpn9FxLKrl58SS*gN)d%)Mz-EygWK6$A*2iyc63|A&^+=?XWLe|I2SKD!O_q>_klLVB@j}Qd}00000NkvXXu0mjf DYDn_< literal 0 HcmV?d00001 diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 066558f8c1..0f42c3f76b 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1541,6 +1541,10 @@ table.databox { color: #fff; } +.databox th input, .databox th textarea, .databox th select, .databox th select option { + color: #222 !important; +} + .tabletitle { background: url(../../images/header_blackout.png) no-repeat; } @@ -2812,3 +2816,24 @@ div#agent_wizard_subtabs { .olLayerDiv { z-index: 102 !important; } + +/* Alert view */ + +table.alert_days th, table.alert_time th{ + height: 30px; + vertical-align: middle; +} + +td.used_field { + #border: solid #6EB432; + background: #6EB432 !important; + color: #FFFFFF; +} + +td.unused_field { + color: #888; +} + +td.empty_field { + background: url('../../images/long_arrow.png') no-repeat 100% center; +}