The format of cpuacct.stat seems to not always have a colon as separator.
It appears to *not* have the colon at least on debian's kernel 3.2.41 and
3.2.35, as well as on RHEL6 with 2.6.32. All of them have decent support for
cgroups/lxc, and the cgroups plugin fails to work with them without this patch.
Also, looking at other implementations shows that they *don't* expect a colon:
https://bitbucket.org/dotcloud/liblxcstats/src/
2558b4fbbf589c609895b0badbfc7d413466d716/probes/cpuacct.c?at=default#cl-71
https://github.com/BrightcoveOS/Diamond/blob/master/src/collectors/cpuacct_cgroup/cpuacct_cgroup.py#L55
*
* user: 12345
* system: 23456
+ *
+ * Or:
+ *
+ * user 12345
+ * system 23456
*/
strstripnewline (buf);
numfields = strsplit (buf, fields, STATIC_ARRAY_SIZE (fields));
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)