Skip to content

Instantly share code, notes, and snippets.

@DazWorrall
Created October 28, 2013 14:37
Show Gist options
  • Save DazWorrall/7197801 to your computer and use it in GitHub Desktop.
Save DazWorrall/7197801 to your computer and use it in GitHub Desktop.
Collecting cgroup memory stats using collectd and ansible
LoadPlugin "table"
<Plugin table>
{% for vm in running_vms.list_vms %}
<Table "/sys/fs/cgroup/memory/libvirt/lxc/{{ vm }}/memory.stat">
Instance "{{ vm }}-memory"
Separator " \\n"
<Result>
Type gauge
InstancesFrom 0
ValuesFrom 1
</Result>
</Table>
{% endfor %}
</Plugin>
---
hosts: all
gather_facts: false
tasks:
- name: fetch list of running containers
virt: command=list_vms state=running uri=lxc:///
register: running_vms
- name: setup collectd cgroup config
template: src=cgroups.conf.j2 dest=/etc/collectd/conf.d/cgroups.conf mode=0600 owner=root group=root
notify: restart collectd
handlers:
- name: restart collectd
service: name=collectd state=restarted
@theonlydoo
Copy link

fixed some stuff commented here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment