projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #312 from jazzmes/libvirt-mem-usage
[collectd.git]
/
src
/
cgroups.c
diff --git
a/src/cgroups.c
b/src/cgroups.c
index
ffb1740
..
6d41972
100644
(file)
--- a/
src/cgroups.c
+++ b/
src/cgroups.c
@@
-93,7
+93,7
@@
static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
if (fh == NULL)
{
char errbuf[1024];
if (fh == NULL)
{
char errbuf[1024];
- ERROR ("cgroups plu
ig
n: fopen (\"%s\") failed: %s",
+ ERROR ("cgroups plu
gi
n: fopen (\"%s\") failed: %s",
abs_path,
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
abs_path,
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
@@
-111,6
+111,11
@@
static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
*
* user: 12345
* system: 23456
*
* user: 12345
* system: 23456
+ *
+ * Or:
+ *
+ * user 12345
+ * system 23456
*/
strstripnewline (buf);
numfields = strsplit (buf, fields, STATIC_ARRAY_SIZE (fields));
*/
strstripnewline (buf);
numfields = strsplit (buf, fields, STATIC_ARRAY_SIZE (fields));
@@
-122,10
+127,9
@@
static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
if (key_len < 2)
continue;
if (key_len < 2)
continue;
- /* Strip colon off the first column */
- if (key[key_len - 1] != ':')
- continue;
- key[key_len - 1] = 0;
+ /* Strip colon off the first column, if found */
+ if (key[key_len - 1] == ':')
+ key[key_len - 1] = 0;
status = parse_value (fields[1], &value, DS_TYPE_DERIVE);
if (status != 0)
status = parse_value (fields[1], &value, DS_TYPE_DERIVE);
if (status != 0)
@@
-140,7
+144,7
@@
static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
/*
* Gets called for every file/folder in /sys/fs/cgroup/cpu,cpuacct (or
/*
* Gets called for every file/folder in /sys/fs/cgroup/cpu,cpuacct (or
- * where
e
ver cpuacct is mounted on the system). Calls walk_directory with the
+ * wherever cpuacct is mounted on the system). Calls walk_directory with the
* read_cpuacct_procs callback on every folder it finds, such as "system".
*/
static int read_cpuacct_root (const char *dirname, const char *filename,
* read_cpuacct_procs callback on every folder it finds, such as "system".
*/
static int read_cpuacct_root (const char *dirname, const char *filename,
@@
-217,8
+221,9
@@
static int cgroups_read (void)
{
/* Find the cgroup mountpoint which contains the cpuacct
* controller. */
{
/* Find the cgroup mountpoint which contains the cpuacct
* controller. */
- if (strcmp(mnt_ptr->type, "cgroup") != 0 ||
- !cu_mount_getoptionvalue(mnt_ptr->options, "cpuacct"))
+ if ((strcmp(mnt_ptr->type, "cgroup") != 0)
+ || !cu_mount_checkoption(mnt_ptr->options,
+ "cpuacct", /* full = */ 1))
continue;
walk_directory (mnt_ptr->dir, read_cpuacct_root,
continue;
walk_directory (mnt_ptr->dir, read_cpuacct_root,