{# # --------------------------------------------------------------------- # # GLPI - Gestionnaire Libre de Parc Informatique # # http://glpi-project.org # # @copyright 2015-2025 Teclib' and contributors. # @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 source_ok = replication_status['source'] is defined and replication_status['source']['file'] is defined %} {% set source_unknown = replication_status['source'] is defined and replication_status['source']['error'] is defined and replication_status['source']['error'] is not null %}
{% if source_unknown %} {% else %}
  • {{ __('Server ID:') }} {{ replication_status['source']['server_id']|default('') }}
  • {{ __('Binary log file:') }} {{ replication_status['source']['file']|default('') }}
  • {{ __('Binary log position:') }} {{ replication_status['source']['position']|default('') }}
  • {{ __('Server version:') }} {{ replication_status['source']['version']|default('') }}
{% endif %}
{% for replica_num, replica_data in replication_status['replica'] %} {# 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 %} {# Replica is OK when both IO and SQL are running and seconds_behind_source is 0 #} {% set replica_ok = not replica_unkown and replica_data['io_running'] == 'Yes' and replica_data['sql_running'] == 'Yes' and replica_data['seconds_behind_source'] == 0 %}
{% if replica_unkown %} {% else %}
  • {{ __('Server ID:') }} {{ replica_data['server_id']|default(__('Undefined')) }}
  • {{ __('Source binary log file:') }} {{ replica_data['source_log_file']|default(__('Undefined')) }}
  • {{ __('Source binary log position:') }} {{ replica_data['source_log_pos']|default(__('Undefined')) }}
  • {{ __('Seconds behind source:') }} {% if replica_data['seconds_behind_source'] is defined and replica_data['seconds_behind_source'] is not null %} {{ replica_data['seconds_behind_source'] }} {% else %} {{ __('Undefined') }} {% endif %}
  • {{ __('GLPI history delay:') }} {% if replication_delay[replica_num] is defined %} {% if replication_delay[replica_num] > 0 %} {{ replication_delay[replica_num]|formatted_duration }} {% elseif replication_delay[replica_num] == 0 %} {{ __('None') }} {% else %} {{ __('Undefined') }} {% endif %} {% else %} {{ __('Undefined') }} {% endif %} {% do call('Html::showToolTip', [ __('This indicates the delay between the source and the replica for GLPI history (table: glpi_logs, column: date_mod).') ]) %}
  • {{ __('IO running:') }} {{ replica_data['io_running']|default(__('Undefined')) }}
  • {{ __('SQL running:') }} {{ replica_data['sql_running']|default(__('Undefined')) }}
  • {{ __('Server version:') }} {{ replica_data['version']|default(__('Undefined')) }}
{# Display errors if io_running or sql_running are not running #} {% set display_alert = (replica_data['io_running'] != 'Yes' or replica_data['sql_running'] != 'Yes') and (replica_data['last_io_error']|length or replica_data['last_sql_error']|length) %} {% if display_alert %} {% endif %} {% endif %}
{% endfor %}
{% endblock %}