diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-09 17:32:26 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:59:09 +0200 |
commit | c3b7f359b022902190c58c1d8f17eb70265bc603 (patch) | |
tree | d3ab05f2063553e9916b692ba542a093a49ca33d /src/test | |
parent | 459590e77817fd0b3d14168642b96b65a4f829e7 (diff) |
procfs-util: add APIs to get consumed CPU time and used memory from /proc
This is preparation for emulating the "usage_usec" keyed attribute of
the "cpu.stat" property of the root cgroup from data in /proc. Similar,
for emulating the "memory.current" attribute.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-procfs-util.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/test-procfs-util.c b/src/test/test-procfs-util.c index 6c4d15ec8..433b06b05 100644 --- a/src/test/test-procfs-util.c +++ b/src/test/test-procfs-util.c @@ -3,15 +3,24 @@ //#include <errno.h> //#include "log.h" +//#include "parse-util.h" //#include "procfs-util.h" int main(int argc, char *argv[]) { + char buf[CONST_MAX(FORMAT_TIMESPAN_MAX, FORMAT_BYTES_MAX)]; + nsec_t nsec; uint64_t v; int r; log_parse_environment(); log_open(); + assert_se(procfs_cpu_get_usage(&nsec) >= 0); + log_info("Current sytem CPU time: %s", format_timespan(buf, sizeof(buf), nsec/NSEC_PER_USEC, 1)); + + assert_se(procfs_memory_get_current(&v) >= 0); + log_info("Current memory usage: %s", format_bytes(buf, sizeof(buf), v)); + assert_se(procfs_tasks_get_current(&v) >= 0); log_info("Current number of tasks: %" PRIu64, v); |