fix attributes
This commit is contained in:
21
main.py
21
main.py
@@ -22,10 +22,6 @@ else:
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
cpu_normal = True
|
||||
ram_normal = True
|
||||
disk_normal = True
|
||||
|
||||
|
||||
SessionLocal = sessionmaker(bind=engine)
|
||||
Base = declarative_base()
|
||||
@@ -143,17 +139,22 @@ def get_info():
|
||||
db.close()
|
||||
raise HTTPException(status_code=404, detail="Limits not found")
|
||||
delta_seconds = int(time.time() - start_time)
|
||||
cpu_percent = psutil.cpu_percent(interval=0.5)
|
||||
ram_percent = psutil.virtual_memory().percent
|
||||
disk_percent = psutil.disk_usage('/').percent
|
||||
|
||||
|
||||
system_information = Info(
|
||||
uptime=datetime.datetime.now() - datetime.timedelta(seconds=delta_seconds),
|
||||
cpu=psutil.cpu_percent(interval=0.5),
|
||||
ram=psutil.virtual_memory().percent,
|
||||
disk=psutil.disk_usage('/').percent,
|
||||
cpu=cpu_percent,
|
||||
ram=ram_percent,
|
||||
disk=disk_percent,
|
||||
cpu_threshold=limits.cpu_threshold,
|
||||
ram_threshold=limits.ram_threshold,
|
||||
disk_threshold=limits.disk_threshold,
|
||||
cpu_normal=cpu_normal,
|
||||
ram_normal=ram_normal,
|
||||
disk_normal=disk_normal
|
||||
cpu_normal= cpu_percent <= limits.cpu_threshold,
|
||||
ram_normal=ram_percent <= limits.cpu_threshold,
|
||||
disk_normal=disk_percent <= limits.cpu_threshold,
|
||||
)
|
||||
print(system_information)
|
||||
return system_information
|
||||
|
||||
Reference in New Issue
Block a user