mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
WIP failover
This commit is contained in:
parent
209681e4c2
commit
22734a4ea2
@ -9,4 +9,6 @@ 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;
|
@ -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] .= " <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] .= " <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, '[…]').'</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);
|
||||
|
@ -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);
|
||||
|
@ -2596,7 +2596,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,
|
||||
@ -2699,11 +2699,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;
|
||||
|
||||
@ -2711,6 +2713,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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -6463,13 +6463,32 @@ function reporting_availability_graph($report, $content, $pdf=false)
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($sla['id_agent_module_failover']) === true
|
||||
&& $sla['id_agent_module_failover'] != 0
|
||||
) {
|
||||
if ($content['failover_mode']) {
|
||||
$sla_failover = [];
|
||||
$sla_failover['primary'] = $sla;
|
||||
$sla_failover['failover'] = $sla;
|
||||
$sla_failover['failover']['id_agent_module'] = $sla['id_agent_module_failover'];
|
||||
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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For graph slice for module-interval, if not slice=0.
|
||||
$module_interval = modules_get_interval($sla['id_agent_module']);
|
||||
@ -6491,7 +6510,8 @@ function reporting_availability_graph($report, $content, $pdf=false)
|
||||
$content,
|
||||
$report['datetime'],
|
||||
$return,
|
||||
$k_sla
|
||||
$k_sla,
|
||||
$pdf
|
||||
);
|
||||
}
|
||||
|
||||
@ -6502,40 +6522,42 @@ function reporting_availability_graph($report, $content, $pdf=false)
|
||||
&& is_array($data_combined) === true
|
||||
&& count($data_combined) > 0
|
||||
) {
|
||||
$data_a = [];
|
||||
$data_a = array_map(
|
||||
function ($primary, $failover) {
|
||||
$return_map = [];
|
||||
if ($primary['date_from'] === $failover['date_from']
|
||||
&& $primary['date_to'] === $failover['date_to']
|
||||
) {
|
||||
if ($primary['sla_fixed'] !== 100
|
||||
&& $primary['sla_fixed'] < $failover['sla_fixed']
|
||||
$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']
|
||||
) {
|
||||
$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'];
|
||||
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_map = $primary;
|
||||
}
|
||||
|
||||
return $return_map;
|
||||
},
|
||||
$data_combined[0],
|
||||
$data_combined[1]
|
||||
);
|
||||
return $return_map;
|
||||
},
|
||||
$data_a,
|
||||
$data_combined[($i)]
|
||||
);
|
||||
}
|
||||
|
||||
$return = prepare_data_for_paint(
|
||||
$sla,
|
||||
@ -6543,7 +6565,8 @@ function reporting_availability_graph($report, $content, $pdf=false)
|
||||
$content,
|
||||
$report['datetime'],
|
||||
$return,
|
||||
'result'
|
||||
'result',
|
||||
$pdf
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -6558,7 +6581,8 @@ function reporting_availability_graph($report, $content, $pdf=false)
|
||||
$sla_array,
|
||||
$content,
|
||||
$report['datetime'],
|
||||
$return
|
||||
$return,
|
||||
$pdf
|
||||
);
|
||||
}
|
||||
|
||||
@ -6790,6 +6814,7 @@ function reporting_get_planned_downtimes_sla($id_agent_module, $datetime, $perio
|
||||
* @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.
|
||||
*/
|
||||
@ -6799,7 +6824,8 @@ function prepare_data_for_paint(
|
||||
$content,
|
||||
$datetime,
|
||||
$return,
|
||||
$failover=''
|
||||
$failover='',
|
||||
$pdf=false
|
||||
) {
|
||||
$data = [];
|
||||
$alias_agent = modules_get_agentmodule_agent_alias(
|
||||
@ -6956,7 +6982,7 @@ function prepare_data_for_paint(
|
||||
100,
|
||||
$height,
|
||||
$urlImage,
|
||||
$ttl,
|
||||
($pdf) ? 2 : 0,
|
||||
$array_result,
|
||||
false
|
||||
);
|
||||
|
@ -3325,7 +3325,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
|
||||
$title .= '<br />'.$chart['module'];
|
||||
break;
|
||||
|
||||
case 'failover':
|
||||
case (preg_match('/failover.*/', $item['data'][$k_chart]['failover']) ? true : false):
|
||||
$title = '<b>'.__('Failover').'</b>';
|
||||
$title .= '<br />'.$chart['agent'];
|
||||
$title .= '<br />'.$chart['module'];
|
||||
|
@ -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,
|
||||
|
@ -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'});
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user