diff --git a/pandora_console/extras/mr/50.sql b/pandora_console/extras/mr/50.sql index 11c4d12cfc..31703904f5 100644 --- a/pandora_console/extras/mr/50.sql +++ b/pandora_console/extras/mr/50.sql @@ -10,5 +10,13 @@ ALTER TABLE `tevent_alert` ADD COLUMN `id_template_conditions` int(10) unsigned ALTER TABLE `tevent_alert` ADD COLUMN `id_template_fields` int(10) unsigned NOT NULL default 0; ALTER TABLE `tevent_filter` ADD COLUMN `time_from` TIME NULL; ALTER TABLE `tevent_filter` ADD COLUMN `time_to` TIME NULL; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_warning_status` TINYINT(1) DEFAULT '0'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_warning_status` TINYINT(1) DEFAULT '0'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_warning_status` TINYINT(1) DEFAULT '0'; +ALTER TABLE `treport_content` ADD COLUMN `checks_in_warning_status` TINYINT(1) DEFAULT '0'; + +INSERT INTO `treport_content` (id_report, id_gs, id_agent_module, type, period, `order`, name, description, id_agent, `text`, external_source, treport_custom_sql_id, header_definition, column_separator, line_separator, time_from, time_to, style, server_name, time_in_warning_status, checks_in_warning_status, failover_mode) SELECT id_report, 0, id_agent_module, 'availability', period, `order`, name, description, id_agent, NULL, NULL, treport_custom_sql_id, header_definition, column_separator, line_separator, time_from, time_to, '{"show_in_same_row":0,"hide_notinit_agents":0,"priority_mode":1,"dyn_height":"230"}', server_name, 1, 1, 0 FROM treport_content WHERE type = 'histogram_data'; +INSERT INTO `treport_content_item` (id_report_content, id_agent_module, id_agent_module_failover, operation, server_name) SELECT id_rc, id_agent_module, 0, '', server_name FROM treport_content WHERE type = 'availability' AND id_agent <> 0 AND id_agent_module <> 0; +DELETE FROM `treport_content` WHERE type = 'histogram_data'; COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 219da5d59a..5cd49029a9 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -898,6 +898,8 @@ ALTER TABLE `treport_content_template` ADD COLUMN `landscape` tinyint(1) UNSIGNE ALTER TABLE `treport_content_template` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content_template` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content_template` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_warning_status` TINYINT(1) DEFAULT '0'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_warning_status` TINYINT(1) DEFAULT '0'; ALTER TABLE `treport_content_template` ADD COLUMN `ipam_network_filter` int(10) UNSIGNED DEFAULT 0; ALTER TABLE `treport_content_template` ADD COLUMN `ipam_alive_ips` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; ALTER TABLE `treport_content_template` ADD COLUMN `ipam_ip_not_assigned_to_agent` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; @@ -1779,6 +1781,8 @@ ALTER TABLE `treport_content` ADD COLUMN `pagebreak` tinyint(1) UNSIGNED NOT NUL ALTER TABLE `treport_content` ADD COLUMN `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content` ADD COLUMN `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content` MODIFY `external_source` MEDIUMTEXT; +ALTER TABLE `treport_content` ADD COLUMN `time_in_warning_status` TINYINT(1) DEFAULT '0'; +ALTER TABLE `treport_content` ADD COLUMN `checks_in_warning_status` TINYINT(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `ipam_network_filter` int(10) UNSIGNED DEFAULT 0; ALTER TABLE `treport_content` ADD COLUMN `ipam_alive_ips` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; ALTER TABLE `treport_content` ADD COLUMN `ipam_ip_not_assigned_to_agent` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 2fd42028e6..aaed1b0137 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -162,12 +162,14 @@ $filter_exclude = ''; $total_time = true; $time_failed = true; $time_in_ok_status = true; +$time_in_warning_status = false; $time_in_unknown_status = true; $time_of_not_initialized_module = true; $time_of_downtime = true; $total_checks = true; $checks_failed = true; $checks_in_ok_status = true; +$checks_in_warning_status = true; $unknown_checks = true; $agent_max_value = true; $agent_min_value = true; @@ -358,7 +360,6 @@ switch ($action) { $failover_type = $item['failover_type']; break; - case 'histogram_data': case 'module_histogram_graph': $description = $item['description']; $period = $item['period']; @@ -679,12 +680,14 @@ switch ($action) { $total_time = $item['total_time']; $time_failed = $item['time_failed']; $time_in_ok_status = $item['time_in_ok_status']; + $time_in_warning_status = $item['time_in_warning_status']; $time_in_unknown_status = $item['time_in_unknown_status']; $time_of_not_initialized_module = $item['time_of_not_initialized_module']; $time_of_downtime = $item['time_of_downtime']; $total_checks = $item['total_checks']; $checks_failed = $item['checks_failed']; $checks_in_ok_status = $item['checks_in_ok_status']; + $checks_in_warning_status = $item['checks_in_warning_status']; $unknown_checks = $item['unknown_checks']; $agent_max_value = $item['agent_max_value']; $agent_min_value = $item['agent_min_value']; @@ -843,7 +846,6 @@ switch ($action) { case 'database_serialized': case 'last_value': case 'monitor_report': - case 'histogram_data': case 'min_value': case 'max_value': case 'avg_value': @@ -2361,6 +2363,14 @@ $class = 'databox filters';
+ '; + html_print_checkbox_switch('time_in_warning_status', 1, $time_in_warning_status); + ?> +
+'; @@ -2473,6 +2483,18 @@ $class = 'databox filters';
+ +
+Worktime @@ -6739,27 +6739,55 @@ function reporting_advanced_sla( // Take in mind: the "inverse" critical threshold. $inverse_interval = ($agentmodule_info['critical_inverse'] == 0) ? 1 : 0; + $inverse_interval_warning = (int) $agentmodule_info['critical_warning']; if (!$is_string_module) { - $min_value = $agentmodule_info['min_critical']; - $max_value = $agentmodule_info['max_critical']; + $min_value = $agentmodule_info['min_critical']; + $max_value = $agentmodule_info['max_critical']; + $min_value_warning = $agentmodule_info['min_warning']; + $max_value_warning = $agentmodule_info['max_warning']; } else { - $max_value = io_safe_output($agentmodule_info['str_critical']); + $max_values = io_safe_output($agentmodule_info['str_critical']); + $max_value_warning = io_safe_output($agentmodule_info['str_warning']); } if (!$is_string_module) { - if ((!isset($min_value)) || ($min_value == 0)) { + if (isset($min_value) === false || (int) $min_value === 0) { $min_value = null; } - if ((!isset($max_value)) || ($max_value == 0)) { - $max_value = null; + if (isset($max_value) === false || (int) $max_value === 0) { + if ($max_value === '0' + && $max_value < $min_value + && isset($min_value_warning) === true + && $min_value_warning > $max_value + ) { + $max_value = $min_value_warning; + } else { + $max_value = null; + } } - if ((!(isset($max_value))) && (!(isset($min_value)))) { + if (isset($max_value) === false && isset($min_value) === false) { $max_value = null; $min_value = null; } + + if (isset($min_value_warning) === false || (int) $min_value_warning === 0) { + $min_value_warning = null; + } + + if (isset($max_value_warning) === false || (int) $max_value_warning === 0) { + if ((int) $max_value_warning === 0 + && $max_value_warning < $min_value_warning + && isset($min_value) === true + && $min_value > $max_value_warning + ) { + $max_value_warning = $min_value; + } else { + $max_value_warning = null; + } + } } if ((!isset($min_value)) && (!isset($max_value))) { @@ -6785,6 +6813,30 @@ function reporting_advanced_sla( $min_value = 0; } } + + if ((!isset($min_value_warning)) && (!isset($max_value_warning))) { + if (($agentmodule_info['id_tipo_modulo'] == '2') + // Generic_proc. + || ($agentmodule_info['id_tipo_modulo'] == '6') + // Remote_icmp_proc. + || ($agentmodule_info['id_tipo_modulo'] == '9') + // Remote_tcp_proc. + || ($agentmodule_info['id_tipo_modulo'] == '18') + // Remote_snmp_proc. + || ($agentmodule_info['id_tipo_modulo'] == '21') + // Async_proc. + || ($agentmodule_info['id_tipo_modulo'] == '31') + ) { + // Web_proc + // boolean values are OK if they're different from 0. + $max_value_warning = 0; + $min_value_warning = 0; + $inverse_interval_warning = 0; + } else if ($agentmodule_info['id_tipo_modulo'] == '100') { + $max_value_warning = 0.9; + $min_value_warning = 0; + } + } } // By default show last day. @@ -7128,6 +7180,7 @@ function reporting_advanced_sla( // Timing. $time_total = 0; $time_in_ok = 0; + $time_in_warning = 0; $time_in_error = 0; $time_in_unknown = 0; $time_in_not_init = 0; @@ -7137,6 +7190,7 @@ function reporting_advanced_sla( // Checks. $bad_checks = 0; $ok_checks = 0; + $warning_checks = 0; $not_init_checks = 0; $unknown_checks = 0; $total_checks = 0; @@ -7229,6 +7283,7 @@ function reporting_advanced_sla( ) { // Check values if module is sring type. if ($is_string_module) { + // OK SLA check. if (empty($max_value)) { $match = preg_match('/^'.$max_value.'$/', $current_data['datos']); } else { @@ -7241,17 +7296,49 @@ function reporting_advanced_sla( } else { $sla_check_value = !$match; } + + // Warning SLA check. + if (empty($max_value_warning)) { + $match = preg_match('/^'.$max_value_warning.'$/', $current_data['datos']); + } else { + $match = preg_match('/'.$max_value_warning.'/', $current_data['datos']); + } + + if ($inverse_interval_warning == 0) { + $sla_check_value_warning = $match; + } else { + $sla_check_value_warning = !$match; + } } else { + // OK SLA check. $sla_check_value = sla_check_value( $current_data['datos'], $min_value, $max_value, $inverse_interval ); + + // Warning SLA check. + $sla_check_value_warning = sla_check_value( + $current_data['datos'], + $min_value_warning, + $max_value_warning, + $inverse_interval_warning, + 1 + ); } // Not unknown nor not init values. - if ($sla_check_value) { + if ($sla_check_value_warning && $sla_check_warning === true) { + if (isset($current_data['type']) === false + || ((int) $current_data['type'] === 0 + && $i !== 0) + ) { + $warning_checks++; + } + + $time_in_warning += $time_interval; + } else if ($sla_check_value === true) { if (isset($current_data['type']) === false || ((int) $current_data['type'] === 0 && $i !== 0) @@ -7326,6 +7413,7 @@ function reporting_advanced_sla( // Timing. $return['time_total'] = $time_total; $return['time_ok'] = $time_in_ok; + $return['time_warning'] = $time_in_warning; $return['time_error'] = $time_in_error; $return['time_unknown'] = $time_in_unknown; $return['time_not_init'] = $time_in_not_init; @@ -7335,12 +7423,13 @@ function reporting_advanced_sla( // Checks. $return['checks_total'] = $total_checks; $return['checks_ok'] = $ok_checks; + $return['checks_warning'] = $warning_checks; $return['checks_error'] = $bad_checks; $return['checks_unknown'] = $unknown_checks; $return['checks_not_init'] = $not_init_checks; // SLA. - $return['SLA'] = reporting_sla_get_compliance_from_array($return); + $return['SLA'] = reporting_sla_get_compliance_from_array($return, $sla_check_warning); $return['sla_fixed'] = sla_truncate( $return['SLA'], $config['graph_precision'] @@ -7545,6 +7634,8 @@ function reporting_availability($report, $content, $date=false, $time=false) $text = ''; + $check_sla_warning = ((int) $content['time_in_warning_status']) === 1; + if (isset($item['compare']) === true && empty($item['compare']) === true ) { @@ -7566,14 +7657,26 @@ function reporting_availability($report, $content, $date=false, $time=false) '7' => $content['saturday'], ], $content['time_from'], - $content['time_to'] + $content['time_to'], + 1, + 1, + $check_sla_warning ); } else { // Intervals is dinamic. $row['data'] = reporting_advanced_sla( $item['id_agent_module'], ($report['datetime'] - $content['period']), - $report['datetime'] + $report['datetime'], + null, + null, + 0, + null, + null, + null, + 1, + 1, + $check_sla_warning ); } @@ -7719,12 +7822,14 @@ function reporting_availability($report, $content, $date=false, $time=false) $return['fields']['total_time'] = $content['total_time']; $return['fields']['time_failed'] = $content['time_failed']; $return['fields']['time_in_ok_status'] = $content['time_in_ok_status']; + $return['fields']['time_in_warning_status'] = $content['time_in_warning_status']; $return['fields']['time_in_unknown_status'] = $content['time_in_unknown_status']; $return['fields']['time_of_not_initialized_module'] = $content['time_of_not_initialized_module']; $return['fields']['time_of_downtime'] = $content['time_of_downtime']; $return['fields']['total_checks'] = $content['total_checks']; $return['fields']['checks_failed'] = $content['checks_failed']; $return['fields']['checks_in_ok_status'] = $content['checks_in_ok_status']; + $return['fields']['checks_in_warning_status'] = $content['checks_in_warning_status']; $return['fields']['unknown_checks'] = $content['unknown_checks']; $return['fields']['agent_max_value'] = $content['agent_max_value']; $return['fields']['agent_min_value'] = $content['agent_min_value']; @@ -9566,12 +9671,14 @@ function reporting_check_structure_content($report) $return['fields']['total_time'] = ''; $return['fields']['time_failed'] = ''; $return['fields']['time_in_ok_status'] = ''; + $return['fields']['time_in_warning_status'] = ''; $return['fields']['time_in_unknown_status'] = ''; $return['fields']['time_of_not_initialized_module'] = ''; $return['fields']['time_of_downtime'] = ''; $return['fields']['total_checks'] = ''; $return['fields']['checks_failed'] = ''; $return['fields']['checks_in_ok_status'] = ''; + $return['fields']['checks_in_warning_status'] = ''; $return['fields']['unknown_checks'] = ''; $return['fields']['agent_max_value'] = ''; $return['fields']['agent_min_value'] = ''; @@ -13623,9 +13730,14 @@ function reporting_sql_macro(array $report, string $sql): string * @param Array With keys time_ok, time_error, time_downtime and time_unknown * @return SLA Return the compliance value. */ -function reporting_sla_get_compliance_from_array($sla_array) +function reporting_sla_get_compliance_from_array($sla_array, $sla_check_warning=false) { $time_compliance = ($sla_array['time_ok'] + $sla_array['time_unknown'] + $sla_array['time_downtime']); + + if ($sla_check_warning === true) { + $time_compliance += $sla_array['time_warning']; + } + $time_total_working = ($time_compliance + $sla_array['time_error']); return $time_compliance == 0 ? 0 : (($time_compliance / $time_total_working) * 100); } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 1524c8f9a5..d93848c3f1 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -437,10 +437,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) $mini ); break; - - case 'histogram_data': - reporting_enterprise_html_histogram_data($table, $item, $mini); - break; } if ($item['type'] == 'agent_module') { @@ -1539,7 +1535,7 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) foreach ($data as $data_field_key => $data_field_value) { $column_value = $data_field_value; - $show_link = $pdf === 0 ? true : false; + $show_link = ($pdf === 0) ? true : false; // Necessary transformations of data prior to represent it. if ($data_field_key === 'id_os') { @@ -3570,25 +3566,31 @@ function reporting_html_availability($table, $item, $pdf=0) $table1->head[4] = __(''); } - if ($item['fields']['time_in_unknown_status']) { - $table1->head[5] = __('Time Unknown'); + if ($item['fields']['time_in_warning_status']) { + $table1->head[5] = __('Time in warning status'); } else { $table1->head[5] = __(''); } - if ($item['fields']['time_of_not_initialized_module']) { - $table1->head[6] = __('Time Not Init Module'); + if ($item['fields']['time_in_unknown_status']) { + $table1->head[6] = __('Time Unknown'); } else { $table1->head[6] = __(''); } - if ($item['fields']['time_of_downtime']) { - $table1->head[7] = __('Time Downtime'); + if ($item['fields']['time_of_not_initialized_module']) { + $table1->head[7] = __('Time Not Init Module'); } else { $table1->head[7] = __(''); } - $table1->head[8] = __('% Ok'); + if ($item['fields']['time_of_downtime']) { + $table1->head[8] = __('Time Downtime'); + } else { + $table1->head[8] = __(''); + } + + $table1->head[9] = __('% Ok'); $table1->headstyle = []; if (isset($item['data'][0]['failover']) === true) { @@ -3604,6 +3606,7 @@ function reporting_html_availability($table, $item, $pdf=0) $table1->headstyle[6] = 'text-align: center'; $table1->headstyle[7] = 'text-align: right'; $table1->headstyle[8] = 'text-align: right'; + $table1->headstyle[9] = 'text-align: right'; if (isset($item['data'][0]['failover']) === true) { $table1->style[-1] = 'text-align: left'; @@ -3619,6 +3622,7 @@ function reporting_html_availability($table, $item, $pdf=0) $table1->style[7] = 'text-align: right'; $table1->style[8] = 'text-align: right'; $table1->style[9] = 'text-align: right'; + $table1->style[10] = 'text-align: right'; $table2 = new stdClass(); $table2->width = '99%'; @@ -3656,12 +3660,18 @@ function reporting_html_availability($table, $item, $pdf=0) $table2->head[4] = __(''); } - if ($item['fields']['unknown_checks']) { - $table2->head[5] = __('Checks Uknown'); + if ($item['fields']['checks_in_warning_status']) { + $table2->head[5] = __('Checks Warning'); } else { $table2->head[5] = __(''); } + if ($item['fields']['unknown_checks']) { + $table2->head[6] = __('Checks Uknown'); + } else { + $table2->head[6] = __(''); + } + $table2->headstyle = []; if (isset($item['data'][0]['failover']) === true) { $table2->headstyle[-1] = 'text-align: left'; @@ -3677,6 +3687,7 @@ function reporting_html_availability($table, $item, $pdf=0) $table2->headstyle[3] = 'text-align: right'; $table2->headstyle[4] = 'text-align: right'; $table2->headstyle[5] = 'text-align: right'; + $table2->headstyle[6] = 'text-align: right'; if (isset($item['data'][0]['failover']) === true) { $table2->style[-1] = 'text-align: left'; @@ -3774,6 +3785,20 @@ function reporting_html_availability($table, $item, $pdf=0) $table_row[] = ''; }; + if ($row['time_warning'] != 0 && $item['fields']['time_in_warning_status']) { + $table_row[] = human_time_description_raw( + $row['time_warning'], + true, + $interval_description + ); + } else if ($row['time_warning'] == 0 + && $item['fields']['time_in_warning_status'] + ) { + $table_row[] = '--'; + } else { + $table_row[] = ''; + }; + if ($row['time_unknown'] != 0 && $item['fields']['time_in_unknown_status'] ) { @@ -3883,6 +3908,12 @@ function reporting_html_availability($table, $item, $pdf=0) $table_row2[] = ''; } + if ($item['fields']['checks_in_warning_status']) { + $table_row2[] = $row['checks_warning']; + } else { + $table_row2[] = ''; + } + if ($item['fields']['unknown_checks']) { $table_row2[] = $row['checks_unknown']; } else { diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index f640bb34e9..09e3340e70 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -764,10 +764,6 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Modules'), 'name' => __('Last value'), ]; - $types['histogram_data'] = [ - 'optgroup' => __('Modules'), - 'name' => __('Histogram'), - ]; $types['general'] = [ 'optgroup' => __('Grouped'), diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a4a2575046..950816dab5 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1562,12 +1562,14 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `total_time` TINYINT(1) DEFAULT '1', `time_failed` TINYINT(1) DEFAULT '1', `time_in_ok_status` TINYINT(1) DEFAULT '1', + `time_in_warning_status` TINYINT(1) DEFAULT '0', `time_in_unknown_status` TINYINT(1) DEFAULT '1', `time_of_not_initialized_module` TINYINT(1) DEFAULT '1', `time_of_downtime` TINYINT(1) DEFAULT '1', `total_checks` TINYINT(1) DEFAULT '1', `checks_failed` TINYINT(1) DEFAULT '1', `checks_in_ok_status` TINYINT(1) DEFAULT '1', + `checks_in_warning_status` TINYINT(1) DEFAULT '0', `unknown_checks` TINYINT(1) DEFAULT '1', `agent_max_value` TINYINT(1) DEFAULT '1', `agent_min_value` TINYINT(1) DEFAULT '1', @@ -3180,12 +3182,14 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `total_time` TINYINT(1) DEFAULT '1', `time_failed` TINYINT(1) DEFAULT '1', `time_in_ok_status` TINYINT(1) DEFAULT '1', + `time_in_warning_status` TINYINT(1) DEFAULT '0', `time_in_unknown_status` TINYINT(1) DEFAULT '1', `time_of_not_initialized_module` TINYINT(1) DEFAULT '1', `time_of_downtime` TINYINT(1) DEFAULT '1', `total_checks` TINYINT(1) DEFAULT '1', `checks_failed` TINYINT(1) DEFAULT '1', `checks_in_ok_status` TINYINT(1) DEFAULT '1', + `checks_in_warning_status` TINYINT(1) DEFAULT '0', `unknown_checks` TINYINT(1) DEFAULT '1', `agent_max_value` TINYINT(1) DEFAULT '1', `agent_min_value` TINYINT(1) DEFAULT '1',