mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
core: include peak memory in unit_log_resources()
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
@@ -2326,6 +2326,7 @@ static int unit_log_resources(Unit *u) {
|
||||
size_t n_message_parts = 0, n_iovec = 0;
|
||||
char* message_parts[1 + 2 + 2 + 1], *t;
|
||||
nsec_t nsec = NSEC_INFINITY;
|
||||
uint64_t memory_peak = UINT64_MAX;
|
||||
int r;
|
||||
const char* const ip_fields[_CGROUP_IP_ACCOUNTING_METRIC_MAX] = {
|
||||
[CGROUP_IP_INGRESS_BYTES] = "IP_METRIC_INGRESS_BYTES",
|
||||
@@ -2369,6 +2370,24 @@ static int unit_log_resources(Unit *u) {
|
||||
nsec > NOTICEWORTHY_CPU_NSEC);
|
||||
}
|
||||
|
||||
(void) unit_get_memory_peak(u, &memory_peak);
|
||||
if (memory_peak != UINT64_MAX) {
|
||||
/* Format peak memory for inclusion in the structured log message */
|
||||
if (asprintf(&t, "MEMORY_PEAK=%" PRIu64, memory_peak) < 0) {
|
||||
r = log_oom();
|
||||
goto finish;
|
||||
}
|
||||
iovec[n_iovec++] = IOVEC_MAKE_STRING(t);
|
||||
|
||||
/* Format peak memory for inclusion in the human language message string */
|
||||
t = strjoin(FORMAT_BYTES(memory_peak), " memory peak");
|
||||
if (!t) {
|
||||
r = log_oom();
|
||||
goto finish;
|
||||
}
|
||||
message_parts[n_message_parts++] = t;
|
||||
}
|
||||
|
||||
for (CGroupIOAccountingMetric k = 0; k < _CGROUP_IO_ACCOUNTING_METRIC_MAX; k++) {
|
||||
uint64_t value = UINT64_MAX;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user