Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding option to install minimal collectd using ppa #13

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8714c2a
adding option to install minimal collectd using ppa
yogeshVU Jun 21, 2017
11e92cb
adding amqp template
yogeshVU Jul 3, 2017
be1ae11
adding amqp config
yogeshVU Jul 3, 2017
787c21f
minor syntax
yogeshVU Jul 3, 2017
8ee93f0
eol correction
yogeshVU Jul 3, 2017
9ace4af
eol changes
yogeshVU Jul 3, 2017
14862ca
added validate
yogeshVU Jul 3, 2017
8cdcc71
load plugin amqp
yogeshVU Jul 3, 2017
3954a23
added cpu config
yogeshVU Jul 3, 2017
5a7af3c
added fqdn to true default
yogeshVU Aug 2, 2017
8b09dc0
added the csv plugin
yogeshVU Aug 12, 2017
105da9b
Merge branch 'develop' of https://github.com/yogeshVU/Stouts.collectd…
yogeshVU Aug 12, 2017
0a7295c
update cpu settings
yogeshVU Aug 12, 2017
ca3852d
new collectd ci ppa
yogeshVU Aug 12, 2017
b07d64d
keys added
yogeshVU Aug 12, 2017
b482bd9
wip numa_cpu_aggregation
yogeshVU Aug 14, 2017
4d541a1
renemed conf file
yogeshVU Aug 14, 2017
fdfbd5b
added more updates to aggregation
yogeshVU Aug 14, 2017
1483875
added updates to the aggregation plugin
yogeshVU Aug 14, 2017
cf6e35f
updates to true/false
yogeshVU Aug 14, 2017
2143870
added support for docker monitoring
yogeshVU Oct 10, 2017
3bb3885
adding template docker config file
yogeshVU Oct 10, 2017
a6fc37e
added flag to check if the plugins are enable/disabl before populatin…
yogeshVU Oct 11, 2017
58b25ab
fixing the boolean error in collectd
yogeshVU Oct 11, 2017
a296ee4
added support for the intel_rdt intel_pmutools collectd compile from …
yogeshVU Oct 12, 2017
6eab9cf
adding support for intel pmu-tools and intel cmt-rdt plugin
yogeshVU Oct 15, 2017
82e0890
adding intelrdt support
yogeshVU Oct 15, 2017
cfae237
updated dockerplugin directory
yogeshVU Oct 20, 2017
b10cd3a
update
yogeshVU Oct 20, 2017
8eae266
added force=yes git clone
yogeshVU Oct 20, 2017
47be8ea
added the plugininstance to the numa-group
yogeshVU Oct 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Ansible role which help you with:

```yaml
collectd_enabled: yes # Enable the role
collectd_version: 5.5.2 # Set version
collectd_version: 5.7.2 # Set version

# PPA options
collectd_use_ppa: no # Use the collectd PPA
Expand Down
10 changes: 10 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[defaults]

# disable SSH key host checking (no need to type 'yes' for every new VM)
host_key_checking = False

hostfile = inventory
roles_path = ./roles:./roles_ext/

remote_user = vagrant
log_path = $HOME/ansible.log
67 changes: 63 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
---

install_collectd: yes
collectd_enabled: yes # Enable the role
collectd_version: 5.5.2 # Set version
collectd_version: 5.7.2 # Set version
collectd_service: upstart
collectd_service_autodetect: true # try to detect collectd_service

# PPA options
collectd_use_ppa: no # Use the collectd PPA
collectd_use_ppa_latest: no # Don't fix package version to collectd_version
collectd_use_ppa_latest: yes # Don't fix package version to collectd_version
collectd_ppa_source: 'ppa:collectd/collectd-5.5'
collectd_use_ppa_minimal: yes

collectd_use_ppa_ci: yes
collectd_use_ppa_ci_codename: collectd-5.7

# Source options
collectd_use_git: yes
collectd_prefix_git_src: /home/ubuntu/collectd
collectd_prefix: /opt/collectd # The place where Collectd will be installed
collectd_prefix_type: "{{collectd_prefix}}/etc"
collectd_prefix_conf: "{{collectd_prefix}}/etc"
Expand All @@ -21,7 +28,7 @@ collectd_plugins_prefix: "{{collectd_prefix_conf}}/conf.d"
collectd_interval: 10
collectd_readthreads: 7
collectd_hostname: "{{ inventory_hostname }}"
collectd_fdqnlookup: false
collectd_fdqnlookup: true

# Collectd plugins
collectd_plugins: [] # Ex. [nginx, memcached]
Expand All @@ -35,6 +42,12 @@ collectd_default_plugins_options:
interface:
- Interface lo
- IgnoreSelected true
cpu:
- ValuesPercentage true
- ReportByState false
- ReportByCpu true
- ReportNumCpu true


# Additional types
# format: { name: ..., value: ... }
Expand All @@ -55,7 +68,7 @@ collectd_write_graphite_options: # Setup write_graphite (https://collectd.org

# Setup logs
collectd_logpath: # If it is not empty, will be used logfile
collectd_loglevel: info
collectd_loglevel: notice
collectd_logrotate: yes
collectd_type: yes
collectd_logrotate_options:
Expand All @@ -66,10 +79,56 @@ collectd_logrotate_options:
- rotate 7
- size 10M

# If the csv path is set the plugin will be enabled
#'/var/lib/collectd/csv'
collectd_csv_logdir:
collectd_csv_logdir_storerates: true

# Paths
collectd_types_db_path: "{{ '/usr/share/collectd/types.db' if collectd_use_ppa else collectd_prefix + '/share/collectd/types.db' }}"
collectd_additional_types_db_path: "{{ '/usr/share/collectd/additional-types.db' if collectd_use_ppa else collectd_prefix_type + '/types.db' }}"
collectd_config_file: "{{ '/etc/collectd/collectd.conf' if collectd_use_ppa else collectd_prefix_conf + '/collectd.conf' }}"
collectd_config_dir: "{{ '/etc/collectd/collectd.conf.d' if collectd_use_ppa else collectd_plugins_prefix }}"
collectd_plugins_dir: "{{ '/usr/lib/collectd' if collectd_use_ppa else collectd_prefix + '/lib/collectd' }}"
collectd_sbin_path: "{{ '/usr/sbin' if collectd_use_ppa else collectd_prefix_sbin }}"

collectd_write_amqp: yes
collectd_write_amqp_options:
Host: "indices-manager"
Port: "5672"
User: "indices_user"
Password: "indices_manager"
Exchange: "collectd-exchange"
RoutingKey: "indices-perf-key"



collectd_numa_cpu_aggr: yes
collectd_numa_node_cpus: [ "0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38",
"1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39"]

collectd_numa_cpu_aggr_options:
CalculateAverage: true
CalculateSum: false


# Enable docker monitoring by default
docker_stats: yes



# Enable docker monitoring by default
collectd_intel_pmutools: no
pmutools_event_dir: ""
pmu_tools_dir: "/opt/pmu-tools"
collectd_intel_pmutools_options:
ReportHardwareCacheEvents: true
ReportKernelPMUEvents: true
ReportSoftwareEvents: true
HardwareEvents: "L2_RQSTS.CODE_RD_HIT,L2_RQSTS.CODE_RD_MISS,L2_RQSTS.ALL_$"

collectd_intel_rdt: no
collectd_intel_rdt_interval: 1
collectd_intel_rdt_options:
Cores: ""

2 changes: 2 additions & 0 deletions inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[localhost]
localhost ansible_connection=local
10 changes: 8 additions & 2 deletions tasks/collectd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
when: ansible_os_family == 'Debian' and collectd_service_autodetect

- include: install.ppa.yml
when: collectd_use_ppa
when: install_collectd and collectd_use_ppa
tags: [collectd, collectd-install]

- include: install.deb.yml
when: not collectd_use_ppa and ansible_os_family == 'Debian'
when: install_collectd and not collectd_use_ppa and not collectd_use_git and ansible_os_family == 'Debian'
tags: [collectd, collectd-install]


- include: install.git.yml
when: install_collectd and not collectd_use_ppa and collectd_use_git and ansible_os_family == 'Debian'
tags: [collectd, collectd-install]


- include: configure.yml
tags: [collectd, collectd-configure]

Expand Down
61 changes: 61 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,64 @@
- name: collectd-configure | Configure additional types
template: src=types.db.j2 dest={{collectd_additional_types_db_path}}
notify: collectd restart

- name: collectd-configure | Configure Addiotnal Plugin AMQP
template: src=amqp.conf.j2 dest={{collectd_config_dir}}/amqp.conf validate='{{collectd_sbin_path}}/collectd -t -C %s'
notify: collectd restart
when: collectd_write_amqp

- name: collectd-configure | Configure Additional Plugin NUMA CPU Aggregation
template: src=numa_cpu_aggregation.conf.j2 dest={{collectd_config_dir}}/numa_cpu_aggregation.conf validate='{{collectd_sbin_path}}/collectd -t -C %s'
notify: collectd restart
when: collectd_numa_cpu_aggr

- name: collectd-configure | Configure Additional Plugin Docker Stats 1 of 3
git:
dest: /usr/share/collectd/docker-collectd-plugin
#repo: "https://github.com/lebauce/docker-collectd-plugin.git"
#repo: "https://github.com/signalfx/docker-collectd-plugin.git"
repo: "https://github.com/doc-vu/docker-collectd-plugin.git"
force: yes
when: docker_stats

- name: collectd-configure | Configure Additional Plugin Docker Stats 2 of 3
shell: pip3 install -r /usr/share/collectd/docker-collectd-plugin/requirements.txt && pip install -r /usr/share/collectd/docker-collectd-plugin/requirements.txt
# notify: collectd restart
when: docker_stats

- name: collectd-configure | Configure Additional Plugin Docker Stats 3 of 3
template: src=docker.conf.j2 dest={{collectd_config_dir}}/docker.conf validate='{{collectd_sbin_path}}/collectd -t -C %s'
notify: collectd restart
when: docker_stats

- name: collectd-configure | Configure Additional Plugin intel_pmutools 1 of 4
shell: cat "{{ pmu_tools_dir }}"/eventlist_info.txt
become: yes
register: event_dir
when: collectd_intel_pmutools

- name: collectd-configure | Configure Additional Plugin intel_pmutools 2 of 4
set_fact:
pmutools_event_dir: "{{ event_dir.stdout|default([]) }}"
when: collectd_intel_pmutools

- name: collectd-configure | Configure Additional Plugin intel_pmutools 3 of 4
debug:
var: pmutools_event_dir
verbosity: 4
when: collectd_intel_pmutools

# - name: collectd-configure | Configure Additional Plugin intel_pmutools 4 of 5
# var: pmutools_event_dir
# when: collectd_intel_pmutools

- name: collectd-configure | Configure Additional Plugin intel_pmutools 4 of 4
template: src=intelpmutool.conf.j2 dest={{collectd_config_dir}}/intelpmutool.conf validate='{{collectd_sbin_path}}/collectd -t -C %s'
notify: collectd restart
when: collectd_intel_pmutools

- name: collectd-configure | Configure Additional Plugin intel_rdt
template: src=intelrdt.conf.j2 dest={{collectd_config_dir}}/intelrdt.conf validate='{{collectd_sbin_path}}/collectd -t -C %s'
notify: collectd restart
when: collectd_intel_rdt

41 changes: 41 additions & 0 deletions tasks/install.git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---

- name: collectd-install | Install dependencies
apt: name={{item}} force=yes
with_items: [build-essential, libcurl4-openssl-dev, libpcap-dev, libyajl-dev, flex, bison, pkg-config, automake]

- name: collectd-install | Download Collectd
git:
dest: "{{ collectd_prefix_git_src }}"
repo: "https://github.com/collectd/collectd.git"
become: yes
register: collectd_source

- name: collectd-install | Install Collectd
shell: ./build.sh && ./configure --prefix={{collectd_prefix}} --with-python LIBPYTHON_CPPFLAGS=/usr/include/python2.7 LIBPYTHON_LDFLAGS=/usr/local/lib/python2.7 PYTHON_CONFIG=/usr/bin/python2.7-config && make -j16 && make all install -j16
args:
chdir: "{{ collectd_prefix_git_src }}"
# when: collectd_source.changed
become: yes
ignore_error: yes

- name: collectd-install | Create /etc/init.d/collectd
template: src=initd.collectd.j2 dest=/etc/init.d/collectd
become: yes

- name: collectd-install | create run/collectd.pid file
shell: mkdir -p "{{collectd_prefix}}/run"
becom: yes


- name: collectd-install | make it executable /etc/init.d/collectd
shell: chmod +x /etc/init.d/collectd
become: yes

- name: collectd-install | Enable collectd.service
shell: systemctl enable collectd.service
become: yes

- name: collectd-install | start the collectd.service
service: name=collectd state=started enabled=yes
become: yes
23 changes: 22 additions & 1 deletion tasks/install.ppa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@
apt_repository: >
repo={{ collectd_ppa_source }}
update_cache=yes
when: not collectd_use_ppa_ci

- name: collectd-install | add signing key
apt_key:
url: "http://pkg.ci.collectd.org/pubkey.asc"
state: present
when: collectd_use_ppa_ci

- name: collectd-install | add ppa key
apt_repository:
repo: deb http://pkg.ci.collectd.org/deb/ {{ansible_distribution_release}} {{collectd_use_ppa_ci_codename}}
state: present
filename: collectd-ci.list
update_cache: yes
when: collectd_use_ppa_ci

# TODO: refine this to decide only based on recommended packages or not
- name: collectd-install | Install specific collectd package
apt: >
name=collectd={{ collectd_version }}
when: not collectd_use_ppa_latest

- name: collectd-install | Install latest collectd minimal package
apt: name=collectd
install_recommends=no
when: collectd_use_ppa_latest and collectd_use_ppa_minimal

- name: collectd-install | Install latest collectd package
apt: name=collectd
when: collectd_use_ppa_latest
when: collectd_use_ppa_latest and not collectd_use_ppa_minimal
12 changes: 12 additions & 0 deletions templates/amqp.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
LoadPlugin amqp
<Plugin amqp>
<Publish "name-amqp">
{% for name, value in collectd_write_amqp_options.items() %}
{{ name }} "{{ value }}"
{% endfor %}
VHost "/"
Persistent false
StoreRates true
Format "json"
</Publish>
</Plugin>
13 changes: 13 additions & 0 deletions templates/collectd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LoadPlugin logfile
LogLevel "{{collectd_loglevel}}"
File "{{collectd_logpath}}"
Timestamp true
PrintSeverity true
</Plugin>
{% else %}
LoadPlugin syslog
Expand All @@ -26,6 +27,18 @@ LoadPlugin syslog
</Plugin>
{% endif %}

# Logging CSV
#StoreRates true|false
#If set to true, convert counter values to rates. If set to false (the default) counter values are stored as is, i. e. as an increasing integer number.
{% if collectd_csv_logdir %}
LoadPlugin csv
<Plugin "csv">
DataDir "{{collectd_csv_logdir}}"
StoreRates "{{collectd_csv_logdir_storerates|default('true')}}"
</Plugin>
{% endif %}


# Default plugins
{% for plugin in collectd_default_plugins %}
LoadPlugin {{ plugin }}
Expand Down
12 changes: 12 additions & 0 deletions templates/docker.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% if docker_stats %}
TypesDB "/usr/share/collectd/docker-collectd-plugin/dockerplugin.db"
LoadPlugin python
<Plugin python>
ModulePath "/usr/share/collectd/docker-collectd-plugin"
Import "dockerplugin"
<Module dockerplugin>
BaseURL "unix://var/run/docker.sock"
Timeout 3
</Module>
</Plugin>
{% endif %}
Loading