Files
natelandau_ansible-homelab-…/templates/scripts/telegraf_custom_metrics.sh.j2
Nathaniel Landau 73419ec0bd Add speedtest cli to Telegraf config
- Install speedtest CLI on cluster leader
- Install speedtest telegraf config on leader
- cleanup hosts in ping list
- Add custom shell script on leader to output speedtest data to influxdb
- improve version checking of Telegraf binary
- bump telegraf version
- allow ' package-latest' to pass ansible-lint
2022-04-19 09:17:15 -04:00

21 lines
567 B
Django/Jinja
Executable File

#!/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}"