# HG changeset patch # User Louis Opter # Date 1294271946 -3600 # Node ID 3a1977ecccc79b24d0c69d6c81076d02b398dcd2 # Parent 6f2e13f5fcfd554dd85461a436cf94c544df296f Add a configure script and fix various things diff -r 6f2e13f5fcfd -r 3a1977ecccc7 configure --- /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" diff -r 6f2e13f5fcfd -r 3a1977ecccc7 probes/cpuacct.c --- 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); } diff -r 6f2e13f5fcfd -r 3a1977ecccc7 probes/memory.c --- 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); } diff -r 6f2e13f5fcfd -r 3a1977ecccc7 probes/probes.h --- 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 diff -r 6f2e13f5fcfd -r 3a1977ecccc7 probes/tests/memory.c --- 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); diff -r 6f2e13f5fcfd -r 3a1977ecccc7 utils.c --- a/utils.c Sun Jan 02 01:50:27 2011 +0100 +++ b/utils.c Thu Jan 06 00:59:06 2011 +0100 @@ -60,6 +60,7 @@ *content = NULL; size = 0; + ret = -1; fd = open(path, O_RDONLY); if (fd != -1) {