show n8n version

This commit is contained in:
usmannasir
2025-04-12 23:51:50 +05:00
parent 1e4a5924b0
commit ce3f7dca5f
2 changed files with 19 additions and 25 deletions

View File

@@ -740,30 +740,27 @@ services:
# Calculate CPU percentage properly with safeguards # Calculate CPU percentage properly with safeguards
try: try:
# Get the CPU stats cpu_stats = stats.get("cpu_stats", {})
cpu_stats = stats["cpu_stats"] precpu_stats = stats.get("precpu_stats", {})
precpu_stats = stats["precpu_stats"]
# Calculate CPU delta # Get CPU usage values
cpu_delta = float(cpu_stats["cpu_usage"]["total_usage"]) - float(precpu_stats["cpu_usage"]["total_usage"]) cpu_total = float(cpu_stats.get("cpu_usage", {}).get("total_usage", 0))
precpu_total = float(precpu_stats.get("cpu_usage", {}).get("total_usage", 0))
# Calculate system CPU delta # Get system CPU values
system_delta = float(cpu_stats["system_cpu_usage"]) - float(precpu_stats["system_cpu_usage"]) sys_total = float(cpu_stats.get("system_cpu_usage", 0))
presys_total = float(precpu_stats.get("system_cpu_usage", 0))
# Get number of CPUs cpu_delta = cpu_total - precpu_total
online_cpus = cpu_stats.get("online_cpus", len(cpu_stats["cpu_usage"]["percpu_usage"])) system_delta = sys_total - presys_total
cpu_usage = 0.0 cpu_usage = 0.0
if system_delta > 0 and cpu_delta >= 0: if system_delta > 0:
# Calculate percentage of total CPU used # Calculate percentage of single CPU
cpu_usage = (cpu_delta / system_delta) * online_cpus * 100.0 cpu_usage = (cpu_delta / system_delta) * 100.0
# Cap at 100% per core # Ensure it's a reasonable value
cpu_usage = min(cpu_usage, online_cpus * 100.0) cpu_usage = max(0.0, min(100.0, cpu_usage))
# Ensure we return a valid number
if cpu_usage < 0 or math.isnan(cpu_usage):
cpu_usage = 0.0
except Exception as e: except Exception as e:
logging.writeToFile(f"CPU calculation error: {str(e)}") logging.writeToFile(f"CPU calculation error: {str(e)}")

View File

@@ -99,14 +99,11 @@ app.controller('ListDockersitecontainer', function ($scope, $http) {
$scope.ContainerList[i].memoryUsage = formatBytes(memoryBytes); $scope.ContainerList[i].memoryUsage = formatBytes(memoryBytes);
$scope.ContainerList[i].memoryUsagePercent = (memoryBytes / (1024 * 1024 * 1024)) * 100; $scope.ContainerList[i].memoryUsagePercent = (memoryBytes / (1024 * 1024 * 1024)) * 100;
// Ensure CPU usage is a valid number and cap it at 800% (8 cores at 100% each) // CPU Usage - ensure it's a valid number and keep original value
var cpuUsage = parseFloat(containerInfo.cpu_usage); var cpuUsage = parseFloat(containerInfo.cpu_usage);
if (isNaN(cpuUsage) || cpuUsage < 0) { $scope.ContainerList[i].cpuUsagePercent = isNaN(cpuUsage) ? 0 : cpuUsage;
cpuUsage = 0;
} else if (cpuUsage > 800) { console.log('Container CPU Usage:', containerInfo.name, cpuUsage);
cpuUsage = 800;
}
$scope.ContainerList[i].cpuUsagePercent = cpuUsage;
// Network & Ports // Network & Ports
$scope.ContainerList[i].ports = containerInfo.ports; $scope.ContainerList[i].ports = containerInfo.ports;