Skip to content

Commit

Permalink
[YUNIKORN-1175] Web UI should show node utilization as percentage (#75)
Browse files Browse the repository at this point in the history
Closes: #75
  • Loading branch information
craigcondit committed Apr 13, 2022
1 parent 8699b70 commit e3f7dc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/app/services/scheduler/scheduler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class SchedulerService {
this.formatResource(node['allocated'] as SchedulerResourceInfo),
this.formatResource(node['occupied'] as SchedulerResourceInfo),
this.formatResource(node['available'] as SchedulerResourceInfo),
this.formatResource(node['utilized'] as SchedulerResourceInfo),
this.formatPercent(node['utilized'] as SchedulerResourceInfo),
[]
);

Expand Down Expand Up @@ -315,4 +315,22 @@ export class SchedulerService {

return formatted.join(', ');
}

private formatPercent(resource: SchedulerResourceInfo): string {
const formatted = [];

if (resource && resource.memory !== undefined) {
formatted.push(`Memory: ${CommonUtil.formatPercent(resource.memory)}`);
} else {
formatted.push(`Memory: ${NOT_AVAILABLE}`);
}

if (resource && resource.vcore !== undefined) {
formatted.push(`CPU: ${CommonUtil.formatPercent(resource.vcore)}`);
} else {
formatted.push(`CPU: ${NOT_AVAILABLE}`);
}

return formatted.join(', ');
}
}
5 changes: 5 additions & 0 deletions src/app/utils/common.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export class CommonUtil {
return `${toValue.toFixed(1)} ${unit}`;
}

static formatPercent(value: number | string): string {
const toValue = +value;
return `${toValue.toFixed(0)}%`;
}

static isEmpty(arg: object | any[]): boolean {
return Object.keys(arg).length === 0;
}
Expand Down

0 comments on commit e3f7dc5

Please sign in to comment.