show n8n version

This commit is contained in:
usmannasir
2025-04-12 22:17:52 +05:00
parent b1acf76e61
commit e74c70b304
2 changed files with 11 additions and 3 deletions

View File

@@ -737,6 +737,14 @@ services:
# Fetch container stats
stats = container.stats(stream=False)
# Calculate CPU percentage properly
cpu_count = len(stats["cpu_stats"]["cpu_usage"]["percpu_usage"])
cpu_delta = float(stats["cpu_stats"]["cpu_usage"]["total_usage"]) - float(stats["precpu_stats"]["cpu_usage"]["total_usage"])
system_delta = float(stats["cpu_stats"]["system_cpu_usage"]) - float(stats["precpu_stats"]["system_cpu_usage"])
cpu_usage = 0.0
if system_delta > 0.0:
cpu_usage = (cpu_delta / system_delta) * 100.0 * cpu_count
dic = {
'id': container.short_id,
'name': container.name,
@@ -744,8 +752,8 @@ services:
'volumes': container.attrs['HostConfig']['Binds'] if 'HostConfig' in container.attrs else [],
'logs_50': container.logs(tail=50).decode('utf-8'),
'ports': container.attrs['HostConfig']['PortBindings'] if 'HostConfig' in container.attrs else {},
'memory': stats['memory_stats']['usage'],
'cpu' : stats['cpu_stats']['cpu_usage']['total_usage']
'memory_usage': stats['memory_stats'].get('usage', 0),
'cpu_usage': cpu_usage # Now sending the properly calculated percentage
}
return 1, dic

View File

@@ -98,7 +98,7 @@ app.controller('ListDockersitecontainer', function ($scope, $http) {
var memoryBytes = containerInfo.memory_usage;
$scope.ContainerList[i].memoryUsage = formatBytes(memoryBytes);
$scope.ContainerList[i].memoryUsagePercent = (memoryBytes / (1024 * 1024 * 1024)) * 100;
$scope.ContainerList[i].cpuUsagePercent = (containerInfo.cpu_usage / 10000000000) * 100;
$scope.ContainerList[i].cpuUsagePercent = containerInfo.cpu_usage;
// Network & Ports
$scope.ContainerList[i].ports = containerInfo.ports;