feat: Initial commit of existing overlay files

This commit is contained in:
2025-10-31 09:39:07 +01:00
commit d8bc68c7b5
9 changed files with 486 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>System Monitor</title>
<style>
body {
font-family: sans-serif;
color: white;
background-color: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 10px;
}
</style>
</head>
<body>
<h1>System Monitor</h1>
<div>
<h2>CPU Usage</h2>
<p id="cpu-usage"></p>
</div>
<div>
<h2>Memory Usage</h2>
<p id="memory-usage"></p>
</div>
<script>
function fetchStats() {
fetch('http://localhost:8000/stats')
.then(response => response.json())
.then(data => {
document.getElementById('cpu-usage').textContent = `${data.cpu_percent}%`;
document.getElementById('memory-usage').textContent = `${data.memory_percent}%`;
})
.catch(error => console.error('Error fetching system stats:', error));
}
// Fetch stats every 2 seconds
setInterval(fetchStats, 2000);
// Initial fetch
fetchStats();
</script>
</body>
</html>

View File

@@ -0,0 +1,25 @@
import psutil
import http.server
import socketserver
import json
PORT = 8000
class SystemInfoHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/stats':
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
stats = {
'cpu_percent': psutil.cpu_percent(interval=1),
'memory_percent': psutil.virtual_memory().percent
}
self.wfile.write(json.dumps(stats).encode('utf-8'))
else:
super().do_GET()
with socketserver.TCPServer(('', PORT), SystemInfoHandler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()