Mercurial > archived > louis > perso > liblxcstats
diff probes/tests/memory.c @ 9:6f2e13f5fcfd
Add the memory probe
author | Louis Opter <louis@dotcloud.com> |
---|---|
date | Sun, 02 Jan 2011 01:50:27 +0100 |
parents | |
children | 3a1977ecccc7 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/probes/tests/memory.c Sun Jan 02 01:50:27 2011 +0100 @@ -0,0 +1,36 @@ +#include <sys/types.h> + +#include <err.h> +#include <stdlib.h> +#include <stdio.h> + +#include "lxcstats.h" +#include "_lxcstats.h" +#include "probes/probes.h" + +int +main(void) +{ + lxcst_handle *hdl; + struct lxcst *c; + + hdl = lxcst_open(); + if (!hdl) + err(EXIT_FAILURE, "lxcst_open failed"); + + c = _lxcst_container_new(hdl, "."); + if (!c) + err(EXIT_FAILURE, "cant create container"); + + if (_lxcst_probe_memory(c)) + err(EXIT_FAILURE, "probe cpuacct failed"); + + printf("used %ju\nmapped %ju\ncached %ju\nswapped %ju\n", + c->memory.used, c->memory.mapped, c->memory.cached, c->memory.swapped); + + _lxcst_container_delete(c); + + lxcst_close(hdl); + + return (EXIT_SUCCESS); +}