/etc/cgconfig.conf file can be generated from the current cgroup configuration using the cgsnapshot utility. This utility takes a snapshot of the current state of all subsystems and their cgroups and returns their configuration as it would appear in the /etc/cgconfig.conf file. Example 2.6, “Using the cgsnapshot utility” shows an example usage of the cgsnapshot utility.
~]#mkdir /cgroup/cpu~]#mount -t cgroup -o cpu cpu /cgroup/cpu~]#mkdir /cgroup/cpu/lab1~]#mkdir /cgroup/cpu/lab2~]#echo 2 > /cgroup/cpu/lab1/cpu.shares~]#echo 3 > /cgroup/cpu/lab2/cpu.shares~]#echo 5000000 > /cgroup/cpu/lab1/cpu.rt_period_us~]#echo 4000000 > /cgroup/cpu/lab1/cpu.rt_runtime_us~]#mkdir /cgroup/cpuacct~]#mount -t cgroup -o cpuacct cpuacct /cgroup/cpuacct
cpu subsystem, with specific values for some of their parameters. Executing the cgsnapshot command (with the -s option and an empty /etc/cgsnapshot_blacklist.conf file[4]) then produces the following output:
~]$ cgsnapshot -s
# Configuration file generated by cgsnapshot
mount {
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpuacct;
}
group lab2 {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.shares="3";
}
}
group lab1 {
cpu {
cpu.rt_period_us="5000000";
cpu.rt_runtime_us="4000000";
cpu.shares="2";
}
}
-s option used in the example above tells cgsnapshot to ignore all warnings in the output file caused by parameters not being defined in the blacklist or whitelist of the cgsnapshot utility. For more information on parameter blacklisting, refer to Section 2.10.1, “Blacklisting Parameters”. For more information on parameter whitelisting, refer to Section 2.10.2, “Whitelisting Parameters”.
-f to specify a file to which the output should be redirected. For example:
~]$ cgsnapshot -f ~/test/cgconfig_test.conf-f option, note that it overwrites any content in the file you specify. Therefore, it is advisable not to direct the output straight to the /etc/cgconfig.conf file.
~]$ cgsnapshot cpuacct
# Configuration file generated by cgsnapshot
mount {
cpuacct = /cgroup/cpuacct;
}
/etc/cgsnapshot_blacklist.conf file is checked for blacklisted parameters. If a parameter is not present in the blacklist, the whitelist is checked. To specify a different blacklist, use the -b option. For example:
~]$ cgsnapshot -b ~/test/my_blacklist.conf