summaryrefslogtreecommitdiff
path: root/src/run
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-09-26 16:33:03 +0200
committerLennart Poettering <lennart@poettering.net>2017-09-26 23:51:14 +0200
commit655aab20563b37058422e88ec3df2182ab895ee1 (patch)
treee61ed39fbe8af3e9cc2bd4188077ae339f26d0e3 /src/run
parent4fe66c868143f891bc2f04b3d8ea239a590ef740 (diff)
downloadsystemd-655aab20563b37058422e88ec3df2182ab895ee1.tar.gz
run: also show IP traffic accounting data on "systemd-run --wait"
If we collect we should show it.
Diffstat (limited to 'src/run')
-rw-r--r--src/run/run.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/run/run.c b/src/run/run.c
index 2e24f46b17..f9ca5683a2 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -816,6 +816,8 @@ typedef struct RunContext {
uint64_t inactive_enter_usec;
char *result;
uint64_t cpu_usage_nsec;
+ uint64_t ip_ingress_bytes;
+ uint64_t ip_egress_bytes;
uint32_t exit_code;
uint32_t exit_status;
} RunContext;
@@ -859,6 +861,8 @@ static int run_context_update(RunContext *c, const char *path) {
{ "ExecMainCode", "i", NULL, offsetof(RunContext, exit_code) },
{ "ExecMainStatus", "i", NULL, offsetof(RunContext, exit_status) },
{ "CPUUsageNSec", "t", NULL, offsetof(RunContext, cpu_usage_nsec) },
+ { "IPIngressBytes", "t", NULL, offsetof(RunContext, ip_ingress_bytes) },
+ { "IPEgressBytes", "t", NULL, offsetof(RunContext, ip_egress_bytes) },
{}
};
@@ -1045,7 +1049,13 @@ static int start_transient_service(
log_info("Running as unit: %s", service);
if (arg_wait || arg_stdio != ARG_STDIO_NONE) {
- _cleanup_(run_context_free) RunContext c = {};
+ _cleanup_(run_context_free) RunContext c = {
+ .cpu_usage_nsec = NSEC_INFINITY,
+ .ip_ingress_bytes = UINT64_MAX,
+ .ip_egress_bytes = UINT64_MAX,
+ .inactive_exit_usec = USEC_INFINITY,
+ .inactive_enter_usec = USEC_INFINITY,
+ };
_cleanup_free_ char *path = NULL;
const char *mt;
@@ -1125,10 +1135,19 @@ static int start_transient_service(
log_info("Service runtime: %s", format_timespan(ts, sizeof(ts), c.inactive_enter_usec - c.inactive_exit_usec, USEC_PER_MSEC));
}
- if (c.cpu_usage_nsec > 0 && c.cpu_usage_nsec != NSEC_INFINITY) {
+ if (c.cpu_usage_nsec != NSEC_INFINITY) {
char ts[FORMAT_TIMESPAN_MAX];
log_info("CPU time consumed: %s", format_timespan(ts, sizeof(ts), (c.cpu_usage_nsec + NSEC_PER_USEC - 1) / NSEC_PER_USEC, USEC_PER_MSEC));
}
+
+ if (c.ip_ingress_bytes != UINT64_MAX) {
+ char bytes[FORMAT_BYTES_MAX];
+ log_info("IP traffic received: %s", format_bytes(bytes, sizeof(bytes), c.ip_ingress_bytes));
+ }
+ if (c.ip_egress_bytes != UINT64_MAX) {
+ char bytes[FORMAT_BYTES_MAX];
+ log_info("IP traffic sent: %s", format_bytes(bytes, sizeof(bytes), c.ip_egress_bytes));
+ }
}
/* Try to propagate the service's return value */