# keep track of image digests
seen_digests = {} # type: Dict[str, List[str]]
- # keep track of memory usage we've seen
+ # keep track of memory and cpu usage we've seen
seen_memusage = {} # type: Dict[str, int]
- seen_cpuperc = {} # type: Dict[str, int]
+ seen_cpuperc = {} # type: Dict[str, str]
out, err, code = call(
ctx,
[container_path, 'stats', '--format', '{{.ID}},{{.MemUsage}}', '--no-stream'],
verbosity=CallVerbosity.DEBUG
)
seen_memusage_cid_len, seen_memusage = _parse_mem_usage(code, out)
-
+
out, err, code = call(
ctx,
[container_path, 'stats', '--format', '{{.ID}},{{.CPUPerc}}', '--no-stream'],
os.path.join(data_dir, fsid, j, 'unit.image'))
val['configured'] = get_file_timestamp(
os.path.join(data_dir, fsid, j, 'unit.configured'))
-
- logger.info("helo %s", val)
ls.append(val)
- logger.info("waah %s", ls)
return ls
pass
return seen_memusage_cid_len, seen_memusage
-def _parse_cpu_perc(code: int, out: str):
+
+def _parse_cpu_perc(code: int, out: str) -> Tuple[int, Dict[str, str]]:
seen_cpuperc = {}
seen_cpuperc_cid_len = 0
if not code:
pass
return seen_cpuperc_cid_len, seen_cpuperc
+
def get_daemon_description(ctx, fsid, name, detail=False, legacy_dir=None):
# type: (CephadmContext, str, str, bool, Optional[str]) -> Dict[str, str]
@mock.patch('cephadm.call')
@mock.patch('cephadm.systemd_target_state')
def test_enter_failure_2(self, _target_state, _call, _listdir):
- _call.side_effect = [('', '', 0), ('', '', 999)]
+ _call.side_effect = [('', '', 0), ('', '', 999), ('', '', 0), ('', '', 999)]
_target_state.return_value = True
ctx: cd.CephadmContext = cd.cephadm_init_ctx(
['host-maintenance', 'enter', '--fsid', TestMaintenance.fsid])
@mock.patch('cephadm.systemd_target_state')
@mock.patch('cephadm.target_exists')
def test_exit_failure_2(self, _target_exists, _target_state, _call, _listdir):
- _call.side_effect = [('', '', 0), ('', '', 999)]
+ _call.side_effect = [('', '', 0), ('', '', 999), ('', '', 0), ('', '', 999)]
_target_state.return_value = False
_target_exists.return_value = True
ctx: cd.CephadmContext = cd.cephadm_init_ctx(
# invalid IPv6 and valid subnets list
with pytest.raises(Exception):
- rc = cd.ip_in_sublets('fe80:2030:31:24', 'fe80::/64')
+ rc = cd.ip_in_sublets('fe80:2030:31:24', 'fe80::/64')
\ No newline at end of file
</li>
</ul>
<ng-template #noEventsAvailable>
- <div *ngIf="events?.length === 0">
+ <div *ngIf="events?.length === 0"
+ class="list-group-item">
<span>No data available</span>
</div>
</ng-template>
</ng-template>
+
+<ng-template #serviceDaemonDetailsTpl>
+ <cd-table *ngIf="hasOrchestrator"
+ #daemonsTable
+ [data]="daemons"
+ selectionType="single"
+ [columns]="columns"
+ columnMode="flex"
+ identifier="daemon_name"
+ (fetchData)="getDaemons($event)"
+ (updateSelection)="updateSelection($event)">
+ <cd-table-actions id="service-daemon-list-actions"
+ class="table-actions"
+ [selection]="selection"
+ [permission]="permissions.hosts"
+ [tableActions]="tableActions">
+ </cd-table-actions>
+ </cd-table>
+</ng-template>
+
+<ng-template #cpuTpl
+ let-row="row">
+ <cd-usage-bar [total]="total"
+ [calculatePerc]="false"
+ [used]="row.cpu_percentage"
+ [isBinary]="false"
+ [warningThreshold]="warningThreshold"
+ [errorThreshold]="errorThreshold">
+ </cd-usage-bar>
+</ng-template>
+
daemon_type: 'osd',
daemon_name: 'osd.3',
version: '15.1.0-1174-g16a11f7',
+ memory_usage: '17.7',
+ cpu_percentage: '3.54%',
status: 1,
status_desc: 'running',
last_refresh: '2020-02-25T04:33:26.465699',
daemon_type: 'osd',
daemon_name: 'osd.4',
version: '15.1.0-1174-g16a11f7',
+ memory_usage: '17.7',
+ cpu_percentage: '3.54%',
status: 1,
status_desc: 'running',
last_refresh: '2020-02-25T04:33:26.465822',
daemon_type: 'osd',
daemon_name: 'osd.5',
version: '15.1.0-1174-g16a11f7',
+ memory_usage: '17.7',
+ cpu_percentage: '3.54%',
status: 1,
status_desc: 'running',
last_refresh: '2020-02-25T04:33:26.465886',
daemon_name: 'mon.a',
daemon_type: 'mon',
version: '15.1.0-1174-g16a11f7',
+ memory_usage: '17.7',
+ cpu_percentage: '3.54%',
status: 1,
status_desc: 'running',
last_refresh: '2020-02-25T04:33:26.465886',
import { OrchestratorService } from '~/app/shared/api/orchestrator.service';
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
import { TableComponent } from '~/app/shared/datatable/table/table.component';
-import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
import { Icons } from '~/app/shared/enum/icons.enum';
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
import { CdTableAction } from '~/app/shared/models/cd-table-action';
@ViewChild('listTpl', { static: true })
listTpl: TemplateRef<any>;
+ @ViewChild('cpuTpl', { static: true })
+ cpuTpl: TemplateRef<any>;
+
@ViewChildren('daemonsTable')
daemonsTableTpls: QueryList<TemplateRef<TableComponent>>;
@Input()
flag?: string;
+ total = 100;
+
+ warningThreshold = 0.8;
+
+ errorThreshold = 0.9;
+
icons = Icons;
daemons: Daemon[] = [];
private cephServiceService: CephServiceService,
private orchService: OrchestratorService,
private relativeDatePipe: RelativeDatePipe,
- private dimlessBinaryPipe: DimlessBinaryPipe,
+ private dimlessBinary: DimlessBinaryPipe,
public actionLabels: ActionLabelsI18n,
private authStorageService: AuthStorageService,
private daemonService: DaemonService,
flexGrow: 1,
filterable: true
},
- {
- name: $localize`Container ID`,
- prop: 'container_id',
- flexGrow: 2,
- filterable: true,
- cellTransformation: CellTemplate.truncate,
- customTemplateConfig: {
- length: 12
- }
- },
- {
- name: $localize`Container Image name`,
- prop: 'container_image_name',
- flexGrow: 3,
- filterable: true
- },
- {
- name: $localize`Container Image ID`,
- prop: 'container_image_id',
- flexGrow: 2,
- filterable: true,
- cellTransformation: CellTemplate.truncate,
- customTemplateConfig: {
- length: 12
- }
- },
{
name: $localize`Version`,
prop: 'version',
flexGrow: 1
},
{
- name: $localize`Daemon Events`,
- prop: 'events',
- flexGrow: 5,
- cellTemplate: this.listTpl
+ name: $localize`CPU Usage`,
+ prop: 'cpu_percentage',
+ flexGrow: 1,
+ cellTemplate: this.cpuTpl
},
{
name: $localize`Memory Usage`,
prop: 'memory_usage',
flexGrow: 1,
- pipe: this.dimlessBinaryPipe
+ pipe: this.dimlessBinary,
+ cellClass: 'text-right'
},
{
- name: $localize`CPU %`,
- prop: 'cpu_percentage',
- flexGrow: 1
+ name: $localize`Daemon Events`,
+ prop: 'events',
+ flexGrow: 2,
+ cellTemplate: this.listTpl
}
];
<td class="text-left">Used: </td>
<td class="text-right"><strong> {{ isBinary ? (used | dimlessBinary) : (used | dimless) }}</strong></td>
</tr>
- <tr>
+ <tr *ngIf="calculatePerc">
<td class="text-left">Free: </td>
<td class="'text-right"><strong>{{ isBinary ? (total - used | dimlessBinary) : (total - used | dimless) }}</strong></td>
</tr>
@Input()
total: number;
@Input()
- used: number;
+ used: any;
@Input()
warningThreshold: number;
@Input()
isBinary = true;
@Input()
decimals = 0;
+ @Input()
+ calculatePerc = true;
usedPercentage: number;
freePercentage: number;
ngOnChanges() {
- this.usedPercentage = this.total > 0 ? (this.used / this.total) * 100 : 0;
- this.freePercentage = 100 - this.usedPercentage;
+ if (this.calculatePerc) {
+ this.usedPercentage = this.total > 0 ? (this.used / this.total) * 100 : 0;
+ this.freePercentage = 100 - this.usedPercentage;
+ } else {
+ if (this.used) {
+ this.used = this.used.slice(0, -1);
+ this.usedPercentage = Number(this.used);
+ this.freePercentage = 100 - this.usedPercentage;
+ } else {
+ this.usedPercentage = 0;
+ }
+ }
}
}