| 1 | [[PageOutline]] |
| 2 | |
| 3 | = munin plugin = |
| 4 | * github:vajtsz/munin-plugins |
| 5 | |
| 6 | == lxc_proc == |
| 7 | * github:vajtsz/munin-plugins/blob/6a426b4bde7addcaf42d72a033e713d0f11776c0/squeeze/lxc_proc#L77 |
| 8 | * Debian Squeezeと異なり、Ubuntu 12.04では{{{lxc-cgroup -t container_name tasks}}}が使えない |
| 9 | |
| 10 | * https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt |
| 11 | > Each cgroup is represented by a directory in the cgroup file system |
| 12 | > containing the following files describing that cgroup: |
| 13 | > |
| 14 | > - tasks: list of tasks (by pid) attached to that cgroup. This list |
| 15 | > is not guaranteed to be sorted. Writing a thread id into this file |
| 16 | > moves the thread into this cgroup. |
| 17 | > - cgroup.procs: list of tgids in the cgroup. This list is not |
| 18 | > guaranteed to be sorted or free of duplicate tgids, and userspace |
| 19 | > should sort/uniquify the list if this property is required. |
| 20 | > Writing a thread group id into this file moves all threads in that |
| 21 | > group into this cgroup. |
| 22 | > - notify_on_release flag: run the release agent on exit? |
| 23 | > - release_agent: the path to use for release notifications (this file |
| 24 | > exists in the top cgroup only) |
| 25 | |
| 26 | * まとめ |
| 27 | * lxc-cgroupコマンドを使わない場合、以下のsysfsにアクセスすると良い模様 |
| 28 | * Debian 6.0: {{{/sys/fs/cgroup/<container>/tasks}}} |
| 29 | * Ubuntu 12.04 with fstab: {{{/sys/fs/cgroup/lxc/<container>/tasks}}} |
| 30 | * Ubuntu 12.04 with cgroup-lite: {{{/sys/fs/cgroup/cpuacct/lxc/<container>/tasks}}} |
| 31 | * Ubuntu 12.04 with cgroup-bin: {{{/sys/fs/cgroup/cpuacct/sysdefault/lxc/<container>/tasks}}} |
| 32 | |
| 33 | === Debian 6.0 === |
| 34 | * http://wiki.debian.org/LXC |
| 35 | > Add this line to /etc/fstab |
| 36 | > {{{ |
| 37 | > cgroup /sys/fs/cgroup cgroup defaults 0 0 |
| 38 | > }}} |
| 39 | > Try to mount it (a reboot solves an eventual "resource busy problem" in any case) |
| 40 | > {{{ |
| 41 | > mount /sys/fs/cgroup |
| 42 | > }}} |
| 43 | |
| 44 | * $ sudo lxc-start -d -n lxc-test |
| 45 | * $ sudo lxc-cgroup -n lxc-test tasks |
| 46 | {{{ |
| 47 | 1432 |
| 48 | 1569 |
| 49 | 1571 |
| 50 | 1598 |
| 51 | }}} |
| 52 | |
| 53 | * $ ls -1F /sys/fs/cgroup/ |
| 54 | {{{ |
| 55 | cgroup.procs |
| 56 | cpuacct.stat |
| 57 | cpuacct.usage |
| 58 | cpuacct.usage_percpu |
| 59 | cpuset.cpu_exclusive |
| 60 | cpuset.cpus |
| 61 | cpuset.mem_exclusive |
| 62 | cpuset.mem_hardwall |
| 63 | cpuset.memory_migrate |
| 64 | cpuset.memory_pressure |
| 65 | cpuset.memory_pressure_enabled |
| 66 | cpuset.memory_spread_page |
| 67 | cpuset.memory_spread_slab |
| 68 | cpuset.mems |
| 69 | cpuset.sched_load_balance |
| 70 | cpuset.sched_relax_domain_level |
| 71 | cpu.shares |
| 72 | devices.allow |
| 73 | devices.deny |
| 74 | devices.list |
| 75 | lxc-test/ |
| 76 | net_cls.classid |
| 77 | notify_on_release |
| 78 | release_agent |
| 79 | tasks |
| 80 | }}} |
| 81 | * /sys/fs/cgroup/lxc-test/ も同じ構造 |
| 82 | * $ cat /sys/fs/cgroup/lxc-test/tasks |
| 83 | {{{ |
| 84 | 1432 |
| 85 | 1569 |
| 86 | 1571 |
| 87 | 1598 |
| 88 | }}} |
| 89 | |
| 90 | === Ubuntu 12.04 === |
| 91 | * Ubuntu 12.04 with {{{aptitude install -R lxc}}} |
| 92 | * cgroup関係のパッケージは{{{-R}}}をつけるとインストールされない |
| 93 | * $ ls -1F /sys/fs/cgroup/ |
| 94 | * N/A |
| 95 | * $ sudo lxc-start -n lxc-test |
| 96 | {{{ |
| 97 | lxc-start: failed to spawn 'lxc-test' |
| 98 | }}} |
| 99 | |
| 100 | ==== /etc/fstab ==== |
| 101 | * Ubuntu 12.04 with /etc/fstab:{{{cgroup /sys/fs/cgroup cgroup defaults 0 0}}} |
| 102 | * 起動時に自動でマウントされないため、{{{mount -a}}}する必要がある |
| 103 | |
| 104 | * $ sudo mount -a |
| 105 | * $ sudo lxc-start -d -n lxc-test |
| 106 | * $ sudo lxc-cgroup -n lxc-test tasks |
| 107 | {{{ |
| 108 | lxc-cgroup: cgroup is not mounted |
| 109 | lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test' |
| 110 | }}} |
| 111 | |
| 112 | * $ ls -1F /sys/fs/cgroup/ |
| 113 | {{{ |
| 114 | blkio.io_merged |
| 115 | blkio.io_queued |
| 116 | blkio.io_service_bytes |
| 117 | blkio.io_serviced |
| 118 | blkio.io_service_time |
| 119 | blkio.io_wait_time |
| 120 | blkio.reset_stats |
| 121 | blkio.sectors |
| 122 | blkio.throttle.io_service_bytes |
| 123 | blkio.throttle.io_serviced |
| 124 | blkio.throttle.read_bps_device |
| 125 | blkio.throttle.read_iops_device |
| 126 | blkio.throttle.write_bps_device |
| 127 | blkio.throttle.write_iops_device |
| 128 | mitty@lein:~$ ls -1F /sys/fs/cgroup/ |
| 129 | blkio.io_merged |
| 130 | blkio.io_queued |
| 131 | blkio.io_service_bytes |
| 132 | blkio.io_serviced |
| 133 | blkio.io_service_time |
| 134 | blkio.io_wait_time |
| 135 | blkio.reset_stats |
| 136 | blkio.sectors |
| 137 | blkio.throttle.io_service_bytes |
| 138 | blkio.throttle.io_serviced |
| 139 | blkio.throttle.read_bps_device |
| 140 | blkio.throttle.read_iops_device |
| 141 | blkio.throttle.write_bps_device |
| 142 | blkio.throttle.write_iops_device |
| 143 | blkio.time |
| 144 | blkio.weight |
| 145 | blkio.weight_device |
| 146 | cgroup.clone_children |
| 147 | cgroup.event_control |
| 148 | cgroup.procs |
| 149 | cpuacct.stat |
| 150 | cpuacct.usage |
| 151 | cpuacct.usage_percpu |
| 152 | cpu.cfs_period_us |
| 153 | cpu.cfs_quota_us |
| 154 | cpu.rt_period_us |
| 155 | cpu.rt_runtime_us |
| 156 | cpuset.cpu_exclusive |
| 157 | cpuset.cpus |
| 158 | cpuset.mem_exclusive |
| 159 | cpuset.mem_hardwall |
| 160 | cpuset.memory_migrate |
| 161 | cpuset.memory_pressure |
| 162 | cpuset.memory_pressure_enabled |
| 163 | cpuset.memory_spread_page |
| 164 | cpuset.memory_spread_slab |
| 165 | cpuset.mems |
| 166 | cpuset.sched_load_balance |
| 167 | cpuset.sched_relax_domain_level |
| 168 | cpu.shares |
| 169 | cpu.stat |
| 170 | devices.allow |
| 171 | devices.deny |
| 172 | devices.list |
| 173 | lxc/ |
| 174 | memory.failcnt |
| 175 | memory.force_empty |
| 176 | memory.limit_in_bytes |
| 177 | memory.max_usage_in_bytes |
| 178 | memory.memsw.failcnt |
| 179 | memory.memsw.limit_in_bytes |
| 180 | memory.memsw.max_usage_in_bytes |
| 181 | memory.memsw.usage_in_bytes |
| 182 | memory.move_charge_at_immigrate |
| 183 | memory.numa_stat |
| 184 | memory.oom_control |
| 185 | memory.soft_limit_in_bytes |
| 186 | memory.stat |
| 187 | memory.swappiness |
| 188 | memory.usage_in_bytes |
| 189 | memory.use_hierarchy |
| 190 | notify_on_release |
| 191 | release_agent |
| 192 | tasks |
| 193 | }}} |
| 194 | * /sys/fs/cgroup/lxc/, /sys/fs/cgroup/lxc/lxc-test/ も同じ構造 |
| 195 | * $ cat /sys/fs/cgroup/lxc/lxc-test/tasks |
| 196 | {{{ |
| 197 | 2712 |
| 198 | 2867 |
| 199 | 2932 |
| 200 | 2943 |
| 201 | 2947 |
| 202 | 2952 |
| 203 | 2953 |
| 204 | 2954 |
| 205 | 2983 |
| 206 | 3002 |
| 207 | 3031 |
| 208 | 3036 |
| 209 | 3037 |
| 210 | 3042 |
| 211 | 3056 |
| 212 | 3058 |
| 213 | }}} |
| 214 | |
| 215 | ==== cgroup-lite ==== |
| 216 | * Ubuntu 12.04 with {{{cgroup-lite}}} |
| 217 | * aptitude install時に-Rとしない場合、{{{cgroup-lite}}}がRecommendsからインストールされる |
| 218 | * /bin/cgroups-mount |
| 219 | {{{ |
| 220 | mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup |
| 221 | }}} |
| 222 | * $ sudo lxc-cgroup -n lxc-test tasks |
| 223 | {{{ |
| 224 | lxc-cgroup: cgroup is not mounted |
| 225 | lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test' |
| 226 | }}} |
| 227 | |
| 228 | * $ ls -1F /sys/fs/cgroup/ |
| 229 | {{{ |
| 230 | blkio/ |
| 231 | cpu/ |
| 232 | cpuacct/ |
| 233 | cpuset/ |
| 234 | devices/ |
| 235 | freezer/ |
| 236 | memory/ |
| 237 | perf_event/ |
| 238 | }}} |
| 239 | * $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc |
| 240 | {{{ |
| 241 | 17 17 102 /sys/fs/cgroup/perf_event/lxc/lxc-test/tasks |
| 242 | 17 17 102 /sys/fs/cgroup/blkio/lxc/lxc-test/tasks |
| 243 | 17 17 102 /sys/fs/cgroup/freezer/lxc/lxc-test/tasks |
| 244 | 17 17 102 /sys/fs/cgroup/devices/lxc/lxc-test/tasks |
| 245 | 17 17 102 /sys/fs/cgroup/memory/lxc/lxc-test/tasks |
| 246 | 17 17 102 /sys/fs/cgroup/cpuacct/lxc/lxc-test/tasks |
| 247 | 17 17 102 /sys/fs/cgroup/cpu/lxc/lxc-test/tasks |
| 248 | 17 17 102 /sys/fs/cgroup/cpuset/lxc/lxc-test/tasks |
| 249 | }}} |
| 250 | * $ cat /sys/fs/cgroup/perf_event/lxc/lxc-test/tasks |
| 251 | {{{ |
| 252 | 17390 |
| 253 | 17539 |
| 254 | 17556 |
| 255 | 17560 |
| 256 | 17562 |
| 257 | 17567 |
| 258 | 17568 |
| 259 | 17570 |
| 260 | 17599 |
| 261 | 17621 |
| 262 | 17647 |
| 263 | 17651 |
| 264 | 17654 |
| 265 | 17659 |
| 266 | 17678 |
| 267 | 17681 |
| 268 | 17829 |
| 269 | }}} |
| 270 | |
| 271 | ==== cgroup-bin ==== |
| 272 | * Ubuntu 12.04 with {{{cgroup-bin}}} |
| 273 | * cgroup-binとcgroup-liteはコンフリクトする |
| 274 | * /etc/init/cgconfig.conf |
| 275 | {{{ |
| 276 | mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroups /sys/fs/cgroup |
| 277 | }}} |
| 278 | * $ sudo lxc-cgroup -n lxc-test tasks |
| 279 | {{{ |
| 280 | lxc-cgroup: cgroup is not mounted |
| 281 | lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test' |
| 282 | }}} |
| 283 | |
| 284 | * $ ls -1F /sys/fs/cgroup/ |
| 285 | {{{ |
| 286 | cpu/ |
| 287 | cpuacct/ |
| 288 | devices/ |
| 289 | freezer/ |
| 290 | memory/ |
| 291 | }}} |
| 292 | * $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc |
| 293 | {{{ |
| 294 | 16 16 80 /sys/fs/cgroup/freezer/sysdefault/lxc/lxc-test/tasks |
| 295 | 16 16 80 /sys/fs/cgroup/memory/sysdefault/lxc/lxc-test/tasks |
| 296 | 16 16 80 /sys/fs/cgroup/devices/sysdefault/lxc/lxc-test/tasks |
| 297 | 16 16 80 /sys/fs/cgroup/cpuacct/sysdefault/lxc/lxc-test/tasks |
| 298 | 16 16 80 /sys/fs/cgroup/cpu/sysdefault/lxc/lxc-test/tasks |
| 299 | }}} |
| 300 | * $ cat /sys/fs/cgroup/freezer/sysdefault/lxc/lxc-test/tasks |
| 301 | {{{ |
| 302 | 1296 |
| 303 | 1390 |
| 304 | 1434 |
| 305 | 1461 |
| 306 | 1470 |
| 307 | 1471 |
| 308 | 1473 |
| 309 | 1474 |
| 310 | 1502 |
| 311 | 1524 |
| 312 | 1552 |
| 313 | 1562 |
| 314 | 1563 |
| 315 | 1566 |
| 316 | 1580 |
| 317 | 1582 |
| 318 | }}} |
| 319 | |