diff --git a/__pycache__/main.cpython-313.pyc b/__pycache__/main.cpython-313.pyc index 987dcb2..1046649 100644 Binary files a/__pycache__/main.cpython-313.pyc and b/__pycache__/main.cpython-313.pyc differ diff --git a/main.py b/main.py index 34dcd1e..d775a54 100644 --- a/main.py +++ b/main.py @@ -107,7 +107,7 @@ def check_and_log_overages(): db.add(event) db.commit() db.close() - time.sleep(10) + time.sleep(60) threading.Thread(target=check_and_log_overages, daemon=True).start() diff --git a/wall_messages.db b/wall_messages.db index 6b74bc4..30e7fd9 100644 Binary files a/wall_messages.db and b/wall_messages.db differ diff --git a/webroot/index.html b/webroot/index.html index cd0f6b5..fbe4d42 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -236,27 +236,49 @@ const cpu = parseInt(document.getElementById('cpuLimit').value, 10); const ram = parseInt(document.getElementById('ramLimit').value, 10); const disk = parseInt(document.getElementById('diskLimit').value, 10); - console.log(cpu, ram, disk); const requestBody = JSON.stringify({ cpu_threshold: cpu, ram_threshold: ram, disk_threshold: disk }); console.log(requestBody); - await fetch('/limits', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: requestBody + }).then(async (response) => { + if (response.ok) { + try { + const limits = await response.json(); + document.getElementById('cpuLimit').value = limits.cpu; + document.getElementById('ramLimit').value = limits.ram; + document.getElementById('diskLimit').value = limits.disk; + document.getElementById('cpuLimitValue').textContent = limits.cpu + '%'; + document.getElementById('ramLimitValue').textContent = limits.ram + '%'; + document.getElementById('diskLimitValue').textContent = limits.disk + '%'; + } catch (e) { + console.error('Error fetching limits:', e); + // fallback: set to 50 if error + document.getElementById('cpuLimit').value = 50; + document.getElementById('ramLimit').value = 50; + document.getElementById('diskLimit').value = 50; + document.getElementById('cpuLimitValue').textContent = '50%'; + document.getElementById('ramLimitValue').textContent = '50%'; + document.getElementById('diskLimitValue').textContent = '50%'; + } + } else { + console.error('Error updating limits:', response.statusText); + } + }).catch(error => { + console.error('Error updating limits:', error); }); }; window.onload = function() { fetchStats(); - setInterval(fetchStats, 5000); // Fetch every 5 seconds + setInterval(fetchStats, 15000); // Fetch every 5 seconds fetchLimits(); setupLimitSliders(); - setInterval(fetchLimits, 5000); // Fetch limits every 5 seconds };