From e41c7fec39a906bf347490d78d4a134f38067121 Mon Sep 17 00:00:00 2001 From: Kerri Wait <kerri.wait@monash.edu> Date: Wed, 23 Sep 2020 16:15:30 +1000 Subject: [PATCH] Telegraf monitoring for Karaage (hpc.erc.monash.edu.au) --- .../{hw_counters.fact => hw_counters.py} | 4 +++- roles/telegraf/tasks/main.yml | 23 +++++++----------- roles/telegraf/templates/telegraf.conf.j2 | 24 +++++++++++++++++++ 3 files changed, 35 insertions(+), 16 deletions(-) rename roles/telegraf/files/{hw_counters.fact => hw_counters.py} (94%) mode change 100644 => 100755 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 4011a8f7..ee6784d3 --- 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 234ab230..f1950914 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 aa6233e9..ae81c112 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 # ############################################################################### -- GitLab