AumCoreAI commited on
Commit
27f63e9
·
verified ·
1 Parent(s): 8fcef98

Update modules/diagnostics.py

Browse files
Files changed (1) hide show
  1. modules/diagnostics.py +3 -6
modules/diagnostics.py CHANGED
@@ -6,7 +6,7 @@ from datetime import datetime
6
 
7
  def register_module(app, client, username):
8
  """Register diagnostics module with FastAPI app"""
9
- router = APIRouter()
10
 
11
  @router.get("/diagnostics/health")
12
  async def diagnostics_health():
@@ -22,7 +22,7 @@ def register_module(app, client, username):
22
  "system": {
23
  "cpu_usage": cpu,
24
  "memory_used": memory.percent,
25
- "memory_available": round(memory.available / (1024**3), 2), # GB
26
  "timestamp": datetime.now().isoformat()
27
  }
28
  }
@@ -37,12 +37,9 @@ def register_module(app, client, username):
37
  async def full_diagnostics():
38
  """Complete system diagnostics"""
39
  try:
40
- # Direct implementation without circular import
41
  cpu = psutil.cpu_percent()
42
  memory = psutil.virtual_memory()
43
  disk = psutil.disk_usage('/')
44
-
45
- # Check if app.py is running
46
  app_running = any('app.py' in p.info().get('cmdline', []) for p in psutil.process_iter(['cmdline']))
47
 
48
  return {
@@ -83,8 +80,8 @@ def register_module(app, client, username):
83
 
84
  app.include_router(router)
85
  print("✅ Diagnostics module registered with FastAPI")
 
86
 
87
- # Export function for direct imports
88
  async def get_basic_metrics():
89
  """Get basic system metrics"""
90
  try:
 
6
 
7
  def register_module(app, client, username):
8
  """Register diagnostics module with FastAPI app"""
9
+ router = APIRouter(prefix="/system")
10
 
11
  @router.get("/diagnostics/health")
12
  async def diagnostics_health():
 
22
  "system": {
23
  "cpu_usage": cpu,
24
  "memory_used": memory.percent,
25
+ "memory_available": round(memory.available / (1024**3), 2),
26
  "timestamp": datetime.now().isoformat()
27
  }
28
  }
 
37
  async def full_diagnostics():
38
  """Complete system diagnostics"""
39
  try:
 
40
  cpu = psutil.cpu_percent()
41
  memory = psutil.virtual_memory()
42
  disk = psutil.disk_usage('/')
 
 
43
  app_running = any('app.py' in p.info().get('cmdline', []) for p in psutil.process_iter(['cmdline']))
44
 
45
  return {
 
80
 
81
  app.include_router(router)
82
  print("✅ Diagnostics module registered with FastAPI")
83
+ return {"status": "registered"}
84
 
 
85
  async def get_basic_metrics():
86
  """Get basic system metrics"""
87
  try: