view _lxcstats.h @ 0:6ce4443e7545

Add the draft of an API to collect statistics on LXC
author Louis Opter <kalessin@kalessin.fr>
date Wed, 29 Dec 2010 23:28:14 +0100
parents
children 2cb8a6cbe468
line wrap: on
line source

#ifndef _LXC_STATS_PRIV_H_
# define _LXC_STATS_PRIV_H_

# include "compat/compat.h"
# include "probes/probes.h"

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. */
};

/**
 * Allocate a new lxcst structure for the given container.
 */
struct lxcst    *_lxcst_container_new(struct _lxcst_controller *, const char *);

/**
 * Free a lxcst structure.
 */
void            _lxcst_container_delete(struct lxcst *);

/**
 * Get statistics on a container.
 */
int             _lxcst_container_read_infos(struct lxcst *);

char            *_lxcst_join_path(char *, size_t , const char *, const char *);

/**
 * Used to select only directories with scandir. We can't directly use it with
 * scandir because we need the cgroup_dir.
 *
 * @return true if the given directory entry is a directory.
 */
int             _lxcst_isdir(const struct _lxcst_controller *, const struct dirent *);

/**
 * 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);

#endif