mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(app): limit the docker API version supported by the frontend (#11855)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
4ba16f1b04
commit
6a8e6734f3
212 changed files with 4439 additions and 3281 deletions
136
app/react/docker/containers/queries/useContainerStats.ts
Normal file
136
app/react/docker/containers/queries/useContainerStats.ts
Normal file
|
@ -0,0 +1,136 @@
|
|||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
|
||||
import { buildDockerProxyUrl } from '../../proxy/queries/buildDockerProxyUrl';
|
||||
import { ContainerId } from '../types';
|
||||
|
||||
/**
|
||||
* This type is arbitrary and only defined based on what we use / observed from the API responses.
|
||||
*/
|
||||
export type ContainerStats = {
|
||||
name?: string;
|
||||
id?: string;
|
||||
read?: string;
|
||||
preread?: string;
|
||||
pids_stats?: {
|
||||
current?: number;
|
||||
limit?: number;
|
||||
};
|
||||
memory_stats?: MemoryStats;
|
||||
num_procs?: number;
|
||||
precpu_stats?: CpuStats;
|
||||
cpu_stats?: CpuStats;
|
||||
networks?: Record<string, NetworkStats>;
|
||||
blkio_stats?: BlkioStats;
|
||||
storage_stats?: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @param id
|
||||
* @returns
|
||||
*/
|
||||
export async function containerStats(
|
||||
environmentId: EnvironmentId,
|
||||
id: ContainerId
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
buildDockerProxyUrl(environmentId, 'containers', id, 'stats'),
|
||||
{ params: { stream: false } }
|
||||
);
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw parseAxiosError(err, 'Unable to retrieve container stats');
|
||||
}
|
||||
}
|
||||
|
||||
type BlkioStats = {
|
||||
io_service_bytes_recursive?: {
|
||||
major: number;
|
||||
minor: number;
|
||||
op: string;
|
||||
value: number;
|
||||
}[];
|
||||
io_serviced_recursive?: null;
|
||||
io_queue_recursive?: null;
|
||||
io_service_time_recursive?: null;
|
||||
io_wait_time_recursive?: null;
|
||||
io_merged_recursive?: null;
|
||||
io_time_recursive?: null;
|
||||
sectors_recursive?: null;
|
||||
};
|
||||
|
||||
type NetworkStats = {
|
||||
rx_bytes?: number;
|
||||
rx_packets?: number;
|
||||
rx_errors?: number;
|
||||
rx_dropped?: number;
|
||||
tx_bytes?: number;
|
||||
tx_packets?: number;
|
||||
tx_errors?: number;
|
||||
tx_dropped?: number;
|
||||
};
|
||||
|
||||
type MemoryStats = {
|
||||
privateworkingset?: number;
|
||||
usage?: number;
|
||||
stats?: MemoryStatsStats;
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
type MemoryStatsStats = {
|
||||
active_anon?: number;
|
||||
active_file?: number;
|
||||
anon?: number;
|
||||
anon_thp?: number;
|
||||
cache?: number;
|
||||
file?: number;
|
||||
file_dirty?: number;
|
||||
file_mapped?: number;
|
||||
file_writeback?: number;
|
||||
inactive_anon?: number;
|
||||
inactive_file?: number;
|
||||
kernel_stack?: number;
|
||||
pgactivate?: number;
|
||||
pgdeactivate?: number;
|
||||
pgfault?: number;
|
||||
pglazyfree?: number;
|
||||
pglazyfreed?: number;
|
||||
pgmajfault?: number;
|
||||
pgrefill?: number;
|
||||
pgscan?: number;
|
||||
pgsteal?: number;
|
||||
shmem?: number;
|
||||
slab?: number;
|
||||
slab_reclaimable?: number;
|
||||
slab_unreclaimable?: number;
|
||||
sock?: number;
|
||||
thp_collapse_alloc?: number;
|
||||
thp_fault_alloc?: number;
|
||||
unevictable?: number;
|
||||
workingset_activate?: number;
|
||||
workingset_nodereclaim?: number;
|
||||
workingset_refault?: number;
|
||||
};
|
||||
|
||||
type CpuUsage = {
|
||||
total_usage?: number;
|
||||
usage_in_kernelmode?: number;
|
||||
usage_in_usermode?: number;
|
||||
percpu_usage?: number[];
|
||||
};
|
||||
|
||||
type ThrottlingData = {
|
||||
periods?: number;
|
||||
throttled_periods?: number;
|
||||
throttled_time?: number;
|
||||
};
|
||||
|
||||
type CpuStats = {
|
||||
cpu_usage?: CpuUsage;
|
||||
system_cpu_usage?: number;
|
||||
online_cpus?: number;
|
||||
throttling_data?: ThrottlingData;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue