diff --git a/roles/telegraf/files/hw_counters.fact b/roles/telegraf/files/hw_counters.py old mode 100644 new mode 100755 similarity index 94% rename from roles/telegraf/files/hw_counters.fact rename to roles/telegraf/files/hw_counters.py index 4011a8f7ad5a6fbfab334e116c7b2ffe134cff4d..ee6784d3d389471ca897ee63785e57918a58fa49 --- a/roles/telegraf/files/hw_counters.fact +++ b/roles/telegraf/files/hw_counters.py @@ -1,11 +1,13 @@ -#!/bin/env python +#!/bin/python -E import json import os + def render_data(data): return json.dumps(data) + hw_counters = {} path_prefix = '/sys/class/infiniband' path_suffix = 'ports/1/hw_counters' diff --git a/roles/telegraf/tasks/main.yml b/roles/telegraf/tasks/main.yml index 234ab230f8cd61708f12362d952ce94e36a3c70c..f19509146bb5caa75bcf05ea4f2942ad76cfab38 100644 --- a/roles/telegraf/tasks/main.yml +++ b/roles/telegraf/tasks/main.yml @@ -8,7 +8,7 @@ - name: Download Telegraf package via URL [Debian/Ubuntu] get_url: - url: "{{ telegraf_install_url }}" + url: "{{ telegraf_install_deb_url }}" dest: /tmp/telegraf-ansible-download.deb when: ansible_os_family == "Debian" become: true @@ -22,21 +22,14 @@ become: true become_user: root -- name: Create custom fact directory - file: - path: /etc/ansible/facts.d - state: directory - become: true - -- name: Insert custom fact file - copy: - src: files/hw_counters.fact - dest: /etc/ansible/facts.d/hw_counters.fact - mode: 0755 - become: true +- name: Get list of hardware counters for interfaces + script: files/hw_counters.py + register: hwcounters + check_mode: no -- name: reload ansible_local - setup: filter=ansible_local +- name: Set hardware counters in facts + set_fact: + hwcounterlist: "{{ hwcounters.stdout | from_json }}" - name: Make a directory for extra files file: diff --git a/roles/telegraf/templates/telegraf.conf.j2 b/roles/telegraf/templates/telegraf.conf.j2 index aa6233e9f8a038e92f2d0baf0a5967a5c85df5c5..ae81c1128da42c257246c9b0d50041559a66fa0b 100644 --- a/roles/telegraf/templates/telegraf.conf.j2 +++ b/roles/telegraf/templates/telegraf.conf.j2 @@ -201,6 +201,30 @@ {% endfor %} {% endfor %} {% endif %} + + +{% if 'Karaage' in group_names %} +[[inputs.apache]] + interval = "60s" + # An array of URLs to gather from, must be directed at the machine + # readable version of the mod_status page including the auto query string. + # Default is "http://localhost/server-status?auto". + urls = ["http://localhost/server-status?auto"] + + # Credentials for basic HTTP authentication. + # username = "myuser" + # password = "mypassword" + + # Maximum time to receive response. + response_timeout = "5s" + + # Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + # Use TLS but skip chain & host verification + # insecure_skip_verify = false +{% endif %} ############################################################################### # SERVICE INPUTS # ###############################################################################