-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (28 loc) · 759 Bytes
/
main.py
File metadata and controls
32 lines (28 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from fastapi import FastAPI
from datetime import datetime
import psutil
app = FastAPI(
title="Python System Monitor API",
description="API simples para monitoramento de recursos do sistema usando FastAPI e psutil",
version="1.0.0"
)
@app.get("/")
def root():
return {
"message": "API de monitoramento funcionando",
"timestamp": datetime.now()
}
@app.get("/health")
def health():
return {
"status": "ok",
"timestamp": datetime.now()
}
@app.get("/metrics")
def metrics():
return {
"cpu_percent": psutil.cpu_percent(interval=1),
"memory_percent": psutil.virtual_memory().percent,
"disk_percent": psutil.disk_usage("/").percent,
"timestamp": datetime.now()
}