comparison lxcstats.h @ 7:8339ab15527d

Add running/stopped containers global statistics and refactor some things
author Louis Opter <louis@dotcloud.com>
date Sat, 01 Jan 2011 17:46:40 +0100
parents 2cb8a6cbe468
children 6f2e13f5fcfd
comparison
equal deleted inserted replaced
6:e2b88f50e136 7:8339ab15527d
25 * This structure contains globals statistics on LXC. 25 * This structure contains globals statistics on LXC.
26 * 26 *
27 * Note: see how lxc-info gets these infos. 27 * Note: see how lxc-info gets these infos.
28 */ 28 */
29 struct lxcst_globals { 29 struct lxcst_globals {
30 uint32_t running_containers; 30 uint16_t running_containers;
31 uint32_t stopped_containers; 31 uint16_t stopped_containers;
32 }; 32 };
33 33
34 /** 34 /**
35 * @brief Initialize the library. 35 * @brief Initialize the library.
36 * 36 *
49 * @return 0 on success, -1 if an error occured with errno set. 49 * @return 0 on success, -1 if an error occured with errno set.
50 */ 50 */
51 int lxcst_close(lxcst_handle *hdl); 51 int lxcst_close(lxcst_handle *hdl);
52 52
53 /** 53 /**
54 * @brief Collect statistic on all containers. 54 * @brief Collect statistics on all containers.
55 *
56 * Walk the cgroup pseudo filesystem and get statistics for all found
57 * containers. Also refresh the global statistics struture.
55 * 58 *
56 * @param [in] hdl The pointer returned by lxcst_handle. 59 * @param [in] hdl The pointer returned by lxcst_handle.
57 * @param [in] cb A function pointer to a callback which takes a pointer to an 60 * @param [in] cb A function pointer to a callback which takes a pointer to an
58 * user context and a pointer to lxcst structure. 61 * user context and a pointer to lxcst structure.
59 * @param [in] ctx A pointer to an user defined variable which will be used as 62 * @param [in] ctx A pointer to an user defined variable which will be used as
60 * an argument to the callback. If the callback returns non zero 63 * an argument to the callback. If the callback returns non zero
61 * lxcst_span_containers stops and return with -1 with errno set to EINTR. 64 * lxcst_span_containers stops and return with -1 with errno set to EINTR.
62 * 65 *
63 * @return 0 on success, -1 on error with errno set. 66 * @return 0 on success, -1 on error with errno set.
67 *
68 * @see lxcst_globals_statistics
69 * @see struct lxcst
64 */ 70 */
65 int lxcst_span_containers(lxcst_handle *hdl, int (*cb)(void *, const struct lxcst *), void *ctx); 71 int lxcst_span_containers(lxcst_handle *hdl, int (*cb)(void *, const struct lxcst *), void *ctx);
66 72
73 /**
74 * @brief Get a copy of the global LXC statistics object.
75 *
76 * @param [out] sb A pointer to a struct lxcst_globals.
77 *
78 * @see struct lxcst_globals
79 * @see lxcst_span_containers
80 */
81 void lxcst_globals_statistics(struct lxcst_globals *sb);
82
67 #endif 83 #endif