52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
import os
|
|
import sys
|
|
import subprocess
|
|
import time
|
|
import urllib.request
|
|
import json
|
|
|
|
def print_header(msg):
|
|
print(f"\n{'='*40}\n {msg}\n{'='*40}")
|
|
|
|
import glob
|
|
|
|
def check_pyarmor_binding():
|
|
print_header("Hardware & License (Machine ID)")
|
|
|
|
try:
|
|
# Usar ferramenta oficial do Pyarmor CLI para HD Info
|
|
subprocess.run([sys.executable, "-m", "pyarmor.cli.hdinfo"], check=False)
|
|
except Exception as e:
|
|
print(f"Erro ao consultar HD Info: {e}")
|
|
|
|
def check_service_status():
|
|
print_header("Service Status (systemd)")
|
|
ret = subprocess.run(["systemctl", "status", "ipv0-olt-api", "--no-pager"], capture_output=False)
|
|
if ret.returncode != 0:
|
|
print("⚠️ Serviço parece estar parado ou com erro.")
|
|
|
|
def check_api_health():
|
|
print_header("API Health Check")
|
|
url = "http://localhost:5050/health"
|
|
try:
|
|
print(f"Connecting to {url}...")
|
|
with urllib.request.urlopen(url, timeout=5) as response:
|
|
if response.status == 200:
|
|
data = json.loads(response.read().decode())
|
|
print(f"✅ API Online! Status: {data}")
|
|
else:
|
|
print(f"❌ API retornou status code: {response.status}")
|
|
except Exception as e:
|
|
print(f"❌ Falha na conexão com API: {e}")
|
|
print("Verifique se o serviço está rodando e se a licença é válida.")
|
|
|
|
if __name__ == "__main__":
|
|
print("IPv0 OLT API - Debug Tool (v3.1)")
|
|
|
|
check_service_status()
|
|
check_pyarmor_binding()
|
|
check_api_health()
|
|
|
|
print("\nLogs recentes:")
|
|
subprocess.run(["journalctl", "-u", "ipv0-olt-api", "-n", "10", "--no-pager"], check=False)
|