Mercurial > archived > louis > perso > liblxcstats
view _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 | e2b88f50e136 |
children |
line wrap: on
line source
#ifndef _LXC_STATS_PRIV_H_ # define _LXC_STATS_PRIV_H_ # include "compat/compat.h" # include "probes/probes.h" # define NSEC_PER_SEC 1000000000L # define LXC_DIR "/var/lib/lxc/" # define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) struct dirent; /** * Store all informations needed to get statistics from a cgroup * hierarchy. */ struct _lxcst_controller { char *cgroup_dir; /**< Mount point of the cgroup hierarchy. */ const char *lxc_dir; /**< LXC configuration directory (LXC_DIR). */ }; extern struct lxcst_globals _lxcst_globals; /** * Allocate a new lxcst structure for the given container. */ struct lxcst *_lxcst_container_new(const struct _lxcst_controller *, const char *); /** * Free a lxcst structure. */ void _lxcst_container_delete(struct lxcst *); /** * Get the total number of LXC containers on this machine. */ int _lxcst_container_count(const struct _lxcst_controller *ct); /** * Get statistics on a container. */ int _lxcst_container_read_infos(struct lxcst *); /** * Reset the global statistics structure. */ void _lxcst_globals_reset(void); char *_lxcst_join_path(char *, size_t , const char *, const char *); /** * @return true if the given path is a directory. */ int _lxcst_isdir(const char *); /** * Allocate a buffer and read an entire file in it. * * @param [in] path Path to the file to read * @param [out] content A pointer to a pointer which will hold the allocated * buffer. * * @return The size of the buffer on sucess, -1 with errno set otherwise. */ ssize_t _lxcst_read_file(const char *path, char **content); /** * Split a string around spaces (defined by isspace()). * * @param [in] str The string to split, spaces are erased with '\0'. * @param [out] fields An array of string, each entry will point to a word of * the string. * @param [in] nfields Number of entries into the fields array. * * @return The number of fields found. */ int _lxcst_strsplit(char *str, char **fields, size_t nfields); #endif