summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-03-01 16:24:19 +0100
committerLennart Poettering <lennart@poettering.net>2015-03-02 12:15:25 +0100
commit5ad096b3f1331b175340129a8c9a5a9d711e5415 (patch)
tree41896760dde9b0ca2d45d04484c4a2308a600b0e /src/core/unit.c
parent606303a93ea52a70ebba55bb3152820e630f2164 (diff)
core: expose consumed CPU time per unit
This adds support for showing the accumulated consumed CPU time per-unit in the "systemctl status" output. The property is also readable via the bus.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 7cd704351c..b639d686ad 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2602,6 +2602,7 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
unit_serialize_item(u, f, "assert-result", yes_no(u->assert_result));
unit_serialize_item(u, f, "transient", yes_no(u->transient));
+ unit_serialize_item_format(u, f, "cpuacct-usage-base", "%" PRIu64, u->cpuacct_usage_base);
if (u->cgroup_path)
unit_serialize_item(u, f, "cgroup", u->cgroup_path);
@@ -2776,6 +2777,12 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
u->transient = b;
continue;
+ } else if (streq(l, "cpuacct-usage-base")) {
+
+ r = safe_atou64(v, &u->cpuacct_usage_base);
+ if (r < 0)
+ log_debug("Failed to parse CPU usage %s", v);
+
} else if (streq(l, "cgroup")) {
char *s;
@@ -2787,8 +2794,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
void *p;
p = hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
- log_info("Removing cgroup_path %s from hashmap (%p)",
- u->cgroup_path, p);
+ log_info("Removing cgroup_path %s from hashmap (%p)", u->cgroup_path, p);
free(u->cgroup_path);
}