});
describe('preparePgStatus', () => {
+ const calcPercentage = (data) => Math.round((data / 10) * 100) || 0;
+
const expectedChart = (data: number[]) => ({
colors: [
{
]
}
],
- labels: ['Clean', 'Working', 'Warning', 'Unknown'],
+ labels: [
+ `Clean (${calcPercentage(data[0])}%)`,
+ `Working (${calcPercentage(data[1])}%)`,
+ `Warning (${calcPercentage(data[2])}%)`,
+ `Unknown (${calcPercentage(data[3])}%)`
+ ],
+ options: {},
dataset: [{ data: data }]
});
it('gets no data', () => {
- const chart = { dataset: [{}] };
- component.preparePgStatus(chart, { pg_info: {} });
+ const chart = { dataset: [{}], options: {} };
+ component.preparePgStatus(chart, {
+ pg_info: { pgs_per_osd: 0 }
+ });
expect(chart).toEqual(expectedChart([undefined, undefined, undefined, undefined]));
});
it('gets data from all categories', () => {
- const chart = { dataset: [{}] };
+ const chart = { dataset: [{}], options: {} };
component.preparePgStatus(chart, {
pg_info: {
+ pgs_per_osd: 10,
statuses: {
'clean+active+scrubbing+nonMappedState': 4,
'clean+active+scrubbing': 2,
import { HealthService } from '../../../shared/api/health.service';
import { Permissions } from '../../../shared/models/permissions';
+import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe';
import { AuthStorageService } from '../../../shared/services/auth-storage.service';
import {
FeatureTogglesMap$,
private authStorageService: AuthStorageService,
private pgCategoryService: PgCategoryService,
private featureToggles: FeatureTogglesService,
- private refreshIntervalService: RefreshIntervalService
+ private refreshIntervalService: RefreshIntervalService,
+ private dimlessBinary: DimlessBinaryPipe
) {
this.permissions = this.authStorageService.getPermissions();
this.enabledFeature$ = this.featureToggles.get();
const ratioLabels = [];
const ratioData = [];
- ratioLabels.push(this.i18n('Writes'));
+ const total =
+ this.healthData.client_perf.write_op_per_sec + this.healthData.client_perf.read_op_per_sec;
+ const calcPercentage = (status) =>
+ Math.round(((this.healthData.client_perf[status] || 0) / total) * 100);
+
+ ratioLabels.push(`${this.i18n('Writes')} (${calcPercentage('write_op_per_sec')}%)`);
ratioData.push(this.healthData.client_perf.write_op_per_sec);
- ratioLabels.push(this.i18n('Reads'));
+ ratioLabels.push(`${this.i18n('Reads')} (${calcPercentage('read_op_per_sec')}%)`);
ratioData.push(this.healthData.client_perf.read_op_per_sec);
chart.dataset[0].data = ratioData;
chart.options.cutoutPercentage = 65;
}
chart.labels = [
- `${this.i18n('Used')} (${percentUsed}%)`,
- `${this.i18n('Avail.')} (${percentAvailable}%)`
+ `${this.dimlessBinary.transform(data.df.stats.total_used_raw_bytes)} ${this.i18n(
+ 'Used'
+ )} (${percentUsed}%)`,
+ `${this.dimlessBinary.transform(
+ data.df.stats.total_bytes - data.df.stats.total_used_raw_bytes
+ )} ${this.i18n('Avail.')} (${percentAvailable}%)`
];
+
+ chart.options.title = {
+ display: true,
+ text: `${this.dimlessBinary.transform(data.df.stats.total_bytes)} total`,
+ position: 'bottom'
+ };
}
preparePgStatus(chart, data) {
const categoryPgAmount = {};
- chart.labels = [
- this.i18n('Clean'),
- this.i18n('Working'),
- this.i18n('Warning'),
- this.i18n('Unknown')
- ];
chart.colors = [
{
backgroundColor: [
chart.dataset[0].data = this.pgCategoryService
.getAllTypes()
.map((categoryType) => categoryPgAmount[categoryType]);
+
+ const calcPercentage = (status) =>
+ Math.round(((categoryPgAmount[status] || 0) / data.pg_info.pgs_per_osd) * 100) || 0;
+
+ chart.labels = [
+ `${this.i18n('Clean')} (${calcPercentage('clean')}%)`,
+ `${this.i18n('Working')} (${calcPercentage('working')}%)`,
+ `${this.i18n('Warning')} (${calcPercentage('warning')}%)`,
+ `${this.i18n('Unknown')} (${calcPercentage('unknown')}%)`
+ ];
}
isClientReadWriteChartShowable() {