mirror of
https://github.com/natelandau/ansible-homelab-config.git
synced 2025-11-18 01:43:40 -05:00
Telegraf configuration changes
- Added shellscript for custom metrics - external IP & Temp - Bumped Telegraf version #
This commit is contained in:
@@ -5,7 +5,7 @@ influxdb_version: 1.8.4
|
||||
nomad_version: 1.2.5
|
||||
prometheus_verssion: 1.1.2
|
||||
tdarr_installer_version: 2.00.13
|
||||
telegraf_version: 1.19.1
|
||||
telegraf_version: 1.21.4
|
||||
traefik_version: "v2.6.0"
|
||||
|
||||
# ---------------------------------- SERVICE STATIC PORT MAPPINGS
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
mode: "644"
|
||||
loop:
|
||||
- { src: "telegraf/base_config.conf.j2", dest: "{{ telegraph_config_location }}/telegraf.conf" }
|
||||
- { src: "telegraf/temperature.conf.j2", dest: "{{ telegraph_config_location }}/telegraf.d/temperature.conf" }
|
||||
- { src: "telegraf/custom_metrics.conf.j2", dest: "{{ telegraph_config_location }}/telegraf.d/custom_metrics.conf" }
|
||||
- { src: "telegraf/nomad.conf.j2", dest: "{{ telegraph_config_location }}/telegraf.d/nomad.conf" }
|
||||
- { src: "telegraf/docker.conf.j2", dest: "{{ telegraph_config_location }}/telegraf.d/docker.conf" }
|
||||
notify: restart_telegraf
|
||||
@@ -181,7 +181,18 @@
|
||||
- is_cluster_leader
|
||||
notify: restart_telegraf
|
||||
|
||||
- name: Reset file ownership (macOS)
|
||||
- name: Copy custom metrics script
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: "scripts/telegraf_custom_metrics.sh.j2"
|
||||
dest: "/usr/local/bin/telegraf_custom_metrics.sh"
|
||||
mode: 0755
|
||||
owner: "{{ ansible_user_uid }}"
|
||||
group: "{{ ansible_user_gid }}"
|
||||
when:
|
||||
- inventory_hostname != 'synology'
|
||||
|
||||
- name: Reset file ownership
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ telegraph_config_location }}"
|
||||
|
||||
0
templates/scripts/service_restore.sh.j2
Normal file → Executable file
0
templates/scripts/service_restore.sh.j2
Normal file → Executable file
20
templates/scripts/telegraf_custom_metrics.sh.j2
Executable file
20
templates/scripts/telegraf_custom_metrics.sh.j2
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
EXTERNAL_IP="$(curl -s http://icanhazip.com)"
|
||||
|
||||
# OS specific support
|
||||
if _uname=$(command -v uname); then
|
||||
case $("${_uname}" | tr '[:upper:]' '[:lower:]') in
|
||||
linux*)
|
||||
TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
|
||||
;;
|
||||
darwin*)
|
||||
if [ -e "/usr/local/bin/osx-cpu-temp" ]; then
|
||||
TEMP="$(/usr/local/bin/osx-cpu-temp | cut -c -4 | sed -E 's/\.//g')00"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Print output
|
||||
printf "exec ip_external=%s,cpu_temp=%s" "\"${EXTERNAL_IP}\"" "${TEMP}"
|
||||
5
templates/telegraf/custom_metrics.conf.j2
Normal file
5
templates/telegraf/custom_metrics.conf.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
[[inputs.exec]]
|
||||
commands = ["/usr/local/bin/telegraf_custom_metrics.sh"]
|
||||
timeout = "5s"
|
||||
name_suffix = "_homelab_metrics"
|
||||
data_format = "influx"
|
||||
@@ -1,10 +0,0 @@
|
||||
[[inputs.exec]]
|
||||
{% if 'pis' in group_names %}
|
||||
commands = ["cat /sys/class/thermal/thermal_zone0/temp"]
|
||||
{% elif 'macs' in group_names %}
|
||||
commands = ["${HOME}/dotfiles-private/config/telegraf/cputemp.sh"]
|
||||
{% endif %}
|
||||
timeout = "5s"
|
||||
name_suffix = "_cpu_temp"
|
||||
data_format = "value"
|
||||
data_type = "integer"
|
||||
Reference in New Issue
Block a user