diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 3730319347..8018d90243 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -130,6 +130,7 @@ switch ($action) { $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; + $priority_mode = REPORT_PRIORITY_MODE_OK; $server_name = ''; $server_id = 0; $dyn_height = 230; @@ -272,6 +273,9 @@ switch ($action) { $time_from = $item['time_from']; $time_to = $item['time_to']; $show_graph = $item['show_graph']; + $priority_mode = isset($style['priority_mode']) + ? $style['priority_mode'] + : REPORT_PRIORITY_MODE_OK; // 'top_n' filed will be reused for SLA sort option $sla_sorted_by = $item['top_n']; $period = $item['period']; @@ -1589,6 +1593,33 @@ You can of course remove the warnings, that's why we include the source and do n + + + + '; + html_print_radio_button ( + 'priority_mode', + REPORT_PRIORITY_MODE_OK, + '', + $priority_mode == REPORT_PRIORITY_MODE_OK, + '' + ); + + echo (''); + + echo __('Priority unknown mode').''; + html_print_radio_button ( + 'priority_mode', + REPORT_PRIORITY_MODE_UNKNOWN, + '', + $priority_mode == REPORT_PRIORITY_MODE_UNKNOWN, + '' + ); + ?> + + + @@ -2801,6 +2832,7 @@ function chooseType() { $("#row_visual_format").hide(); $("#row_show_in_landscape").hide(); $('#row_hide_notinit_agents').hide(); + $('#row_priority_mode').hide(); $("#row_module_group").hide(); $("#row_servers").hide(); $("#row_sort").hide(); @@ -2946,6 +2978,7 @@ function chooseType() { $("#sla_list").show(); $("#row_working_time").show(); $("#row_historical_db_check").hide(); + $("#row_priority_mode").show(); break; case 'module_histogram_graph': @@ -2963,6 +2996,7 @@ function chooseType() { $("#sla_list").show(); $("#row_working_time").show(); $("#row_sort").show(); + $("#row_priority_mode").show(); $("#row_historical_db_check").hide(); break; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 5c16b60150..f07ee98f86 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1212,6 +1212,7 @@ switch ($action) { $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); + $style['priority_mode'] = get_parameter('priority_mode', REPORT_PRIORITY_MODE_OK); $style['dyn_height'] = get_parameter('dyn_height', 230); switch ($values['type']) { @@ -1552,6 +1553,7 @@ switch ($action) { $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); + $style['priority_mode'] = get_parameter('priority_mode', REPORT_PRIORITY_MODE_OK); $style['dyn_height'] = get_parameter('dyn_height', 230); switch ($values['type']) { diff --git a/pandora_console/images/square_violet.png b/pandora_console/images/square_violet.png new file mode 100644 index 0000000000..877b43871d Binary files /dev/null and b/pandora_console/images/square_violet.png differ diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index cb0069cf10..a4aaefbbe9 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -129,6 +129,8 @@ define('COL_WARNING_DARK', '#FFB900'); define('COL_NORMAL', '#80BA27'); define('COL_NOTINIT', '#3BA0FF'); define('COL_UNKNOWN', '#B2B2B2'); +define('COL_DOWNTIME', '#976DB1'); +define('COL_IGNORED', '#DDD'); define('COL_ALERTFIRED', '#FFA631'); define('COL_MINOR', '#F099A2'); define('COL_MAJOR', '#C97A4A'); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 787283fce2..5be7f386c3 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2843,9 +2843,9 @@ function graph_sla_slicebar ($id, $period, $sla_min, $sla_max, $date, $daysWeek 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN, - 5 => "#ff8400",//COL_MINOR, + 5 => COL_DOWNTIME, 6 => COL_NOTINIT, - 7 => "#ddd");//COL_MAJOR); + 7 => COL_IGNORED); return slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $round_corner, $home_url, $ttl); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 5df97acf9d..be3dbad1a2 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -39,6 +39,21 @@ include_once($config['homedir'] . "/include/functions_ui.php"); include_once($config['homedir'] . "/include/functions_netflow.php"); include_once($config['homedir'] . "/include/functions_os.php"); +///////////////////////////////////////////////////////// +// CONSTANTS DEFINITIONS // +///////////////////////////////////////////////////////// +// Priority modes +define ('REPORT_PRIORITY_MODE_OK', 1); +define ('REPORT_PRIORITY_MODE_UNKNOWN', 2); + +// Status +define ('REPORT_STATUS_ERR', 0); +define ('REPORT_STATUS_OK', 1); +define ('REPORT_STATUS_UNKNOWN', 2); +define ('REPORT_STATUS_NOT_INIT', 3); +define ('REPORT_STATUS_DOWNTIME', 4); +define ('REPORT_STATUS_IGNORED', 5); + function reporting_user_can_see_report($id_report, $id_user = null) { global $config; @@ -748,7 +763,7 @@ function reporting_SLA($report, $content, $type = 'dinamic', $content['time_from'], $content['time_to'], $slice - ); + ); if ($metaconsole_on) { @@ -804,7 +819,7 @@ function reporting_SLA($report, $content, $type = 'dinamic', $data['min'] = $sla['sla_min']; $data['sla_limit'] = $sla['sla_limit']; $data['dinamic_text'] = $dinamic_text; - + if(isset($sla_array[0])){ $data['time_total'] = 0; $data['time_ok'] = 0; @@ -864,7 +879,7 @@ function reporting_SLA($report, $content, $type = 'dinamic', } $i++; } - $data['sla_value'] = ($data['time_ok']/($data['time_ok']+$data['time_error']))*100; + $data['sla_value'] = reporting_sla_get_compliance_from_array($data) * 100; $data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision'] ); } else{ @@ -880,7 +895,8 @@ function reporting_SLA($report, $content, $type = 'dinamic', $data['checks_error'] = $sla_array['checks_error']; $data['checks_unknown'] = $sla_array['checks_unknown']; $data['checks_not_init'] = $sla_array['checks_not_init']; - $data['sla_value'] = $sla_array['SLA']; + $data['sla_value'] = $sla_array['SLA'] * 100; + $data['sla_fixed'] = $sla_array['sla_fixed'] * 100; } //checks whether or not it meets the SLA @@ -4662,7 +4678,7 @@ function sla_fixed_worktime($wt_start, $wt_end, $worktime = null, $planned_downt $return["wt_valid"] = 1; $return["interval"] = $wt_end - $wt_start; - if ( (!isset($wt_start)) || (!isset($wt_end)) || ($wt_start > $wt_end)) { + if ( (!isset($wt_start)) || (!isset($wt_end)) || ($wt_start > $wt_end) || ($wt_start > time())) { $return["wt_valid"] = 0; $return["interval"] = 0; } @@ -5317,7 +5333,6 @@ function reporting_advanced_sla ($id_agent_module, $time_from = null, $time_to = // Add downtime interval as OK in inclusion mode $total_checks++; $ok_checks++; - $time_in_ok += $wt_check["downtime_interval"]; $time_total += $wt_check["downtime_interval"]; $time_in_down += $wt_check["downtime_interval"]; } @@ -5366,14 +5381,7 @@ function reporting_advanced_sla ($id_agent_module, $time_from = null, $time_to = $return["checks_not_init"] = $not_init_checks; // SLA - if (($time_in_error+$time_in_ok) == 0) { - $return["SLA"] = 0; - } - else { - $return["SLA"] = (($time_in_ok/($time_in_error+$time_in_ok))*100); - } - - // SLA + $return["SLA"] = reporting_sla_get_compliance_from_array($return); $return["SLA_fixed"] = sla_truncate($return["SLA"], $config['graph_precision']); // Time ranges @@ -5491,7 +5499,7 @@ function reporting_availability($report, $content, $date=false, $time=false) { $row = array(); $text = ""; - + $row['data'] = reporting_advanced_sla( $item['id_agent_module'], $report["datetime"] - $content['period'], @@ -5689,6 +5697,8 @@ function reporting_availability_graph($report, $content, $pdf=false) { $total_result_SLA = 'ok'; $sla_showed = array(); $sla_showed_values = array(); + + $priority_mode = $content['style']['priority_mode']; foreach ($slas as $sla) { $server_name = $sla ['server_name']; @@ -5755,7 +5765,7 @@ function reporting_availability_graph($report, $content, $pdf=false) { $content['time_from'], $content['time_to'], $slice - ); + ); if ($metaconsole_on) { @@ -5839,42 +5849,12 @@ function reporting_availability_graph($report, $content, $pdf=false) { $data['checks_not_init'] += $value_sla['checks_not_init']; // generate raw data for graph - if ($value_sla['time_total'] != 0) { - if ($value_sla['time_error'] > 0) { // ERR - $raw_graph[$i]['data'] = 3; - } - elseif ($value_sla['time_unknown'] > 0) { // UNKNOWN - $raw_graph[$i]['data'] = 4; - } - elseif ($value_sla['time_not_init'] == $value_sla['time_total']) { // NOT INIT - $raw_graph[$i]['data'] = 6; - } - else { - $raw_graph[$i]['data'] = 1; - } - } - else { - $raw_graph[$i]['data'] = 7; - } + $period = reporting_sla_get_status_period($value_sla, $priority_mode); + $raw_graph[$i]['data'] = reporting_translate_sla_status_for_graph($period); $raw_graph[$i]['utimestamp'] = $value_sla['date_to'] - $value_sla['date_from']; - - if (isset($planned_downtimes)) { - foreach($planned_downtimes as $pd){ - if( ($value_sla['date_from'] >= $pd['date_from']) - && ($value_sla['date_to'] <= $pd['date_to']) ) { - $raw_graph[$i]['data'] = 5; // in scheduled downtime - break; - } - } - } $i++; } - if (($data['time_ok']+$data['time_error']) > 0 ) { - $data['sla_value'] = ($data['time_ok']/($data['time_ok']+$data['time_error']))*100; - } - else { - $data['sla_value'] = 0; - } + $data['sla_value'] = reporting_sla_get_compliance_from_array($data) * 100; $data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision'] ); } else{ @@ -5890,7 +5870,7 @@ function reporting_availability_graph($report, $content, $pdf=false) { $data['checks_error'] = $sla_array['checks_error']; $data['checks_unknown'] = $sla_array['checks_unknown']; $data['checks_not_init'] = $sla_array['checks_not_init']; - $data['sla_value'] = $sla_array['SLA']; + $data['sla_value'] = $sla_array['SLA'] * 100; } //checks whether or not it meets the SLA @@ -11025,4 +11005,69 @@ function reporting_label_macro ($item, $label) { return $label; } +/** + * @brief Calculates the SLA compliance value given an sla array + * + * @param Array With keys time_ok, time_error, time_downtime and time_unknown + */ +function reporting_sla_get_compliance_from_array ($sla_array) { + $time_compliance = $sla_array['time_ok'] + $sla_array['time_unknown'] + $sla_array['time_downtime']; + $time_total_working = $time_compliance + $sla_array['time_error']; + return $time_compliance == 0 + ? 0 + : $time_compliance/$time_total_working; +} + +/** + * @brief Given a period, get the SLA status of the period. + * + * @param Array An array with all times to calculate the SLA + * @param int Priority mode. Setting this parameter to REPORT_PRIORITY_MODE_OK + * and there is no critical in this period, return an OK without look for + * not init, downtimes, unknown and others... + * + * @return int Status + */ +function reporting_sla_get_status_period($sla_times, $priority_mode = REPORT_PRIORITY_MODE_OK) { + if ($sla_times['time_error'] > 0) { + return REPORT_STATUS_ERR; + } + if ($priority_mode == REPORT_PRIORITY_MODE_OK && $sla_times['time_ok'] > 0) { + return REPORT_STATUS_OK; + } + if ($sla_times['time_out'] > 0) { + return REPORT_STATUS_IGNORED; + } + if ($sla_times['time_downtime'] > 0) { + return REPORT_STATUS_DOWNTIME; + } + if ($sla_times['time_unknown'] > 0) { + return REPORT_STATUS_UNKNOWN; + } + if ($sla_times['time_not_init'] > 0) { + return REPORT_STATUS_NOT_INIT; + } + if ($sla_times['time_ok'] > 0) { + return REPORT_STATUS_OK; + } + return REPORT_STATUS_IGNORED; +} + +/** + * @brief Translate the status to the color to graph_sla_slicebar function + * + * @param int The status in number + * @return int The index of color array to graph_sla_slicebar function + */ +function reporting_translate_sla_status_for_graph ($status) { + $sts = array ( + REPORT_STATUS_ERR => 3, + REPORT_STATUS_OK => 1, + REPORT_STATUS_UNKNOWN => 4, + REPORT_STATUS_NOT_INIT => 6, + REPORT_STATUS_DOWNTIME => 5, + REPORT_STATUS_IGNORED => 7 + ); + return $sts[$status]; +} ?> diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 619f986d63..040a4f625f 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -535,7 +535,7 @@ function reporting_html_SLA($table, $item, $mini) { $row2[] = '--'; if($sla['time_downtime'] != 0) - $row2[] = '' . human_time_description_raw($sla['time_downtime'], true) . ''; + $row2[] = '' . human_time_description_raw($sla['time_downtime'], true) . ''; else $row2[] = '--'; @@ -614,7 +614,7 @@ function reporting_html_SLA($table, $item, $mini) { $row2[] = '--'; if($sla['time_downtime'] != 0) - $row2[] = '' . human_time_description_raw($sla['time_downtime'], true) . ''; + $row2[] = ''. human_time_description_raw($sla['time_downtime'], true) . ''; else $row2[] = '--'; @@ -693,7 +693,7 @@ function reporting_html_SLA($table, $item, $mini) { $table1->data[0][7] = ''.__('Not Init'). ''; $table1->size[8] = '2%'; - $table1->data[0][8] = ''; + $table1->data[0][8] = ''; $table1->size[9] = '14%'; $table1->data[0][9] = ''.__('Downtimes'). ''; @@ -2427,7 +2427,7 @@ function reporting_html_availability(&$table, $item) { else $table_row[] = '--'; - $table_row[] = '' . sla_truncate($row['SLA'], $config['graph_precision']). '%'; + $table_row[] = '' . sla_truncate($row['SLA'] * 100, $config['graph_precision']). '%'; $table_row2 = array(); $table_row2[] = $row['agent']; @@ -2473,7 +2473,7 @@ function reporting_html_availability(&$table, $item) { else $table_row[] = '--'; - $table_row[] = '' . sla_truncate($row['SLA'], $config['graph_precision']). '%'; + $table_row[] = '' . sla_truncate($row['SLA'] * 100, $config['graph_precision']). '%'; $table_row2 = array(); $table_row2[] = $row['agent']; @@ -2563,27 +2563,28 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) { $table1 = new stdClass(); $table1->width = '99%'; $table1->data = array (); - if (!$hide_notinit_agent) { - foreach ($item['charts'] as $chart) { - $table1->data[] = array( - $chart['agent'] . "
" . $chart['module'], - $chart['chart'], - "" . sla_truncate($chart['sla_value'], $config['graph_precision']) . '%', - "(" . $chart['checks_ok'] . "/" . $chart['checks_total'] . ")" - ); + foreach ($item['charts'] as $chart) { + switch ($chart['sla_status']) { + case REPORT_STATUS_ERR: + $color = COL_CRITICAL; + break; + case REPORT_STATUS_OK: + $color = COL_NORMAL; + break; + default: + $color = COL_UNKNOWN; + break; } + $table1->data[] = array( + $chart['agent'] . "
" . $chart['module'], + $chart['chart'], + "" . + sla_truncate($chart['sla_value'], $config['graph_precision']) . '%' . + '', + "(" . $chart['checks_ok'] . "/" . $chart['checks_total'] . ")" + ); } - else{ - foreach ($item['charts'] as $chart) { - $the_first_men_time = get_agent_first_time(io_safe_output($chart['agent'])); - if ($item['date']['to'] > $the_first_men_time) { - $table1->data[] = array( - $chart['agent'] . "
" . $chart['module'], - $chart['chart']); - } - } - } - + if($item['type'] == 'availability_graph'){ //table_legend_graphs; @@ -2612,7 +2613,7 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) { $table2->data[0][7] = ''.__('Not Init'). ''; $table2->size[8] = '2%'; - $table2->data[0][8] = ''; + $table2->data[0][8] = ''; $table2->size[9] = '14%'; $table2->data[0][9] = ''.__('Downtimes'). '';