ADD failover option availability_graph

This commit is contained in:
Daniel Barbero 2019-07-02 11:50:58 +02:00
parent 0064bc0cba
commit 209681e4c2
9 changed files with 230 additions and 89 deletions

View File

@ -0,0 +1,12 @@
START TRANSACTION;
ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL;
ALTER TABLE `treport_content_sla_combined` ADD `id_server_failover` int(10) unsigned NOT NULL;
ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0';
ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0';
ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1';
COMMIT;

View File

@ -796,6 +796,8 @@ ALTER TABLE `treport_content_template` ADD COLUMN `unknown_checks` TINYINT(1) DE
ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1';
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template)
@ -1442,6 +1444,8 @@ ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'
ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0';
ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tmodule_relationship` -- Table `tmodule_relationship`
@ -2213,4 +2217,5 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` (
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `treport_content_sla_combined` -- Table `treport_content_sla_combined`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_secondary` int(10) unsigned NOT NULL; ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL;
ALTER TABLE `treport_content_sla_combined` ADD `id_server_failover` int(10) unsigned NOT NULL;

View File

@ -165,6 +165,8 @@ switch ($action) {
$show_in_landscape = 0; $show_in_landscape = 0;
$hide_notinit_agents = 0; $hide_notinit_agents = 0;
$priority_mode = REPORT_PRIORITY_MODE_OK; $priority_mode = REPORT_PRIORITY_MODE_OK;
$failover_mode = 0;
$failover_type = REPORT_FAILOVER_TYPE_NORMAL;
$server_name = ''; $server_name = '';
$server_id = 0; $server_id = 0;
$dyn_height = 230; $dyn_height = 230;
@ -314,6 +316,8 @@ switch ($action) {
$sla_sorted_by = $item['top_n']; $sla_sorted_by = $item['top_n'];
$period = $item['period']; $period = $item['period'];
$current_month = $item['current_month']; $current_month = $item['current_month'];
$failover_mode = $item['failover_mode'];
$failover_type = $item['failover_type'];
break; break;
case 'module_histogram_graph': case 'module_histogram_graph':
@ -2237,6 +2241,7 @@ $class = 'databox filters';
?> ?>
</td> </td>
</tr> </tr>
<tr id="row_select_fields2" style="" class="datos"> <tr id="row_select_fields2" style="" class="datos">
<td style="font-weight:bold;margin-right:150px;"> <td style="font-weight:bold;margin-right:150px;">
<?php <?php
@ -2608,6 +2613,59 @@ $class = 'databox filters';
</td> </td>
</tr> </tr>
<tr id="row_failover_mode" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Failover mode').ui_print_help_tip(
__('XXX.'),
true
);
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'failover_mode',
1,
$failover_mode
);
?>
</td>
</tr>
<tr id="row_failover_type" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Failover type');
?>
</td>
<td>
<?php
echo __('Failover normal');
echo '<span style="margin-left:5px;"></span>';
html_print_radio_button(
'failover_type',
REPORT_FAILOVER_TYPE_NORMAL,
'',
$failover_type == REPORT_FAILOVER_TYPE_NORMAL,
''
);
echo '<span style="margin:30px;"></span>';
echo __('Failover simple');
echo '<span style="margin-left:5px;"></span>';
html_print_radio_button(
'failover_type',
REPORT_FAILOVER_TYPE_SIMPLE,
'',
$failover_type == REPORT_FAILOVER_TYPE_SIMPLE,
''
);
?>
</td>
</tr>
<tr id="row_filter_search" style="" class="datos"> <tr id="row_filter_search" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Free search'); ?></td> <td style="font-weight:bold;"><?php echo __('Free search'); ?></td>
<td> <td>
@ -2771,6 +2829,13 @@ function print_SLA_list($width, $action, $idItem=null)
'id_rc', 'id_rc',
$idItem $idItem
); );
$failover_mode = db_get_value(
'failover_mode',
'treport_content',
'id_rc',
$idItem
);
?> ?>
<table class="databox data" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="100%"> <table class="databox data" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="100%">
<thead> <thead>
@ -2783,16 +2848,18 @@ 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') { if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
?> ?>
<th class="header sla_list_agent_secondary" scope="col"> <th class="header sla_list_agent_failover" scope="col">
<?php <?php
echo __('Agent Secondary'); echo __('Agent Failover');
?> ?>
</th> </th>
<th class="header sla_list_module_secondary" scope="col"> <th class="header sla_list_module_failover" scope="col">
<?php <?php
echo __('Module Secondary'); echo __('Module Failover');
?> ?>
</th> </th>
<?php <?php
@ -2878,22 +2945,22 @@ 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 if (isset($item['id_agent_module_failover']) === true
&& $item['id_agent_module_secondary'] !== 0 && $item['id_agent_module_failover'] !== 0
) { ) {
$idAgentSecondary = db_get_value_filter( $idAgentFailover = db_get_value_filter(
'id_agente', 'id_agente',
'tagente_modulo', 'tagente_modulo',
['id_agente_modulo' => $item['id_agent_module_secondary']] ['id_agente_modulo' => $item['id_agent_module_failover']]
); );
$nameAgentSecondary = agents_get_alias( $nameAgentFailover = agents_get_alias(
$idAgentSecondary $idAgentFailover
); );
$nameModuleSecondary = db_get_value_filter( $nameModuleFailover = db_get_value_filter(
'nombre', 'nombre',
'tagente_modulo', 'tagente_modulo',
['id_agente_modulo' => $item['id_agent_module_secondary']] ['id_agente_modulo' => $item['id_agent_module_failover']]
); );
} }
@ -2910,12 +2977,14 @@ function print_SLA_list($width, $action, $idItem=null)
echo printSmallFont($nameModule); echo printSmallFont($nameModule);
echo '</td>'; echo '</td>';
if ($report_item_type == 'availability_graph') { if ($report_item_type == 'availability_graph'
echo '<td class="sla_list_agent_secondary">'; && $failover_mode
echo printSmallFont($nameAgentSecondary).$server_name_element; ) {
echo '<td class="sla_list_agent_failover">';
echo printSmallFont($nameAgentFailover).$server_name_element;
echo '</td>'; echo '</td>';
echo '<td class="sla_list_module_secondary">'; echo '<td class="sla_list_module_failover">';
echo printSmallFont($nameModuleSecondary); echo printSmallFont($nameModuleFailover);
echo '</td>'; echo '</td>';
} }
@ -2967,10 +3036,12 @@ 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') { if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
?> ?>
<td class="sla_list_agent_secondary agent_name_secondary"></td> <td class="sla_list_agent_failover agent_name_failover"></td>
<td class="sla_list_module_secondary module_name_secondary"></td> <td class="sla_list_module_failover module_name_failover"></td>
<?php <?php
} }
@ -3030,20 +3101,22 @@ function print_SLA_list($width, $action, $idItem=null)
</select> </select>
</td> </td>
<?php <?php
if ($report_item_type == 'availability_graph') { if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
?> ?>
<td class="sla_list_agent_secondary_col"> <td class="sla_list_agent_failover_col">
<input id="hidden-id_agent_secondary" name="id_agent_secondary" value="" type="hidden"> <input id="hidden-id_agent_failover" name="id_agent_failover" value="" type="hidden">
<input id="hidden-server_name_secondary" name="server_name_secondary" value="" type="hidden"> <input id="hidden-server_name_failover" name="server_name_failover" value="" type="hidden">
<?php <?php
$params = []; $params = [];
$params['show_helptip'] = true; $params['show_helptip'] = true;
$params['input_name'] = 'agent_secondary'; $params['input_name'] = 'agent_failover';
$params['value'] = ''; $params['value'] = '';
$params['use_hidden_input_idagent'] = true; $params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agent_secondary'; $params['hidden_input_idagent_id'] = 'hidden-id_agent_failover';
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_secondary'; $params['selectbox_id'] = 'id_agent_module_failover';
$params['add_none_module'] = false; $params['add_none_module'] = false;
if ($meta) { if ($meta) {
$params['use_input_id_server'] = true; $params['use_input_id_server'] = true;
@ -3054,8 +3127,8 @@ function print_SLA_list($width, $action, $idItem=null)
ui_print_agent_autocomplete_input($params); ui_print_agent_autocomplete_input($params);
?> ?>
</td> </td>
<td class="sla_list_module_secondary_col"> <td class="sla_list_module_failover_col">
<select id="id_agent_module_secondary" name="id_agent_module_secondary" disabled="disabled" style="max-width: 180px"> <select id="id_agent_module_failover" name="id_agent_module_failover" disabled="disabled" style="max-width: 180px">
<option value="0"> <option value="0">
<?php <?php
echo __('Select an Agent first'); echo __('Select an Agent first');
@ -3701,11 +3774,18 @@ $(document).ready (function () {
$("#checkbox-checkbox_show_resume").change(function(){ $("#checkbox-checkbox_show_resume").change(function(){
if($(this).is(":checked")){ if($(this).is(":checked")){
$("#row_select_fields2").show(); $("#row_select_fields2").show();
$("#row_select_fields3").show();
} }
else{ else{
$("#row_select_fields2").hide(); $("#row_select_fields2").hide();
$("#row_select_fields3").hide(); }
});
$("#checkbox-failover_mode").change(function(){
if($(this).is(":checked")){
$("#row_failover_type").show();
}
else{
$("#row_failover_type").hide();
} }
}); });
}); });
@ -3999,13 +4079,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 nameAgentFailover = $("input[name=agent_failover]").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 idModuleFailover = $("#id_agent_module_failover").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 nameModuleFailover = $("#id_agent_module_failover :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();
@ -4066,11 +4146,11 @@ function addSLARow() {
}); });
} }
if (nameAgentSecondary != '') { if (nameAgentFailover != '') {
//Truncate nameAgentSecondary //Truncate nameAgentFailover
var params = []; var params = [];
params.push("truncate_text=1"); params.push("truncate_text=1");
params.push("text=" + nameAgentSecondary); params.push("text=" + nameAgentFailover);
params.push("page=include/ajax/reporting.ajax"); params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({ jQuery.ajax ({
data: params.join ("&"), data: params.join ("&"),
@ -4088,14 +4168,14 @@ function addSLARow() {
async: false, async: false,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
nameAgentSecondary = data; nameAgentFailover = data;
} }
}); });
//Truncate nameModuleSecondary //Truncate nameModuleFailover
var params = []; var params = [];
params.push("truncate_text=1"); params.push("truncate_text=1");
params.push("text=" + nameModuleSecondary); params.push("text=" + nameModuleFailover);
params.push("page=include/ajax/reporting.ajax"); params.push("page=include/ajax/reporting.ajax");
jQuery.ajax ({ jQuery.ajax ({
data: params.join ("&"), data: params.join ("&"),
@ -4113,7 +4193,7 @@ function addSLARow() {
async: false, async: false,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
nameModuleSecondary = data; nameModuleFailover = data;
} }
}); });
} }
@ -4122,7 +4202,7 @@ function addSLARow() {
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("id_module_failover=" + idModuleFailover);
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);
@ -4155,8 +4235,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); $(".agent_name_failover", row).html(nameAgentFailover);
$(".module_name_secondary", row).html(nameModuleSecondary); $(".module_name_failover", row).html(nameModuleFailover);
$(".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);
@ -4167,19 +4247,19 @@ 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_agent_failover]").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(''); $("input[name=agent_failover]").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_failover").empty();
$("#id_agent_module_secondary").attr('disabled', 'true'); $("#id_agent_module_failover").attr('disabled', 'true');
$("#id_agent_module_secondary").append( $("#id_agent_module_failover").append(
$("<option></option>") $("<option></option>")
.attr ("value", 0) .attr ("value", 0)
.html ($("#module_sla_text").html())); .html ($("#module_sla_text").html()));
@ -4360,6 +4440,8 @@ function chooseType() {
$("#row_custom_example").hide(); $("#row_custom_example").hide();
$("#row_group").hide(); $("#row_group").hide();
$("#row_current_month").hide(); $("#row_current_month").hide();
$("#row_failover_mode").hide();
$("#row_failover_type").hide();
$("#row_working_time").hide(); $("#row_working_time").hide();
$("#row_only_display_wrong").hide(); $("#row_only_display_wrong").hide();
$("#row_combo_module").hide(); $("#row_combo_module").hide();
@ -4533,6 +4615,11 @@ function chooseType() {
$("#row_working_time").show(); $("#row_working_time").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
$("#row_priority_mode").show(); $("#row_priority_mode").show();
$("#row_failover_mode").show();
var failover_checked = $("input[name='failover_mode']").prop("checked");
if(failover_checked){
$("#row_failover_type").show();
}
break; break;
case 'module_histogram_graph': case 'module_histogram_graph':

View File

@ -1441,6 +1441,14 @@ switch ($action) {
$values['show_graph'] = get_parameter( $values['show_graph'] = get_parameter(
'combo_graph_options' 'combo_graph_options'
); );
$values['failover_mode'] = get_parameter(
'failover_mode',
0
);
$values['failover_type'] = get_parameter(
'failover_type',
REPORT_FAILOVER_TYPE_NORMAL
);
$good_format = true; $good_format = true;
break; break;
@ -2398,6 +2406,16 @@ switch ($action) {
$values['current_month'] = get_parameter('current_month'); $values['current_month'] = get_parameter('current_month');
$values['failover_mode'] = get_parameter(
'failover_mode',
0
);
$values['failover_type'] = get_parameter(
'failover_type',
REPORT_FAILOVER_TYPE_NORMAL
);
$style = []; $style = [];
$style['show_in_same_row'] = get_parameter( $style['show_in_same_row'] = get_parameter(
'show_in_same_row', 'show_in_same_row',

View File

@ -65,7 +65,8 @@ 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_module_failover = (int) get_parameter('id_module_failover', 0);
$id_server_failover = (int) get_parameter('id_server_failover', 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)) {
@ -86,13 +87,14 @@ if ($add_sla) {
$result = db_process_sql_insert( $result = db_process_sql_insert(
'treport_content_sla_combined', 'treport_content_sla_combined',
[ [
'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, 'id_agent_module_failover' => $id_module_failover,
'sla_max' => $sla_max, 'sla_max' => $sla_max,
'sla_min' => $sla_min, 'sla_min' => $sla_min,
'sla_limit' => $sla_limit, 'sla_limit' => $sla_limit,
'server_name' => $connection['server_name'], 'server_name' => $connection['server_name'],
'id_server_failover' => $id_server_failover,
] ]
); );

View File

@ -134,7 +134,6 @@ 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);

View File

@ -53,6 +53,10 @@ require_once $config['homedir'].'/include/functions_network.php';
define('REPORT_PRIORITY_MODE_OK', 1); define('REPORT_PRIORITY_MODE_OK', 1);
define('REPORT_PRIORITY_MODE_UNKNOWN', 2); define('REPORT_PRIORITY_MODE_UNKNOWN', 2);
// Failover type.
define('REPORT_FAILOVER_TYPE_NORMAL', 1);
define('REPORT_FAILOVER_TYPE_SIMPLE', 2);
// Status. // Status.
define('REPORT_STATUS_ERR', 0); define('REPORT_STATUS_ERR', 0);
define('REPORT_STATUS_OK', 1); define('REPORT_STATUS_OK', 1);
@ -6403,6 +6407,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$return['title'] = $content['name']; $return['title'] = $content['name'];
$return['description'] = $content['description']; $return['description'] = $content['description'];
$return['failover_type'] = $content['failover_type'];
$return['date'] = reporting_get_date_text($report, $content); $return['date'] = reporting_get_date_text($report, $content);
// Get chart. // Get chart.
@ -6458,18 +6463,20 @@ function reporting_availability_graph($report, $content, $pdf=false)
} }
} }
if (isset($sla['id_agent_module_secondary']) === true if (isset($sla['id_agent_module_failover']) === true
&& $sla['id_agent_module_secondary'] != 0 && $sla['id_agent_module_failover'] != 0
) { ) {
$sla_secondary['primary'] = $sla; $sla_failover = [];
$sla_secondary['failover'] = $sla; $sla_failover['primary'] = $sla;
$sla_secondary['failover']['id_agent_module'] = $sla['id_agent_module_secondary']; $sla_failover['failover'] = $sla;
$sla_failover['failover']['id_agent_module'] = $sla['id_agent_module_failover'];
// For graph slice for module-interval, if not 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);
$data_combined = [];
foreach ($sla_secondary as $k_sla => $v_sla) { foreach ($sla_failover as $k_sla => $v_sla) {
$sla_array = data_db_uncompress_module( $sla_array = data_db_uncompress_module(
$v_sla, $v_sla,
$content, $content,
@ -6477,14 +6484,16 @@ function reporting_availability_graph($report, $content, $pdf=false)
$slice $slice
); );
$return = prepare_data_for_paint( if ($content['failover_type'] == REPORT_FAILOVER_TYPE_NORMAL) {
$v_sla, $return = prepare_data_for_paint(
$sla_array, $v_sla,
$content, $sla_array,
$report['datetime'], $content,
$return, $report['datetime'],
$k_sla $return,
); $k_sla
);
}
$data_combined[] = $sla_array; $data_combined[] = $sla_array;
} }
@ -6493,8 +6502,10 @@ function reporting_availability_graph($report, $content, $pdf=false)
&& is_array($data_combined) === true && is_array($data_combined) === true
&& count($data_combined) > 0 && count($data_combined) > 0
) { ) {
$data_a = [];
$data_a = array_map( $data_a = array_map(
function ($primary, $failover) { function ($primary, $failover) {
$return_map = [];
if ($primary['date_from'] === $failover['date_from'] if ($primary['date_from'] === $failover['date_from']
&& $primary['date_to'] === $failover['date_to'] && $primary['date_to'] === $failover['date_to']
) { ) {
@ -6517,10 +6528,10 @@ function reporting_availability_graph($report, $content, $pdf=false)
$primary['sla_fixed'] = $failover['sla_fixed']; $primary['sla_fixed'] = $failover['sla_fixed'];
} }
$return = $primary; $return_map = $primary;
} }
return $return; return $return_map;
}, },
$data_combined[0], $data_combined[0],
$data_combined[1] $data_combined[1]
@ -6778,7 +6789,7 @@ function reporting_get_planned_downtimes_sla($id_agent_module, $datetime, $perio
* @param array $content Content report data. * @param array $content Content report data.
* @param integer $datetime Date. * @param integer $datetime Date.
* @param array $return Array return. * @param array $return Array return.
* @param string $secondary Type secondaary primary, failover, Result. * @param string $failover Type primary, failover, Result.
* *
* @return array Return modify. * @return array Return modify.
*/ */
@ -6788,7 +6799,7 @@ function prepare_data_for_paint(
$content, $content,
$datetime, $datetime,
$return, $return,
$secondary='' $failover=''
) { ) {
$data = []; $data = [];
$alias_agent = modules_get_agentmodule_agent_alias( $alias_agent = modules_get_agentmodule_agent_alias(
@ -6804,7 +6815,7 @@ function prepare_data_for_paint(
$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; $data['failover'] = $failover;
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;
@ -6929,7 +6940,7 @@ function prepare_data_for_paint(
$dataslice['sla_value'] = $data['sla_value']; $dataslice['sla_value'] = $data['sla_value'];
$height = 80; $height = 80;
if ($secondary !== '' && $secondary !== 'result') { if ($failover !== '' && $failover !== 'result') {
$height = 50; $height = 50;
} }

View File

@ -3284,7 +3284,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
} }
// Check failover availability report. // Check failover availability report.
if ($item['data'][$k_chart]['secondary'] === '') { if ($item['data'][$k_chart]['failover'] === '') {
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
$table1->data = []; $table1->data = [];
@ -3302,7 +3302,9 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
true true
); );
} else { } else {
if ($item['data'][$k_chart]['secondary'] === 'primary') { if ($item['data'][$k_chart]['failover'] === 'primary'
|| $item['failover_type'] == REPORT_FAILOVER_TYPE_SIMPLE
) {
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
$table1->data = []; $table1->data = [];
@ -3316,7 +3318,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$title = ''; $title = '';
$checks_resume_text = $checks_resume; $checks_resume_text = $checks_resume;
$sla_value_text = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>'; $sla_value_text = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>';
switch ($item['data'][$k_chart]['secondary']) { switch ($item['data'][$k_chart]['failover']) {
case 'primary': case 'primary':
$title = '<b>'.__('Primary').'</b>'; $title = '<b>'.__('Primary').'</b>';
$title .= '<br />'.$chart['agent']; $title .= '<br />'.$chart['agent'];
@ -3339,12 +3341,12 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
break; break;
} }
$table1->data[$item['data'][$k_chart]['secondary']][0] = $title; $table1->data[$item['data'][$k_chart]['failover']][0] = $title;
$table1->data[$item['data'][$k_chart]['secondary']][1] = $chart['chart']; $table1->data[$item['data'][$k_chart]['failover']][1] = $chart['chart'];
$table1->data[$item['data'][$k_chart]['secondary']][2] = $sla_value_text; $table1->data[$item['data'][$k_chart]['failover']][2] = $sla_value_text;
$table1->data[$item['data'][$k_chart]['secondary']][3] = $checks_resume_text; $table1->data[$item['data'][$k_chart]['failover']][3] = $checks_resume_text;
if ($item['data'][$k_chart]['secondary'] === 'result') { if ($item['data'][$k_chart]['failover'] === 'result') {
$tables_chart .= html_print_table( $tables_chart .= html_print_table(
$table1, $table1,
true true

View File

@ -1452,6 +1452,8 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`agent_max_value` TINYINT(1) DEFAULT '1', `agent_max_value` TINYINT(1) DEFAULT '1',
`agent_min_value` TINYINT(1) DEFAULT '1', `agent_min_value` TINYINT(1) DEFAULT '1',
`current_month` TINYINT(1) DEFAULT '1', `current_month` TINYINT(1) DEFAULT '1',
`failover_mode` tinyint(1) DEFAULT '1',
`failover_type` tinyint(1) DEFAULT '1',
PRIMARY KEY(`id_rc`), PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
@ -1464,7 +1466,8 @@ 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, `id_agent_module_failover` int(10) unsigned NOT NULL,
`id_server_failover` int(10) unsigned NOT NULL default 0,
`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,
@ -2993,6 +2996,8 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`agent_max_value` TINYINT(1) DEFAULT '1', `agent_max_value` TINYINT(1) DEFAULT '1',
`agent_min_value` TINYINT(1) DEFAULT '1', `agent_min_value` TINYINT(1) DEFAULT '1',
`current_month` TINYINT(1) DEFAULT '1', `current_month` TINYINT(1) DEFAULT '1',
`failover_mode` tinyint(1) DEFAULT '1',
`failover_type` tinyint(1) DEFAULT '1',
PRIMARY KEY(`id_rc`) PRIMARY KEY(`id_rc`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;