]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: show IO stats in --wait resource output
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Mar 2019 11:18:19 +0000 (12:18 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Apr 2019 12:25:44 +0000 (14:25 +0200)
src/run/run.c

index 56aa9aaee64d54f8e43ddb29ff211b77ad5f6aa9..18b46f2a40a4c762ad055bb3b5df8d6a888413c8 100644 (file)
@@ -930,6 +930,8 @@ typedef struct RunContext {
         uint64_t cpu_usage_nsec;
         uint64_t ip_ingress_bytes;
         uint64_t ip_egress_bytes;
+        uint64_t io_read_bytes;
+        uint64_t io_write_bytes;
         uint32_t exit_code;
         uint32_t exit_status;
 } RunContext;
@@ -975,6 +977,8 @@ static int run_context_update(RunContext *c, const char *path) {
                 { "CPUUsageNSec",                     "t", NULL, offsetof(RunContext, cpu_usage_nsec)      },
                 { "IPIngressBytes",                   "t", NULL, offsetof(RunContext, ip_ingress_bytes)    },
                 { "IPEgressBytes",                    "t", NULL, offsetof(RunContext, ip_egress_bytes)     },
+                { "IOReadBytes",                      "t", NULL, offsetof(RunContext, io_read_bytes)       },
+                { "IOWriteBytes",                     "t", NULL, offsetof(RunContext, io_write_bytes)      },
                 {}
         };
 
@@ -1163,6 +1167,8 @@ static int start_transient_service(
                         .cpu_usage_nsec = NSEC_INFINITY,
                         .ip_ingress_bytes = UINT64_MAX,
                         .ip_egress_bytes = UINT64_MAX,
+                        .io_read_bytes = UINT64_MAX,
+                        .io_write_bytes = UINT64_MAX,
                         .inactive_exit_usec = USEC_INFINITY,
                         .inactive_enter_usec = USEC_INFINITY,
                 };
@@ -1262,6 +1268,14 @@ static int start_transient_service(
                                 char bytes[FORMAT_BYTES_MAX];
                                 log_info("IP traffic sent: %s", format_bytes(bytes, sizeof(bytes), c.ip_egress_bytes));
                         }
+                        if (c.io_read_bytes != UINT64_MAX) {
+                                char bytes[FORMAT_BYTES_MAX];
+                                log_info("IO bytes read: %s", format_bytes(bytes, sizeof(bytes), c.io_read_bytes));
+                        }
+                        if (c.io_write_bytes != UINT64_MAX) {
+                                char bytes[FORMAT_BYTES_MAX];
+                                log_info("IO bytes written: %s", format_bytes(bytes, sizeof(bytes), c.io_write_bytes));
+                        }
                 }
 
                 /* Try to propagate the service's return value */