wiki:TipAndDoc/Linux/LXC/munin-plugins

munin plugin

lxc_proc

  • https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt

    Each cgroup is represented by a directory in the cgroup file system containing the following files describing that cgroup:

    • tasks: list of tasks (by pid) attached to that cgroup. This list is not guaranteed to be sorted. Writing a thread id into this file moves the thread into this cgroup.
    • cgroup.procs: list of tgids in the cgroup. This list is not guaranteed to be sorted or free of duplicate tgids, and userspace should sort/uniquify the list if this property is required. Writing a thread group id into this file moves all threads in that group into this cgroup.
    • notify_on_release flag: run the release agent on exit?
    • release_agent: the path to use for release notifications (this file exists in the top cgroup only)
  • まとめ
    • lxc-cgroupコマンドを使わない場合、以下のsysfsにアクセスすると良い模様
    • Debian 6.0: /sys/fs/cgroup/<container>/tasks
    • Ubuntu 12.04 with fstab: /sys/fs/cgroup/lxc/<container>/tasks
    • Ubuntu 12.04 with cgroup-lite: /sys/fs/cgroup/cpuacct/lxc/<container>/tasks
    • Ubuntu 12.04 with cgroup-bin: /sys/fs/cgroup/cpuacct/sysdefault/lxc/<container>/tasks

Debian 6.0

  • http://wiki.debian.org/LXC

    Add this line to /etc/fstab

    cgroup  /sys/fs/cgroup  cgroup  defaults  0   0
    

    Try to mount it (a reboot solves an eventual "resource busy problem" in any case)

    mount /sys/fs/cgroup
    
  • $ sudo lxc-start -d -n lxc-test
  • $ sudo lxc-cgroup -n lxc-test tasks
    1432
    1569
    1571
    1598
    
  • $ ls -1F /sys/fs/cgroup/
    cgroup.procs
    cpuacct.stat
    cpuacct.usage
    cpuacct.usage_percpu
    cpuset.cpu_exclusive
    cpuset.cpus
    cpuset.mem_exclusive
    cpuset.mem_hardwall
    cpuset.memory_migrate
    cpuset.memory_pressure
    cpuset.memory_pressure_enabled
    cpuset.memory_spread_page
    cpuset.memory_spread_slab
    cpuset.mems
    cpuset.sched_load_balance
    cpuset.sched_relax_domain_level
    cpu.shares
    devices.allow
    devices.deny
    devices.list
    lxc-test/
    net_cls.classid
    notify_on_release
    release_agent
    tasks
    
    • /sys/fs/cgroup/lxc-test/ も同じ構造
  • $ cat /sys/fs/cgroup/lxc-test/tasks
    1432
    1569
    1571
    1598
    

Ubuntu 12.04

  • Ubuntu 12.04 with aptitude install -R lxc
    • cgroup関係のパッケージは-Rをつけるとインストールされない
  • $ ls -1F /sys/fs/cgroup/
    • N/A
  • $ sudo lxc-start -n lxc-test
    lxc-start: failed to spawn 'lxc-test'
    

/etc/fstab

  • Ubuntu 12.04 with /etc/fstab:cgroup /sys/fs/cgroup cgroup defaults 0 0
    • 起動時に自動でマウントされないため、mount -aする必要がある
  • $ sudo mount -a
  • $ sudo lxc-start -d -n lxc-test
  • $ sudo lxc-cgroup -n lxc-test tasks
    lxc-cgroup: cgroup is not mounted
    lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test'
    
  • $ ls -1F /sys/fs/cgroup/
    blkio.io_merged
    blkio.io_queued
    blkio.io_service_bytes
    blkio.io_serviced
    blkio.io_service_time
    blkio.io_wait_time
    blkio.reset_stats
    blkio.sectors
    blkio.throttle.io_service_bytes
    blkio.throttle.io_serviced
    blkio.throttle.read_bps_device
    blkio.throttle.read_iops_device
    blkio.throttle.write_bps_device
    blkio.throttle.write_iops_device
    mitty@lein:~$ ls -1F /sys/fs/cgroup/
    blkio.io_merged
    blkio.io_queued
    blkio.io_service_bytes
    blkio.io_serviced
    blkio.io_service_time
    blkio.io_wait_time
    blkio.reset_stats
    blkio.sectors
    blkio.throttle.io_service_bytes
    blkio.throttle.io_serviced
    blkio.throttle.read_bps_device
    blkio.throttle.read_iops_device
    blkio.throttle.write_bps_device
    blkio.throttle.write_iops_device
    blkio.time
    blkio.weight
    blkio.weight_device
    cgroup.clone_children
    cgroup.event_control
    cgroup.procs
    cpuacct.stat
    cpuacct.usage
    cpuacct.usage_percpu
    cpu.cfs_period_us
    cpu.cfs_quota_us
    cpu.rt_period_us
    cpu.rt_runtime_us
    cpuset.cpu_exclusive
    cpuset.cpus
    cpuset.mem_exclusive
    cpuset.mem_hardwall
    cpuset.memory_migrate
    cpuset.memory_pressure
    cpuset.memory_pressure_enabled
    cpuset.memory_spread_page
    cpuset.memory_spread_slab
    cpuset.mems
    cpuset.sched_load_balance
    cpuset.sched_relax_domain_level
    cpu.shares
    cpu.stat
    devices.allow
    devices.deny
    devices.list
    lxc/
    memory.failcnt
    memory.force_empty
    memory.limit_in_bytes
    memory.max_usage_in_bytes
    memory.memsw.failcnt
    memory.memsw.limit_in_bytes
    memory.memsw.max_usage_in_bytes
    memory.memsw.usage_in_bytes
    memory.move_charge_at_immigrate
    memory.numa_stat
    memory.oom_control
    memory.soft_limit_in_bytes
    memory.stat
    memory.swappiness
    memory.usage_in_bytes
    memory.use_hierarchy
    notify_on_release
    release_agent
    tasks
    
    • /sys/fs/cgroup/lxc/, /sys/fs/cgroup/lxc/lxc-test/ も同じ構造
  • $ cat /sys/fs/cgroup/lxc/lxc-test/tasks
    2712
    2867
    2932
    2943
    2947
    2952
    2953
    2954
    2983
    3002
    3031
    3036
    3037
    3042
    3056
    3058
    

cgroup-lite

  • Ubuntu 12.04 with cgroup-lite
    • aptitude install時に-Rとしない場合、cgroup-liteがRecommendsからインストールされる
    • /bin/cgroups-mount
      mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
      
  • $ sudo lxc-cgroup -n lxc-test tasks
    lxc-cgroup: cgroup is not mounted
    lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test'
    
  • $ ls -1F /sys/fs/cgroup/
    blkio/
    cpu/
    cpuacct/
    cpuset/
    devices/
    freezer/
    memory/
    perf_event/
    
    • $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc
      17 17 102 /sys/fs/cgroup/perf_event/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/blkio/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/freezer/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/devices/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/memory/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/cpuacct/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/cpu/lxc/lxc-test/tasks
      17 17 102 /sys/fs/cgroup/cpuset/lxc/lxc-test/tasks
      
  • $ cat /sys/fs/cgroup/perf_event/lxc/lxc-test/tasks
    17390
    17539
    17556
    17560
    17562
    17567
    17568
    17570
    17599
    17621
    17647
    17651
    17654
    17659
    17678
    17681
    17829
    

cgroup-bin

  • Ubuntu 12.04 with cgroup-bin
    • cgroup-binとcgroup-liteはコンフリクトする
    • /etc/init/cgconfig.conf
      mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroups /sys/fs/cgroup
      
  • $ sudo lxc-cgroup -n lxc-test tasks
    lxc-cgroup: cgroup is not mounted
    lxc-cgroup: failed to retrieve value of 'tasks' for 'lxc-test'
    
  • $ ls -1F /sys/fs/cgroup/
    cpu/
    cpuacct/
    devices/
    freezer/
    memory/
    
    • $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc
      16 16 80 /sys/fs/cgroup/freezer/sysdefault/lxc/lxc-test/tasks
      16 16 80 /sys/fs/cgroup/memory/sysdefault/lxc/lxc-test/tasks
      16 16 80 /sys/fs/cgroup/devices/sysdefault/lxc/lxc-test/tasks
      16 16 80 /sys/fs/cgroup/cpuacct/sysdefault/lxc/lxc-test/tasks
      16 16 80 /sys/fs/cgroup/cpu/sysdefault/lxc/lxc-test/tasks
      
  • $ cat /sys/fs/cgroup/freezer/sysdefault/lxc/lxc-test/tasks
    1296
    1390
    1434
    1461
    1470
    1471
    1473
    1474
    1502
    1524
    1552
    1562
    1563
    1566
    1580
    1582
    

Arch Linux

  • linux 4.8.6-1
  • lxc 1:2.0.4-2
    • lxc.service is enabled.
  • $ sudo lxc-cgroup -n lxc-test tasks
    lxc-cgroup: tools/lxc_cgroup.c: main: 113 failed to retrieve value of 'tasks' for '/var/lib/lxc:lxc-test'
    
  • $ ls -1F /sys/fs/cgroup/
    blkio/
    cpu@
    cpu,cpuacct/
    cpuacct@
    cpuset/
    devices/
    freezer/
    memory/
    net_cls/
    pids/
    systemd/
    
    cpu -> cpu,cpuacct
    cpu,cpuacct
    cpuacct -> cpu,cpuacct
    
  • $ find /sys/fs/cgroup/ | grep lxc-test/tasks | xargs wc -l
    19 /sys/fs/cgroup/devices/lxc/lxc-test/tasks
    19 /sys/fs/cgroup/memory/lxc/lxc-test/tasks
    19 /sys/fs/cgroup/cpuset/lxc/lxc-test/tasks
    0 /sys/fs/cgroup/pids/lxc/lxc-test/tasks
    19 /sys/fs/cgroup/cpu,cpuacct/lxc/lxc-test/tasks
    19 /sys/fs/cgroup/blkio/lxc/lxc-test/tasks
    19 /sys/fs/cgroup/freezer/lxc/lxc-test/tasks
    19 /sys/fs/cgroup/net_cls/lxc/lxc-test/tasks
    0 /sys/fs/cgroup/systemd/lxc/lxc-test/tasks
    
Last modified 8 months ago Last modified on Nov 7, 2016 12:45:00 AM