diff --git a/.github/single-node-filebeat-check.sh b/.github/single-node-filebeat-check.sh index 7f9ae7d3..5a84207f 100755 --- a/.github/single-node-filebeat-check.sh +++ b/.github/single-node-filebeat-check.sh @@ -1,9 +1,20 @@ -filebeatout=$(docker exec single-node_wazuh.manager_1 sh -c 'filebeat test output') -filebeatstatus=$(echo "${filebeatout}" | grep -c OK) -if [[ filebeatstatus -eq 7 ]]; then - echo "No errors in filebeat" +COMMAND_TO_EXECUTE="filebeat test output" + +MASTER_CONTAINERS=$(docker ps --format '{{.Names}}' | grep -E '*manager*') + +if [ -z "$CONTAINER_NAMES" ]; then + echo "No se encontraron contenedores con 'master' en su nombre." else - echo "Errors in filebeat" - echo "${filebeatout}" - exit 1 + for MASTER_CONTAINERS in $MASTER_CONTAINERS; do + FILEBEAT_OUTPUT=$(docker exec "$MASTER_CONTAINERS" $COMMAND_TO_EXECUTE) + FILEBEAT_STATUS=$(echo "${FILEBEAT_OUTPUT}" | grep -c OK) + if [[ filebeatstatus -eq 7 ]]; then + echo "No errors in filebeat" + echo "${FILEBEAT_OUTPUT}" + else + echo "Errors in filebeat" + echo "${FILEBEAT_OUTPUT}" + exit 1 + fi + done fi \ No newline at end of file