Skip to content

Instantly share code, notes, and snippets.

@Doooooo0o
Forked from DazWorrall/cgroups.conf.j2
Created March 29, 2016 15:23
Show Gist options
  • Save Doooooo0o/9fa77e68861099c8a99a to your computer and use it in GitHub Desktop.
Save Doooooo0o/9fa77e68861099c8a99a 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 " \\t"
<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
@Doooooo0o
Copy link
Author

forking to change from \\n to \\t according to collectd documentation

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