diff _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 diff
--- a/_lxcstats.h	Sat Jan 01 16:18:17 2011 +0100
+++ b/_lxcstats.h	Sat Jan 01 17:46:40 2011 +0100
@@ -6,6 +6,8 @@
 
 # define NSEC_PER_SEC   1000000000L
 
+# define LXC_DIR        "/var/lib/lxc/"
+
 # define ARRAY_SIZE(a)  (sizeof((a)) / sizeof((a)[0]))
 
 struct      dirent;
@@ -14,14 +16,17 @@
  * Store all informations needed to get statistics from a cgroup
  * hierarchy.
  */
-struct      _lxcst_controller {
-    char    *cgroup_dir; /**< Mount point of the 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(struct _lxcst_controller *, const char *);
+struct lxcst    *_lxcst_container_new(const struct _lxcst_controller *, const char *);
 
 /**
  * Free a lxcst structure.
@@ -29,19 +34,26 @@
 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 *);
 
 /**
- * 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.
+ * @return true if the given path is a directory.
  */
-int             _lxcst_isdir(const struct _lxcst_controller *, const struct dirent *);
+int             _lxcst_isdir(const char *);
 
 /**
  * Allocate a buffer and read an entire file in it.