{# # --------------------------------------------------------------------- # # GLPI - Gestionnaire Libre de Parc Informatique # # http://glpi-project.org # # @copyright 2015-2024 Teclib' and contributors. # @copyright 2003-2014 by the INDEPNET Development Team. # @licence https://www.gnu.org/licenses/gpl-3.0.html # # --------------------------------------------------------------------- # # LICENSE # # This file is part of GLPI. # # 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, either version 3 of the License, or # (at your option) any later version. # # 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. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # --------------------------------------------------------------------- #} {% extends "pages/setup/general/base_form.html.twig" %} {% import 'components/form/fields_macros.html.twig' as fields %} {% import 'components/form/basic_inputs_macros.html.twig' as inputs %} {% block config_fields %}
{{ __('Replica configuration') }}
{{ fields.textField('_dbreplicate_dbhost', replica_config['host'], __('SQL server (MariaDB or MySQL)')) }} {{ fields.textField('_dbreplicate_dbdefault', replica_config['default'], _n('Database', 'Databases', 1)) }} {{ fields.textField('_dbreplicate_dbuser', replica_config['user'], __('SQL user')) }} {{ fields.passwordField('_dbreplicate_dbpassword', replica_config['password'], __('SQL password'), { clearable: false }) }} {% set replica_search_opts = { 0: __('Never'), 1: __('If synced (all changes)'), 2: __('If synced (current user changes)'), 3: __('If synced or read-only account'), 4: __('Always'), } %} {{ fields.dropdownArrayField('use_slave_for_search', config['use_slave_for_search'], replica_search_opts, __('Use the replica for the search engine')) }} {{ inputs.hidden('_dbslave_status', 1) }}
{{ __('Replication status') }}
{% set primary_ok = replication_status['primary']['file'] %} {% set primary_unknown = replication_status['primary']['error'] is defined and replication_status['primary']['error'] is not null %}

{% if primary_unknown %} {% else %}
  • {{ __('Server ID:') }} {{ replication_status['primary']['server_id'] }}
  • {{ __('Binary log file:') }} {{ replication_status['primary']['file'] }}
  • {{ __('Binary log position:') }} {{ replication_status['primary']['position'] }}
  • {{ __('Binary log GTID:') }} {{ replication_status['primary']['gtid_binlog_pos'] }}
  • {{ __('Server version:') }} {{ replication_status['primary']['version'] }}
{% endif %}
{% for replica_num, replica_data in replication_status['replica'] %} {# Replica is OK when both IO and SQL are running and seconds_behind_master is 0 #} {% set replica_ok = replica_data['slave_io_running'] == 'Yes' and replica_data['slave_sql_running'] == 'Yes' and replica_data['seconds_behind_master'] == 0 %} {# Replica is unknown when there is an error (connection, missing grants, ...) #} {% set replica_unkown = replica_data['error'] is defined and replica_data['error'] is not null %}

{% if replica_unkown %} {% else %}
  • {{ __('Server ID:') }} {{ replica_data['server_id'] }}
  • {{ __('Primary binary log file:') }} {{ replica_data['master_log_file'] }}
  • {{ __('Primary binary log position:') }} {{ replica_data['read_master_log_pos'] }}
  • {{ __('Seconds behind primary:') }} {% if replica_data['seconds_behind_master'] is defined and replica_data['seconds_behind_master'] is not null %} {{ replica_data['seconds_behind_master'] }} {% else %} {{ __('Undefined') }} {% endif %}
  • {{ __('GLPI history delay:') }} {% if replication_delay[replica_num] > 0 %} {{ replication_delay[replica_num]|formatted_duration }} {% elseif replication_delay[replica_num] == 0 %} {{ __('None') }} {% else %} {{ __('Undefined') }} {% endif %} {% do call('Html::showToolTip', [ __('This indicates the delay between the primary and the replica for GLPI history (table: glpi_logs, column: date_mod).') ]) %}
  • {{ __('Binary log GTID:') }} {{ replica_data['gtid_slave_pos'] }}
  • {{ __('IO running:') }} {{ replica_data['slave_io_running'] }}
  • {{ __('SQL running:') }} {{ replica_data['slave_sql_running'] }}
  • {{ __('Server version:') }} {{ replica_data['version'] }}
{# Display errors if slave_io_running or slave_sql_running are not running #} {% set display_alert = (replica_data['slave_io_running'] != 'Yes' or replica_data['slave_sql_running'] != 'Yes') and (replica_data['last_io_error']|length or replica_data['last_sql_error']|length) %} {% if display_alert %} {% endif %} {% endif %}
{% endfor %}
{% endblock %}