From 7b6a43337471d30fe4d95abdd4fa618589fabd6a Mon Sep 17 00:00:00 2001 From: Dario Necco Date: Thu, 15 Jan 2026 18:09:15 +0100 Subject: [PATCH] fix(import) : detect metrics exists with occorrences count --- files/metrics_import.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/files/metrics_import.sh b/files/metrics_import.sh index 91db95c..c743958 100755 --- a/files/metrics_import.sh +++ b/files/metrics_import.sh @@ -71,7 +71,12 @@ for f in /opt/mft-automations/puppet_enterprise_support*gz \ fi fi - if ! tar tf "$f" | grep -q -m 1 'metrics\/.*json'; then + # Check if the archive contains any metrics JSON files + json_count=$(tar -tzf "$f" | grep -c '^metrics/.*\.json$') + + if [ "$json_count" -gt 0 ]; then + echo "Found $json_count JSON file(s)" + else log "No metrics found in $f. Skipping" rm -- "$f" continue