import paramiko

HOST = "135.125.102.180"
USER = "ubuntu"
PASS = "BotPascal2026!"
REMOTE_BASE = "/var/www/html/repondeur_mail_grok"

def main():
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(HOST, username=USER, password=PASS)
        
        print("🔍 Inspection de queue.csv...")
        print("=" * 60)
        
        # Count lines
        stdin, stdout, stderr = ssh.exec_command(f"wc -l {REMOTE_BASE}/data/queue.csv")
        print(f"Lignes totales: {stdout.read().decode().strip()}")
        
        # Head
        print("\n📜 Début du fichier (5 lignes):")
        stdin, stdout, stderr = ssh.exec_command(f"head -n 5 {REMOTE_BASE}/data/queue.csv")
        print(stdout.read().decode())
        
        # Tail
        print("\n📜 Fin du fichier (5 lignes):")
        stdin, stdout, stderr = ssh.exec_command(f"tail -n 5 {REMOTE_BASE}/data/queue.csv")
        print(stdout.read().decode())
        
        # Count Yellow tags specifically
        stdin, stdout, stderr = ssh.exec_command(f"grep 'Yellow' {REMOTE_BASE}/data/queue.csv | wc -l")
        print(f"\n🟡 Total Yellow tags: {stdout.read().decode().strip()}")
        
        ssh.close()
        
    except Exception as e:
        print(f"❌ Error: {e}")

if __name__ == "__main__":
    main()
