Mercurial > archived > louis > perso > liblxcstats
changeset 10:3a1977ecccc7
Add a configure script and fix various things
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Thu, 06 Jan 2011 00:59:06 +0100 |
parents | 6f2e13f5fcfd |
children | cff6be97dae1 |
files | configure probes/cpuacct.c probes/memory.c probes/probes.h probes/tests/memory.c utils.c |
diffstat | 6 files changed, 32 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure Thu Jan 06 00:59:06 2011 +0100 @@ -0,0 +1,6 @@ +#!/bin/sh + +# Use /usr as a prefix so it works our of the box with collectd. +which cmake >/dev/null 2>&1 \ + && cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/ . \ + || echo "You need to install cmake (http://www.cmake.org/) to configure the liblxcstats"
--- a/probes/cpuacct.c Sun Jan 02 01:50:27 2011 +0100 +++ b/probes/cpuacct.c Thu Jan 06 00:59:06 2011 +0100 @@ -101,6 +101,7 @@ { assert(c); - return (read_stat(c) - || read_usage_percpu(c)); + if (read_stat(c) || read_usage_percpu(c)) + return (-1); + return (0); }
--- a/probes/memory.c Sun Jan 02 01:50:27 2011 +0100 +++ b/probes/memory.c Thu Jan 06 00:59:06 2011 +0100 @@ -44,5 +44,7 @@ { assert(c); - return (read_stat(c)); + if (read_stat(c)) + return (-1); + return (0); }
--- a/probes/probes.h Sun Jan 02 01:50:27 2011 +0100 +++ b/probes/probes.h Thu Jan 06 00:59:06 2011 +0100 @@ -8,9 +8,27 @@ const char *name; }; +/** + * The array of available probe functions. + */ extern const struct _lxcst_probe _lxcst_probes[]; +/** + * Read the cpuacct files and fill the cpuacct field of the struct lxcst. + * + * @param [in,out] c The container to work on. + * + * @return 0 on success, -1 otherwise + */ int _lxcst_probe_cpuacct(struct lxcst *c); + +/** + * Read the cpuacct files and fill the memory field of the struct lxcst. + * + * @param [in,out] c The container to work on. + * + * @return 0 on success, -1 otherwise + */ int _lxcst_probe_memory(struct lxcst *c); #endif
--- a/probes/tests/memory.c Sun Jan 02 01:50:27 2011 +0100 +++ b/probes/tests/memory.c Thu Jan 06 00:59:06 2011 +0100 @@ -23,7 +23,7 @@ err(EXIT_FAILURE, "cant create container"); if (_lxcst_probe_memory(c)) - err(EXIT_FAILURE, "probe cpuacct failed"); + err(EXIT_FAILURE, "probe memory failed"); printf("used %ju\nmapped %ju\ncached %ju\nswapped %ju\n", c->memory.used, c->memory.mapped, c->memory.cached, c->memory.swapped);