'', 'label' => __('Alerts'), ], ] ); // TABLE DETAILS. $table_details = new stdClass; $table_details->class = 'databox'; $table_details->width = '100%'; $table_details->size = []; $table_details->data = []; $table_details->style = []; $table_details->style[0] = 'font-weight: bold;'; $data = []; $data[0] = __('List alerts'); $data[1] = ''.__('List alerts').''; $table_details->data[] = $data; $data[0] = __('Agent'); $data[1] = ''.$agent_alias.''; $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'].' '.__('time(s)'); } else if ($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_mc.png'; $policy = ''; $policy .= html_print_image( $img, true, ['title' => $policyInfo['name']] ); $policy .= ''; } $data[0] = __('Policy'); $data[1] = $policy; $table_details->data[] = $data; } $table_conditions = new stdClass; $table_conditions->class = 'databox'; $table_conditions->width = '100%'; $table_conditions->size = []; $table_conditions->data = []; $table_conditions->style = []; $table_conditions->style[0] = 'font-weight: bold; width: 50%;'; $data = []; $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 'not_normal': $condition = __('The alert would fire when the module is in not normal status'); break; case 'unknown': $condition = __('The alert would fire when the module is in unknown status'); break; case 'always': $condition = __('Always'); break; default: // Not possible. break; } $data[0] = $condition; $table_conditions->data[] = $data; $table_conditions->colspan[1][0] = 2; $schedule = io_safe_output( $template['schedule'] ); $data[0] = ''; $data[0] .= html_print_input_hidden('schedule', $schedule, true); $data[0] .= '
'; $data[1] = ''; $table_conditions->data[] = $data; $data[0] = __('Use special days list'); $data[1] = (isset($template['special_day']) && (int) $template['special_day'] !== 0) ? __('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 = new stdClass; $table->class = 'alert_list databox'; $table->width = '98%'; $table->size = []; $table->head = []; $table->data = []; $table->style = []; $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); $actions = alerts_get_actions_escalation($actions, $default_action); // ESCALATION. $table = new stdClass; $table->class = 'alert_list databox alternate alert_escalation'; $table->width = '98%'; $table->size = []; $table->head = []; $table->data = []; $table->styleTable = 'text-align: center;'; echo '
'; $table->head[0] = __('Actions'); $table->style[0] = 'font-weight: bold; text-align: left;'; if (count($actions) == 1 && isset($actions[0])) { $table->head[1] = __('Every time that the alert is fired'); $table->data[0][0] = $actions[0]['name']; $table->data[0][1] = html_print_image( 'images/tick.png', true, ['class' => 'invert_filter'] ); } else { foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; if (count($action['escalation']) > 1) { foreach ($action['escalation'] as $k => $v) { $table->head[$k] = '#'.$k; if ($v > 0) { $table->data[$kaction][$k] .= html_print_image( 'images/tick.png', true, ['class' => 'invert_filter'] ); } else { $table->data[$kaction][$k] = html_print_image( 'images/blade.png', true ); } } } else { $table->head[1] = __('Every time that the alert is fired'); if (count($action['escalation']) > 0) { if ($action['escalation'][0] > 0) { $table->data[$kaction][1] .= html_print_image( 'images/tick.png', true, ['class' => 'invert_filter'] ); } else { $table->data[$kaction][1] = html_print_image( 'images/blade.png', true ); } } else { $table->data[$kaction][1] = html_print_image( 'images/blade.png', true ); } } $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold']; if ($action_threshold == 0) { $table->data[$kaction][] = __('No'); } else { $table->data[$kaction][] = human_time_description_raw( $action_threshold, true, 'tiny' ); } } $table->head[] = __('Threshold'); } html_print_table($table); unset($table); echo '
'; // ESCALATION TABLE. $table = new stdClass; $table->class = 'alert_list databox'; $table->width = '98%'; $table->size = []; $table->head = []; $table->data = []; $table->rowstyle[1] = 'font-weight: bold;'; if ((int) $default_action != 0) { $actions_select[0] = $default_action['name']; } foreach ($actions as $kaction => $action) { $actions_select[$kaction] = $action['name']; } $table->data[0][0] = __('Select the desired action and mode to see the Firing/Recovery fields for this action'); $table->colspan[0][0] = 2; $table->data[1][0] = __('Action'); $table->data[1][0] .= '
'; $table->data[1][0] .= html_print_select( $actions_select, 'firing_action_select', -1, '', __('Select the action'), -1, true, false, false ); $modes = []; $modes['firing'] = __('Firing'); $modes['recovering'] = __('Recovering'); $table->data[1][1] = ''; html_print_table($table); $table = new stdClass; $table->class = 'alert_list databox alternate'; $table->width = '98%'; $table->size = []; $table->head = []; $table->data = []; $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'); $table->title .= ui_print_help_tip( __('Fields passed to the command executed by this action when the alert is fired'), true ); $table->head[0] = __('Field'); $table->head[0] .= ui_print_help_tip( __('Fields configured on the command associated to the action'), true ); $table->head[1] = __('Template fields'); $table->head[1] .= ui_print_help_tip( __('Triggering fields configured in template'), true ); $table->head[2] = __('Action fields'); $table->head[2] .= ui_print_help_tip( __('Triggering fields configured in action'), true ); $table->head[3] = __('Executed on firing'); $table->head[3] .= ui_print_help_tip( __('Fields used on execution when the alert is fired'), true ); $firing_fields = []; foreach ($actions as $kaction => $action) { $command = alerts_get_alert_command($action['id_alert_command']); $command_preview = $command['command']; $firing_fields[$kaction] = $action; $firing_fields[$kaction]['command'] = $command['command']; $descriptions = json_decode($command['fields_descriptions'], true); foreach ($descriptions as $kdesc => $desc) { $field = 'field'.($kdesc + 1); $data = []; $data[0] = $desc; $firing_fields[$kaction]['description'][$field] = $desc; if (empty($data[0]) === false) { $data[0] = ''.$data[0].'
'; } $data[0] .= '
('.sprintf( __('Field %s'), ($kdesc + 1) ).')'; $data[1] = $template[$field]; $data[2] = $action[$field]; $data[3] = (empty($action[$field]) === true) ? $template[$field] : $action[$field]; $firing_fields[$kaction]['value'][$field] = (empty($action[$field]) === true) ? $template[$field] : $action[$field]; $first_level = $template[$field]; $second_level = $action[$field]; if (empty($second_level) === false || empty($first_level) === false) { if (empty($second_level) === false) { $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; $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 ''; ui_require_css_file('main.min', 'include/javascript/fullcalendar/'); ui_require_javascript_file('main.min', 'include/javascript/fullcalendar/'); ui_require_javascript_file('pandora_fullcalendar'); ?>