feat: show stats of a zun container

Show stats of a zun container

Change-Id: I508a97d1a86217a590ccb624a0009cc44daef95f
This commit is contained in:
xusongfu 2022-08-02 14:26:43 +08:00
parent 37885d343d
commit 251a353e98
5 changed files with 63 additions and 5 deletions

View File

@ -27,12 +27,10 @@ export class ZunClient extends Base {
get resources() { get resources() {
return [ return [
{ {
name: 'capsules',
key: 'capsules', key: 'capsules',
responseKey: 'capsule', responseKey: 'capsule',
}, },
{ {
name: 'containers',
key: 'containers', key: 'containers',
responseKey: 'container', responseKey: 'container',
extendOperations: [ extendOperations: [
@ -69,14 +67,17 @@ export class ZunClient extends Base {
method: 'post', method: 'post',
}, },
], ],
subResources: [
{
key: 'stats',
},
],
}, },
{ {
name: 'hosts',
key: 'hosts', key: 'hosts',
responseKey: 'host', responseKey: 'host',
}, },
{ {
name: 'quotas',
key: 'quotas', key: 'quotas',
}, },
]; ];

View File

@ -191,6 +191,7 @@
"Average PGs per OSD": "Average PGs per OSD", "Average PGs per OSD": "Average PGs per OSD",
"Awaiting Transfer": "Awaiting Transfer", "Awaiting Transfer": "Awaiting Transfer",
"Azerbaijan": "Azerbaijan", "Azerbaijan": "Azerbaijan",
"BLOCK I/O(B)": "BLOCK I/O(B)",
"Back": "Back", "Back": "Back",
"Back End": "Back End", "Back End": "Back End",
"Back to Home": "Back to Home", "Back to Home": "Back to Home",
@ -269,6 +270,7 @@
"COE": "COE", "COE": "COE",
"COE Version": "COE Version", "COE Version": "COE Version",
"CPU": "CPU", "CPU": "CPU",
"CPU %": "CPU %",
"CPU (Core)": "CPU (Core)", "CPU (Core)": "CPU (Core)",
"CPU Arch": "CPU Arch", "CPU Arch": "CPU Arch",
"CPU Cores": "CPU Cores", "CPU Cores": "CPU Cores",
@ -1357,6 +1359,9 @@
"MAC Address": "MAC Address", "MAC Address": "MAC Address",
"MAC Learning State": "MAC Learning State", "MAC Learning State": "MAC Learning State",
"MAPRFS": "MAPRFS", "MAPRFS": "MAPRFS",
"MEM %": "MEM %",
"MEM LIMIT(MiB)": "MEM LIMIT(MiB)",
"MEM USAGE(MiB)": "MEM USAGE(MiB)",
"MTU": "MTU", "MTU": "MTU",
"Mac Address": "Mac Address", "Mac Address": "Mac Address",
"MacVTap": "MacVTap", "MacVTap": "MacVTap",
@ -1471,6 +1476,7 @@
"MySQL Actions": "MySQL Actions", "MySQL Actions": "MySQL Actions",
"Myanmar": "Myanmar", "Myanmar": "Myanmar",
"N/A": "N/A", "N/A": "N/A",
"NET I/O(B)": "NET I/O(B)",
"NFS": "NFS", "NFS": "NFS",
"NOOP": "NOOP", "NOOP": "NOOP",
"NUMA Node": "NUMA Node", "NUMA Node": "NUMA Node",
@ -2152,6 +2158,7 @@
"Startup Parameters": "Startup Parameters", "Startup Parameters": "Startup Parameters",
"State": "State", "State": "State",
"Static Routes": "Static Routes", "Static Routes": "Static Routes",
"Stats Information": "Stats Information",
"Status": "Status", "Status": "Status",
"Status Code": "Status Code", "Status Code": "Status Code",
"Status Detail": "Status Detail", "Status Detail": "Status Detail",

View File

@ -191,6 +191,7 @@
"Average PGs per OSD": "每个OSD平均PG数量", "Average PGs per OSD": "每个OSD平均PG数量",
"Awaiting Transfer": "等待转让", "Awaiting Transfer": "等待转让",
"Azerbaijan": "阿塞拜疆", "Azerbaijan": "阿塞拜疆",
"BLOCK I/O(B)": "块 I/O(B)",
"Back": "返回", "Back": "返回",
"Back End": "后端", "Back End": "后端",
"Back to Home": "返回首页", "Back to Home": "返回首页",
@ -269,6 +270,7 @@
"COE": "COE", "COE": "COE",
"COE Version": "COE版本", "COE Version": "COE版本",
"CPU": "CPU", "CPU": "CPU",
"CPU %": "CPU使用率(%)",
"CPU (Core)": "CPU (核)", "CPU (Core)": "CPU (核)",
"CPU Arch": "CPU架构", "CPU Arch": "CPU架构",
"CPU Cores": "CPU核数", "CPU Cores": "CPU核数",
@ -1357,6 +1359,9 @@
"MAC Address": "MAC地址", "MAC Address": "MAC地址",
"MAC Learning State": "MAC学习状态", "MAC Learning State": "MAC学习状态",
"MAPRFS": "", "MAPRFS": "",
"MEM %": "内存使用率(%)",
"MEM LIMIT(MiB)": "总内存(MiB)",
"MEM USAGE(MiB)": "已用内存(MiB)",
"MTU": "", "MTU": "",
"Mac Address": "Mac地址", "Mac Address": "Mac地址",
"MacVTap": "", "MacVTap": "",
@ -1471,6 +1476,7 @@
"MySQL Actions": "", "MySQL Actions": "",
"Myanmar": "缅甸", "Myanmar": "缅甸",
"N/A": "", "N/A": "",
"NET I/O(B)": "网络 I/O(B)",
"NFS": "", "NFS": "",
"NOOP": "", "NOOP": "",
"NUMA Node": "NUMA节点", "NUMA Node": "NUMA节点",
@ -2152,6 +2158,7 @@
"Startup Parameters": "启动参数", "Startup Parameters": "启动参数",
"State": "状态", "State": "状态",
"Static Routes": "静态路由", "Static Routes": "静态路由",
"Stats Information": "统计信息",
"Status": "状态", "Status": "状态",
"Status Code": "状态码", "Status Code": "状态码",
"Status Detail": "状态详情", "Status Detail": "状态详情",

View File

@ -20,7 +20,7 @@ import { isEmpty } from 'lodash';
export class BaseDetail extends Base { export class BaseDetail extends Base {
get leftCards() { get leftCards() {
const cards = [this.baseInfoCard, this.miscellaneousCard]; const cards = [this.baseInfoCard, this.statsCard, this.miscellaneousCard];
return cards; return cards;
} }
@ -170,6 +170,43 @@ export class BaseDetail extends Base {
options, options,
}; };
} }
get statsCard() {
const options = [
{
label: t('BLOCK I/O(B)'),
dataIndex: 'BLOCK I/O(B)',
},
{
label: t('NET I/O(B)'),
dataIndex: 'NET I/O(B)',
},
{
label: t('CPU %'),
dataIndex: 'CPU %',
render: (value = 0) => value.toFixed(4),
},
{
label: t('MEM LIMIT(MiB)'),
dataIndex: 'MEM LIMIT(MiB)',
},
{
label: t('MEM USAGE(MiB)'),
dataIndex: 'MEM USAGE(MiB)',
render: (value = 0) => value.toFixed(4),
},
{
label: t('MEM %'),
dataIndex: 'MEM %',
render: (value = 0) => value.toFixed(4),
},
];
return {
title: t('Stats Information'),
options,
};
}
} }
export default inject('rootStore')(observer(BaseDetail)); export default inject('rootStore')(observer(BaseDetail));

View File

@ -75,6 +75,12 @@ export class ContainersStore extends Base {
async execute(id, data) { async execute(id, data) {
return this.client.execute(id, data); return this.client.execute(id, data);
} }
async detailDidFetch(item) {
const { uuid } = item;
const stats = (await this.client.stats.list(uuid)) || {};
return { ...item, ...stats };
}
} }
const globalContainersStore = new ContainersStore(); const globalContainersStore = new ContainersStore();