Files
scripts/scraper/monitor_structure.sh

79 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# Monitor CTF_Carstuff Structure Progress
# Author: Descomplicar® Crescimento Digital
# Link: https://descomplicar.pt
# Copyright: 2025 Descomplicar®
OUTPUT_DIR="/media/ealmeida/Dados/GDrive/Cloud/Clientes_360/CTF_Carstuff/KB/Scrapper/sites/formatted"
LOG_FILE="structure_execution.log"
clear
echo "═══════════════════════════════════════════════════════════════"
echo " 🤖 CTF_CARSTUFF - MONITOR ESTRUTURAÇÃO INTELIGENTE"
echo " Formato: Problema → Solução → Resultado"
echo "═══════════════════════════════════════════════════════════════"
echo ""
# Verificar se processo está a correr
if pgrep -f "structure_content_ctf.py" > /dev/null; then
echo "✅ Status: ATIVO (a processar com AI)"
echo ""
else
echo "⚠️ Status: CONCLUÍDO ou PARADO"
echo ""
fi
# Contar ficheiros
MD_COUNT=$(find "$OUTPUT_DIR" -type f -name "structured_*.md" 2>/dev/null | wc -l)
JSON_COUNT=$(find "$OUTPUT_DIR" -type f -name "structured_*.json" 2>/dev/null | wc -l)
TOTAL_SIZE=$(du -sh "$OUTPUT_DIR" 2>/dev/null | cut -f1)
echo "📊 Progresso Atual:"
echo " • Ficheiros MD estruturados: $MD_COUNT / 822"
echo " • Ficheiros JSON gerados: $JSON_COUNT / 822"
echo " • Tamanho total: $TOTAL_SIZE"
echo ""
# Calcular percentagem
if [ $MD_COUNT -gt 0 ]; then
PERCENT=$((MD_COUNT * 100 / 822))
echo " 🎯 Progresso: $PERCENT%"
echo ""
fi
# Tempo estimado
if [ $MD_COUNT -gt 0 ]; then
# Assumir ~18s por ficheiro
REMAINING=$((822 - MD_COUNT))
SECONDS=$((REMAINING * 18))
HOURS=$((SECONDS / 3600))
MINUTES=$(((SECONDS % 3600) / 60))
echo " ⏱️ Tempo estimado restante: ${HOURS}h ${MINUTES}m"
echo ""
fi
# Últimos ficheiros processados
echo "📝 Últimas atividades:"
tail -15 "$LOG_FILE" 2>/dev/null | grep -E "(Processando|Guardado|Erro)" | tail -10 | sed 's/^/ /'
echo ""
# Estatísticas de sucesso/erro
SUCESSOS=$(grep -c "✅ Guardado" "$LOG_FILE" 2>/dev/null)
ERROS=$(grep -c "❌ Falha" "$LOG_FILE" 2>/dev/null)
echo "📈 Estatísticas:"
echo " • Sucessos: $SUCESSOS"
echo " • Erros: $ERROS"
if [ $SUCESSOS -gt 0 ]; then
TAXA=$((SUCESSOS * 100 / (SUCESSOS + ERROS)))
echo " • Taxa de sucesso: ${TAXA}%"
fi
echo ""
echo "═══════════════════════════════════════════════════════════════"
echo "Comandos úteis:"
echo " • Ver log completo: tail -f structure_execution.log"
echo " • Ver ficheiros gerados: ls -lh $OUTPUT_DIR"
echo " • Parar processo: pkill -f structure_content_ctf.py"
echo "═══════════════════════════════════════════════════════════════"