fixed errors

This commit is contained in:
Daniel Barbero Martin 2019-07-01 17:07:39 +02:00
parent 8c7acdb02e
commit 0064bc0cba
9 changed files with 697 additions and 323 deletions

View File

View File

@ -1239,13 +1239,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 29); INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 30);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '736'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '737');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
@ -2209,3 +2209,8 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` (
`extra_2` text, `extra_2` text,
PRIMARY KEY (`identifier`) PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `treport_content_sla_combined`
-- ---------------------------------------------------------------------
ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_secondary` int(10) unsigned NOT NULL;

View File

@ -566,7 +566,6 @@ switch ($action) {
$include_extended_events = $item['show_extended_events']; $include_extended_events = $item['show_extended_events'];
$filter_search = $style['event_filter_search']; $filter_search = $style['event_filter_search'];
break; break;
case 'event_report_group': case 'event_report_group':
@ -2784,8 +2783,21 @@ function print_SLA_list($width, $action, $idItem=null)
<th class="header sla_list_module_col" scope="col"> <th class="header sla_list_module_col" scope="col">
<?php <?php
echo __('Module'); echo __('Module');
if ($report_item_type == 'availability_graph') {
?>
<th class="header sla_list_agent_secondary" scope="col">
<?php
echo __('Agent Secondary');
?> ?>
</th> </th>
<th class="header sla_list_module_secondary" scope="col">
<?php
echo __('Module Secondary');
?>
</th>
<?php
}
?>
<th class="header sla_list_service_col" scope="col"> <th class="header sla_list_service_col" scope="col">
<?php <?php
echo __('Service'); echo __('Service');
@ -2831,6 +2843,7 @@ function print_SLA_list($width, $action, $idItem=null)
case 'update': case 'update':
case 'edit': case 'edit':
echo '<tbody id="list_sla">'; echo '<tbody id="list_sla">';
$itemsSLA = db_get_all_rows_filter( $itemsSLA = db_get_all_rows_filter(
'treport_content_sla_combined', 'treport_content_sla_combined',
['id_report_content' => $idItem] ['id_report_content' => $idItem]
@ -2865,6 +2878,25 @@ function print_SLA_list($width, $action, $idItem=null)
['id_agente_modulo' => $item['id_agent_module']] ['id_agente_modulo' => $item['id_agent_module']]
); );
if (isset($item['id_agent_module_secondary']) === true
&& $item['id_agent_module_secondary'] !== 0
) {
$idAgentSecondary = db_get_value_filter(
'id_agente',
'tagente_modulo',
['id_agente_modulo' => $item['id_agent_module_secondary']]
);
$nameAgentSecondary = agents_get_alias(
$idAgentSecondary
);
$nameModuleSecondary = db_get_value_filter(
'nombre',
'tagente_modulo',
['id_agente_modulo' => $item['id_agent_module_secondary']]
);
}
$server_name_element = ''; $server_name_element = '';
if ($meta && $server_name != '') { if ($meta && $server_name != '') {
$server_name_element .= ' ('.$server_name.')'; $server_name_element .= ' ('.$server_name.')';
@ -2878,6 +2910,15 @@ function print_SLA_list($width, $action, $idItem=null)
echo printSmallFont($nameModule); echo printSmallFont($nameModule);
echo '</td>'; echo '</td>';
if ($report_item_type == 'availability_graph') {
echo '<td class="sla_list_agent_secondary">';
echo printSmallFont($nameAgentSecondary).$server_name_element;
echo '</td>';
echo '<td class="sla_list_module_secondary">';
echo printSmallFont($nameModuleSecondary);
echo '</td>';
}
if (enterprise_installed() if (enterprise_installed()
&& $report_item_type == 'SLA_services' && $report_item_type == 'SLA_services'
) { ) {
@ -2926,6 +2967,13 @@ function print_SLA_list($width, $action, $idItem=null)
<td class="sla_list_agent_col agent_name"></td> <td class="sla_list_agent_col agent_name"></td>
<td class="sla_list_module_col module_name"></td> <td class="sla_list_module_col module_name"></td>
<?php <?php
if ($report_item_type == 'availability_graph') {
?>
<td class="sla_list_agent_secondary agent_name_secondary"></td>
<td class="sla_list_module_secondary module_name_secondary"></td>
<?php
}
if (enterprise_installed() if (enterprise_installed()
&& $report_item_type == 'SLA_services' && $report_item_type == 'SLA_services'
) { ) {
@ -2982,6 +3030,42 @@ function print_SLA_list($width, $action, $idItem=null)
</select> </select>
</td> </td>
<?php <?php
if ($report_item_type == 'availability_graph') {
?>
<td class="sla_list_agent_secondary_col">
<input id="hidden-id_agent_secondary" name="id_agent_secondary" value="" type="hidden">
<input id="hidden-server_name_secondary" name="server_name_secondary" value="" type="hidden">
<?php
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'agent_secondary';
$params['value'] = '';
$params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agent_secondary';
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_secondary';
$params['add_none_module'] = false;
if ($meta) {
$params['use_input_id_server'] = true;
$params['input_id_server_id'] = 'hidden-id_server';
$params['disabled_javascript_on_blur_function'] = true;
}
ui_print_agent_autocomplete_input($params);
?>
</td>
<td class="sla_list_module_secondary_col">
<select id="id_agent_module_secondary" name="id_agent_module_secondary" disabled="disabled" style="max-width: 180px">
<option value="0">
<?php
echo __('Select an Agent first');
?>
</option>
</select>
</td>
<?php
}
if (enterprise_installed() if (enterprise_installed()
&& $report_item_type == 'SLA_services' && $report_item_type == 'SLA_services'
) { ) {
@ -3915,10 +3999,13 @@ function deleteGeneralRow(id_row) {
function addSLARow() { function addSLARow() {
var nameAgent = $("input[name=agent_sla]").val(); var nameAgent = $("input[name=agent_sla]").val();
var nameAgentSecondary = $("input[name=agent_secondary]").val();
var idAgent = $("input[name=id_agent_sla]").val(); var idAgent = $("input[name=id_agent_sla]").val();
var serverId = $("input[name=id_server]").val(); var serverId = $("input[name=id_server]").val();
var idModule = $("#id_agent_module_sla").val(); var idModule = $("#id_agent_module_sla").val();
var idModuleSecondary = $("#id_agent_module_secondary").val();
var nameModule = $("#id_agent_module_sla :selected").text(); var nameModule = $("#id_agent_module_sla :selected").text();
var nameModuleSecondary = $("#id_agent_module_secondary :selected").text();
var slaMin = $("input[name=sla_min]").val(); var slaMin = $("input[name=sla_min]").val();
var slaMax = $("input[name=sla_max]").val(); var slaMax = $("input[name=sla_max]").val();
var slaLimit = $("input[name=sla_limit]").val(); var slaLimit = $("input[name=sla_limit]").val();
@ -3979,10 +4066,63 @@ function addSLARow() {
}); });
} }
if (nameAgentSecondary != '') {
//Truncate nameAgentSecondary
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameAgentSecondary);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action=
<?php
echo '"'.ui_get_full_url(
false,
false,
false,
false
).'"';
?>
+ "/ajax.php",
async: false,
timeout: 10000,
success: function (data) {
nameAgentSecondary = data;
}
});
//Truncate nameModuleSecondary
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameModuleSecondary);
params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action=
<?php
echo '"'.ui_get_full_url(
false,
false,
false,
false
).'"';
?>
+ "/ajax.php",
async: false,
timeout: 10000,
success: function (data) {
nameModuleSecondary = data;
}
});
}
var params = []; var params = [];
params.push("add_sla=1"); params.push("add_sla=1");
params.push("id=" + $("input[name=id_item]").val()); params.push("id=" + $("input[name=id_item]").val());
params.push("id_module=" + idModule); params.push("id_module=" + idModule);
params.push("id_module_secondary=" + idModuleSecondary);
params.push("sla_min=" + slaMin); params.push("sla_min=" + slaMin);
params.push("sla_max=" + slaMax); params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit); params.push("sla_limit=" + slaLimit);
@ -4015,6 +4155,8 @@ function addSLARow() {
$("#row", row).attr('id', 'sla_' + data['id']); $("#row", row).attr('id', 'sla_' + data['id']);
$(".agent_name", row).html(nameAgent); $(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule); $(".module_name", row).html(nameModule);
$(".agent_name_secondary", row).html(nameAgentSecondary);
$(".module_name_secondary", row).html(nameModuleSecondary);
$(".service_name", row).html(serviceName); $(".service_name", row).html(serviceName);
$(".sla_min", row).html(slaMin); $(".sla_min", row).html(slaMin);
$(".sla_max", row).html(slaMax); $(".sla_max", row).html(slaMax);
@ -4025,14 +4167,22 @@ function addSLARow() {
); );
$("#list_sla").append($(row).html()); $("#list_sla").append($(row).html());
$("input[name=id_agent_sla]").val(''); $("input[name=id_agent_sla]").val('');
$("input[name=id_agent_secondary]").val('');
$("input[name=id_server]").val(''); $("input[name=id_server]").val('');
$("input[name=agent_sla]").val(''); $("input[name=agent_sla]").val('');
$("input[name=agent_secondary]").val('');
$("#id_agent_module_sla").empty(); $("#id_agent_module_sla").empty();
$("#id_agent_module_sla").attr('disabled', 'true'); $("#id_agent_module_sla").attr('disabled', 'true');
$("#id_agent_module_sla").append( $("#id_agent_module_sla").append(
$("<option></option>") $("<option></option>")
.attr ("value", 0) .attr ("value", 0)
.html ($("#module_sla_text").html())); .html ($("#module_sla_text").html()));
$("#id_agent_module_secondary").empty();
$("#id_agent_module_secondary").attr('disabled', 'true');
$("#id_agent_module_secondary").append(
$("<option></option>")
.attr ("value", 0)
.html ($("#module_sla_text").html()));
$("input[name=sla_min]").val(''); $("input[name=sla_min]").val('');
$("input[name=sla_max]").val(''); $("input[name=sla_max]").val('');
$("input[name=sla_limit]").val(''); $("input[name=sla_limit]").val('');
@ -4161,7 +4311,6 @@ function addGeneralRow() {
success: function (data) { success: function (data) {
if (data['correct']) { if (data['correct']) {
row = $("#general_template").clone(); row = $("#general_template").clone();
$("#row", row).show(); $("#row", row).show();
$("#row", row).attr('id', 'general_' + data['id']); $("#row", row).attr('id', 'general_' + data['id']);
$(".agent_name", row).html(nameAgent); $(".agent_name", row).html(nameAgent);

View File

@ -65,6 +65,7 @@ if ($add_sla) {
$sla_max = get_parameter('sla_max', 0); $sla_max = get_parameter('sla_max', 0);
$sla_min = get_parameter('sla_min', 0); $sla_min = get_parameter('sla_min', 0);
$server_id = (int) get_parameter('server_id', 0); $server_id = (int) get_parameter('server_id', 0);
$id_module_secondary = (int) get_parameter('id_module_secondary', 0);
$id_service = (int) get_parameter('id_service'); $id_service = (int) get_parameter('id_service');
if (empty($id_module) && !empty($id_service)) { if (empty($id_module) && !empty($id_service)) {
@ -87,6 +88,7 @@ if ($add_sla) {
[ [
'id_report_content' => $id, 'id_report_content' => $id,
'id_agent_module' => $id_module, 'id_agent_module' => $id_module,
'id_agent_module_secondary' => $id_module_secondary,
'sla_max' => $sla_max, 'sla_max' => $sla_max,
'sla_min' => $sla_min, 'sla_min' => $sla_min,
'sla_limit' => $sla_limit, 'sla_limit' => $sla_limit,

View File

@ -134,6 +134,7 @@ if ($install_package) {
$accept = (bool) get_parameter('accept', false); $accept = (bool) get_parameter('accept', false);
if ($accept) { if ($accept) {
hd($accept, true);
$package = (string) get_parameter('package'); $package = (string) get_parameter('package');
$package = trim($package); $package = trim($package);
@ -163,6 +164,7 @@ if ($install_package) {
unlink($files_copied); unlink($files_copied);
} }
if (file_exists($package)) { if (file_exists($package)) {
if ($files_h = fopen($files_total, 'r')) { if ($files_h = fopen($files_total, 'r')) {
while ($line = stream_get_line($files_h, 65535, "\n")) { while ($line = stream_get_line($files_h, 65535, "\n")) {

View File

@ -1,20 +1,30 @@
<?php <?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/** /**
* @package Include * Extension to manage a list of gateways and the node address where they should
* @subpackage Reporting * point to.
*
* @category Reporting
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/ */
/** /**
@ -38,9 +48,7 @@ require_once $config['homedir'].'/include/functions_netflow.php';
require_once $config['homedir'].'/include/functions_os.php'; require_once $config['homedir'].'/include/functions_os.php';
require_once $config['homedir'].'/include/functions_network.php'; require_once $config['homedir'].'/include/functions_network.php';
// // CONSTANTS DEFINITIONS.
// CONSTANTS DEFINITIONS //
//
// Priority modes. // Priority modes.
define('REPORT_PRIORITY_MODE_OK', 1); define('REPORT_PRIORITY_MODE_OK', 1);
define('REPORT_PRIORITY_MODE_UNKNOWN', 2); define('REPORT_PRIORITY_MODE_UNKNOWN', 2);
@ -6371,9 +6379,13 @@ function reporting_availability($report, $content, $date=false, $time=false)
/** /**
* reporting_availability_graph * Reporting_availability_graph.
* *
* Generates a structure the report. * @param array $report Info report.
* @param array $content Content data.
* @param boolean $pdf Output type PDF.
*
* @return array Generates a structure the report.
*/ */
function reporting_availability_graph($report, $content, $pdf=false) function reporting_availability_graph($report, $content, $pdf=false)
{ {
@ -6393,7 +6405,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$return['description'] = $content['description']; $return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content); $return['date'] = reporting_get_date_text($report, $content);
// Get chart // Get chart.
reporting_set_conf_charts( reporting_set_conf_charts(
$width, $width,
$height, $height,
@ -6437,27 +6449,221 @@ function reporting_availability_graph($report, $content, $pdf=false)
foreach ($slas as $sla) { foreach ($slas as $sla) {
$server_name = $sla['server_name']; $server_name = $sla['server_name'];
// Metaconsole connection
// Metaconsole connection.
if ($metaconsole_on && $server_name != '') { if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) { if (metaconsole_connect($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue; continue;
} }
} }
if (modules_is_disable_agent($sla['id_agent_module']) if (isset($sla['id_agent_module_secondary']) === true
|| modules_is_not_init($sla['id_agent_module']) && $sla['id_agent_module_secondary'] != 0
) { ) {
$sla_secondary['primary'] = $sla;
$sla_secondary['failover'] = $sla;
$sla_secondary['failover']['id_agent_module'] = $sla['id_agent_module_secondary'];
// For graph slice for module-interval, if not slice=0.
$module_interval = modules_get_interval($sla['id_agent_module']);
$slice = ($content['period'] / $module_interval);
foreach ($sla_secondary as $k_sla => $v_sla) {
$sla_array = data_db_uncompress_module(
$v_sla,
$content,
$report['datetime'],
$slice
);
$return = prepare_data_for_paint(
$v_sla,
$sla_array,
$content,
$report['datetime'],
$return,
$k_sla
);
$data_combined[] = $sla_array;
}
if (isset($data_combined) === true
&& is_array($data_combined) === true
&& count($data_combined) > 0
) {
$data_a = array_map(
function ($primary, $failover) {
if ($primary['date_from'] === $failover['date_from']
&& $primary['date_to'] === $failover['date_to']
) {
if ($primary['sla_fixed'] !== 100
&& $primary['sla_fixed'] < $failover['sla_fixed']
) {
$primary['time_total'] = $failover['time_total'];
$primary['time_ok'] = $failover['time_ok'];
$primary['time_error'] = $failover['time_error'];
$primary['time_unknown'] = $failover['time_unknown'];
$primary['time_not_init'] = $failover['time_not_init'];
$primary['time_downtime'] = $failover['time_downtime'];
$primary['time_out'] = $failover['time_out'];
$primary['checks_total'] = $failover['checks_total'];
$primary['checks_ok'] = $failover['checks_ok'];
$primary['checks_error'] = $failover['checks_error'];
$primary['checks_unknown'] = $failover['checks_unknown'];
$primary['checks_not_init'] = $failover['checks_not_init'];
$primary['SLA'] = $failover['SLA'];
$primary['sla_fixed'] = $failover['sla_fixed'];
}
$return = $primary;
}
return $return;
},
$data_combined[0],
$data_combined[1]
);
$return = prepare_data_for_paint(
$sla,
$data_a,
$content,
$report['datetime'],
$return,
'result'
);
}
} else {
$sla_array = data_db_uncompress_module(
$sla,
$content,
$report['datetime']
);
$return = prepare_data_for_paint(
$sla,
$sla_array,
$content,
$report['datetime'],
$return
);
}
if ($metaconsole_on) { if ($metaconsole_on) {
// Restore db connection // Restore db connection.
metaconsole_restore_db(); metaconsole_restore_db();
} }
continue;
} }
// controller min and max == 0 then dinamic min and max critical // SLA items sorted descending.
if ($content['top_n'] == 2) {
arsort($return['data']['']);
} else if ($content['top_n'] == 1) {
// SLA items sorted ascending.
asort($sla_showed_values);
}
// Order data for ascending or descending.
if ($content['top_n'] != 0) {
switch ($content['top_n']) {
case 1:
// Order tables.
$temp = [];
foreach ($return['data'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] < $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['data'] = $temp;
// Order graphs.
$temp = [];
foreach ($return['charts'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] < $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['charts'] = $temp;
break;
case 2:
// Order tables.
$temp = [];
foreach ($return['data'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] > $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['data'] = $temp;
// Order graph.
$temp = [];
foreach ($return['charts'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] > $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['charts'] = $temp;
break;
default:
// If not posible.
break;
}
}
}
return reporting_check_structure_content($return);
}
/**
* Return data db uncompress for module.
*
* @param array $sla Data neccesary for db_uncompress.
* @param array $content Conetent report.
* @param array $datetime Date.
* @param integer $slice Defined slice.
*
* @return array
*/
function data_db_uncompress_module($sla, $content, $datetime, $slice=0)
{
// Controller min and max == 0 then dinamic min and max critical.
$dinamic_text = 0; $dinamic_text = 0;
if ($sla['sla_min'] == 0 && $sla['sla_max'] == 0) { if ($sla['sla_min'] == 0 && $sla['sla_max'] == 0) {
$sla['sla_min'] = null; $sla['sla_min'] = null;
@ -6465,7 +6671,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$dinamic_text = __('Dynamic'); $dinamic_text = __('Dynamic');
} }
// controller inverse interval // Controller inverse interval.
$inverse_interval = 0; $inverse_interval = 0;
if ((isset($sla['sla_max'])) && (isset($sla['sla_min']))) { if ((isset($sla['sla_max'])) && (isset($sla['sla_min']))) {
if ($sla['sla_max'] < $sla['sla_min']) { if ($sla['sla_max'] < $sla['sla_min']) {
@ -6477,22 +6683,21 @@ function reporting_availability_graph($report, $content, $pdf=false)
} }
} }
// for graph slice for module-interval, if not slice=0; if ($slice === 0) {
// For graph slice for module-interval, if not slice=0.
$module_interval = modules_get_interval($sla['id_agent_module']); $module_interval = modules_get_interval($sla['id_agent_module']);
$slice = ($content['period'] / $module_interval); $slice = ($content['period'] / $module_interval);
}
// call functions sla // Call functions sla.
$sla_array = []; $sla_array = [];
$sla_array = reporting_advanced_sla( $sla_array = reporting_advanced_sla(
$sla['id_agent_module'], $sla['id_agent_module'],
($report['datetime'] - $content['period']), ($datetime - $content['period']),
$report['datetime'], $datetime,
$sla['sla_min'], $sla['sla_min'],
// min_value -> dynamic
$sla['sla_max'], $sla['sla_max'],
// max_value -> dynamic
$inverse_interval, $inverse_interval,
// inverse_interval -> dynamic
[ [
'1' => $content['sunday'], '1' => $content['sunday'],
'2' => $content['monday'], '2' => $content['monday'],
@ -6507,24 +6712,31 @@ function reporting_availability_graph($report, $content, $pdf=false)
$slice $slice
); );
if ($metaconsole_on) { return $sla_array;
// Restore db connection
metaconsole_restore_db();
} }
$server_name = $sla['server_name'];
// Metaconsole connection
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
}
$planned_downtimes = reporting_get_planned_downtimes_intervals($sla['id_agent_module'], ($report['datetime'] - $content['period']), $report['datetime']); /**
* Return array planned downtimes.
*
* @param integer $id_agent_module Id module.
* @param integer $datetime Date utimestamp.
* @param integer $period Period utimestamp.
*
* @return array
*/
function reporting_get_planned_downtimes_sla($id_agent_module, $datetime, $period)
{
$planned_downtimes = reporting_get_planned_downtimes_intervals(
$id_agent_module,
($datetime - $period),
$datetime
);
if ((is_array($planned_downtimes)) && (count($planned_downtimes) > 0)) { if ((is_array($planned_downtimes))
// Sort retrieved planned downtimes && (count($planned_downtimes) > 0)
) {
// Sort retrieved planned downtimes.
usort( usort(
$planned_downtimes, $planned_downtimes,
function ($a, $b) { function ($a, $b) {
@ -6534,16 +6746,16 @@ function reporting_availability_graph($report, $content, $pdf=false)
return 0; return 0;
} }
return ($a < $b) ? -1 : 1; return ($a < $b) ? (-1) : 1;
} }
); );
// Compress (overlapped) planned downtimes // Compress (overlapped) planned downtimes.
$npd = count($planned_downtimes); $npd = count($planned_downtimes);
for ($i = 0; $i < $npd; $i++) { for ($i = 0; $i < $npd; $i++) {
if (isset($planned_downtimes[($i + 1)])) { if (isset($planned_downtimes[($i + 1)])) {
if ($planned_downtimes[$i]['date_to'] >= $planned_downtimes[($i + 1)]['date_from']) { if ($planned_downtimes[$i]['date_to'] >= $planned_downtimes[($i + 1)]['date_from']) {
// merge // Merge.
$planned_downtimes[$i]['date_to'] = $planned_downtimes[($i + 1)]['date_to']; $planned_downtimes[$i]['date_to'] = $planned_downtimes[($i + 1)]['date_to'];
array_splice($planned_downtimes, ($i + 1), 1); array_splice($planned_downtimes, ($i + 1), 1);
$npd--; $npd--;
@ -6551,17 +6763,48 @@ function reporting_availability_graph($report, $content, $pdf=false)
} }
} }
} else { } else {
$planned_downtimes = null; $planned_downtimes = [];
} }
return $planned_downtimes;
}
/**
* Prepare data for Paint in report.
*
* @param array $sla Data Module to sla.
* @param array $sla_array Data uncompressed.
* @param array $content Content report data.
* @param integer $datetime Date.
* @param array $return Array return.
* @param string $secondary Type secondaary primary, failover, Result.
*
* @return array Return modify.
*/
function prepare_data_for_paint(
$sla,
$sla_array,
$content,
$datetime,
$return,
$secondary=''
) {
$data = []; $data = [];
$data['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']); $alias_agent = modules_get_agentmodule_agent_alias(
$data['module'] = modules_get_agentmodule_name($sla['id_agent_module']); $sla['id_agent_module']
);
$name_module = modules_get_agentmodule_name(
$sla['id_agent_module']
);
$data['agent'] = $alias_agent;
$data['module'] = $name_module;
$data['max'] = $sla['sla_max']; $data['max'] = $sla['sla_max'];
$data['min'] = $sla['sla_min']; $data['min'] = $sla['sla_min'];
$data['sla_limit'] = $sla['sla_limit']; $data['sla_limit'] = $sla['sla_limit'];
$data['dinamic_text'] = $dinamic_text; $data['dinamic_text'] = $dinamic_text;
$data['secondary'] = $secondary;
if (isset($sla_array[0])) { if (isset($sla_array[0])) {
$data['time_total'] = 0; $data['time_total'] = 0;
$data['time_ok'] = 0; $data['time_ok'] = 0;
@ -6590,17 +6833,27 @@ function reporting_availability_graph($report, $content, $pdf=false)
$data['checks_unknown'] += $value_sla['checks_unknown']; $data['checks_unknown'] += $value_sla['checks_unknown'];
$data['checks_not_init'] += $value_sla['checks_not_init']; $data['checks_not_init'] += $value_sla['checks_not_init'];
// generate raw data for graph // Generate raw data for graph.
$period = reporting_sla_get_status_period($value_sla, $priority_mode); $period = reporting_sla_get_status_period(
$raw_graph[$i]['data'] = reporting_translate_sla_status_for_graph($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']); $raw_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']);
$i++; $i++;
} }
$data['sla_value'] = reporting_sla_get_compliance_from_array($data); $data['sla_value'] = reporting_sla_get_compliance_from_array(
$data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision']); $data
);
$data['sla_fixed'] = sla_truncate(
$data['sla_value'],
$config['graph_precision']
);
} else { } else {
// Show only table not divider in slice for defect slice=1 // Show only table not divider in slice for defect slice=1.
$data['time_total'] = $sla_array['time_total']; $data['time_total'] = $sla_array['time_total'];
$data['time_ok'] = $sla_array['time_ok']; $data['time_ok'] = $sla_array['time_ok'];
$data['time_error'] = $sla_array['time_error']; $data['time_error'] = $sla_array['time_error'];
@ -6615,7 +6868,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$data['sla_value'] = $sla_array['SLA']; $data['sla_value'] = $sla_array['SLA'];
} }
// checks whether or not it meets the SLA // Checks whether or not it meets the SLA.
if ($data['sla_value'] >= $sla['sla_limit']) { if ($data['sla_value'] >= $sla['sla_limit']) {
$data['sla_status'] = 1; $data['sla_status'] = 1;
$sla_failed = false; $sla_failed = false;
@ -6624,12 +6877,12 @@ function reporting_availability_graph($report, $content, $pdf=false)
$data['sla_status'] = 0; $data['sla_status'] = 0;
} }
// Do not show right modules if 'only_display_wrong' is active // Do not show right modules if 'only_display_wrong' is active.
if ($content['only_display_wrong'] && $sla_failed == false) { if ($content['only_display_wrong'] && $sla_failed == false) {
continue; return $return;
} }
// find order // Find order.
$data['order'] = $data['sla_value']; $data['order'] = $data['sla_value'];
$return['data'][] = $data; $return['data'][] = $data;
@ -6663,10 +6916,10 @@ function reporting_availability_graph($report, $content, $pdf=false)
$array_result[$i]['utimestamp'] = $acum; $array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum; $array_result[$i]['real_data'] = $sum;
// Slice graphs calculation // Slice graphs calculation.
$dataslice = []; $dataslice = [];
$dataslice['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']); $dataslice['agent'] = $alias_agent;
$dataslice['module'] = modules_get_agentmodule_name($sla['id_agent_module']); $dataslice['module'] = $name_module;
$dataslice['order'] = $data['sla_value']; $dataslice['order'] = $data['sla_value'];
$dataslice['checks_total'] = $data['checks_total']; $dataslice['checks_total'] = $data['checks_total'];
$dataslice['checks_ok'] = $data['checks_ok']; $dataslice['checks_ok'] = $data['checks_ok'];
@ -6675,17 +6928,22 @@ function reporting_availability_graph($report, $content, $pdf=false)
$dataslice['sla_status'] = $data['sla_status']; $dataslice['sla_status'] = $data['sla_status'];
$dataslice['sla_value'] = $data['sla_value']; $dataslice['sla_value'] = $data['sla_value'];
$height = 80;
if ($secondary !== '' && $secondary !== 'result') {
$height = 50;
}
$dataslice['chart'] = graph_sla_slicebar( $dataslice['chart'] = graph_sla_slicebar(
$sla['id_agent_module'], $sla['id_agent_module'],
$content['period'], $content['period'],
$sla['sla_min'], $sla['sla_min'],
$sla['sla_max'], $sla['sla_max'],
$report['datetime'], $datetime,
$content, $content,
$content['time_from'], $content['time_from'],
$content['time_to'], $content['time_to'],
100, 100,
70, $height,
$urlImage, $urlImage,
$ttl, $ttl,
$array_result, $array_result,
@ -6694,102 +6952,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$return['charts'][] = $dataslice; $return['charts'][] = $dataslice;
if ($metaconsole_on) { return $return;
// Restore db connection
metaconsole_restore_db();
}
}
// SLA items sorted descending ()
if ($content['top_n'] == 2) {
arsort($return['data']['']);
}
// SLA items sorted ascending
else if ($content['top_n'] == 1) {
asort($sla_showed_values);
}
// order data for ascending or descending
if ($content['top_n'] != 0) {
switch ($content['top_n']) {
case 1:
// order tables
$temp = [];
foreach ($return['data'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] < $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['data'] = $temp;
// order graphs
$temp = [];
foreach ($return['charts'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] < $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['charts'] = $temp;
break;
case 2:
// order tables
$temp = [];
foreach ($return['data'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] > $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['data'] = $temp;
// order graph
$temp = [];
foreach ($return['charts'] as $row) {
$i = 0;
foreach ($temp as $t_row) {
if ($row['sla_value'] > $t_row['order']) {
break;
}
$i++;
}
array_splice($temp, $i, 0, [$row]);
}
$return['charts'] = $temp;
break;
}
}
}
return reporting_check_structure_content($return);
} }

View File

@ -3252,15 +3252,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$tables_chart = ''; $tables_chart = '';
$table1 = new stdClass(); foreach ($item['charts'] as $k_chart => $chart) {
$table1->width = '99%';
$table1->data = [];
$table1->size = [];
$table1->size[0] = '10%';
$table1->size[1] = '80%';
$table1->size[2] = '5%';
$table1->size[3] = '5%';
foreach ($item['charts'] as $chart) {
$checks_resume = ''; $checks_resume = '';
$sla_value = ''; $sla_value = '';
if (reporting_sla_is_not_init_from_array($chart)) { if (reporting_sla_is_not_init_from_array($chart)) {
@ -3291,6 +3283,16 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')'; $checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')';
} }
// Check failover availability report.
if ($item['data'][$k_chart]['secondary'] === '') {
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = [];
$table1->size = [];
$table1->size[0] = '10%';
$table1->size[1] = '80%';
$table1->size[2] = '5%';
$table1->size[3] = '5%';
$table1->data[0][0] = $chart['agent'].'<br />'.$chart['module']; $table1->data[0][0] = $chart['agent'].'<br />'.$chart['module'];
$table1->data[0][1] = $chart['chart']; $table1->data[0][1] = $chart['chart'];
$table1->data[0][2] = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>'; $table1->data[0][2] = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>';
@ -3299,6 +3301,56 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$table1, $table1,
true true
); );
} else {
if ($item['data'][$k_chart]['secondary'] === 'primary') {
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = [];
$table1->size = [];
$table1->size[0] = '10%';
$table1->size[1] = '80%';
$table1->size[2] = '5%';
$table1->size[3] = '5%';
}
$title = '';
$checks_resume_text = $checks_resume;
$sla_value_text = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>';
switch ($item['data'][$k_chart]['secondary']) {
case 'primary':
$title = '<b>'.__('Primary').'</b>';
$title .= '<br />'.$chart['agent'];
$title .= '<br />'.$chart['module'];
break;
case 'failover':
$title = '<b>'.__('Failover').'</b>';
$title .= '<br />'.$chart['agent'];
$title .= '<br />'.$chart['module'];
break;
case 'result':
default:
$title = '<b>'.__('Result').'</b>';
$sla_value_text = "<span style = 'font: bold 3em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>';
$checks_resume_text = '<span style = "font-size: 12pt;">';
$checks_resume_text .= $checks_resume;
$checks_resume_text .= '</span>';
break;
}
$table1->data[$item['data'][$k_chart]['secondary']][0] = $title;
$table1->data[$item['data'][$k_chart]['secondary']][1] = $chart['chart'];
$table1->data[$item['data'][$k_chart]['secondary']][2] = $sla_value_text;
$table1->data[$item['data'][$k_chart]['secondary']][3] = $checks_resume_text;
if ($item['data'][$k_chart]['secondary'] === 'result') {
$tables_chart .= html_print_table(
$table1,
true
);
}
}
} }
if ($item['type'] == 'availability_graph') { if ($item['type'] == 'availability_graph') {

View File

@ -1464,6 +1464,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` (
`id` INTEGER UNSIGNED NOT NULL auto_increment, `id` INTEGER UNSIGNED NOT NULL auto_increment,
`id_report_content` INTEGER UNSIGNED NOT NULL, `id_report_content` INTEGER UNSIGNED NOT NULL,
`id_agent_module` int(10) unsigned NOT NULL, `id_agent_module` int(10) unsigned NOT NULL,
`id_agent_module_secondary` int(10) unsigned NOT NULL,
`sla_max` double(18,2) NOT NULL default 0, `sla_max` double(18,2) NOT NULL default 0,
`sla_min` double(18,2) NOT NULL default 0, `sla_min` double(18,2) NOT NULL default 0,
`sla_limit` double(18,2) NOT NULL default 0, `sla_limit` double(18,2) NOT NULL default 0,

View File

@ -114,10 +114,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''), ('custom_report_front_header', ''),
('custom_report_front_footer', ''), ('custom_report_front_footer', ''),
('MR', 29), ('MR', 30),
('identification_reminder', 1), ('identification_reminder', 1),
('identification_reminder_timestamp', 0), ('identification_reminder_timestamp', 0),
('current_package_enterprise', '736'), ('current_package_enterprise', '737'),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'), ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'), ('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'), ('custom_support_logo', 'default_support.png'),