changelog v2:
fix te forgotten hardcoded path
fix cgroup_get_value_string problem with *.stat output
the problem was in the low limit for value for the output of stat variables -
now there are used the functions cgroup_read_stats_{begin/next/end} for this
purpose
bogus output:
./src/tools/cgget -r memory.stat /
/:
memory.stat=cache 1024561152
rss 291270656
pgpgin 1209259
pgpgout 888011
inactive_anon 8192
active_anon 2976481
fixed output:
$ ./src/tools/cgget -r memory.stat /
/:
memory.stat=cache 1024610304
rss 291270656
pgpgin 1209271
pgpgout 888011
inactive_anon 8192
active_anon 297648128
inactive_file 619126784
active_file 399073280
unevictable 24576
hierarchical_memory_limit 9223372036854775807
hierarchical_memsw_limit 9223372036854775807
total_cache 1024610304
total_rss 291270656
total_pgpgin 1209271
total_pgpgout 888011
total_inactive_anon 8192
total_active_anon 297648128
total_inactive_file 619126784
total_active_file 399073280
total_unevictable 24576
Signed-off-by: Ivana Hutarova Varekova <[email protected]>
---
src/tools/cgget.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/include/libcgroup.h b/include/libcgroup.h
index ce75d2e..c8f1240 100644
--- a/include/libcgroup.h
+++ b/include/libcgroup.h
@@ -141,6 +141,7 @@ struct cgroup_file_info {
#define CG_NV_MAX 100
#define CG_CONTROLLER_MAX 100
+/* this is NOT ENOUGH for stat variables */
#define CG_VALUE_MAX 100
/* Max number of mounted hierarchies. Event if one controller is mounted per
* hier, it can not exceed CG_CONTROLLER_MAX
diff --git a/src/tools/cgget.c b/src/tools/cgget.c
index 4ca064e..8e07690 100644
--- a/src/tools/cgget.c
+++ b/src/tools/cgget.c
@@ -27,7 +27,7 @@ void usage(int status, char *program_name)
}
int display_one_record(char *name, struct cgroup_controller *group_controller,
- const char *program_name, int mode)
+ const char *program_name, int mode, char *path)
{
int ret;
char *value = NULL;
@@ -43,7 +43,28 @@ int display_one_record(char *name, struct cgroup_controller
*group_controller,
if (mode & MODE_SHOW_NAMES)
printf("%s=", name);
- printf("%s\n", value);
+ if (strcmp(strchr(name, '.')+1, "stat"))
+ printf("%s\n", value);
+
+ else {
+ void *handle;
+ struct cgroup_stat stat;
+
+ cgroup_read_stats_begin(group_controller->name,
+ path, &handle, &stat);
+ if (ret != 0) {
+ fprintf(stderr, "stats read failed\n");
+ return ret;
+ }
+ printf("%s %s", stat.name, stat.value);
+
+ while ((ret = cgroup_read_stats_next(&handle, &stat)) !=
+ ECGEOF) {
+ printf("\t%s %s", stat.name, stat.value);
+ }
+
+ cgroup_read_stats_end(&handle);
+ }
free(value);
return ret;
@@ -103,7 +124,7 @@ int display_name_values(char **names, int count, const
char* group_name,
/* Finally read the parameter value.*/
ret = display_one_record(names[i], group_controller,
- program_name, mode);
+ program_name, mode, group->name);
if (ret != 0)
goto err;
}
@@ -165,7 +186,7 @@ int display_controller_values(char **controllers, int count,
name = cgroup_get_value_name(group_controller, i);
if (name != NULL) {
ret = display_one_record(name, group_controller,
- program_name, mode);
+ program_name, mode, group->name);
if (ret) {
result = ret;
goto err;
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel