view _lxcstats.h @ 3:2cb8a6cbe468

cpuacct: convert per cpu usage from nanoseconds to jiffies
author Louis Opter <louis@dotcloud.com>
date Fri, 31 Dec 2010 20:04:25 +0100
parents 6ce4443e7545
children 50215911acb3
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

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