diff --git a/websiteFunctions/templates/websiteFunctions/website.html b/websiteFunctions/templates/websiteFunctions/website.html index 7fd02f0db..52166d631 100644 --- a/websiteFunctions/templates/websiteFunctions/website.html +++ b/websiteFunctions/templates/websiteFunctions/website.html @@ -1486,6 +1486,69 @@ {% endif %} + + {% if resource_limits %} +
+
+ + + + {% trans "Resource Limits" %} +
+
+ {% if resource_limits.cpu %} +
+
+ +
+
{% trans "CPU" %}
+
{{ resource_limits.cpu }}%
+
{% trans "CPU cores allocated" %}
+
+ {% endif %} + + {% if resource_limits.memory %} +
+
+ +
+
{% trans "Memory" %}
+
{{ resource_limits.memory }}
+
{% trans "RAM limit" %}
+
+ {% endif %} + + {% if resource_limits.io %} +
+
+ +
+
{% trans "I/O" %}
+
{{ resource_limits.io }}
+
{% trans "Disk I/O limit" %}
+
+ {% endif %} + + {% if resource_limits.tasks %} +
+
+ +
+
{% trans "Processes" %}
+
{{ resource_limits.tasks }}
+
{% trans "Max processes" %}
+
+ {% endif %} +
+
+

+ + {% trans "These are the actual resource limits applied to this website. Limits are enforced at the system level using OpenLiteSpeed cgroups." %} +

+
+
+ {% endif %} +
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index c82e5d70b..5dd390506 100644 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -3700,6 +3700,44 @@ context /cyberpanel_suspension_page.html { except Exception as e: CyberCPLogFileWriter.writeLog(f"Failed to ensure fastapi_ssh_server is running: {e}") + # Fetch actual resource limits from lscgctl command if they exist + Data['resource_limits'] = None + try: + import subprocess + lscgctl_path = '/usr/local/lsws/lsns/bin/lscgctl' + if os.path.exists(lscgctl_path): + # Get the website username + username = website.exsysUser + + # Run lscgctl list-user command + result = subprocess.run( + [lscgctl_path, 'list-user', username], + capture_output=True, + text=True, + timeout=5 + ) + + if result.returncode == 0 and result.stdout.strip(): + # Parse JSON output + import json + limits_data = json.loads(result.stdout.strip()) + + # Find the user's limits (key is UID) + for uid, user_limits in limits_data.items(): + if user_limits.get('name') == username: + # Extract and format the limits for display + Data['resource_limits'] = { + 'cpu': user_limits.get('cpu', ''), + 'memory': user_limits.get('mem', ''), + 'io': user_limits.get('io', ''), + 'tasks': user_limits.get('tasks', ''), + 'iops': user_limits.get('iops', '') + } + break + except Exception as e: + # Silently fail - resource limits are optional + CyberCPLogFileWriter.writeToFile(f"Could not fetch resource limits for {self.domain}: {str(e)}") + proc = httpProc(request, 'websiteFunctions/website.html', Data) return proc.render() else: