Merge branch 'ent-4252-Ampliacion_del_informe_de_disponibilidad_para_fuentes_secundarias' into 'develop'

Ent 4252 ampliacion del informe de disponibilidad para fuentes secundarias

See merge request artica/pandorafms!2577
This commit is contained in:
Daniel Rodriguez 2019-07-10 09:33:41 +02:00
commit f864573486
16 changed files with 1024 additions and 417 deletions

View File

@ -0,0 +1,13 @@
START TRANSACTION;
ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_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';
ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct';
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_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 `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)
@ -1239,13 +1241,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 ('small_operation_step_datos_purge', '1000');
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_support_logo', 'default_support.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';
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');
-- ---------------------------------------------------------------------
@ -1442,11 +1444,14 @@ 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_min_value` 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`
-- ---------------------------------------------------------------------
ALTER TABLE tmodule_relationship ADD COLUMN `id_server` varchar(100) NOT NULL DEFAULT '';
ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct';
-- ---------------------------------------------------------------------
-- Table `tpolicy_module`
@ -2209,3 +2214,8 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` (
`extra_2` text,
PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
-- Table `treport_content_sla_combined`
-- ---------------------------------------------------------------------
ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL;

View File

@ -1101,9 +1101,8 @@ $macro_count++;
html_print_input_hidden('module_macro_count', $macro_count);
/*
Advanced form part */
// Add relationships
// Advanced form part.
// Add relationships.
$table_new_relations = new stdClass();
$table_new_relations->id = 'module_new_relations';
$table_new_relations->width = '100%';
@ -1114,7 +1113,8 @@ $table_new_relations->style[0] = 'width: 10%; font-weight: bold;';
$table_new_relations->style[1] = 'width: 25%; text-align: center;';
$table_new_relations->style[2] = 'width: 10%; font-weight: bold;';
$table_new_relations->style[3] = 'width: 25%; text-align: center;';
$table_new_relations->style[4] = 'width: 30%; text-align: center;';
$table_new_relations->style[4] = 'width: 10%; font-weight: bold;';
$table_new_relations->style[5] = 'width: 25%; text-align: center;';
$table_new_relations->data[0][0] = __('Agent');
$params = [];
@ -1128,10 +1128,35 @@ $params['javascript_function_action_after_select_js_call'] = 'change_modules_aut
$table_new_relations->data[0][1] = ui_print_agent_autocomplete_input($params);
$table_new_relations->data[0][2] = __('Module');
$table_new_relations->data[0][3] = "<div id='module_autocomplete'></div>";
$table_new_relations->data[0][4] = html_print_button(__('Add relationship'), 'add_relation', false, 'javascript: add_new_relation();', 'class="sub add"', true);
$table_new_relations->data[0][4] .= "&nbsp;&nbsp;<div id='add_relation_status' style='display: inline;'></div>";
// Relationship list
$array_rel_type = [];
$array_rel_type['direct'] = __('Direct');
$array_rel_type['failover'] = __('Failover');
$table_new_relations->data[0][4] = __('Rel. type');
$table_new_relations->data[0][5] = html_print_select(
$array_rel_type,
'relation_type',
'',
'',
'',
0,
true,
false,
true,
''
);
$table_new_relations->data[0][6] = html_print_button(
__('Add relationship'),
'add_relation',
false,
'javascript: add_new_relation();',
'class="sub add"',
true
);
$table_new_relations->data[0][6] .= "&nbsp;&nbsp;<div id='add_relation_status' style='display: inline;'></div>";
// Relationship list.
$table_relations = new stdClass();
$table_relations->id = 'module_relations';
$table_relations->width = '100%';
@ -1141,19 +1166,26 @@ $table_relations->data = [];
$table_relations->rowstyle = [];
$table_relations->rowstyle[-1] = 'display: none;';
$table_relations->style = [];
$table_relations->style[2] = 'width: 10%; text-align: center;';
$table_relations->style[3] = 'width: 10%; text-align: center;';
$table_relations->style[4] = 'width: 10%; text-align: center;';
$table_relations->head[0] = __('Agent');
$table_relations->head[1] = __('Module');
$table_relations->head[2] = __('Changes').ui_print_help_tip(__('Activate this to prevent the relation from being updated or deleted'), true);
$table_relations->head[3] = __('Delete');
$table_relations->head[2] = __('Type');
$table_relations->head[3] = __('Changes').ui_print_help_tip(
__('Activate this to prevent the relation from being updated or deleted'),
true
);
$table_relations->head[4] = __('Delete');
// Create an invisible row to use their html to add new rows
// Create an invisible row to use their html to add new rows.
$table_relations->data[-1][0] = '';
$table_relations->data[-1][1] = '';
$table_relations->data[-1][2] = '<a id="disable_updates_button" class="alpha50" href="">'.html_print_image('images/lock.png', true).'</a>';
$table_relations->data[-1][3] = '<a id="delete_relation_button" href="">'.html_print_image('images/cross.png', true).'</a>';
$table_relations->data[-1][2] = '';
$table_relations->data[-1][3] = '<a id="disable_updates_button" class="alpha50" href="">';
$table_relations->data[-1][3] .= html_print_image('images/lock.png', true).'</a>';
$table_relations->data[-1][4] = '<a id="delete_relation_button" href="">';
$table_relations->data[-1][4] .= html_print_image('images/cross.png', true).'</a>';
$module_relations = modules_get_relations(['id_module' => $id_agent_module]);
if (!$module_relations) {
@ -1164,10 +1196,14 @@ $relations_count = 0;
foreach ($module_relations as $key => $module_relation) {
if ($module_relation['module_a'] == $id_agent_module) {
$module_id = $module_relation['module_b'];
$agent_id = modules_give_agent_id_from_module_id($module_relation['module_b']);
$agent_id = modules_give_agent_id_from_module_id(
$module_relation['module_b']
);
} else {
$module_id = $module_relation['module_a'];
$agent_id = modules_give_agent_id_from_module_id($module_relation['module_a']);
$agent_id = modules_give_agent_id_from_module_id(
$module_relation['module_a']
);
}
$agent_name = ui_print_agent_name($agent_id, true);
@ -1183,14 +1219,16 @@ foreach ($module_relations as $key => $module_relation) {
$disabled_update_class = 'alpha50';
}
// Agent name
// Agent name.
$table_relations->data[$relations_count][0] = $agent_name;
// Module name
// Module name.
$table_relations->data[$relations_count][1] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$agent_id.'&tab=module&edit_module=1&id_agent_module='.$module_id."'>".ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[&hellip;]').'</a>';
// Lock relationship updates
$table_relations->data[$relations_count][2] = '<a id="disable_updates_button" class="'.$disabled_update_class.'"href="javascript: change_lock_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/lock.png', true).'</a>';
// Delete relationship
$table_relations->data[$relations_count][3] = '<a id="delete_relation_button" href="javascript: delete_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/cross.png', true).'</a>';
// Type.
$table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover');
// Lock relationship updates.
$table_relations->data[$relations_count][3] = '<a id="disable_updates_button" class="'.$disabled_update_class.'"href="javascript: change_lock_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/lock.png', true).'</a>';
// Delete relationship.
$table_relations->data[$relations_count][4] = '<a id="delete_relation_button" href="javascript: delete_relation('.$relations_count.', '.$module_relation['id'].');">'.html_print_image('images/cross.png', true).'</a>';
$relations_count++;
}
@ -1198,7 +1236,6 @@ html_print_input_hidden('module_relations_count', $relations_count);
ui_require_jquery_file('json');
?>
<script type="text/javascript">
@ -1343,8 +1380,6 @@ $(document).ready (function () {
'width=800,height=600'
);
}
}
if(type_name_selected == 'web_data' ||
type_name_selected == 'web_proc' ||
@ -1365,8 +1400,6 @@ $(document).ready (function () {
'width=800,height=600'
);
}
}
}
@ -1386,7 +1419,7 @@ $(document).ready (function () {
$('#minmax_warning').hide();
$('#svg_dinamic').hide();
}
if (type_name_selected.match(/async/) == null) {
$('#ff_timeout').hide();
$('#ff_timeout_disable').show();
@ -1396,16 +1429,16 @@ $(document).ready (function () {
$('#ff_timeout_disable').hide();
}
});
$("#id_module_type").trigger('change');
// Prevent the form submission when the user hits the enter button from the relationship autocomplete inputs
$("#text-autocomplete_agent_name").keydown(function(event) {
if(event.keyCode == 13) { // key code 13 is the enter button
event.preventDefault();
}
});
//validate post_process. Change ',' by '.'
$("#submit-updbutton").click (function () {
validate_post_process();
@ -1512,7 +1545,6 @@ function advanced_option_dynamic() {
} else {
$('.hide_dinamic').show();
}
}
@ -1524,11 +1556,9 @@ function change_modules_autocomplete_input () {
var module_autocomplete = $("#module_autocomplete");
var load_icon = '<?php html_print_image('images/spinner.gif', false); ?>';
var error_icon = '<?php html_print_image('images/error_red.png', false); ?>';
if (!module_autocomplete.hasClass('working')) {
module_autocomplete.addClass('working');
module_autocomplete.html(load_icon);
$.ajax({
type: "POST",
url: "ajax.php",
@ -1563,22 +1593,26 @@ function change_modules_autocomplete_input () {
// Add a new relation
function add_new_relation () {
var module_a_id = parseInt($("#hidden-id_agent_module").val());
var module_b_id = parseInt($("#hidden-autocomplete_module_name_hidden").val());
var module_a_id = parseInt(
$("#hidden-id_agent_module").val()
);
var module_b_id = parseInt(
$("#hidden-autocomplete_module_name_hidden").val()
);
var module_b_name = $("#text-autocomplete_module_name").val();
var agent_b_name = $("#text-autocomplete_agent_name").val();
var relation_type = $("#relation_type").val();
var hiddenRow = $("#module_relations--1");
var button = $("#button-add_relation");
var iconPlaceholder = $("#add_relation_status");
var load_icon = '<?php html_print_image('images/spinner.gif', false, ['style' => 'vertical-align:middle;']); ?>';
var suc_icon = '<?php html_print_image('images/ok.png', false, ['style' => 'vertical-align:middle;']); ?>';
var error_icon = '<?php html_print_image('images/error_red.png', false, ['style' => 'vertical-align:middle;']); ?>';
if (!button.hasClass('working')) {
button.addClass('working');
iconPlaceholder.html(load_icon);
$.ajax({
type: "POST",
url: "ajax.php",
@ -1588,7 +1622,8 @@ function add_new_relation () {
add_module_relation: true,
id_module_a: module_a_id,
id_module_b: module_b_id,
name_module_b: module_b_name
name_module_b: module_b_name,
relation_type: relation_type
},
success: function (data) {
button.removeClass('working');
@ -1599,29 +1634,30 @@ function add_new_relation () {
else {
iconPlaceholder.html(suc_icon);
setTimeout( function() { iconPlaceholder.html(''); }, 2000);
// Add the new row
var relationsCount = parseInt($("#hidden-module_relations_count").val());
var rowClass = "datos";
if (relationsCount % 2 != 0) {
rowClass = "datos2";
}
var rowHTML = '<tr id="module_relations-' + relationsCount + '" class="' + rowClass + '">' +
'<td id="module_relations-' + relationsCount + '-0"><b>' + agent_b_name + '</b></td>' +
'<td id="module_relations-' + relationsCount + '-1">' + module_b_name + '</td>' +
'<td id="module_relations-' + relationsCount + '-2" style="width: 10%; text-align: center;">' +
'<a id="disable_updates_button" class="alpha50" href="javascript: change_lock_relation(' + relationsCount + ', ' + data + ');">' +
'<?php echo html_print_image('images/lock.png', true); ?>' +
'</a>' +
'</td>' +
'<td id="module_relations-' + relationsCount + '-3" style="width: 10%; text-align: center;">' +
'<a id="delete_relation_button" href="javascript: delete_relation(' + relationsCount + ', ' + data + ');">' +
'<?php echo html_print_image('images/cross.png', true); ?>' +
'</a>' +
'</td>' +
'</tr>';
'<td id="module_relations-' + relationsCount + '-0"><b>' + agent_b_name + '</b></td>' +
'<td id="module_relations-' + relationsCount + '-1">' + module_b_name + '</td>' +
'<td id="module_relations-' + relationsCount + '-2">' + relation_type + '</td>' +
'<td id="module_relations-' + relationsCount + '-3" style="width: 10%; text-align: center;">' +
'<a id="disable_updates_button" class="alpha50" href="javascript: change_lock_relation(' + relationsCount + ', ' + data + ');">' +
'<?php echo html_print_image('images/lock.png', true); ?>' +
'</a>' +
'</td>' +
'<td id="module_relations-' + relationsCount + '-4" style="width: 10%; text-align: center;">' +
'<a id="delete_relation_button" href="javascript: delete_relation(' + relationsCount + ', ' + data + ');">' +
'<?php echo html_print_image('images/cross.png', true); ?>' +
'</a>' +
'</td>' +
'</tr>';
$("#module_relations").find("tbody").append(rowHTML);
$("#hidden-module_relations_count").val(relationsCount + 1);

View File

@ -165,6 +165,8 @@ switch ($action) {
$show_in_landscape = 0;
$hide_notinit_agents = 0;
$priority_mode = REPORT_PRIORITY_MODE_OK;
$failover_mode = 0;
$failover_type = REPORT_FAILOVER_TYPE_NORMAL;
$server_name = '';
$server_id = 0;
$dyn_height = 230;
@ -314,6 +316,8 @@ switch ($action) {
$sla_sorted_by = $item['top_n'];
$period = $item['period'];
$current_month = $item['current_month'];
$failover_mode = $item['failover_mode'];
$failover_type = $item['failover_type'];
break;
case 'module_histogram_graph':
@ -566,7 +570,6 @@ switch ($action) {
$include_extended_events = $item['show_extended_events'];
$filter_search = $style['event_filter_search'];
break;
case 'event_report_group':
@ -2238,6 +2241,7 @@ $class = 'databox filters';
?>
</td>
</tr>
<tr id="row_select_fields2" style="" class="datos">
<td style="font-weight:bold;margin-right:150px;">
<?php
@ -2609,6 +2613,59 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_failover_mode" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Failover mode').ui_print_help_tip(
__('SLA calculation must be performed taking into account the failover modules assigned to the primary module'),
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">
<td style="font-weight:bold;"><?php echo __('Free search'); ?></td>
<td>
@ -2772,6 +2829,13 @@ function print_SLA_list($width, $action, $idItem=null)
'id_rc',
$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%">
<thead>
@ -2784,8 +2848,23 @@ function print_SLA_list($width, $action, $idItem=null)
<th class="header sla_list_module_col" scope="col">
<?php
echo __('Module');
?>
if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
?>
<th class="header sla_list_agent_failover" scope="col">
<?php
echo __('Agent Failover');
?>
</th>
<th class="header sla_list_module_failover" scope="col">
<?php
echo __('Module Failover');
?>
</th>
<?php
}
?>
<th class="header sla_list_service_col" scope="col">
<?php
echo __('Service');
@ -2831,6 +2910,7 @@ function print_SLA_list($width, $action, $idItem=null)
case 'update':
case 'edit':
echo '<tbody id="list_sla">';
$itemsSLA = db_get_all_rows_filter(
'treport_content_sla_combined',
['id_report_content' => $idItem]
@ -2865,6 +2945,25 @@ function print_SLA_list($width, $action, $idItem=null)
['id_agente_modulo' => $item['id_agent_module']]
);
if (isset($item['id_agent_module_failover']) === true
&& $item['id_agent_module_failover'] !== 0
) {
$idAgentFailover = db_get_value_filter(
'id_agente',
'tagente_modulo',
['id_agente_modulo' => $item['id_agent_module_failover']]
);
$nameAgentFailover = agents_get_alias(
$idAgentFailover
);
$nameModuleFailover = db_get_value_filter(
'nombre',
'tagente_modulo',
['id_agente_modulo' => $item['id_agent_module_failover']]
);
}
$server_name_element = '';
if ($meta && $server_name != '') {
$server_name_element .= ' ('.$server_name.')';
@ -2878,6 +2977,17 @@ function print_SLA_list($width, $action, $idItem=null)
echo printSmallFont($nameModule);
echo '</td>';
if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
echo '<td class="sla_list_agent_failover">';
echo printSmallFont($nameAgentFailover).$server_name_element;
echo '</td>';
echo '<td class="sla_list_module_failover">';
echo printSmallFont($nameModuleFailover);
echo '</td>';
}
if (enterprise_installed()
&& $report_item_type == 'SLA_services'
) {
@ -2926,6 +3036,15 @@ function print_SLA_list($width, $action, $idItem=null)
<td class="sla_list_agent_col agent_name"></td>
<td class="sla_list_module_col module_name"></td>
<?php
if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
?>
<td class="sla_list_agent_failover agent_name_failover"></td>
<td class="sla_list_module_failover module_name_failover"></td>
<?php
}
if (enterprise_installed()
&& $report_item_type == 'SLA_services'
) {
@ -2982,6 +3101,44 @@ function print_SLA_list($width, $action, $idItem=null)
</select>
</td>
<?php
if ($report_item_type == 'availability_graph'
&& $failover_mode
) {
?>
<td class="sla_list_agent_failover_col">
<input id="hidden-id_agent_failover" name="id_agent_failover" value="" type="hidden">
<input id="hidden-server_name_failover" name="server_name_failover" value="" type="hidden">
<?php
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'agent_failover';
$params['value'] = '';
$params['use_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-id_agent_failover';
$params['javascript_is_function_select'] = true;
$params['selectbox_id'] = 'id_agent_module_failover';
$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_failover_col">
<select id="id_agent_module_failover" name="id_agent_module_failover" disabled="disabled" style="max-width: 180px">
<option value="0">
<?php
echo __('Select an Agent first');
?>
</option>
</select>
</td>
<?php
}
if (enterprise_installed()
&& $report_item_type == 'SLA_services'
) {
@ -3002,23 +3159,23 @@ function print_SLA_list($width, $action, $idItem=null)
],
]
);
if (!empty($services_tmp)
&& $services_tmp != ENTERPRISE_NOT_HOOK
if (!empty($services_tmp)
&& $services_tmp != ENTERPRISE_NOT_HOOK
) {
foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
) {
foreach ($services_tmp as $service) {
$check_module_sla = modules_check_agentmodule_exists(
$service['sla_id_module']
);
$check_module_sla_value = modules_check_agentmodule_exists(
$service['sla_value_id_module']
);
if ($check_module_sla
&& $check_module_sla_value
) {
$services[$service['id']] = $service['name'];
}
}
$services[$service['id']] = $service['name'];
}
}
}
echo '<td class="sla_list_service_col">';
echo html_print_select(
@ -3617,11 +3774,18 @@ $(document).ready (function () {
$("#checkbox-checkbox_show_resume").change(function(){
if($(this).is(":checked")){
$("#row_select_fields2").show();
$("#row_select_fields3").show();
}
else{
$("#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();
}
});
});
@ -3915,10 +4079,13 @@ function deleteGeneralRow(id_row) {
function addSLARow() {
var nameAgent = $("input[name=agent_sla]").val();
var nameAgentFailover = $("input[name=agent_failover]").val();
var idAgent = $("input[name=id_agent_sla]").val();
var serverId = $("input[name=id_server]").val();
var idModule = $("#id_agent_module_sla").val();
var idModuleFailover = $("#id_agent_module_failover").val();
var nameModule = $("#id_agent_module_sla :selected").text();
var nameModuleFailover = $("#id_agent_module_failover :selected").text();
var slaMin = $("input[name=sla_min]").val();
var slaMax = $("input[name=sla_max]").val();
var slaLimit = $("input[name=sla_limit]").val();
@ -3979,10 +4146,63 @@ function addSLARow() {
});
}
if (nameAgentFailover != '') {
//Truncate nameAgentFailover
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameAgentFailover);
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) {
nameAgentFailover = data;
}
});
//Truncate nameModuleFailover
var params = [];
params.push("truncate_text=1");
params.push("text=" + nameModuleFailover);
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) {
nameModuleFailover = data;
}
});
}
var params = [];
params.push("add_sla=1");
params.push("id=" + $("input[name=id_item]").val());
params.push("id_module=" + idModule);
params.push("id_module_failover=" + idModuleFailover);
params.push("sla_min=" + slaMin);
params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit);
@ -4015,6 +4235,8 @@ function addSLARow() {
$("#row", row).attr('id', 'sla_' + data['id']);
$(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule);
$(".agent_name_failover", row).html(nameAgentFailover);
$(".module_name_failover", row).html(nameModuleFailover);
$(".service_name", row).html(serviceName);
$(".sla_min", row).html(slaMin);
$(".sla_max", row).html(slaMax);
@ -4025,14 +4247,22 @@ function addSLARow() {
);
$("#list_sla").append($(row).html());
$("input[name=id_agent_sla]").val('');
$("input[name=id_agent_failover]").val('');
$("input[name=id_server]").val('');
$("input[name=agent_sla]").val('');
$("input[name=agent_failover]").val('');
$("#id_agent_module_sla").empty();
$("#id_agent_module_sla").attr('disabled', 'true');
$("#id_agent_module_sla").append(
$("<option></option>")
.attr ("value", 0)
.html ($("#module_sla_text").html()));
$("#id_agent_module_failover").empty();
$("#id_agent_module_failover").attr('disabled', 'true');
$("#id_agent_module_failover").append(
$("<option></option>")
.attr ("value", 0)
.html ($("#module_sla_text").html()));
$("input[name=sla_min]").val('');
$("input[name=sla_max]").val('');
$("input[name=sla_limit]").val('');
@ -4161,7 +4391,6 @@ function addGeneralRow() {
success: function (data) {
if (data['correct']) {
row = $("#general_template").clone();
$("#row", row).show();
$("#row", row).attr('id', 'general_' + data['id']);
$(".agent_name", row).html(nameAgent);
@ -4211,6 +4440,8 @@ function chooseType() {
$("#row_custom_example").hide();
$("#row_group").hide();
$("#row_current_month").hide();
$("#row_failover_mode").hide();
$("#row_failover_type").hide();
$("#row_working_time").hide();
$("#row_only_display_wrong").hide();
$("#row_combo_module").hide();
@ -4384,6 +4615,11 @@ function chooseType() {
$("#row_working_time").show();
$("#row_historical_db_check").hide();
$("#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;
case 'module_histogram_graph':

View File

@ -1441,6 +1441,14 @@ switch ($action) {
$values['show_graph'] = get_parameter(
'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;
break;
@ -2398,6 +2406,16 @@ switch ($action) {
$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['show_in_same_row'] = get_parameter(
'show_in_same_row',

View File

@ -472,11 +472,17 @@ if (check_login()) {
$result = false;
$id_module_a = (int) get_parameter('id_module_a');
$id_module_b = (int) get_parameter('id_module_b');
$type = (string) get_parameter('relation_type');
if ($id_module_a < 1) {
$name_module_a = get_parameter('name_module_a', '');
if ($name_module_a) {
$id_module_a = (int) db_get_value('id_agente_modulo', 'tagente_modulo', 'nombre', $name_module_a);
$id_module_a = (int) db_get_value(
'id_agente_modulo',
'tagente_modulo',
'nombre',
$name_module_a
);
} else {
echo json_encode($result);
return;
@ -486,7 +492,12 @@ if (check_login()) {
if ($id_module_b < 1) {
$name_module_b = get_parameter('name_module_b', '');
if ($name_module_b) {
$id_module_b = (int) db_get_value('id_agente_modulo', 'tagente_modulo', 'nombre', $name_module_b);
$id_module_b = (int) db_get_value(
'id_agente_modulo',
'tagente_modulo',
'nombre',
$name_module_b
);
} else {
echo json_encode($result);
return;
@ -494,7 +505,7 @@ if (check_login()) {
}
if ($id_module_a > 0 && $id_module_b > 0) {
$result = modules_add_relation($id_module_a, $id_module_b);
$result = modules_add_relation($id_module_a, $id_module_b, $type);
}
echo json_encode($result);

View File

@ -65,6 +65,7 @@ if ($add_sla) {
$sla_max = get_parameter('sla_max', 0);
$sla_min = get_parameter('sla_min', 0);
$server_id = (int) get_parameter('server_id', 0);
$id_module_failover = (int) get_parameter('id_module_failover', 0);
$id_service = (int) get_parameter('id_service');
if (empty($id_module) && !empty($id_service)) {
@ -85,12 +86,13 @@ if ($add_sla) {
$result = db_process_sql_insert(
'treport_content_sla_combined',
[
'id_report_content' => $id,
'id_agent_module' => $id_module,
'sla_max' => $sla_max,
'sla_min' => $sla_min,
'sla_limit' => $sla_limit,
'server_name' => $connection['server_name'],
'id_report_content' => $id,
'id_agent_module' => $id_module,
'id_agent_module_failover' => $id_module_failover,
'sla_max' => $sla_max,
'sla_min' => $sla_min,
'sla_limit' => $sla_limit,
'server_name' => $connection['server_name'],
]
);

View File

@ -163,6 +163,7 @@ if ($install_package) {
unlink($files_copied);
}
if (file_exists($package)) {
if ($files_h = fopen($files_total, 'r')) {
while ($line = stream_get_line($files_h, 65535, "\n")) {

View File

@ -2631,7 +2631,7 @@ function modules_get_relations($params=[])
}
$sql = 'SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b,
tmr.disable_update
tmr.disable_update, tmr.type
FROM tmodule_relationship tmr,
tagente_modulo tam,
tagente ta,
@ -2734,11 +2734,13 @@ function modules_relation_exists($id_module, $id_module_other=false)
/**
* Change the 'disabled_update' value of a relation row.
*
* @param int Relation id.
* @param integer $id_module_a Id agent module a.
* @param integer $id_module_b Id agent module b.
* @param string $type Type direct or failover.
*
* @return boolean True if the 'disabled_update' changes to 1, false otherwise.
*/
function modules_add_relation($id_module_a, $id_module_b)
function modules_add_relation($id_module_a, $id_module_b, $type='direct')
{
$result = false;
@ -2746,6 +2748,7 @@ function modules_add_relation($id_module_a, $id_module_b)
$values = [
'module_a' => $id_module_a,
'module_b' => $id_module_b,
'type' => $type,
];
$result = db_process_sql_insert('tmodule_relationship', $values);
}

View File

@ -450,14 +450,26 @@ function networkmap_generate_dot(
$nodes[$node_count] = $module;
}
} else {
$have_relations_a = db_get_value('id', 'tmodule_relationship', 'module_a', $module['id_agente_modulo']);
$have_relations_b = db_get_value('id', 'tmodule_relationship', 'module_b', $module['id_agente_modulo']);
$sql_a = sprintf(
'SELECT id
FROM tmodule_relationship
WHERE module_a = %d AND type = "direct"',
$module['id_agente_modulo']
);
$sql_b = sprintf(
'SELECT id
FROM tmodule_relationship
WHERE module_b = %d AND type = "direct"',
$module['id_agente_modulo']
);
$have_relations_a = db_get_value_sql($sql_a);
$have_relations_b = db_get_value_sql($sql_b);
if ($have_relations_a || $have_relations_b) {
// Save node parent information to define edges later
// Save node parent information to define edges later.
$parents[$node_count] = $module['parent'] = $agent['id_node'];
// Add node
// Add node.
$nodes[$node_count] = $module;
}
}

View File

@ -1,20 +1,30 @@
<?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
* @subpackage Reporting
* Extension to manage a list of gateways and the node address where they should
* 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,13 +48,15 @@ require_once $config['homedir'].'/include/functions_netflow.php';
require_once $config['homedir'].'/include/functions_os.php';
require_once $config['homedir'].'/include/functions_network.php';
//
// CONSTANTS DEFINITIONS //
//
// CONSTANTS DEFINITIONS.
// Priority modes.
define('REPORT_PRIORITY_MODE_OK', 1);
define('REPORT_PRIORITY_MODE_UNKNOWN', 2);
// Failover type.
define('REPORT_FAILOVER_TYPE_NORMAL', 1);
define('REPORT_FAILOVER_TYPE_SIMPLE', 2);
// Status.
define('REPORT_STATUS_ERR', 0);
define('REPORT_STATUS_OK', 1);
@ -6389,11 +6401,15 @@ function reporting_availability($report, $content, $date=false, $time=false)
}
/**
* reporting_availability_graph
*
* Generates a structure the report.
*/
/**
* Reporting_availability_graph.
*
* @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)
{
global $config;
@ -6410,9 +6426,10 @@ function reporting_availability_graph($report, $content, $pdf=false)
$return['title'] = $content['name'];
$return['description'] = $content['description'];
$return['failover_type'] = $content['failover_type'];
$return['date'] = reporting_get_date_text($report, $content);
// Get chart
// Get chart.
reporting_set_conf_charts(
$width,
$height,
@ -6456,83 +6473,8 @@ function reporting_availability_graph($report, $content, $pdf=false)
foreach ($slas as $sla) {
$server_name = $sla['server_name'];
// Metaconsole connection
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue;
}
}
if (modules_is_disable_agent($sla['id_agent_module'])
|| modules_is_not_init($sla['id_agent_module'])
) {
if ($metaconsole_on) {
// Restore db connection
metaconsole_restore_db();
}
continue;
}
// controller min and max == 0 then dinamic min and max critical
$dinamic_text = 0;
if ($sla['sla_min'] == 0 && $sla['sla_max'] == 0) {
$sla['sla_min'] = null;
$sla['sla_max'] = null;
$dinamic_text = __('Dynamic');
}
// controller inverse interval
$inverse_interval = 0;
if ((isset($sla['sla_max'])) && (isset($sla['sla_min']))) {
if ($sla['sla_max'] < $sla['sla_min']) {
$content_sla_max = $sla['sla_max'];
$sla['sla_max'] = $sla['sla_min'];
$sla['sla_min'] = $content_sla_max;
$inverse_interval = 1;
$dinamic_text = __('Inverse');
}
}
// for graph slice for module-interval, if not slice=0;
$module_interval = modules_get_interval($sla['id_agent_module']);
$slice = ($content['period'] / $module_interval);
// call functions sla
$sla_array = [];
$sla_array = reporting_advanced_sla(
$sla['id_agent_module'],
($report['datetime'] - $content['period']),
$report['datetime'],
$sla['sla_min'],
// min_value -> dynamic
$sla['sla_max'],
// max_value -> dynamic
$inverse_interval,
// inverse_interval -> dynamic
[
'1' => $content['sunday'],
'2' => $content['monday'],
'3' => $content['tuesday'],
'4' => $content['wednesday'],
'5' => $content['thursday'],
'6' => $content['friday'],
'7' => $content['saturday'],
],
$content['time_from'],
$content['time_to'],
$slice
);
if ($metaconsole_on) {
// Restore db connection
metaconsole_restore_db();
}
$server_name = $sla['server_name'];
// Metaconsole connection
// Metaconsole connection.
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_connect($connection) != NOERR) {
@ -6540,199 +6482,149 @@ function reporting_availability_graph($report, $content, $pdf=false)
}
}
$planned_downtimes = reporting_get_planned_downtimes_intervals($sla['id_agent_module'], ($report['datetime'] - $content['period']), $report['datetime']);
if ((is_array($planned_downtimes)) && (count($planned_downtimes) > 0)) {
// Sort retrieved planned downtimes
usort(
$planned_downtimes,
function ($a, $b) {
$a = intval($a['date_from']);
$b = intval($b['date_from']);
if ($a == $b) {
return 0;
if ($content['failover_mode']) {
$sla_failover = [];
$sla_failover['primary'] = $sla;
if (isset($sla['id_agent_module_failover']) === true
&& $sla['id_agent_module_failover'] != 0
) {
$sla_failover['failover'] = $sla;
$sla_failover['failover']['id_agent_module'] = $sla['id_agent_module_failover'];
} else {
$sql_relations = sprintf(
'SELECT module_b
FROM tmodule_relationship
WHERE module_a = %d
AND type = "failover"',
$sla['id_agent_module']
);
$relations = db_get_all_rows_sql($sql_relations);
if (isset($relations) === true
&& is_array($relations) === true
) {
foreach ($relations as $key => $value) {
$sla_failover['failover_'.$key] = $sla;
$sla_failover['failover_'.$key]['id_agent_module'] = $value['module_b'];
}
return ($a < $b) ? -1 : 1;
}
}
// For graph slice for module-interval, if not slice=0.
$module_interval = modules_get_interval($sla['id_agent_module']);
$slice = ($content['period'] / $module_interval);
$data_combined = [];
foreach ($sla_failover as $k_sla => $v_sla) {
$sla_array = data_db_uncompress_module(
$v_sla,
$content,
$report['datetime'],
$slice
);
if ($content['failover_type'] == REPORT_FAILOVER_TYPE_NORMAL) {
$return = prepare_data_for_paint(
$v_sla,
$sla_array,
$content,
$report['datetime'],
$return,
$k_sla,
$pdf
);
}
$data_combined[] = $sla_array;
}
if (isset($data_combined) === true
&& is_array($data_combined) === true
&& count($data_combined) > 0
) {
$count_failover = count($data_combined);
$data_a = $data_combined[0];
for ($i = 1; $count_failover > $i; $i++) {
$data_a = array_map(
function ($primary, $failover) {
$return_map = [];
if ($primary['date_from'] === $failover['date_from']
&& $primary['date_to'] === $failover['date_to']
) {
if ($primary['time_ok'] < $failover['time_ok']) {
$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_map = $primary;
}
return $return_map;
},
$data_a,
$data_combined[($i)]
);
}
$return = prepare_data_for_paint(
$sla,
$data_a,
$content,
$report['datetime'],
$return,
'result',
$pdf
);
}
} else {
$sla_array = data_db_uncompress_module(
$sla,
$content,
$report['datetime']
);
// Compress (overlapped) planned downtimes
$npd = count($planned_downtimes);
for ($i = 0; $i < $npd; $i++) {
if (isset($planned_downtimes[($i + 1)])) {
if ($planned_downtimes[$i]['date_to'] >= $planned_downtimes[($i + 1)]['date_from']) {
// merge
$planned_downtimes[$i]['date_to'] = $planned_downtimes[($i + 1)]['date_to'];
array_splice($planned_downtimes, ($i + 1), 1);
$npd--;
}
}
}
} else {
$planned_downtimes = null;
$return = prepare_data_for_paint(
$sla,
$sla_array,
$content,
$report['datetime'],
$return,
'',
$pdf
);
}
$data = [];
$data['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']);
$data['module'] = modules_get_agentmodule_name($sla['id_agent_module']);
$data['max'] = $sla['sla_max'];
$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;
$data['time_error'] = 0;
$data['time_unknown'] = 0;
$data['time_not_init'] = 0;
$data['time_downtime'] = 0;
$data['checks_total'] = 0;
$data['checks_ok'] = 0;
$data['checks_error'] = 0;
$data['checks_unknown'] = 0;
$data['checks_not_init'] = 0;
$raw_graph = [];
$i = 0;
foreach ($sla_array as $value_sla) {
$data['time_total'] += $value_sla['time_total'];
$data['time_ok'] += $value_sla['time_ok'];
$data['time_error'] += $value_sla['time_error'];
$data['time_unknown'] += $value_sla['time_unknown'];
$data['time_downtime'] += $value_sla['time_downtime'];
$data['time_not_init'] += $value_sla['time_not_init'];
$data['checks_total'] += $value_sla['checks_total'];
$data['checks_ok'] += $value_sla['checks_ok'];
$data['checks_error'] += $value_sla['checks_error'];
$data['checks_unknown'] += $value_sla['checks_unknown'];
$data['checks_not_init'] += $value_sla['checks_not_init'];
// generate raw data for graph
$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']);
$i++;
}
$data['sla_value'] = reporting_sla_get_compliance_from_array($data);
$data['sla_fixed'] = sla_truncate($data['sla_value'], $config['graph_precision']);
} else {
// Show only table not divider in slice for defect slice=1
$data['time_total'] = $sla_array['time_total'];
$data['time_ok'] = $sla_array['time_ok'];
$data['time_error'] = $sla_array['time_error'];
$data['time_unknown'] = $sla_array['time_unknown'];
$data['time_downtime'] = $sla_array['time_downtime'];
$data['time_not_init'] = $sla_array['time_not_init'];
$data['checks_total'] = $sla_array['checks_total'];
$data['checks_ok'] = $sla_array['checks_ok'];
$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'];
}
// checks whether or not it meets the SLA
if ($data['sla_value'] >= $sla['sla_limit']) {
$data['sla_status'] = 1;
$sla_failed = false;
} else {
$sla_failed = true;
$data['sla_status'] = 0;
}
// Do not show right modules if 'only_display_wrong' is active
if ($content['only_display_wrong'] && $sla_failed == false) {
continue;
}
// find order
$data['order'] = $data['sla_value'];
$return['data'][] = $data;
$data_init = -1;
$acum = 0;
$sum = 0;
$array_result = [];
$i = 0;
foreach ($raw_graph as $key => $value) {
if ($data_init == -1) {
$data_init = $value['data'];
$acum = $value['utimestamp'];
$sum = $value['data'];
} else {
if ($data_init == $value['data']) {
$acum = ($acum + $value['utimestamp']);
$sum = ($sum + $value['real_data']);
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
$i++;
$data_init = $value['data'];
$acum = $value['utimestamp'];
$sum = $value['real_data'];
}
}
}
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
// Slice graphs calculation
$dataslice = [];
$dataslice['agent'] = modules_get_agentmodule_agent_alias($sla['id_agent_module']);
$dataslice['module'] = modules_get_agentmodule_name($sla['id_agent_module']);
$dataslice['order'] = $data['sla_value'];
$dataslice['checks_total'] = $data['checks_total'];
$dataslice['checks_ok'] = $data['checks_ok'];
$dataslice['time_total'] = $data['time_total'];
$dataslice['time_not_init'] = $data['time_not_init'];
$dataslice['sla_status'] = $data['sla_status'];
$dataslice['sla_value'] = $data['sla_value'];
$dataslice['chart'] = graph_sla_slicebar(
$sla['id_agent_module'],
$content['period'],
$sla['sla_min'],
$sla['sla_max'],
$report['datetime'],
$content,
$content['time_from'],
$content['time_to'],
100,
70,
$urlImage,
$ttl,
$array_result,
false
);
$return['charts'][] = $dataslice;
if ($metaconsole_on) {
// Restore db connection
// Restore db connection.
metaconsole_restore_db();
}
}
// SLA items sorted descending ()
// SLA items sorted descending.
if ($content['top_n'] == 2) {
arsort($return['data']['']);
}
// SLA items sorted ascending
else if ($content['top_n'] == 1) {
} else if ($content['top_n'] == 1) {
// SLA items sorted ascending.
asort($sla_showed_values);
}
// order data for ascending or descending
// Order data for ascending or descending.
if ($content['top_n'] != 0) {
switch ($content['top_n']) {
case 1:
// order tables
// Order tables.
$temp = [];
foreach ($return['data'] as $row) {
$i = 0;
@ -6749,7 +6641,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$return['data'] = $temp;
// order graphs
// Order graphs.
$temp = [];
foreach ($return['charts'] as $row) {
$i = 0;
@ -6765,11 +6657,10 @@ function reporting_availability_graph($report, $content, $pdf=false)
}
$return['charts'] = $temp;
break;
case 2:
// order tables
// Order tables.
$temp = [];
foreach ($return['data'] as $row) {
$i = 0;
@ -6786,7 +6677,7 @@ function reporting_availability_graph($report, $content, $pdf=false)
$return['data'] = $temp;
// order graph
// Order graph.
$temp = [];
foreach ($return['charts'] as $row) {
$i = 0;
@ -6802,7 +6693,10 @@ function reporting_availability_graph($report, $content, $pdf=false)
}
$return['charts'] = $temp;
break;
default:
// If not posible.
break;
}
}
@ -6812,6 +6706,313 @@ function reporting_availability_graph($report, $content, $pdf=false)
}
/**
* 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;
if ($sla['sla_min'] == 0 && $sla['sla_max'] == 0) {
$sla['sla_min'] = null;
$sla['sla_max'] = null;
$dinamic_text = __('Dynamic');
}
// Controller inverse interval.
$inverse_interval = 0;
if ((isset($sla['sla_max'])) && (isset($sla['sla_min']))) {
if ($sla['sla_max'] < $sla['sla_min']) {
$content_sla_max = $sla['sla_max'];
$sla['sla_max'] = $sla['sla_min'];
$sla['sla_min'] = $content_sla_max;
$inverse_interval = 1;
$dinamic_text = __('Inverse');
}
}
if ($slice === 0) {
// For graph slice for module-interval, if not slice=0.
$module_interval = modules_get_interval($sla['id_agent_module']);
$slice = ($content['period'] / $module_interval);
}
// Call functions sla.
$sla_array = [];
$sla_array = reporting_advanced_sla(
$sla['id_agent_module'],
($datetime - $content['period']),
$datetime,
$sla['sla_min'],
$sla['sla_max'],
$inverse_interval,
[
'1' => $content['sunday'],
'2' => $content['monday'],
'3' => $content['tuesday'],
'4' => $content['wednesday'],
'5' => $content['thursday'],
'6' => $content['friday'],
'7' => $content['saturday'],
],
$content['time_from'],
$content['time_to'],
$slice
);
return $sla_array;
}
/**
* 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)
) {
// Sort retrieved planned downtimes.
usort(
$planned_downtimes,
function ($a, $b) {
$a = intval($a['date_from']);
$b = intval($b['date_from']);
if ($a == $b) {
return 0;
}
return ($a < $b) ? (-1) : 1;
}
);
// Compress (overlapped) planned downtimes.
$npd = count($planned_downtimes);
for ($i = 0; $i < $npd; $i++) {
if (isset($planned_downtimes[($i + 1)])) {
if ($planned_downtimes[$i]['date_to'] >= $planned_downtimes[($i + 1)]['date_from']) {
// Merge.
$planned_downtimes[$i]['date_to'] = $planned_downtimes[($i + 1)]['date_to'];
array_splice($planned_downtimes, ($i + 1), 1);
$npd--;
}
}
}
} else {
$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 $failover Type primary, failover, Result.
* @param boolean $pdf Chart pdf mode.
*
* @return array Return modify.
*/
function prepare_data_for_paint(
$sla,
$sla_array,
$content,
$datetime,
$return,
$failover='',
$pdf=false
) {
$data = [];
$alias_agent = modules_get_agentmodule_agent_alias(
$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['min'] = $sla['sla_min'];
$data['sla_limit'] = $sla['sla_limit'];
$data['dinamic_text'] = $dinamic_text;
$data['failover'] = $failover;
if (isset($sla_array[0])) {
$data['time_total'] = 0;
$data['time_ok'] = 0;
$data['time_error'] = 0;
$data['time_unknown'] = 0;
$data['time_not_init'] = 0;
$data['time_downtime'] = 0;
$data['checks_total'] = 0;
$data['checks_ok'] = 0;
$data['checks_error'] = 0;
$data['checks_unknown'] = 0;
$data['checks_not_init'] = 0;
$raw_graph = [];
$i = 0;
foreach ($sla_array as $value_sla) {
$data['time_total'] += $value_sla['time_total'];
$data['time_ok'] += $value_sla['time_ok'];
$data['time_error'] += $value_sla['time_error'];
$data['time_unknown'] += $value_sla['time_unknown'];
$data['time_downtime'] += $value_sla['time_downtime'];
$data['time_not_init'] += $value_sla['time_not_init'];
$data['checks_total'] += $value_sla['checks_total'];
$data['checks_ok'] += $value_sla['checks_ok'];
$data['checks_error'] += $value_sla['checks_error'];
$data['checks_unknown'] += $value_sla['checks_unknown'];
$data['checks_not_init'] += $value_sla['checks_not_init'];
// Generate raw data for graph.
$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']);
$i++;
}
$data['sla_value'] = reporting_sla_get_compliance_from_array(
$data
);
$data['sla_fixed'] = sla_truncate(
$data['sla_value'],
$config['graph_precision']
);
} else {
// Show only table not divider in slice for defect slice=1.
$data['time_total'] = $sla_array['time_total'];
$data['time_ok'] = $sla_array['time_ok'];
$data['time_error'] = $sla_array['time_error'];
$data['time_unknown'] = $sla_array['time_unknown'];
$data['time_downtime'] = $sla_array['time_downtime'];
$data['time_not_init'] = $sla_array['time_not_init'];
$data['checks_total'] = $sla_array['checks_total'];
$data['checks_ok'] = $sla_array['checks_ok'];
$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'];
}
// Checks whether or not it meets the SLA.
if ($data['sla_value'] >= $sla['sla_limit']) {
$data['sla_status'] = 1;
$sla_failed = false;
} else {
$sla_failed = true;
$data['sla_status'] = 0;
}
// Do not show right modules if 'only_display_wrong' is active.
if ($content['only_display_wrong'] && $sla_failed == false) {
return $return;
}
// Find order.
$data['order'] = $data['sla_value'];
$return['data'][] = $data;
$data_init = -1;
$acum = 0;
$sum = 0;
$array_result = [];
$i = 0;
foreach ($raw_graph as $key => $value) {
if ($data_init == -1) {
$data_init = $value['data'];
$acum = $value['utimestamp'];
$sum = $value['data'];
} else {
if ($data_init == $value['data']) {
$acum = ($acum + $value['utimestamp']);
$sum = ($sum + $value['real_data']);
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
$i++;
$data_init = $value['data'];
$acum = $value['utimestamp'];
$sum = $value['real_data'];
}
}
}
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
// Slice graphs calculation.
$dataslice = [];
$dataslice['agent'] = $alias_agent;
$dataslice['module'] = $name_module;
$dataslice['order'] = $data['sla_value'];
$dataslice['checks_total'] = $data['checks_total'];
$dataslice['checks_ok'] = $data['checks_ok'];
$dataslice['time_total'] = $data['time_total'];
$dataslice['time_not_init'] = $data['time_not_init'];
$dataslice['sla_status'] = $data['sla_status'];
$dataslice['sla_value'] = $data['sla_value'];
$height = 80;
if ($failover !== '' && $failover !== 'result') {
$height = 50;
}
$dataslice['chart'] = graph_sla_slicebar(
$sla['id_agent_module'],
$content['period'],
$sla['sla_min'],
$sla['sla_max'],
$datetime,
$content,
$content['time_from'],
$content['time_to'],
100,
$height,
$urlImage,
($pdf) ? 2 : 0,
$array_result,
false
);
$return['charts'][] = $dataslice;
return $return;
}
/**
* reporting_increment
*

View File

@ -3252,53 +3252,111 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$tables_chart = '';
$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%';
foreach ($item['charts'] as $chart) {
$checks_resume = '';
$sla_value = '';
if (reporting_sla_is_not_init_from_array($chart)) {
$color = COL_NOTINIT;
$sla_value = __('Not init');
} else if (reporting_sla_is_ignored_from_array($chart)) {
$color = COL_IGNORED;
$sla_value = __('No data');
} else {
switch ($chart['sla_status']) {
case REPORT_STATUS_ERR:
$color = COL_CRITICAL;
break;
if (isset($item['failed']) === true && empty($item['failed']) === false) {
$tables_chart .= $item['failed'];
} else {
foreach ($item['charts'] as $k_chart => $chart) {
$checks_resume = '';
$sla_value = '';
if (reporting_sla_is_not_init_from_array($chart)) {
$color = COL_NOTINIT;
$sla_value = __('Not init');
} else if (reporting_sla_is_ignored_from_array($chart)) {
$color = COL_IGNORED;
$sla_value = __('No data');
} else {
switch ($chart['sla_status']) {
case REPORT_STATUS_ERR:
$color = COL_CRITICAL;
break;
case REPORT_STATUS_OK:
$color = COL_NORMAL;
break;
case REPORT_STATUS_OK:
$color = COL_NORMAL;
break;
default:
$color = COL_UNKNOWN;
break;
default:
$color = COL_UNKNOWN;
break;
}
$sla_value = sla_truncate(
$chart['sla_value'],
$config['graph_precision']
).'%';
$checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')';
}
$sla_value = sla_truncate(
$chart['sla_value'],
$config['graph_precision']
).'%';
$checks_resume = '('.$chart['checks_ok'].'/'.$chart['checks_total'].')';
}
// Check failover availability report.
if ($item['data'][$k_chart]['failover'] === '') {
$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][1] = $chart['chart'];
$table1->data[0][2] = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>';
$table1->data[0][3] = $checks_resume;
$tables_chart .= html_print_table(
$table1,
true
);
} else {
if ($item['data'][$k_chart]['failover'] === 'primary'
|| $item['failover_type'] == REPORT_FAILOVER_TYPE_SIMPLE
) {
$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][1] = $chart['chart'];
$table1->data[0][2] = "<span style = 'font: bold 2em Arial, Sans-serif; color: ".$color."'>".$sla_value.'</span>';
$table1->data[0][3] = $checks_resume;
$tables_chart .= html_print_table(
$table1,
true
);
$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]['failover']) {
case 'primary':
$title = '<b>'.__('Primary').'</b>';
$title .= '<br />'.$chart['agent'];
$title .= '<br />'.$chart['module'];
break;
case (preg_match('/failover.*/', $item['data'][$k_chart]['failover']) ? true : false):
$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]['failover']][0] = $title;
$table1->data[$item['data'][$k_chart]['failover']][1] = $chart['chart'];
$table1->data[$item['data'][$k_chart]['failover']][2] = $sla_value_text;
$table1->data[$item['data'][$k_chart]['failover']][3] = $checks_resume_text;
if ($item['data'][$k_chart]['failover'] === 'result') {
$tables_chart .= html_print_table(
$table1,
true
);
}
}
}
}
if ($item['type'] == 'availability_graph') {

View File

@ -820,6 +820,7 @@ CREATE TABLE IF NOT EXISTS `tmodule_relationship` (
`module_a` int(10) unsigned NOT NULL,
`module_b` int(10) unsigned NOT NULL,
`disable_update` tinyint(1) unsigned NOT NULL default '0',
`type` ENUM('direct', 'failover') DEFAULT 'direct',
PRIMARY KEY (`id`),
FOREIGN KEY (`module_a`) REFERENCES tagente_modulo(`id_agente_modulo`)
ON DELETE CASCADE,
@ -1452,6 +1453,8 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`agent_max_value` TINYINT(1) DEFAULT '1',
`agent_min_value` 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`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -1464,6 +1467,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` (
`id` INTEGER UNSIGNED NOT NULL auto_increment,
`id_report_content` INTEGER UNSIGNED NOT NULL,
`id_agent_module` int(10) unsigned NOT NULL,
`id_agent_module_failover` int(10) unsigned NOT NULL,
`sla_max` 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,
@ -2992,6 +2996,8 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`agent_max_value` TINYINT(1) DEFAULT '1',
`agent_min_value` 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`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;

View File

@ -114,10 +114,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''),
('custom_report_front_footer', ''),
('MR', 29),
('MR', 30),
('identification_reminder', 1),
('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"}'),
('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'),

View File

@ -490,7 +490,7 @@ sub PandoraFMS::Recon::Base::connect_agents($$$$$) {
}
# Connect the modules if they are not already connected.
my $connection_id = get_db_value($self->{'dbh'}, 'SELECT id FROM tmodule_relationship WHERE (module_a = ? AND module_b = ?) OR (module_b = ? AND module_a = ?)', $module_id_1, $module_id_2, $module_id_1, $module_id_2);
my $connection_id = get_db_value($self->{'dbh'}, 'SELECT id FROM tmodule_relationship WHERE (module_a = ? AND module_b = ? AND `type` = "direct") OR (module_b = ? AND module_a = ? AND `type` = "direct")', $module_id_1, $module_id_2, $module_id_1, $module_id_2);
if (! defined($connection_id)) {
db_do($self->{'dbh'}, 'INSERT INTO tmodule_relationship (`module_a`, `module_b`, `id_rt`) VALUES(?, ?, ?)', $module_id_1, $module_id_2, $self->{'task_id'});
}

View File

@ -1005,7 +1005,7 @@ sub connect_pandora_agents($$$$) {
}
# Connect the modules if they are not already connected.
my $connection_id = get_db_value($DBH, 'SELECT id FROM tmodule_relationship WHERE (module_a = ? AND module_b = ?) OR (module_b = ? AND module_a = ?)', $module_id_1, $module_id_2, $module_id_1, $module_id_2);
my $connection_id = get_db_value($DBH, 'SELECT id FROM tmodule_relationship WHERE (module_a = ? AND module_b = ? AND `type` = "direct") OR (module_b = ? AND module_a = ? AND `type` = "direct")', $module_id_1, $module_id_2, $module_id_1, $module_id_2);
if (! defined($connection_id)) {
db_do($DBH, 'INSERT INTO tmodule_relationship (`module_a`, `module_b`, `id_rt`) VALUES(?, ?, ?)', $module_id_1, $module_id_2, $TASK_ID);
}