Skip to content

Commit 78416ce

Browse files
-
1 parent 36067be commit 78416ce

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/Controller/ElasticsearchClusterController.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public function audit(Request $request, string $elasticsearchUsername, string $e
398398
'shard_allocation_enabled',
399399
'max_shards_per_node',
400400
'total_shards_per_node',
401+
'replication_100_percent',
401402
];
402403

403404
$checkpoints = [];
@@ -495,6 +496,20 @@ public function audit(Request $request, string $elasticsearchUsername, string $e
495496
}
496497
}
497498
break;
499+
case 'replication_100_percent':
500+
if (1 == count($nodes)) {
501+
$results['audit_notice'][$checkpoint] = [];
502+
} else {
503+
if (true === isset($parameters['cluster_stats']['indices']['shards']['replication'])) {
504+
$replication = $parameters['cluster_stats']['indices']['shards']['replication'];
505+
if (1 > $replication) {
506+
$results['audit_fail'][$checkpoint] = round($replication * 100, 2).'%';
507+
} else {
508+
$results['audit_pass'][$checkpoint] = round($replication * 100, 2).'%';
509+
}
510+
}
511+
}
512+
break;
498513
case 'indices_replicas_data_nodes':
499514
if ($indicesCount['enough_data_nodes'] < count($indices)) {
500515
$results['audit_fail'][$checkpoint] = $dataNodes;

templates/Modules/cluster/cluster_audit.html.twig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@
148148
{% block comment %}
149149
{% if 'audit_notice' == result %}
150150
{{ ('audit_comments.' ~ checkpoint ~ '.notice')|trans|raw }}
151-
{% elseif parameters %}
152-
{{ ('audit_comments.' ~ checkpoint ~ '.note')|trans({'{replication}': parameters})|raw }}
153151
{% endif %}
154152
{% endblock %}
155153

@@ -161,6 +159,18 @@
161159
{% endembed %}
162160
{% endif %}
163161

162+
{% if 'replication_100_percent' == checkpoint %}
163+
{% embed 'Embed/audit_checkpoint_embed.html.twig' %}
164+
{% block comment %}
165+
{% if 'audit_notice' == result %}
166+
{{ ('audit_comments.' ~ checkpoint ~ '.notice')|trans|raw }}
167+
{% else %}
168+
{{ ('audit_comments.' ~ checkpoint ~ '.note')|trans({'{replication}': parameters})|raw }}
169+
{% endif %}
170+
{% endblock %}
171+
{% endembed %}
172+
{% endif %}
173+
164174
{% if 'indices_replicas_data_nodes' == checkpoint %}
165175
{% embed 'Embed/audit_checkpoint_embed.html.twig' %}
166176
{% block comment %}

translations/messages.en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ audit_checkpoints:
6565
unassigned_shards: "There is no unassigned shards"
6666
adaptive_replica_selection: "The Adaptive Replica Selection is enabled"
6767
indices_with_replica: "All indices have a replica"
68+
replication_100_percent: "The replication is at 100%"
6869
indices_replicas_data_nodes: "All indices have a number of replicas inferior to data nodes count"
6970
indices_opened: "All indices are open"
7071
close_index_not_enabled: "Closing an index is not allowed"
@@ -103,6 +104,8 @@ audit_comments:
103104
fail: "The setting <code>{setting}</code> should be set to <code>{value}</code>."
104105
indices_with_replica:
105106
notice: "There is only one node."
107+
replication_100_percent:
108+
notice: "There is only one node."
106109
note: "The replication is at <code>{replication}</code>."
107110
indices_replicas_data_nodes:
108111
note: "The number of replicas per index should be inferior to <code>{data_nodes}</code> (number of data nodes)."

0 commit comments

Comments
 (0)