From df5f0a6fc6da27d12b839f6386a6926c34c9c9c1 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Thu, 30 Apr 2020 22:41:26 +0200 Subject: [PATCH] telegraf: add CPU temperature on Raspberry Pi --- handlers/main.yml | 1 + templates/telegraf.conf | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/handlers/main.yml b/handlers/main.yml index 4ce74e6..333f373 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -17,6 +17,7 @@ state: restarted - name: Enable and restart telegraf + become: yes service: name: telegraf state: restarted diff --git a/templates/telegraf.conf b/templates/telegraf.conf index 3ba1023..ab3296c 100644 --- a/templates/telegraf.conf +++ b/templates/telegraf.conf @@ -72,3 +72,12 @@ # ## Remove numbers from field names. # ## If true, a field name like 'temp1_input' will be changed to 'temp_input'. # # remove_numbers = true + +{% if ansible_lsb.id == "Raspbian" %} +# On Raspbian, get CPU temperature (in millicelsius) +[[inputs.exec]] + commands = ["cat /sys/class/thermal/thermal_zone0/temp"] + data_format = "value" + data_type = "integer" + name_override = "cpu_temp" +{% endif %}