275 | | = munin plugin = |
276 | | * github:vajtsz/munin-plugins |
277 | | |
278 | | == lxc_proc == |
279 | | * github:vajtsz/munin-plugins/blob/6a426b4bde7addcaf42d72a033e713d0f11776c0/squeeze/lxc_proc#L77 |
280 | | * Debian Squeezeと異なり、Ubuntu 12.04では{{{lxc-cgroup -t container_name tasks}}}が使えない |
281 | | |
282 | | * https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt |
283 | | > Each cgroup is represented by a directory in the cgroup file system |
284 | | > containing the following files describing that cgroup: |
285 | | > |
286 | | > - tasks: list of tasks (by pid) attached to that cgroup. This list |
287 | | > is not guaranteed to be sorted. Writing a thread id into this file |
288 | | > moves the thread into this cgroup. |
289 | | > - cgroup.procs: list of tgids in the cgroup. This list is not |
290 | | > guaranteed to be sorted or free of duplicate tgids, and userspace |
291 | | > should sort/uniquify the list if this property is required. |
292 | | > Writing a thread group id into this file moves all threads in that |
293 | | > group into this cgroup. |
294 | | > - notify_on_release flag: run the release agent on exit? |
295 | | > - release_agent: the path to use for release notifications (this file |
296 | | > exists in the top cgroup only) |
297 | | |
298 | | * まとめ |
299 | | * lxc-cgroupコマンドを使わない場合、以下のsysfsにアクセスすると良い模様 |
300 | | * Debian 6.0: {{{/sys/fs/cgroup/<container>/tasks}}} |
301 | | * Ubuntu 12.04 with fstab: {{{/sys/fs/cgroup/lxc/<container>/tasks}}} |
302 | | * Ubuntu 12.04 with cgroup-lite: {{{/sys/fs/cgroup/cpuacct/lxc/<container>/tasks}}} |
303 | | * Ubuntu 12.04 with cgroup-bin: {{{/sys/fs/cgroup/cpuacct/sysdefault/lxc/<container>/tasks}}} |
304 | | |
305 | | === Debian 6.0 === |
306 | | * http://wiki.debian.org/LXC |
307 | | > Add this line to /etc/fstab |
308 | | > {{{ |
309 | | > cgroup /sys/fs/cgroup cgroup defaults 0 0 |
310 | | > }}} |
311 | | > Try to mount it (a reboot solves an eventual "resource busy problem" in any case) |
312 | | > {{{ |
313 | | > mount /sys/fs/cgroup |
314 | | > }}} |
315 | | |
316 | | * $ sudo lxc-start -d -n lxc-test |
317 | | * $ sudo lxc-cgroup -n lxc-test tasks |
318 | | {{{ |
319 | | 1432 |
320 | | 1569 |
321 | | 1571 |
322 | | 1598 |
323 | | }}} |
324 | | |
325 | | * $ ls -1F /sys/fs/cgroup/ |
326 | | {{{ |
327 | | cgroup.procs |
328 | | cpuacct.stat |
329 | | cpuacct.usage |
330 | | cpuacct.usage_percpu |
331 | | cpuset.cpu_exclusive |
332 | | cpuset.cpus |
333 | | cpuset.mem_exclusive |
334 | | cpuset.mem_hardwall |
335 | | cpuset.memory_migrate |
336 | | cpuset.memory_pressure |
337 | | cpuset.memory_pressure_enabled |
338 | | cpuset.memory_spread_page |
339 | | cpuset.memory_spread_slab |
340 | | cpuset.mems |
341 | | cpuset.sched_load_balance |
342 | | cpuset.sched_relax_domain_level |
343 | | cpu.shares |
344 | | devices.allow |
345 | | devices.deny |
346 | | devices.list |
347 | | lxc-test/ |
348 | | net_cls.classid |
349 | | notify_on_release |
350 | | release_agent |
351 | | tasks |
352 | | }}} |
353 | | * /sys/fs/cgroup/lxc-test/ も同じ構造 |
354 | | * $ cat /sys/fs/cgroup/lxc-test/tasks |
355 | | {{{ |
356 | | 1432 |
357 | | 1569 |
358 | | 1571 |
359 | | 1598 |
360 | | }}} |
361 | | |
362 | | === Ubuntu 12.04 === |
363 | | * Ubuntu 12.04 with {{{aptitude install -R lxc}}} |
364 | | * cgroup関係のパッケージは{{{-R}}}をつけるとインストールされない |
365 | | * $ ls -1F /sys/fs/cgroup/ |
366 | | * N/A |
367 | | * $ sudo lxc-start -n lxc-test |
368 | | {{{ |
369 | | lxc-start: failed to spawn 'lxc-test' |
370 | | }}} |
371 | | |
372 | | ==== /etc/fstab ==== |
373 | | * Ubuntu 12.04 with /etc/fstab:{{{cgroup /sys/fs/cgroup cgroup defaults 0 0}}} |
374 | | * 起動時に自動でマウントされないため、{{{mount -a}}}する必要がある |
375 | | |
376 | | * $ sudo mount -a |
377 | | * $ sudo lxc-start -d -n lxc-test |
378 | | * $ sudo lxc-cgroup -n lxc-test tasks |
379 | | {{{ |
380 | | lxc-cgroup: cgroup is not mounted |
381 | | lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test' |
382 | | }}} |
383 | | |
384 | | * $ ls -1F /sys/fs/cgroup/ |
385 | | {{{ |
386 | | blkio.io_merged |
387 | | blkio.io_queued |
388 | | blkio.io_service_bytes |
389 | | blkio.io_serviced |
390 | | blkio.io_service_time |
391 | | blkio.io_wait_time |
392 | | blkio.reset_stats |
393 | | blkio.sectors |
394 | | blkio.throttle.io_service_bytes |
395 | | blkio.throttle.io_serviced |
396 | | blkio.throttle.read_bps_device |
397 | | blkio.throttle.read_iops_device |
398 | | blkio.throttle.write_bps_device |
399 | | blkio.throttle.write_iops_device |
400 | | mitty@lein:~$ ls -1F /sys/fs/cgroup/ |
401 | | blkio.io_merged |
402 | | blkio.io_queued |
403 | | blkio.io_service_bytes |
404 | | blkio.io_serviced |
405 | | blkio.io_service_time |
406 | | blkio.io_wait_time |
407 | | blkio.reset_stats |
408 | | blkio.sectors |
409 | | blkio.throttle.io_service_bytes |
410 | | blkio.throttle.io_serviced |
411 | | blkio.throttle.read_bps_device |
412 | | blkio.throttle.read_iops_device |
413 | | blkio.throttle.write_bps_device |
414 | | blkio.throttle.write_iops_device |
415 | | blkio.time |
416 | | blkio.weight |
417 | | blkio.weight_device |
418 | | cgroup.clone_children |
419 | | cgroup.event_control |
420 | | cgroup.procs |
421 | | cpuacct.stat |
422 | | cpuacct.usage |
423 | | cpuacct.usage_percpu |
424 | | cpu.cfs_period_us |
425 | | cpu.cfs_quota_us |
426 | | cpu.rt_period_us |
427 | | cpu.rt_runtime_us |
428 | | cpuset.cpu_exclusive |
429 | | cpuset.cpus |
430 | | cpuset.mem_exclusive |
431 | | cpuset.mem_hardwall |
432 | | cpuset.memory_migrate |
433 | | cpuset.memory_pressure |
434 | | cpuset.memory_pressure_enabled |
435 | | cpuset.memory_spread_page |
436 | | cpuset.memory_spread_slab |
437 | | cpuset.mems |
438 | | cpuset.sched_load_balance |
439 | | cpuset.sched_relax_domain_level |
440 | | cpu.shares |
441 | | cpu.stat |
442 | | devices.allow |
443 | | devices.deny |
444 | | devices.list |
445 | | lxc/ |
446 | | memory.failcnt |
447 | | memory.force_empty |
448 | | memory.limit_in_bytes |
449 | | memory.max_usage_in_bytes |
450 | | memory.memsw.failcnt |
451 | | memory.memsw.limit_in_bytes |
452 | | memory.memsw.max_usage_in_bytes |
453 | | memory.memsw.usage_in_bytes |
454 | | memory.move_charge_at_immigrate |
455 | | memory.numa_stat |
456 | | memory.oom_control |
457 | | memory.soft_limit_in_bytes |
458 | | memory.stat |
459 | | memory.swappiness |
460 | | memory.usage_in_bytes |
461 | | memory.use_hierarchy |
462 | | notify_on_release |
463 | | release_agent |
464 | | tasks |
465 | | }}} |
466 | | * /sys/fs/cgroup/lxc/, /sys/fs/cgroup/lxc/lxc-test/ も同じ構造 |
467 | | * $ cat /sys/fs/cgroup/lxc/lxc-test/tasks |
468 | | {{{ |
469 | | 2712 |
470 | | 2867 |
471 | | 2932 |
472 | | 2943 |
473 | | 2947 |
474 | | 2952 |
475 | | 2953 |
476 | | 2954 |
477 | | 2983 |
478 | | 3002 |
479 | | 3031 |
480 | | 3036 |
481 | | 3037 |
482 | | 3042 |
483 | | 3056 |
484 | | 3058 |
485 | | }}} |
486 | | |
487 | | ==== cgroup-lite ==== |
488 | | * Ubuntu 12.04 with {{{cgroup-lite}}} |
489 | | * aptitude install時に-Rとしない場合、{{{cgroup-lite}}}がRecommendsからインストールされる |
490 | | * /bin/cgroups-mount |
491 | | {{{ |
492 | | mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup |
493 | | }}} |
494 | | * $ sudo lxc-cgroup -n lxc-test tasks |
495 | | {{{ |
496 | | lxc-cgroup: cgroup is not mounted |
497 | | lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test' |
498 | | }}} |
499 | | |
500 | | * $ ls -1F /sys/fs/cgroup/ |
501 | | {{{ |
502 | | blkio/ |
503 | | cpu/ |
504 | | cpuacct/ |
505 | | cpuset/ |
506 | | devices/ |
507 | | freezer/ |
508 | | memory/ |
509 | | perf_event/ |
510 | | }}} |
511 | | * $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc |
512 | | {{{ |
513 | | 17 17 102 /sys/fs/cgroup/perf_event/lxc/lxc-test/tasks |
514 | | 17 17 102 /sys/fs/cgroup/blkio/lxc/lxc-test/tasks |
515 | | 17 17 102 /sys/fs/cgroup/freezer/lxc/lxc-test/tasks |
516 | | 17 17 102 /sys/fs/cgroup/devices/lxc/lxc-test/tasks |
517 | | 17 17 102 /sys/fs/cgroup/memory/lxc/lxc-test/tasks |
518 | | 17 17 102 /sys/fs/cgroup/cpuacct/lxc/lxc-test/tasks |
519 | | 17 17 102 /sys/fs/cgroup/cpu/lxc/lxc-test/tasks |
520 | | 17 17 102 /sys/fs/cgroup/cpuset/lxc/lxc-test/tasks |
521 | | }}} |
522 | | * $ cat /sys/fs/cgroup/perf_event/lxc/lxc-test/tasks |
523 | | {{{ |
524 | | 17390 |
525 | | 17539 |
526 | | 17556 |
527 | | 17560 |
528 | | 17562 |
529 | | 17567 |
530 | | 17568 |
531 | | 17570 |
532 | | 17599 |
533 | | 17621 |
534 | | 17647 |
535 | | 17651 |
536 | | 17654 |
537 | | 17659 |
538 | | 17678 |
539 | | 17681 |
540 | | 17829 |
541 | | }}} |
542 | | |
543 | | ==== cgroup-bin ==== |
544 | | * Ubuntu 12.04 with {{{cgroup-bin}}} |
545 | | * cgroup-binとcgroup-liteはコンフリクトする |
546 | | * /etc/init/cgconfig.conf |
547 | | {{{ |
548 | | mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroups /sys/fs/cgroup |
549 | | }}} |
550 | | * $ sudo lxc-cgroup -n lxc-test tasks |
551 | | {{{ |
552 | | lxc-cgroup: cgroup is not mounted |
553 | | lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test' |
554 | | }}} |
555 | | |
556 | | * $ ls -1F /sys/fs/cgroup/ |
557 | | {{{ |
558 | | cpu/ |
559 | | cpuacct/ |
560 | | devices/ |
561 | | freezer/ |
562 | | memory/ |
563 | | }}} |
564 | | * $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc |
565 | | {{{ |
566 | | 16 16 80 /sys/fs/cgroup/freezer/sysdefault/lxc/lxc-test/tasks |
567 | | 16 16 80 /sys/fs/cgroup/memory/sysdefault/lxc/lxc-test/tasks |
568 | | 16 16 80 /sys/fs/cgroup/devices/sysdefault/lxc/lxc-test/tasks |
569 | | 16 16 80 /sys/fs/cgroup/cpuacct/sysdefault/lxc/lxc-test/tasks |
570 | | 16 16 80 /sys/fs/cgroup/cpu/sysdefault/lxc/lxc-test/tasks |
571 | | }}} |
572 | | * $ cat /sys/fs/cgroup/freezer/sysdefault/lxc/lxc-test/tasks |
573 | | {{{ |
574 | | 1296 |
575 | | 1390 |
576 | | 1434 |
577 | | 1461 |
578 | | 1470 |
579 | | 1471 |
580 | | 1473 |
581 | | 1474 |
582 | | 1502 |
583 | | 1524 |
584 | | 1552 |
585 | | 1562 |
586 | | 1563 |
587 | | 1566 |
588 | | 1580 |
589 | | 1582 |
590 | | }}} |
591 | | |