fixes
This commit is contained in:
16
app/sbin/api
16
app/sbin/api
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
from fastapi import FastAPI, HTTPException, Depends, Response
|
||||
from fastapi.security.api_key import APIKeyHeader
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.responses import RedirectResponse, PlainTextResponse
|
||||
from pydantic import BaseModel
|
||||
import psutil
|
||||
import sqlite3
|
||||
@@ -14,6 +14,8 @@ import json
|
||||
import re
|
||||
from collections import deque
|
||||
import time
|
||||
from pathlib import Path
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
||||
@@ -277,6 +279,18 @@ def list_images():
|
||||
images = run_command(["docker", "images", "--format", "{{.Repository}}:{{.Tag}}"])
|
||||
return {"images": images.split("\n")}
|
||||
|
||||
@app.get("/system/cpu", dependencies=[Depends(verify_api_key)])
|
||||
def get_cpu_log():
|
||||
CPU_LOG_PATH = Path("/4server/data/log/cpu.log")
|
||||
if not CPU_LOG_PATH.exists():
|
||||
raise HTTPException(status_code=404, detail="CPU log file not found")
|
||||
|
||||
try:
|
||||
with CPU_LOG_PATH.open("r") as f:
|
||||
content = f.read()
|
||||
return PlainTextResponse(content)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error reading CPU log: {e}")
|
||||
|
||||
@app.get("/system/info", dependencies=[Depends(verify_api_key)])
|
||||
def get_system_info():
|
||||
|
||||
Reference in New Issue
Block a user